babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @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
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. 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);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * 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".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * 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"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * 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"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * 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)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * 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
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. 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;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. 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;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * 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"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * 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".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * 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"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * 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".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /**
  4092. * Defines that alpha blending to SRC + DST
  4093. * Alpha will be set to SRC ALPHA + DST ALPHA
  4094. */
  4095. static readonly ALPHA_ONEONE_ONEONE: number;
  4096. /**
  4097. * Defines that alpha blending to SRC * DST ALPHA + DST
  4098. * Alpha will be set to 0
  4099. */
  4100. static readonly ALPHA_ALPHATOCOLOR: number;
  4101. /**
  4102. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4103. */
  4104. static readonly ALPHA_REVERSEONEMINUS: number;
  4105. /**
  4106. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4107. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4108. */
  4109. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4110. /**
  4111. * Defines that alpha blending to SRC + DST
  4112. * Alpha will be set to SRC ALPHA
  4113. */
  4114. static readonly ALPHA_ONEONE_ONEZERO: number;
  4115. /** Defines that alpha blending equation a SUM */
  4116. static readonly ALPHA_EQUATION_ADD: number;
  4117. /** Defines that alpha blending equation a SUBSTRACTION */
  4118. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4119. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4120. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4121. /** Defines that alpha blending equation a MAX operation */
  4122. static readonly ALPHA_EQUATION_MAX: number;
  4123. /** Defines that alpha blending equation a MIN operation */
  4124. static readonly ALPHA_EQUATION_MIN: number;
  4125. /**
  4126. * Defines that alpha blending equation a DARKEN operation:
  4127. * It takes the min of the src and sums the alpha channels.
  4128. */
  4129. static readonly ALPHA_EQUATION_DARKEN: number;
  4130. /** Defines that the ressource is not delayed*/
  4131. static readonly DELAYLOADSTATE_NONE: number;
  4132. /** Defines that the ressource was successfully delay loaded */
  4133. static readonly DELAYLOADSTATE_LOADED: number;
  4134. /** Defines that the ressource is currently delay loading */
  4135. static readonly DELAYLOADSTATE_LOADING: number;
  4136. /** Defines that the ressource is delayed and has not started loading */
  4137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4139. static readonly NEVER: number;
  4140. /** 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 */
  4141. static readonly ALWAYS: number;
  4142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4143. static readonly LESS: number;
  4144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4145. static readonly EQUAL: number;
  4146. /** 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 */
  4147. static readonly LEQUAL: number;
  4148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4149. static readonly GREATER: number;
  4150. /** 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 */
  4151. static readonly GEQUAL: number;
  4152. /** 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 */
  4153. static readonly NOTEQUAL: number;
  4154. /** Passed to stencilOperation to specify that stencil value must be kept */
  4155. static readonly KEEP: number;
  4156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4157. static readonly REPLACE: number;
  4158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4159. static readonly INCR: number;
  4160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4161. static readonly DECR: number;
  4162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4163. static readonly INVERT: number;
  4164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4165. static readonly INCR_WRAP: number;
  4166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4167. static readonly DECR_WRAP: number;
  4168. /** Texture is not repeating outside of 0..1 UVs */
  4169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4170. /** Texture is repeating outside of 0..1 UVs */
  4171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4172. /** Texture is repeating and mirrored */
  4173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4174. /** ALPHA */
  4175. static readonly TEXTUREFORMAT_ALPHA: number;
  4176. /** LUMINANCE */
  4177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4178. /** LUMINANCE_ALPHA */
  4179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4180. /** RGB */
  4181. static readonly TEXTUREFORMAT_RGB: number;
  4182. /** RGBA */
  4183. static readonly TEXTUREFORMAT_RGBA: number;
  4184. /** RED */
  4185. static readonly TEXTUREFORMAT_RED: number;
  4186. /** RED (2nd reference) */
  4187. static readonly TEXTUREFORMAT_R: number;
  4188. /** RG */
  4189. static readonly TEXTUREFORMAT_RG: number;
  4190. /** RED_INTEGER */
  4191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4192. /** RED_INTEGER (2nd reference) */
  4193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4194. /** RG_INTEGER */
  4195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4196. /** RGB_INTEGER */
  4197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4198. /** RGBA_INTEGER */
  4199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4200. /** UNSIGNED_BYTE */
  4201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4202. /** UNSIGNED_BYTE (2nd reference) */
  4203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4204. /** FLOAT */
  4205. static readonly TEXTURETYPE_FLOAT: number;
  4206. /** HALF_FLOAT */
  4207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4208. /** BYTE */
  4209. static readonly TEXTURETYPE_BYTE: number;
  4210. /** SHORT */
  4211. static readonly TEXTURETYPE_SHORT: number;
  4212. /** UNSIGNED_SHORT */
  4213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4214. /** INT */
  4215. static readonly TEXTURETYPE_INT: number;
  4216. /** UNSIGNED_INT */
  4217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4218. /** UNSIGNED_SHORT_4_4_4_4 */
  4219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4220. /** UNSIGNED_SHORT_5_5_5_1 */
  4221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4222. /** UNSIGNED_SHORT_5_6_5 */
  4223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4224. /** UNSIGNED_INT_2_10_10_10_REV */
  4225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4226. /** UNSIGNED_INT_24_8 */
  4227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4228. /** UNSIGNED_INT_10F_11F_11F_REV */
  4229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4230. /** UNSIGNED_INT_5_9_9_9_REV */
  4231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4234. /** nearest is mag = nearest and min = nearest and mip = linear */
  4235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4238. /** Trilinear is mag = linear and min = linear and mip = linear */
  4239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4240. /** nearest is mag = nearest and min = nearest and mip = linear */
  4241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4244. /** Trilinear is mag = linear and min = linear and mip = linear */
  4245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4246. /** mag = nearest and min = nearest and mip = nearest */
  4247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4248. /** mag = nearest and min = linear and mip = nearest */
  4249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4250. /** mag = nearest and min = linear and mip = linear */
  4251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4252. /** mag = nearest and min = linear and mip = none */
  4253. static readonly TEXTURE_NEAREST_LINEAR: number;
  4254. /** mag = nearest and min = nearest and mip = none */
  4255. static readonly TEXTURE_NEAREST_NEAREST: number;
  4256. /** mag = linear and min = nearest and mip = nearest */
  4257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4258. /** mag = linear and min = nearest and mip = linear */
  4259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4260. /** mag = linear and min = linear and mip = none */
  4261. static readonly TEXTURE_LINEAR_LINEAR: number;
  4262. /** mag = linear and min = nearest and mip = none */
  4263. static readonly TEXTURE_LINEAR_NEAREST: number;
  4264. /** Explicit coordinates mode */
  4265. static readonly TEXTURE_EXPLICIT_MODE: number;
  4266. /** Spherical coordinates mode */
  4267. static readonly TEXTURE_SPHERICAL_MODE: number;
  4268. /** Planar coordinates mode */
  4269. static readonly TEXTURE_PLANAR_MODE: number;
  4270. /** Cubic coordinates mode */
  4271. static readonly TEXTURE_CUBIC_MODE: number;
  4272. /** Projection coordinates mode */
  4273. static readonly TEXTURE_PROJECTION_MODE: number;
  4274. /** Skybox coordinates mode */
  4275. static readonly TEXTURE_SKYBOX_MODE: number;
  4276. /** Inverse Cubic coordinates mode */
  4277. static readonly TEXTURE_INVCUBIC_MODE: number;
  4278. /** Equirectangular coordinates mode */
  4279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4280. /** Equirectangular Fixed coordinates mode */
  4281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4282. /** Equirectangular Fixed Mirrored coordinates mode */
  4283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4285. static readonly SCALEMODE_FLOOR: number;
  4286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4287. static readonly SCALEMODE_NEAREST: number;
  4288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4289. static readonly SCALEMODE_CEILING: number;
  4290. /**
  4291. * The dirty texture flag value
  4292. */
  4293. static readonly MATERIAL_TextureDirtyFlag: number;
  4294. /**
  4295. * The dirty light flag value
  4296. */
  4297. static readonly MATERIAL_LightDirtyFlag: number;
  4298. /**
  4299. * The dirty fresnel flag value
  4300. */
  4301. static readonly MATERIAL_FresnelDirtyFlag: number;
  4302. /**
  4303. * The dirty attribute flag value
  4304. */
  4305. static readonly MATERIAL_AttributesDirtyFlag: number;
  4306. /**
  4307. * The dirty misc flag value
  4308. */
  4309. static readonly MATERIAL_MiscDirtyFlag: number;
  4310. /**
  4311. * The all dirty flag value
  4312. */
  4313. static readonly MATERIAL_AllDirtyFlag: number;
  4314. /**
  4315. * Returns the triangle fill mode
  4316. */
  4317. static readonly MATERIAL_TriangleFillMode: number;
  4318. /**
  4319. * Returns the wireframe mode
  4320. */
  4321. static readonly MATERIAL_WireFrameFillMode: number;
  4322. /**
  4323. * Returns the point fill mode
  4324. */
  4325. static readonly MATERIAL_PointFillMode: number;
  4326. /**
  4327. * Returns the point list draw mode
  4328. */
  4329. static readonly MATERIAL_PointListDrawMode: number;
  4330. /**
  4331. * Returns the line list draw mode
  4332. */
  4333. static readonly MATERIAL_LineListDrawMode: number;
  4334. /**
  4335. * Returns the line loop draw mode
  4336. */
  4337. static readonly MATERIAL_LineLoopDrawMode: number;
  4338. /**
  4339. * Returns the line strip draw mode
  4340. */
  4341. static readonly MATERIAL_LineStripDrawMode: number;
  4342. /**
  4343. * Returns the triangle strip draw mode
  4344. */
  4345. static readonly MATERIAL_TriangleStripDrawMode: number;
  4346. /**
  4347. * Returns the triangle fan draw mode
  4348. */
  4349. static readonly MATERIAL_TriangleFanDrawMode: number;
  4350. /**
  4351. * Stores the clock-wise side orientation
  4352. */
  4353. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4354. /**
  4355. * Stores the counter clock-wise side orientation
  4356. */
  4357. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4358. /**
  4359. * Nothing
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_NothingTrigger: number;
  4363. /**
  4364. * On pick
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPickTrigger: number;
  4368. /**
  4369. * On left pick
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnLeftPickTrigger: number;
  4373. /**
  4374. * On right pick
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnRightPickTrigger: number;
  4378. /**
  4379. * On center pick
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnCenterPickTrigger: number;
  4383. /**
  4384. * On pick down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnPickDownTrigger: number;
  4388. /**
  4389. * On double pick
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnDoublePickTrigger: number;
  4393. /**
  4394. * On pick up
  4395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4396. */
  4397. static readonly ACTION_OnPickUpTrigger: number;
  4398. /**
  4399. * On pick out.
  4400. * This trigger will only be raised if you also declared a OnPickDown
  4401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4402. */
  4403. static readonly ACTION_OnPickOutTrigger: number;
  4404. /**
  4405. * On long press
  4406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4407. */
  4408. static readonly ACTION_OnLongPressTrigger: number;
  4409. /**
  4410. * On pointer over
  4411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4412. */
  4413. static readonly ACTION_OnPointerOverTrigger: number;
  4414. /**
  4415. * On pointer out
  4416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4417. */
  4418. static readonly ACTION_OnPointerOutTrigger: number;
  4419. /**
  4420. * On every frame
  4421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4422. */
  4423. static readonly ACTION_OnEveryFrameTrigger: number;
  4424. /**
  4425. * On intersection enter
  4426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4427. */
  4428. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4429. /**
  4430. * On intersection exit
  4431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4432. */
  4433. static readonly ACTION_OnIntersectionExitTrigger: number;
  4434. /**
  4435. * On key down
  4436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4437. */
  4438. static readonly ACTION_OnKeyDownTrigger: number;
  4439. /**
  4440. * On key up
  4441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4442. */
  4443. static readonly ACTION_OnKeyUpTrigger: number;
  4444. /**
  4445. * Billboard mode will only apply to Y axis
  4446. */
  4447. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4448. /**
  4449. * Billboard mode will apply to all axes
  4450. */
  4451. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4452. /**
  4453. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4454. */
  4455. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4456. /**
  4457. * Gets or sets base Assets URL
  4458. */
  4459. static PARTICLES_BaseAssetsUrl: string;
  4460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4461. * Test order :
  4462. * Is the bounding sphere outside the frustum ?
  4463. * If not, are the bounding box vertices outside the frustum ?
  4464. * It not, then the cullable object is in the frustum.
  4465. */
  4466. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4467. /** Culling strategy : Bounding Sphere Only.
  4468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4469. * It's also less accurate than the standard because some not visible objects can still be selected.
  4470. * Test : is the bounding sphere outside the frustum ?
  4471. * If not, then the cullable object is in the frustum.
  4472. */
  4473. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4474. /** Culling strategy : Optimistic Inclusion.
  4475. * This in an inclusion test first, then the standard exclusion test.
  4476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4477. * 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.
  4478. * Anyway, it's as accurate as the standard strategy.
  4479. * Test :
  4480. * Is the cullable object bounding sphere center in the frustum ?
  4481. * If not, apply the default culling strategy.
  4482. */
  4483. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4487. * 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.
  4488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4489. * Test :
  4490. * Is the cullable object bounding sphere center in the frustum ?
  4491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4492. */
  4493. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4494. /**
  4495. * No logging while loading
  4496. */
  4497. static readonly SCENELOADER_NO_LOGGING: number;
  4498. /**
  4499. * Minimal logging while loading
  4500. */
  4501. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4502. /**
  4503. * Summary logging while loading
  4504. */
  4505. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4506. /**
  4507. * Detailled logging while loading
  4508. */
  4509. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4510. }
  4511. }
  4512. declare module "babylonjs/Engines/IPipelineContext" {
  4513. /**
  4514. * Class used to store and describe the pipeline context associated with an effect
  4515. */
  4516. export interface IPipelineContext {
  4517. /**
  4518. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4519. */
  4520. isAsync: boolean;
  4521. /**
  4522. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4523. */
  4524. isReady: boolean;
  4525. /** @hidden */
  4526. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4527. }
  4528. }
  4529. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4530. /** @hidden */
  4531. export interface IShaderProcessor {
  4532. attributeProcessor?: (attribute: string) => string;
  4533. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4534. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4535. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4536. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4537. lineProcessor?: (line: string, isFragment: boolean) => string;
  4538. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4539. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4540. }
  4541. }
  4542. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4543. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4544. /** @hidden */
  4545. export interface ProcessingOptions {
  4546. defines: string[];
  4547. indexParameters: any;
  4548. isFragment: boolean;
  4549. shouldUseHighPrecisionShader: boolean;
  4550. supportsUniformBuffers: boolean;
  4551. shadersRepository: string;
  4552. includesShadersStore: {
  4553. [key: string]: string;
  4554. };
  4555. processor?: IShaderProcessor;
  4556. version: string;
  4557. platformName: string;
  4558. lookForClosingBracketForUniformBuffer?: boolean;
  4559. }
  4560. }
  4561. declare module "babylonjs/Misc/stringTools" {
  4562. /**
  4563. * Helper to manipulate strings
  4564. */
  4565. export class StringTools {
  4566. /**
  4567. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4568. * @param str Source string
  4569. * @param suffix Suffix to search for in the source string
  4570. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4571. */
  4572. static EndsWith(str: string, suffix: string): boolean;
  4573. /**
  4574. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4575. * @param str Source string
  4576. * @param suffix Suffix to search for in the source string
  4577. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4578. */
  4579. static StartsWith(str: string, suffix: string): boolean;
  4580. }
  4581. }
  4582. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4583. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4584. /** @hidden */
  4585. export class ShaderCodeNode {
  4586. line: string;
  4587. children: ShaderCodeNode[];
  4588. additionalDefineKey?: string;
  4589. additionalDefineValue?: string;
  4590. isValid(preprocessors: {
  4591. [key: string]: string;
  4592. }): boolean;
  4593. process(preprocessors: {
  4594. [key: string]: string;
  4595. }, options: ProcessingOptions): string;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4599. /** @hidden */
  4600. export class ShaderCodeCursor {
  4601. private _lines;
  4602. lineIndex: number;
  4603. readonly currentLine: string;
  4604. readonly canRead: boolean;
  4605. lines: string[];
  4606. }
  4607. }
  4608. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4609. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4610. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4611. /** @hidden */
  4612. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4613. process(preprocessors: {
  4614. [key: string]: string;
  4615. }, options: ProcessingOptions): string;
  4616. }
  4617. }
  4618. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4619. /** @hidden */
  4620. export class ShaderDefineExpression {
  4621. isTrue(preprocessors: {
  4622. [key: string]: string;
  4623. }): boolean;
  4624. }
  4625. }
  4626. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4627. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4628. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4629. /** @hidden */
  4630. export class ShaderCodeTestNode extends ShaderCodeNode {
  4631. testExpression: ShaderDefineExpression;
  4632. isValid(preprocessors: {
  4633. [key: string]: string;
  4634. }): boolean;
  4635. }
  4636. }
  4637. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4638. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4639. /** @hidden */
  4640. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4641. define: string;
  4642. not: boolean;
  4643. constructor(define: string, not?: boolean);
  4644. isTrue(preprocessors: {
  4645. [key: string]: string;
  4646. }): boolean;
  4647. }
  4648. }
  4649. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4650. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4651. /** @hidden */
  4652. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4653. leftOperand: ShaderDefineExpression;
  4654. rightOperand: ShaderDefineExpression;
  4655. isTrue(preprocessors: {
  4656. [key: string]: string;
  4657. }): boolean;
  4658. }
  4659. }
  4660. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4661. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4662. /** @hidden */
  4663. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4664. leftOperand: ShaderDefineExpression;
  4665. rightOperand: ShaderDefineExpression;
  4666. isTrue(preprocessors: {
  4667. [key: string]: string;
  4668. }): boolean;
  4669. }
  4670. }
  4671. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4672. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4673. /** @hidden */
  4674. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4675. define: string;
  4676. operand: string;
  4677. testValue: string;
  4678. constructor(define: string, operand: string, testValue: string);
  4679. isTrue(preprocessors: {
  4680. [key: string]: string;
  4681. }): boolean;
  4682. }
  4683. }
  4684. declare module "babylonjs/Misc/loadFileError" {
  4685. import { WebRequest } from "babylonjs/Misc/webRequest";
  4686. /**
  4687. * @ignore
  4688. * Application error to support additional information when loading a file
  4689. */
  4690. export class LoadFileError extends Error {
  4691. /** defines the optional web request */
  4692. request?: WebRequest | undefined;
  4693. private static _setPrototypeOf;
  4694. /**
  4695. * Creates a new LoadFileError
  4696. * @param message defines the message of the error
  4697. * @param request defines the optional web request
  4698. */
  4699. constructor(message: string,
  4700. /** defines the optional web request */
  4701. request?: WebRequest | undefined);
  4702. }
  4703. }
  4704. declare module "babylonjs/Offline/IOfflineProvider" {
  4705. /**
  4706. * Class used to enable access to offline support
  4707. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4708. */
  4709. export interface IOfflineProvider {
  4710. /**
  4711. * Gets a boolean indicating if scene must be saved in the database
  4712. */
  4713. enableSceneOffline: boolean;
  4714. /**
  4715. * Gets a boolean indicating if textures must be saved in the database
  4716. */
  4717. enableTexturesOffline: boolean;
  4718. /**
  4719. * Open the offline support and make it available
  4720. * @param successCallback defines the callback to call on success
  4721. * @param errorCallback defines the callback to call on error
  4722. */
  4723. open(successCallback: () => void, errorCallback: () => void): void;
  4724. /**
  4725. * Loads an image from the offline support
  4726. * @param url defines the url to load from
  4727. * @param image defines the target DOM image
  4728. */
  4729. loadImage(url: string, image: HTMLImageElement): void;
  4730. /**
  4731. * Loads a file from offline support
  4732. * @param url defines the URL to load from
  4733. * @param sceneLoaded defines a callback to call on success
  4734. * @param progressCallBack defines a callback to call when progress changed
  4735. * @param errorCallback defines a callback to call on error
  4736. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4737. */
  4738. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4739. }
  4740. }
  4741. declare module "babylonjs/Misc/filesInputStore" {
  4742. /**
  4743. * Class used to help managing file picking and drag'n'drop
  4744. * File Storage
  4745. */
  4746. export class FilesInputStore {
  4747. /**
  4748. * List of files ready to be loaded
  4749. */
  4750. static FilesToLoad: {
  4751. [key: string]: File;
  4752. };
  4753. }
  4754. }
  4755. declare module "babylonjs/Misc/retryStrategy" {
  4756. import { WebRequest } from "babylonjs/Misc/webRequest";
  4757. /**
  4758. * Class used to define a retry strategy when error happens while loading assets
  4759. */
  4760. export class RetryStrategy {
  4761. /**
  4762. * Function used to defines an exponential back off strategy
  4763. * @param maxRetries defines the maximum number of retries (3 by default)
  4764. * @param baseInterval defines the interval between retries
  4765. * @returns the strategy function to use
  4766. */
  4767. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4768. }
  4769. }
  4770. declare module "babylonjs/Misc/fileTools" {
  4771. import { WebRequest } from "babylonjs/Misc/webRequest";
  4772. import { Nullable } from "babylonjs/types";
  4773. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4774. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4775. /**
  4776. * @hidden
  4777. */
  4778. export class FileTools {
  4779. /**
  4780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4781. */
  4782. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4783. /**
  4784. * Gets or sets the base URL to use to load assets
  4785. */
  4786. static BaseUrl: string;
  4787. /**
  4788. * Default behaviour for cors in the application.
  4789. * It can be a string if the expected behavior is identical in the entire app.
  4790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4791. */
  4792. static CorsBehavior: string | ((url: string | string[]) => string);
  4793. /**
  4794. * Gets or sets a function used to pre-process url before using them to load assets
  4795. */
  4796. static PreprocessUrl: (url: string) => string;
  4797. /**
  4798. * Removes unwanted characters from an url
  4799. * @param url defines the url to clean
  4800. * @returns the cleaned url
  4801. */
  4802. private static _CleanUrl;
  4803. /**
  4804. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4805. * @param url define the url we are trying
  4806. * @param element define the dom element where to configure the cors policy
  4807. */
  4808. static SetCorsBehavior(url: string | string[], element: {
  4809. crossOrigin: string | null;
  4810. }): void;
  4811. /**
  4812. * Loads an image as an HTMLImageElement.
  4813. * @param input url string, ArrayBuffer, or Blob to load
  4814. * @param onLoad callback called when the image successfully loads
  4815. * @param onError callback called when the image fails to load
  4816. * @param offlineProvider offline provider for caching
  4817. * @returns the HTMLImageElement of the loaded image
  4818. */
  4819. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4820. /**
  4821. * Loads a file
  4822. * @param fileToLoad defines the file to load
  4823. * @param callback defines the callback to call when data is loaded
  4824. * @param progressCallBack defines the callback to call during loading process
  4825. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4826. * @returns a file request object
  4827. */
  4828. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4829. /**
  4830. * Loads a file
  4831. * @param url url string, ArrayBuffer, or Blob to load
  4832. * @param onSuccess callback called when the file successfully loads
  4833. * @param onProgress callback called while file is loading (if the server supports this mode)
  4834. * @param offlineProvider defines the offline provider for caching
  4835. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4836. * @param onError callback called when the file fails to load
  4837. * @returns a file request object
  4838. */
  4839. 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;
  4840. /**
  4841. * Checks if the loaded document was accessed via `file:`-Protocol.
  4842. * @returns boolean
  4843. */
  4844. static IsFileURL(): boolean;
  4845. }
  4846. }
  4847. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4848. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4849. /** @hidden */
  4850. export class ShaderProcessor {
  4851. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4852. private static _ProcessPrecision;
  4853. private static _ExtractOperation;
  4854. private static _BuildSubExpression;
  4855. private static _BuildExpression;
  4856. private static _MoveCursorWithinIf;
  4857. private static _MoveCursor;
  4858. private static _EvaluatePreProcessors;
  4859. private static _PreparePreProcessors;
  4860. private static _ProcessShaderConversion;
  4861. private static _ProcessIncludes;
  4862. }
  4863. }
  4864. declare module "babylonjs/Maths/math.color" {
  4865. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4866. /**
  4867. * Class used to hold a RBG color
  4868. */
  4869. export class Color3 {
  4870. /**
  4871. * Defines the red component (between 0 and 1, default is 0)
  4872. */
  4873. r: number;
  4874. /**
  4875. * Defines the green component (between 0 and 1, default is 0)
  4876. */
  4877. g: number;
  4878. /**
  4879. * Defines the blue component (between 0 and 1, default is 0)
  4880. */
  4881. b: number;
  4882. /**
  4883. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4884. * @param r defines the red component (between 0 and 1, default is 0)
  4885. * @param g defines the green component (between 0 and 1, default is 0)
  4886. * @param b defines the blue component (between 0 and 1, default is 0)
  4887. */
  4888. constructor(
  4889. /**
  4890. * Defines the red component (between 0 and 1, default is 0)
  4891. */
  4892. r?: number,
  4893. /**
  4894. * Defines the green component (between 0 and 1, default is 0)
  4895. */
  4896. g?: number,
  4897. /**
  4898. * Defines the blue component (between 0 and 1, default is 0)
  4899. */
  4900. b?: number);
  4901. /**
  4902. * Creates a string with the Color3 current values
  4903. * @returns the string representation of the Color3 object
  4904. */
  4905. toString(): string;
  4906. /**
  4907. * Returns the string "Color3"
  4908. * @returns "Color3"
  4909. */
  4910. getClassName(): string;
  4911. /**
  4912. * Compute the Color3 hash code
  4913. * @returns an unique number that can be used to hash Color3 objects
  4914. */
  4915. getHashCode(): number;
  4916. /**
  4917. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4918. * @param array defines the array where to store the r,g,b components
  4919. * @param index defines an optional index in the target array to define where to start storing values
  4920. * @returns the current Color3 object
  4921. */
  4922. toArray(array: FloatArray, index?: number): Color3;
  4923. /**
  4924. * Returns a new Color4 object from the current Color3 and the given alpha
  4925. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4926. * @returns a new Color4 object
  4927. */
  4928. toColor4(alpha?: number): Color4;
  4929. /**
  4930. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4931. * @returns the new array
  4932. */
  4933. asArray(): number[];
  4934. /**
  4935. * Returns the luminance value
  4936. * @returns a float value
  4937. */
  4938. toLuminance(): number;
  4939. /**
  4940. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4941. * @param otherColor defines the second operand
  4942. * @returns the new Color3 object
  4943. */
  4944. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4945. /**
  4946. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4947. * @param otherColor defines the second operand
  4948. * @param result defines the Color3 object where to store the result
  4949. * @returns the current Color3
  4950. */
  4951. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4952. /**
  4953. * Determines equality between Color3 objects
  4954. * @param otherColor defines the second operand
  4955. * @returns true if the rgb values are equal to the given ones
  4956. */
  4957. equals(otherColor: DeepImmutable<Color3>): boolean;
  4958. /**
  4959. * Determines equality between the current Color3 object and a set of r,b,g values
  4960. * @param r defines the red component to check
  4961. * @param g defines the green component to check
  4962. * @param b defines the blue component to check
  4963. * @returns true if the rgb values are equal to the given ones
  4964. */
  4965. equalsFloats(r: number, g: number, b: number): boolean;
  4966. /**
  4967. * Multiplies in place each rgb value by scale
  4968. * @param scale defines the scaling factor
  4969. * @returns the updated Color3
  4970. */
  4971. scale(scale: number): Color3;
  4972. /**
  4973. * Multiplies the rgb values by scale and stores the result into "result"
  4974. * @param scale defines the scaling factor
  4975. * @param result defines the Color3 object where to store the result
  4976. * @returns the unmodified current Color3
  4977. */
  4978. scaleToRef(scale: number, result: Color3): Color3;
  4979. /**
  4980. * Scale the current Color3 values by a factor and add the result to a given Color3
  4981. * @param scale defines the scale factor
  4982. * @param result defines color to store the result into
  4983. * @returns the unmodified current Color3
  4984. */
  4985. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4986. /**
  4987. * Clamps the rgb values by the min and max values and stores the result into "result"
  4988. * @param min defines minimum clamping value (default is 0)
  4989. * @param max defines maximum clamping value (default is 1)
  4990. * @param result defines color to store the result into
  4991. * @returns the original Color3
  4992. */
  4993. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4994. /**
  4995. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4996. * @param otherColor defines the second operand
  4997. * @returns the new Color3
  4998. */
  4999. add(otherColor: DeepImmutable<Color3>): Color3;
  5000. /**
  5001. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5002. * @param otherColor defines the second operand
  5003. * @param result defines Color3 object to store the result into
  5004. * @returns the unmodified current Color3
  5005. */
  5006. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5007. /**
  5008. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5009. * @param otherColor defines the second operand
  5010. * @returns the new Color3
  5011. */
  5012. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5013. /**
  5014. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5015. * @param otherColor defines the second operand
  5016. * @param result defines Color3 object to store the result into
  5017. * @returns the unmodified current Color3
  5018. */
  5019. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5020. /**
  5021. * Copy the current object
  5022. * @returns a new Color3 copied the current one
  5023. */
  5024. clone(): Color3;
  5025. /**
  5026. * Copies the rgb values from the source in the current Color3
  5027. * @param source defines the source Color3 object
  5028. * @returns the updated Color3 object
  5029. */
  5030. copyFrom(source: DeepImmutable<Color3>): Color3;
  5031. /**
  5032. * Updates the Color3 rgb values from the given floats
  5033. * @param r defines the red component to read from
  5034. * @param g defines the green component to read from
  5035. * @param b defines the blue component to read from
  5036. * @returns the current Color3 object
  5037. */
  5038. copyFromFloats(r: number, g: number, b: number): Color3;
  5039. /**
  5040. * Updates the Color3 rgb values from the given floats
  5041. * @param r defines the red component to read from
  5042. * @param g defines the green component to read from
  5043. * @param b defines the blue component to read from
  5044. * @returns the current Color3 object
  5045. */
  5046. set(r: number, g: number, b: number): Color3;
  5047. /**
  5048. * Compute the Color3 hexadecimal code as a string
  5049. * @returns a string containing the hexadecimal representation of the Color3 object
  5050. */
  5051. toHexString(): string;
  5052. /**
  5053. * Computes a new Color3 converted from the current one to linear space
  5054. * @returns a new Color3 object
  5055. */
  5056. toLinearSpace(): Color3;
  5057. /**
  5058. * Converts current color in rgb space to HSV values
  5059. * @returns a new color3 representing the HSV values
  5060. */
  5061. toHSV(): Color3;
  5062. /**
  5063. * Converts current color in rgb space to HSV values
  5064. * @param result defines the Color3 where to store the HSV values
  5065. */
  5066. toHSVToRef(result: Color3): void;
  5067. /**
  5068. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5069. * @param convertedColor defines the Color3 object where to store the linear space version
  5070. * @returns the unmodified Color3
  5071. */
  5072. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5073. /**
  5074. * Computes a new Color3 converted from the current one to gamma space
  5075. * @returns a new Color3 object
  5076. */
  5077. toGammaSpace(): Color3;
  5078. /**
  5079. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5080. * @param convertedColor defines the Color3 object where to store the gamma space version
  5081. * @returns the unmodified Color3
  5082. */
  5083. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5084. private static _BlackReadOnly;
  5085. /**
  5086. * Convert Hue, saturation and value to a Color3 (RGB)
  5087. * @param hue defines the hue
  5088. * @param saturation defines the saturation
  5089. * @param value defines the value
  5090. * @param result defines the Color3 where to store the RGB values
  5091. */
  5092. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5093. /**
  5094. * Creates a new Color3 from the string containing valid hexadecimal values
  5095. * @param hex defines a string containing valid hexadecimal values
  5096. * @returns a new Color3 object
  5097. */
  5098. static FromHexString(hex: string): Color3;
  5099. /**
  5100. * Creates a new Color3 from the starting index of the given array
  5101. * @param array defines the source array
  5102. * @param offset defines an offset in the source array
  5103. * @returns a new Color3 object
  5104. */
  5105. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5106. /**
  5107. * Creates a new Color3 from integer values (< 256)
  5108. * @param r defines the red component to read from (value between 0 and 255)
  5109. * @param g defines the green component to read from (value between 0 and 255)
  5110. * @param b defines the blue component to read from (value between 0 and 255)
  5111. * @returns a new Color3 object
  5112. */
  5113. static FromInts(r: number, g: number, b: number): Color3;
  5114. /**
  5115. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5116. * @param start defines the start Color3 value
  5117. * @param end defines the end Color3 value
  5118. * @param amount defines the gradient value between start and end
  5119. * @returns a new Color3 object
  5120. */
  5121. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5122. /**
  5123. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5124. * @param left defines the start value
  5125. * @param right defines the end value
  5126. * @param amount defines the gradient factor
  5127. * @param result defines the Color3 object where to store the result
  5128. */
  5129. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5130. /**
  5131. * Returns a Color3 value containing a red color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Red(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a green color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Green(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a blue color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Blue(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a black color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Black(): Color3;
  5150. /**
  5151. * Gets a Color3 value containing a black color that must not be updated
  5152. */
  5153. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5154. /**
  5155. * Returns a Color3 value containing a white color
  5156. * @returns a new Color3 object
  5157. */
  5158. static White(): Color3;
  5159. /**
  5160. * Returns a Color3 value containing a purple color
  5161. * @returns a new Color3 object
  5162. */
  5163. static Purple(): Color3;
  5164. /**
  5165. * Returns a Color3 value containing a magenta color
  5166. * @returns a new Color3 object
  5167. */
  5168. static Magenta(): Color3;
  5169. /**
  5170. * Returns a Color3 value containing a yellow color
  5171. * @returns a new Color3 object
  5172. */
  5173. static Yellow(): Color3;
  5174. /**
  5175. * Returns a Color3 value containing a gray color
  5176. * @returns a new Color3 object
  5177. */
  5178. static Gray(): Color3;
  5179. /**
  5180. * Returns a Color3 value containing a teal color
  5181. * @returns a new Color3 object
  5182. */
  5183. static Teal(): Color3;
  5184. /**
  5185. * Returns a Color3 value containing a random color
  5186. * @returns a new Color3 object
  5187. */
  5188. static Random(): Color3;
  5189. }
  5190. /**
  5191. * Class used to hold a RBGA color
  5192. */
  5193. export class Color4 {
  5194. /**
  5195. * Defines the red component (between 0 and 1, default is 0)
  5196. */
  5197. r: number;
  5198. /**
  5199. * Defines the green component (between 0 and 1, default is 0)
  5200. */
  5201. g: number;
  5202. /**
  5203. * Defines the blue component (between 0 and 1, default is 0)
  5204. */
  5205. b: number;
  5206. /**
  5207. * Defines the alpha component (between 0 and 1, default is 1)
  5208. */
  5209. a: number;
  5210. /**
  5211. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5212. * @param r defines the red component (between 0 and 1, default is 0)
  5213. * @param g defines the green component (between 0 and 1, default is 0)
  5214. * @param b defines the blue component (between 0 and 1, default is 0)
  5215. * @param a defines the alpha component (between 0 and 1, default is 1)
  5216. */
  5217. constructor(
  5218. /**
  5219. * Defines the red component (between 0 and 1, default is 0)
  5220. */
  5221. r?: number,
  5222. /**
  5223. * Defines the green component (between 0 and 1, default is 0)
  5224. */
  5225. g?: number,
  5226. /**
  5227. * Defines the blue component (between 0 and 1, default is 0)
  5228. */
  5229. b?: number,
  5230. /**
  5231. * Defines the alpha component (between 0 and 1, default is 1)
  5232. */
  5233. a?: number);
  5234. /**
  5235. * Adds in place the given Color4 values to the current Color4 object
  5236. * @param right defines the second operand
  5237. * @returns the current updated Color4 object
  5238. */
  5239. addInPlace(right: DeepImmutable<Color4>): Color4;
  5240. /**
  5241. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5242. * @returns the new array
  5243. */
  5244. asArray(): number[];
  5245. /**
  5246. * Stores from the starting index in the given array the Color4 successive values
  5247. * @param array defines the array where to store the r,g,b components
  5248. * @param index defines an optional index in the target array to define where to start storing values
  5249. * @returns the current Color4 object
  5250. */
  5251. toArray(array: number[], index?: number): Color4;
  5252. /**
  5253. * Determines equality between Color4 objects
  5254. * @param otherColor defines the second operand
  5255. * @returns true if the rgba values are equal to the given ones
  5256. */
  5257. equals(otherColor: DeepImmutable<Color4>): boolean;
  5258. /**
  5259. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5260. * @param right defines the second operand
  5261. * @returns a new Color4 object
  5262. */
  5263. add(right: DeepImmutable<Color4>): Color4;
  5264. /**
  5265. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5266. * @param right defines the second operand
  5267. * @returns a new Color4 object
  5268. */
  5269. subtract(right: DeepImmutable<Color4>): Color4;
  5270. /**
  5271. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5272. * @param right defines the second operand
  5273. * @param result defines the Color4 object where to store the result
  5274. * @returns the current Color4 object
  5275. */
  5276. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5277. /**
  5278. * Creates a new Color4 with the current Color4 values multiplied by scale
  5279. * @param scale defines the scaling factor to apply
  5280. * @returns a new Color4 object
  5281. */
  5282. scale(scale: number): Color4;
  5283. /**
  5284. * Multiplies the current Color4 values by scale and stores the result in "result"
  5285. * @param scale defines the scaling factor to apply
  5286. * @param result defines the Color4 object where to store the result
  5287. * @returns the current unmodified Color4
  5288. */
  5289. scaleToRef(scale: number, result: Color4): Color4;
  5290. /**
  5291. * Scale the current Color4 values by a factor and add the result to a given Color4
  5292. * @param scale defines the scale factor
  5293. * @param result defines the Color4 object where to store the result
  5294. * @returns the unmodified current Color4
  5295. */
  5296. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5297. /**
  5298. * Clamps the rgb values by the min and max values and stores the result into "result"
  5299. * @param min defines minimum clamping value (default is 0)
  5300. * @param max defines maximum clamping value (default is 1)
  5301. * @param result defines color to store the result into.
  5302. * @returns the cuurent Color4
  5303. */
  5304. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5305. /**
  5306. * Multipy an Color4 value by another and return a new Color4 object
  5307. * @param color defines the Color4 value to multiply by
  5308. * @returns a new Color4 object
  5309. */
  5310. multiply(color: Color4): Color4;
  5311. /**
  5312. * Multipy a Color4 value by another and push the result in a reference value
  5313. * @param color defines the Color4 value to multiply by
  5314. * @param result defines the Color4 to fill the result in
  5315. * @returns the result Color4
  5316. */
  5317. multiplyToRef(color: Color4, result: Color4): Color4;
  5318. /**
  5319. * Creates a string with the Color4 current values
  5320. * @returns the string representation of the Color4 object
  5321. */
  5322. toString(): string;
  5323. /**
  5324. * Returns the string "Color4"
  5325. * @returns "Color4"
  5326. */
  5327. getClassName(): string;
  5328. /**
  5329. * Compute the Color4 hash code
  5330. * @returns an unique number that can be used to hash Color4 objects
  5331. */
  5332. getHashCode(): number;
  5333. /**
  5334. * Creates a new Color4 copied from the current one
  5335. * @returns a new Color4 object
  5336. */
  5337. clone(): Color4;
  5338. /**
  5339. * Copies the given Color4 values into the current one
  5340. * @param source defines the source Color4 object
  5341. * @returns the current updated Color4 object
  5342. */
  5343. copyFrom(source: Color4): Color4;
  5344. /**
  5345. * Copies the given float values into the current one
  5346. * @param r defines the red component to read from
  5347. * @param g defines the green component to read from
  5348. * @param b defines the blue component to read from
  5349. * @param a defines the alpha component to read from
  5350. * @returns the current updated Color4 object
  5351. */
  5352. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5353. /**
  5354. * Copies the given float values into the current one
  5355. * @param r defines the red component to read from
  5356. * @param g defines the green component to read from
  5357. * @param b defines the blue component to read from
  5358. * @param a defines the alpha component to read from
  5359. * @returns the current updated Color4 object
  5360. */
  5361. set(r: number, g: number, b: number, a: number): Color4;
  5362. /**
  5363. * Compute the Color4 hexadecimal code as a string
  5364. * @returns a string containing the hexadecimal representation of the Color4 object
  5365. */
  5366. toHexString(): string;
  5367. /**
  5368. * Computes a new Color4 converted from the current one to linear space
  5369. * @returns a new Color4 object
  5370. */
  5371. toLinearSpace(): Color4;
  5372. /**
  5373. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5374. * @param convertedColor defines the Color4 object where to store the linear space version
  5375. * @returns the unmodified Color4
  5376. */
  5377. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5378. /**
  5379. * Computes a new Color4 converted from the current one to gamma space
  5380. * @returns a new Color4 object
  5381. */
  5382. toGammaSpace(): Color4;
  5383. /**
  5384. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5385. * @param convertedColor defines the Color4 object where to store the gamma space version
  5386. * @returns the unmodified Color4
  5387. */
  5388. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5389. /**
  5390. * Creates a new Color4 from the string containing valid hexadecimal values
  5391. * @param hex defines a string containing valid hexadecimal values
  5392. * @returns a new Color4 object
  5393. */
  5394. static FromHexString(hex: string): Color4;
  5395. /**
  5396. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5397. * @param left defines the start value
  5398. * @param right defines the end value
  5399. * @param amount defines the gradient factor
  5400. * @returns a new Color4 object
  5401. */
  5402. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5403. /**
  5404. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5405. * @param left defines the start value
  5406. * @param right defines the end value
  5407. * @param amount defines the gradient factor
  5408. * @param result defines the Color4 object where to store data
  5409. */
  5410. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5411. /**
  5412. * Creates a new Color4 from a Color3 and an alpha value
  5413. * @param color3 defines the source Color3 to read from
  5414. * @param alpha defines the alpha component (1.0 by default)
  5415. * @returns a new Color4 object
  5416. */
  5417. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5418. /**
  5419. * Creates a new Color4 from the starting index element of the given array
  5420. * @param array defines the source array to read from
  5421. * @param offset defines the offset in the source array
  5422. * @returns a new Color4 object
  5423. */
  5424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5425. /**
  5426. * Creates a new Color3 from integer values (< 256)
  5427. * @param r defines the red component to read from (value between 0 and 255)
  5428. * @param g defines the green component to read from (value between 0 and 255)
  5429. * @param b defines the blue component to read from (value between 0 and 255)
  5430. * @param a defines the alpha component to read from (value between 0 and 255)
  5431. * @returns a new Color3 object
  5432. */
  5433. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5434. /**
  5435. * Check the content of a given array and convert it to an array containing RGBA data
  5436. * If the original array was already containing count * 4 values then it is returned directly
  5437. * @param colors defines the array to check
  5438. * @param count defines the number of RGBA data to expect
  5439. * @returns an array containing count * 4 values (RGBA)
  5440. */
  5441. static CheckColors4(colors: number[], count: number): number[];
  5442. }
  5443. /**
  5444. * @hidden
  5445. */
  5446. export class TmpColors {
  5447. static Color3: Color3[];
  5448. static Color4: Color4[];
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/sphericalPolynomial" {
  5452. import { Vector3 } from "babylonjs/Maths/math.vector";
  5453. import { Color3 } from "babylonjs/Maths/math.color";
  5454. /**
  5455. * Class representing spherical harmonics coefficients to the 3rd degree
  5456. */
  5457. export class SphericalHarmonics {
  5458. /**
  5459. * Defines whether or not the harmonics have been prescaled for rendering.
  5460. */
  5461. preScaled: boolean;
  5462. /**
  5463. * The l0,0 coefficients of the spherical harmonics
  5464. */
  5465. l00: Vector3;
  5466. /**
  5467. * The l1,-1 coefficients of the spherical harmonics
  5468. */
  5469. l1_1: Vector3;
  5470. /**
  5471. * The l1,0 coefficients of the spherical harmonics
  5472. */
  5473. l10: Vector3;
  5474. /**
  5475. * The l1,1 coefficients of the spherical harmonics
  5476. */
  5477. l11: Vector3;
  5478. /**
  5479. * The l2,-2 coefficients of the spherical harmonics
  5480. */
  5481. l2_2: Vector3;
  5482. /**
  5483. * The l2,-1 coefficients of the spherical harmonics
  5484. */
  5485. l2_1: Vector3;
  5486. /**
  5487. * The l2,0 coefficients of the spherical harmonics
  5488. */
  5489. l20: Vector3;
  5490. /**
  5491. * The l2,1 coefficients of the spherical harmonics
  5492. */
  5493. l21: Vector3;
  5494. /**
  5495. * The l2,2 coefficients of the spherical harmonics
  5496. */
  5497. l22: Vector3;
  5498. /**
  5499. * Adds a light to the spherical harmonics
  5500. * @param direction the direction of the light
  5501. * @param color the color of the light
  5502. * @param deltaSolidAngle the delta solid angle of the light
  5503. */
  5504. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5505. /**
  5506. * Scales the spherical harmonics by the given amount
  5507. * @param scale the amount to scale
  5508. */
  5509. scaleInPlace(scale: number): void;
  5510. /**
  5511. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5512. *
  5513. * ```
  5514. * E_lm = A_l * L_lm
  5515. * ```
  5516. *
  5517. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5518. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5519. * the scaling factors are given in equation 9.
  5520. */
  5521. convertIncidentRadianceToIrradiance(): void;
  5522. /**
  5523. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5524. *
  5525. * ```
  5526. * L = (1/pi) * E * rho
  5527. * ```
  5528. *
  5529. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5530. */
  5531. convertIrradianceToLambertianRadiance(): void;
  5532. /**
  5533. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5534. * required operations at run time.
  5535. *
  5536. * This is simply done by scaling back the SH with Ylm constants parameter.
  5537. * The trigonometric part being applied by the shader at run time.
  5538. */
  5539. preScaleForRendering(): void;
  5540. /**
  5541. * Constructs a spherical harmonics from an array.
  5542. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5543. * @returns the spherical harmonics
  5544. */
  5545. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5546. /**
  5547. * Gets the spherical harmonics from polynomial
  5548. * @param polynomial the spherical polynomial
  5549. * @returns the spherical harmonics
  5550. */
  5551. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5552. }
  5553. /**
  5554. * Class representing spherical polynomial coefficients to the 3rd degree
  5555. */
  5556. export class SphericalPolynomial {
  5557. private _harmonics;
  5558. /**
  5559. * The spherical harmonics used to create the polynomials.
  5560. */
  5561. readonly preScaledHarmonics: SphericalHarmonics;
  5562. /**
  5563. * The x coefficients of the spherical polynomial
  5564. */
  5565. x: Vector3;
  5566. /**
  5567. * The y coefficients of the spherical polynomial
  5568. */
  5569. y: Vector3;
  5570. /**
  5571. * The z coefficients of the spherical polynomial
  5572. */
  5573. z: Vector3;
  5574. /**
  5575. * The xx coefficients of the spherical polynomial
  5576. */
  5577. xx: Vector3;
  5578. /**
  5579. * The yy coefficients of the spherical polynomial
  5580. */
  5581. yy: Vector3;
  5582. /**
  5583. * The zz coefficients of the spherical polynomial
  5584. */
  5585. zz: Vector3;
  5586. /**
  5587. * The xy coefficients of the spherical polynomial
  5588. */
  5589. xy: Vector3;
  5590. /**
  5591. * The yz coefficients of the spherical polynomial
  5592. */
  5593. yz: Vector3;
  5594. /**
  5595. * The zx coefficients of the spherical polynomial
  5596. */
  5597. zx: Vector3;
  5598. /**
  5599. * Adds an ambient color to the spherical polynomial
  5600. * @param color the color to add
  5601. */
  5602. addAmbient(color: Color3): void;
  5603. /**
  5604. * Scales the spherical polynomial by the given amount
  5605. * @param scale the amount to scale
  5606. */
  5607. scaleInPlace(scale: number): void;
  5608. /**
  5609. * Gets the spherical polynomial from harmonics
  5610. * @param harmonics the spherical harmonics
  5611. * @returns the spherical polynomial
  5612. */
  5613. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5614. /**
  5615. * Constructs a spherical polynomial from an array.
  5616. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5617. * @returns the spherical polynomial
  5618. */
  5619. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5620. }
  5621. }
  5622. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5623. /**
  5624. * Define options used to create a render target texture
  5625. */
  5626. export class RenderTargetCreationOptions {
  5627. /**
  5628. * Specifies is mipmaps must be generated
  5629. */
  5630. generateMipMaps?: boolean;
  5631. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5632. generateDepthBuffer?: boolean;
  5633. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5634. generateStencilBuffer?: boolean;
  5635. /** Defines texture type (int by default) */
  5636. type?: number;
  5637. /** Defines sampling mode (trilinear by default) */
  5638. samplingMode?: number;
  5639. /** Defines format (RGBA by default) */
  5640. format?: number;
  5641. }
  5642. }
  5643. declare module "babylonjs/States/alphaCullingState" {
  5644. /**
  5645. * @hidden
  5646. **/
  5647. export class _AlphaState {
  5648. private _isAlphaBlendDirty;
  5649. private _isBlendFunctionParametersDirty;
  5650. private _isBlendEquationParametersDirty;
  5651. private _isBlendConstantsDirty;
  5652. private _alphaBlend;
  5653. private _blendFunctionParameters;
  5654. private _blendEquationParameters;
  5655. private _blendConstants;
  5656. /**
  5657. * Initializes the state.
  5658. */
  5659. constructor();
  5660. readonly isDirty: boolean;
  5661. alphaBlend: boolean;
  5662. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5663. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5664. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5665. reset(): void;
  5666. apply(gl: WebGLRenderingContext): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/States/depthCullingState" {
  5670. import { Nullable } from "babylonjs/types";
  5671. /**
  5672. * @hidden
  5673. **/
  5674. export class _DepthCullingState {
  5675. private _isDepthTestDirty;
  5676. private _isDepthMaskDirty;
  5677. private _isDepthFuncDirty;
  5678. private _isCullFaceDirty;
  5679. private _isCullDirty;
  5680. private _isZOffsetDirty;
  5681. private _isFrontFaceDirty;
  5682. private _depthTest;
  5683. private _depthMask;
  5684. private _depthFunc;
  5685. private _cull;
  5686. private _cullFace;
  5687. private _zOffset;
  5688. private _frontFace;
  5689. /**
  5690. * Initializes the state.
  5691. */
  5692. constructor();
  5693. readonly isDirty: boolean;
  5694. zOffset: number;
  5695. cullFace: Nullable<number>;
  5696. cull: Nullable<boolean>;
  5697. depthFunc: Nullable<number>;
  5698. depthMask: boolean;
  5699. depthTest: boolean;
  5700. frontFace: Nullable<number>;
  5701. reset(): void;
  5702. apply(gl: WebGLRenderingContext): void;
  5703. }
  5704. }
  5705. declare module "babylonjs/States/stencilState" {
  5706. /**
  5707. * @hidden
  5708. **/
  5709. export class _StencilState {
  5710. /** 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 */
  5711. static readonly ALWAYS: number;
  5712. /** Passed to stencilOperation to specify that stencil value must be kept */
  5713. static readonly KEEP: number;
  5714. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5715. static readonly REPLACE: number;
  5716. private _isStencilTestDirty;
  5717. private _isStencilMaskDirty;
  5718. private _isStencilFuncDirty;
  5719. private _isStencilOpDirty;
  5720. private _stencilTest;
  5721. private _stencilMask;
  5722. private _stencilFunc;
  5723. private _stencilFuncRef;
  5724. private _stencilFuncMask;
  5725. private _stencilOpStencilFail;
  5726. private _stencilOpDepthFail;
  5727. private _stencilOpStencilDepthPass;
  5728. readonly isDirty: boolean;
  5729. stencilFunc: number;
  5730. stencilFuncRef: number;
  5731. stencilFuncMask: number;
  5732. stencilOpStencilFail: number;
  5733. stencilOpDepthFail: number;
  5734. stencilOpStencilDepthPass: number;
  5735. stencilMask: number;
  5736. stencilTest: boolean;
  5737. constructor();
  5738. reset(): void;
  5739. apply(gl: WebGLRenderingContext): void;
  5740. }
  5741. }
  5742. declare module "babylonjs/States/index" {
  5743. export * from "babylonjs/States/alphaCullingState";
  5744. export * from "babylonjs/States/depthCullingState";
  5745. export * from "babylonjs/States/stencilState";
  5746. }
  5747. declare module "babylonjs/Instrumentation/timeToken" {
  5748. import { Nullable } from "babylonjs/types";
  5749. /**
  5750. * @hidden
  5751. **/
  5752. export class _TimeToken {
  5753. _startTimeQuery: Nullable<WebGLQuery>;
  5754. _endTimeQuery: Nullable<WebGLQuery>;
  5755. _timeElapsedQuery: Nullable<WebGLQuery>;
  5756. _timeElapsedQueryEnded: boolean;
  5757. }
  5758. }
  5759. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5760. /**
  5761. * Class used to evalaute queries containing `and` and `or` operators
  5762. */
  5763. export class AndOrNotEvaluator {
  5764. /**
  5765. * Evaluate a query
  5766. * @param query defines the query to evaluate
  5767. * @param evaluateCallback defines the callback used to filter result
  5768. * @returns true if the query matches
  5769. */
  5770. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5771. private static _HandleParenthesisContent;
  5772. private static _SimplifyNegation;
  5773. }
  5774. }
  5775. declare module "babylonjs/Misc/tags" {
  5776. /**
  5777. * Class used to store custom tags
  5778. */
  5779. export class Tags {
  5780. /**
  5781. * Adds support for tags on the given object
  5782. * @param obj defines the object to use
  5783. */
  5784. static EnableFor(obj: any): void;
  5785. /**
  5786. * Removes tags support
  5787. * @param obj defines the object to use
  5788. */
  5789. static DisableFor(obj: any): void;
  5790. /**
  5791. * Gets a boolean indicating if the given object has tags
  5792. * @param obj defines the object to use
  5793. * @returns a boolean
  5794. */
  5795. static HasTags(obj: any): boolean;
  5796. /**
  5797. * Gets the tags available on a given object
  5798. * @param obj defines the object to use
  5799. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5800. * @returns the tags
  5801. */
  5802. static GetTags(obj: any, asString?: boolean): any;
  5803. /**
  5804. * Adds tags to an object
  5805. * @param obj defines the object to use
  5806. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5807. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5808. */
  5809. static AddTagsTo(obj: any, tagsString: string): void;
  5810. /**
  5811. * @hidden
  5812. */
  5813. static _AddTagTo(obj: any, tag: string): void;
  5814. /**
  5815. * Removes specific tags from a specific object
  5816. * @param obj defines the object to use
  5817. * @param tagsString defines the tags to remove
  5818. */
  5819. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5820. /**
  5821. * @hidden
  5822. */
  5823. static _RemoveTagFrom(obj: any, tag: string): void;
  5824. /**
  5825. * Defines if tags hosted on an object match a given query
  5826. * @param obj defines the object to use
  5827. * @param tagsQuery defines the tag query
  5828. * @returns a boolean
  5829. */
  5830. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5831. }
  5832. }
  5833. declare module "babylonjs/Maths/math.path" {
  5834. import { DeepImmutable, Nullable } from "babylonjs/types";
  5835. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5836. /**
  5837. * Defines potential orientation for back face culling
  5838. */
  5839. export enum Orientation {
  5840. /**
  5841. * Clockwise
  5842. */
  5843. CW = 0,
  5844. /** Counter clockwise */
  5845. CCW = 1
  5846. }
  5847. /** Class used to represent a Bezier curve */
  5848. export class BezierCurve {
  5849. /**
  5850. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5851. * @param t defines the time
  5852. * @param x1 defines the left coordinate on X axis
  5853. * @param y1 defines the left coordinate on Y axis
  5854. * @param x2 defines the right coordinate on X axis
  5855. * @param y2 defines the right coordinate on Y axis
  5856. * @returns the interpolated value
  5857. */
  5858. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5859. }
  5860. /**
  5861. * Defines angle representation
  5862. */
  5863. export class Angle {
  5864. private _radians;
  5865. /**
  5866. * Creates an Angle object of "radians" radians (float).
  5867. * @param radians the angle in radians
  5868. */
  5869. constructor(radians: number);
  5870. /**
  5871. * Get value in degrees
  5872. * @returns the Angle value in degrees (float)
  5873. */
  5874. degrees(): number;
  5875. /**
  5876. * Get value in radians
  5877. * @returns the Angle value in radians (float)
  5878. */
  5879. radians(): number;
  5880. /**
  5881. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5882. * @param a defines first vector
  5883. * @param b defines second vector
  5884. * @returns a new Angle
  5885. */
  5886. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5887. /**
  5888. * Gets a new Angle object from the given float in radians
  5889. * @param radians defines the angle value in radians
  5890. * @returns a new Angle
  5891. */
  5892. static FromRadians(radians: number): Angle;
  5893. /**
  5894. * Gets a new Angle object from the given float in degrees
  5895. * @param degrees defines the angle value in degrees
  5896. * @returns a new Angle
  5897. */
  5898. static FromDegrees(degrees: number): Angle;
  5899. }
  5900. /**
  5901. * This represents an arc in a 2d space.
  5902. */
  5903. export class Arc2 {
  5904. /** Defines the start point of the arc */
  5905. startPoint: Vector2;
  5906. /** Defines the mid point of the arc */
  5907. midPoint: Vector2;
  5908. /** Defines the end point of the arc */
  5909. endPoint: Vector2;
  5910. /**
  5911. * Defines the center point of the arc.
  5912. */
  5913. centerPoint: Vector2;
  5914. /**
  5915. * Defines the radius of the arc.
  5916. */
  5917. radius: number;
  5918. /**
  5919. * Defines the angle of the arc (from mid point to end point).
  5920. */
  5921. angle: Angle;
  5922. /**
  5923. * Defines the start angle of the arc (from start point to middle point).
  5924. */
  5925. startAngle: Angle;
  5926. /**
  5927. * Defines the orientation of the arc (clock wise/counter clock wise).
  5928. */
  5929. orientation: Orientation;
  5930. /**
  5931. * Creates an Arc object from the three given points : start, middle and end.
  5932. * @param startPoint Defines the start point of the arc
  5933. * @param midPoint Defines the midlle point of the arc
  5934. * @param endPoint Defines the end point of the arc
  5935. */
  5936. constructor(
  5937. /** Defines the start point of the arc */
  5938. startPoint: Vector2,
  5939. /** Defines the mid point of the arc */
  5940. midPoint: Vector2,
  5941. /** Defines the end point of the arc */
  5942. endPoint: Vector2);
  5943. }
  5944. /**
  5945. * Represents a 2D path made up of multiple 2D points
  5946. */
  5947. export class Path2 {
  5948. private _points;
  5949. private _length;
  5950. /**
  5951. * If the path start and end point are the same
  5952. */
  5953. closed: boolean;
  5954. /**
  5955. * Creates a Path2 object from the starting 2D coordinates x and y.
  5956. * @param x the starting points x value
  5957. * @param y the starting points y value
  5958. */
  5959. constructor(x: number, y: number);
  5960. /**
  5961. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5962. * @param x the added points x value
  5963. * @param y the added points y value
  5964. * @returns the updated Path2.
  5965. */
  5966. addLineTo(x: number, y: number): Path2;
  5967. /**
  5968. * 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.
  5969. * @param midX middle point x value
  5970. * @param midY middle point y value
  5971. * @param endX end point x value
  5972. * @param endY end point y value
  5973. * @param numberOfSegments (default: 36)
  5974. * @returns the updated Path2.
  5975. */
  5976. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5977. /**
  5978. * Closes the Path2.
  5979. * @returns the Path2.
  5980. */
  5981. close(): Path2;
  5982. /**
  5983. * Gets the sum of the distance between each sequential point in the path
  5984. * @returns the Path2 total length (float).
  5985. */
  5986. length(): number;
  5987. /**
  5988. * Gets the points which construct the path
  5989. * @returns the Path2 internal array of points.
  5990. */
  5991. getPoints(): Vector2[];
  5992. /**
  5993. * Retreives the point at the distance aways from the starting point
  5994. * @param normalizedLengthPosition the length along the path to retreive the point from
  5995. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5996. */
  5997. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5998. /**
  5999. * Creates a new path starting from an x and y position
  6000. * @param x starting x value
  6001. * @param y starting y value
  6002. * @returns a new Path2 starting at the coordinates (x, y).
  6003. */
  6004. static StartingAt(x: number, y: number): Path2;
  6005. }
  6006. /**
  6007. * Represents a 3D path made up of multiple 3D points
  6008. */
  6009. export class Path3D {
  6010. /**
  6011. * an array of Vector3, the curve axis of the Path3D
  6012. */
  6013. path: Vector3[];
  6014. private _curve;
  6015. private _distances;
  6016. private _tangents;
  6017. private _normals;
  6018. private _binormals;
  6019. private _raw;
  6020. /**
  6021. * new Path3D(path, normal, raw)
  6022. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  6023. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  6024. * @param path an array of Vector3, the curve axis of the Path3D
  6025. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  6026. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  6027. */
  6028. constructor(
  6029. /**
  6030. * an array of Vector3, the curve axis of the Path3D
  6031. */
  6032. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  6033. /**
  6034. * Returns the Path3D array of successive Vector3 designing its curve.
  6035. * @returns the Path3D array of successive Vector3 designing its curve.
  6036. */
  6037. getCurve(): Vector3[];
  6038. /**
  6039. * Returns an array populated with tangent vectors on each Path3D curve point.
  6040. * @returns an array populated with tangent vectors on each Path3D curve point.
  6041. */
  6042. getTangents(): Vector3[];
  6043. /**
  6044. * Returns an array populated with normal vectors on each Path3D curve point.
  6045. * @returns an array populated with normal vectors on each Path3D curve point.
  6046. */
  6047. getNormals(): Vector3[];
  6048. /**
  6049. * Returns an array populated with binormal vectors on each Path3D curve point.
  6050. * @returns an array populated with binormal vectors on each Path3D curve point.
  6051. */
  6052. getBinormals(): Vector3[];
  6053. /**
  6054. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6055. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6056. */
  6057. getDistances(): number[];
  6058. /**
  6059. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6060. * @param path path which all values are copied into the curves points
  6061. * @param firstNormal which should be projected onto the curve
  6062. * @returns the same object updated.
  6063. */
  6064. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6065. private _compute;
  6066. private _getFirstNonNullVector;
  6067. private _getLastNonNullVector;
  6068. private _normalVector;
  6069. }
  6070. /**
  6071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6072. * A Curve3 is designed from a series of successive Vector3.
  6073. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6074. */
  6075. export class Curve3 {
  6076. private _points;
  6077. private _length;
  6078. /**
  6079. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6080. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6081. * @param v1 (Vector3) the control point
  6082. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6083. * @param nbPoints (integer) the wanted number of points in the curve
  6084. * @returns the created Curve3
  6085. */
  6086. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6087. /**
  6088. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6089. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6090. * @param v1 (Vector3) the first control point
  6091. * @param v2 (Vector3) the second control point
  6092. * @param v3 (Vector3) the end point of the Cubic Bezier
  6093. * @param nbPoints (integer) the wanted number of points in the curve
  6094. * @returns the created Curve3
  6095. */
  6096. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6097. /**
  6098. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6099. * @param p1 (Vector3) the origin point of the Hermite Spline
  6100. * @param t1 (Vector3) the tangent vector at the origin point
  6101. * @param p2 (Vector3) the end point of the Hermite Spline
  6102. * @param t2 (Vector3) the tangent vector at the end point
  6103. * @param nbPoints (integer) the wanted number of points in the curve
  6104. * @returns the created Curve3
  6105. */
  6106. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6107. /**
  6108. * Returns a Curve3 object along a CatmullRom Spline curve :
  6109. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6110. * @param nbPoints (integer) the wanted number of points between each curve control points
  6111. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6112. * @returns the created Curve3
  6113. */
  6114. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6115. /**
  6116. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6117. * A Curve3 is designed from a series of successive Vector3.
  6118. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6119. * @param points points which make up the curve
  6120. */
  6121. constructor(points: Vector3[]);
  6122. /**
  6123. * @returns the Curve3 stored array of successive Vector3
  6124. */
  6125. getPoints(): Vector3[];
  6126. /**
  6127. * @returns the computed length (float) of the curve.
  6128. */
  6129. length(): number;
  6130. /**
  6131. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6132. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6133. * curveA and curveB keep unchanged.
  6134. * @param curve the curve to continue from this curve
  6135. * @returns the newly constructed curve
  6136. */
  6137. continue(curve: DeepImmutable<Curve3>): Curve3;
  6138. private _computeLength;
  6139. }
  6140. }
  6141. declare module "babylonjs/Animations/easing" {
  6142. /**
  6143. * This represents the main contract an easing function should follow.
  6144. * Easing functions are used throughout the animation system.
  6145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export interface IEasingFunction {
  6148. /**
  6149. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6150. * of the easing function.
  6151. * The link below provides some of the most common examples of easing functions.
  6152. * @see https://easings.net/
  6153. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6154. * @returns the corresponding value on the curve defined by the easing function
  6155. */
  6156. ease(gradient: number): number;
  6157. }
  6158. /**
  6159. * Base class used for every default easing function.
  6160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6161. */
  6162. export class EasingFunction implements IEasingFunction {
  6163. /**
  6164. * Interpolation follows the mathematical formula associated with the easing function.
  6165. */
  6166. static readonly EASINGMODE_EASEIN: number;
  6167. /**
  6168. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6169. */
  6170. static readonly EASINGMODE_EASEOUT: number;
  6171. /**
  6172. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6173. */
  6174. static readonly EASINGMODE_EASEINOUT: number;
  6175. private _easingMode;
  6176. /**
  6177. * Sets the easing mode of the current function.
  6178. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6179. */
  6180. setEasingMode(easingMode: number): void;
  6181. /**
  6182. * Gets the current easing mode.
  6183. * @returns the easing mode
  6184. */
  6185. getEasingMode(): number;
  6186. /**
  6187. * @hidden
  6188. */
  6189. easeInCore(gradient: number): number;
  6190. /**
  6191. * Given an input gradient between 0 and 1, this returns the corresponding value
  6192. * of the easing function.
  6193. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6194. * @returns the corresponding value on the curve defined by the easing function
  6195. */
  6196. ease(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with a circle shape (see link below).
  6200. * @see https://easings.net/#easeInCirc
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class CircleEase extends EasingFunction implements IEasingFunction {
  6204. /** @hidden */
  6205. easeInCore(gradient: number): number;
  6206. }
  6207. /**
  6208. * Easing function with a ease back shape (see link below).
  6209. * @see https://easings.net/#easeInBack
  6210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6211. */
  6212. export class BackEase extends EasingFunction implements IEasingFunction {
  6213. /** Defines the amplitude of the function */
  6214. amplitude: number;
  6215. /**
  6216. * Instantiates a back ease easing
  6217. * @see https://easings.net/#easeInBack
  6218. * @param amplitude Defines the amplitude of the function
  6219. */
  6220. constructor(
  6221. /** Defines the amplitude of the function */
  6222. amplitude?: number);
  6223. /** @hidden */
  6224. easeInCore(gradient: number): number;
  6225. }
  6226. /**
  6227. * Easing function with a bouncing shape (see link below).
  6228. * @see https://easings.net/#easeInBounce
  6229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6230. */
  6231. export class BounceEase extends EasingFunction implements IEasingFunction {
  6232. /** Defines the number of bounces */
  6233. bounces: number;
  6234. /** Defines the amplitude of the bounce */
  6235. bounciness: number;
  6236. /**
  6237. * Instantiates a bounce easing
  6238. * @see https://easings.net/#easeInBounce
  6239. * @param bounces Defines the number of bounces
  6240. * @param bounciness Defines the amplitude of the bounce
  6241. */
  6242. constructor(
  6243. /** Defines the number of bounces */
  6244. bounces?: number,
  6245. /** Defines the amplitude of the bounce */
  6246. bounciness?: number);
  6247. /** @hidden */
  6248. easeInCore(gradient: number): number;
  6249. }
  6250. /**
  6251. * Easing function with a power of 3 shape (see link below).
  6252. * @see https://easings.net/#easeInCubic
  6253. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6254. */
  6255. export class CubicEase extends EasingFunction implements IEasingFunction {
  6256. /** @hidden */
  6257. easeInCore(gradient: number): number;
  6258. }
  6259. /**
  6260. * Easing function with an elastic shape (see link below).
  6261. * @see https://easings.net/#easeInElastic
  6262. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6263. */
  6264. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6265. /** Defines the number of oscillations*/
  6266. oscillations: number;
  6267. /** Defines the amplitude of the oscillations*/
  6268. springiness: number;
  6269. /**
  6270. * Instantiates an elastic easing function
  6271. * @see https://easings.net/#easeInElastic
  6272. * @param oscillations Defines the number of oscillations
  6273. * @param springiness Defines the amplitude of the oscillations
  6274. */
  6275. constructor(
  6276. /** Defines the number of oscillations*/
  6277. oscillations?: number,
  6278. /** Defines the amplitude of the oscillations*/
  6279. springiness?: number);
  6280. /** @hidden */
  6281. easeInCore(gradient: number): number;
  6282. }
  6283. /**
  6284. * Easing function with an exponential shape (see link below).
  6285. * @see https://easings.net/#easeInExpo
  6286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6287. */
  6288. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6289. /** Defines the exponent of the function */
  6290. exponent: number;
  6291. /**
  6292. * Instantiates an exponential easing function
  6293. * @see https://easings.net/#easeInExpo
  6294. * @param exponent Defines the exponent of the function
  6295. */
  6296. constructor(
  6297. /** Defines the exponent of the function */
  6298. exponent?: number);
  6299. /** @hidden */
  6300. easeInCore(gradient: number): number;
  6301. }
  6302. /**
  6303. * Easing function with a power shape (see link below).
  6304. * @see https://easings.net/#easeInQuad
  6305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6306. */
  6307. export class PowerEase extends EasingFunction implements IEasingFunction {
  6308. /** Defines the power of the function */
  6309. power: number;
  6310. /**
  6311. * Instantiates an power base easing function
  6312. * @see https://easings.net/#easeInQuad
  6313. * @param power Defines the power of the function
  6314. */
  6315. constructor(
  6316. /** Defines the power of the function */
  6317. power?: number);
  6318. /** @hidden */
  6319. easeInCore(gradient: number): number;
  6320. }
  6321. /**
  6322. * Easing function with a power of 2 shape (see link below).
  6323. * @see https://easings.net/#easeInQuad
  6324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6325. */
  6326. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6327. /** @hidden */
  6328. easeInCore(gradient: number): number;
  6329. }
  6330. /**
  6331. * Easing function with a power of 4 shape (see link below).
  6332. * @see https://easings.net/#easeInQuart
  6333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6334. */
  6335. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6336. /** @hidden */
  6337. easeInCore(gradient: number): number;
  6338. }
  6339. /**
  6340. * Easing function with a power of 5 shape (see link below).
  6341. * @see https://easings.net/#easeInQuint
  6342. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6343. */
  6344. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6345. /** @hidden */
  6346. easeInCore(gradient: number): number;
  6347. }
  6348. /**
  6349. * Easing function with a sin shape (see link below).
  6350. * @see https://easings.net/#easeInSine
  6351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6352. */
  6353. export class SineEase extends EasingFunction implements IEasingFunction {
  6354. /** @hidden */
  6355. easeInCore(gradient: number): number;
  6356. }
  6357. /**
  6358. * Easing function with a bezier shape (see link below).
  6359. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6361. */
  6362. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6363. /** Defines the x component of the start tangent in the bezier curve */
  6364. x1: number;
  6365. /** Defines the y component of the start tangent in the bezier curve */
  6366. y1: number;
  6367. /** Defines the x component of the end tangent in the bezier curve */
  6368. x2: number;
  6369. /** Defines the y component of the end tangent in the bezier curve */
  6370. y2: number;
  6371. /**
  6372. * Instantiates a bezier function
  6373. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6374. * @param x1 Defines the x component of the start tangent in the bezier curve
  6375. * @param y1 Defines the y component of the start tangent in the bezier curve
  6376. * @param x2 Defines the x component of the end tangent in the bezier curve
  6377. * @param y2 Defines the y component of the end tangent in the bezier curve
  6378. */
  6379. constructor(
  6380. /** Defines the x component of the start tangent in the bezier curve */
  6381. x1?: number,
  6382. /** Defines the y component of the start tangent in the bezier curve */
  6383. y1?: number,
  6384. /** Defines the x component of the end tangent in the bezier curve */
  6385. x2?: number,
  6386. /** Defines the y component of the end tangent in the bezier curve */
  6387. y2?: number);
  6388. /** @hidden */
  6389. easeInCore(gradient: number): number;
  6390. }
  6391. }
  6392. declare module "babylonjs/Animations/animationKey" {
  6393. /**
  6394. * Defines an interface which represents an animation key frame
  6395. */
  6396. export interface IAnimationKey {
  6397. /**
  6398. * Frame of the key frame
  6399. */
  6400. frame: number;
  6401. /**
  6402. * Value at the specifies key frame
  6403. */
  6404. value: any;
  6405. /**
  6406. * The input tangent for the cubic hermite spline
  6407. */
  6408. inTangent?: any;
  6409. /**
  6410. * The output tangent for the cubic hermite spline
  6411. */
  6412. outTangent?: any;
  6413. /**
  6414. * The animation interpolation type
  6415. */
  6416. interpolation?: AnimationKeyInterpolation;
  6417. }
  6418. /**
  6419. * Enum for the animation key frame interpolation type
  6420. */
  6421. export enum AnimationKeyInterpolation {
  6422. /**
  6423. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6424. */
  6425. STEP = 1
  6426. }
  6427. }
  6428. declare module "babylonjs/Animations/animationRange" {
  6429. /**
  6430. * Represents the range of an animation
  6431. */
  6432. export class AnimationRange {
  6433. /**The name of the animation range**/
  6434. name: string;
  6435. /**The starting frame of the animation */
  6436. from: number;
  6437. /**The ending frame of the animation*/
  6438. to: number;
  6439. /**
  6440. * Initializes the range of an animation
  6441. * @param name The name of the animation range
  6442. * @param from The starting frame of the animation
  6443. * @param to The ending frame of the animation
  6444. */
  6445. constructor(
  6446. /**The name of the animation range**/
  6447. name: string,
  6448. /**The starting frame of the animation */
  6449. from: number,
  6450. /**The ending frame of the animation*/
  6451. to: number);
  6452. /**
  6453. * Makes a copy of the animation range
  6454. * @returns A copy of the animation range
  6455. */
  6456. clone(): AnimationRange;
  6457. }
  6458. }
  6459. declare module "babylonjs/Animations/animationEvent" {
  6460. /**
  6461. * Composed of a frame, and an action function
  6462. */
  6463. export class AnimationEvent {
  6464. /** The frame for which the event is triggered **/
  6465. frame: number;
  6466. /** The event to perform when triggered **/
  6467. action: (currentFrame: number) => void;
  6468. /** Specifies if the event should be triggered only once**/
  6469. onlyOnce?: boolean | undefined;
  6470. /**
  6471. * Specifies if the animation event is done
  6472. */
  6473. isDone: boolean;
  6474. /**
  6475. * Initializes the animation event
  6476. * @param frame The frame for which the event is triggered
  6477. * @param action The event to perform when triggered
  6478. * @param onlyOnce Specifies if the event should be triggered only once
  6479. */
  6480. constructor(
  6481. /** The frame for which the event is triggered **/
  6482. frame: number,
  6483. /** The event to perform when triggered **/
  6484. action: (currentFrame: number) => void,
  6485. /** Specifies if the event should be triggered only once**/
  6486. onlyOnce?: boolean | undefined);
  6487. /** @hidden */
  6488. _clone(): AnimationEvent;
  6489. }
  6490. }
  6491. declare module "babylonjs/Behaviors/behavior" {
  6492. import { Nullable } from "babylonjs/types";
  6493. /**
  6494. * Interface used to define a behavior
  6495. */
  6496. export interface Behavior<T> {
  6497. /** gets or sets behavior's name */
  6498. name: string;
  6499. /**
  6500. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6501. */
  6502. init(): void;
  6503. /**
  6504. * Called when the behavior is attached to a target
  6505. * @param target defines the target where the behavior is attached to
  6506. */
  6507. attach(target: T): void;
  6508. /**
  6509. * Called when the behavior is detached from its target
  6510. */
  6511. detach(): void;
  6512. }
  6513. /**
  6514. * Interface implemented by classes supporting behaviors
  6515. */
  6516. export interface IBehaviorAware<T> {
  6517. /**
  6518. * Attach a behavior
  6519. * @param behavior defines the behavior to attach
  6520. * @returns the current host
  6521. */
  6522. addBehavior(behavior: Behavior<T>): T;
  6523. /**
  6524. * Remove a behavior from the current object
  6525. * @param behavior defines the behavior to detach
  6526. * @returns the current host
  6527. */
  6528. removeBehavior(behavior: Behavior<T>): T;
  6529. /**
  6530. * Gets a behavior using its name to search
  6531. * @param name defines the name to search
  6532. * @returns the behavior or null if not found
  6533. */
  6534. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6535. }
  6536. }
  6537. declare module "babylonjs/Misc/smartArray" {
  6538. /**
  6539. * Defines an array and its length.
  6540. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6541. */
  6542. export interface ISmartArrayLike<T> {
  6543. /**
  6544. * The data of the array.
  6545. */
  6546. data: Array<T>;
  6547. /**
  6548. * The active length of the array.
  6549. */
  6550. length: number;
  6551. }
  6552. /**
  6553. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6554. */
  6555. export class SmartArray<T> implements ISmartArrayLike<T> {
  6556. /**
  6557. * The full set of data from the array.
  6558. */
  6559. data: Array<T>;
  6560. /**
  6561. * The active length of the array.
  6562. */
  6563. length: number;
  6564. protected _id: number;
  6565. /**
  6566. * Instantiates a Smart Array.
  6567. * @param capacity defines the default capacity of the array.
  6568. */
  6569. constructor(capacity: number);
  6570. /**
  6571. * Pushes a value at the end of the active data.
  6572. * @param value defines the object to push in the array.
  6573. */
  6574. push(value: T): void;
  6575. /**
  6576. * Iterates over the active data and apply the lambda to them.
  6577. * @param func defines the action to apply on each value.
  6578. */
  6579. forEach(func: (content: T) => void): void;
  6580. /**
  6581. * Sorts the full sets of data.
  6582. * @param compareFn defines the comparison function to apply.
  6583. */
  6584. sort(compareFn: (a: T, b: T) => number): void;
  6585. /**
  6586. * Resets the active data to an empty array.
  6587. */
  6588. reset(): void;
  6589. /**
  6590. * Releases all the data from the array as well as the array.
  6591. */
  6592. dispose(): void;
  6593. /**
  6594. * Concats the active data with a given array.
  6595. * @param array defines the data to concatenate with.
  6596. */
  6597. concat(array: any): void;
  6598. /**
  6599. * Returns the position of a value in the active data.
  6600. * @param value defines the value to find the index for
  6601. * @returns the index if found in the active data otherwise -1
  6602. */
  6603. indexOf(value: T): number;
  6604. /**
  6605. * Returns whether an element is part of the active data.
  6606. * @param value defines the value to look for
  6607. * @returns true if found in the active data otherwise false
  6608. */
  6609. contains(value: T): boolean;
  6610. private static _GlobalId;
  6611. }
  6612. /**
  6613. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6614. * The data in this array can only be present once
  6615. */
  6616. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6617. private _duplicateId;
  6618. /**
  6619. * Pushes a value at the end of the active data.
  6620. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6621. * @param value defines the object to push in the array.
  6622. */
  6623. push(value: T): void;
  6624. /**
  6625. * Pushes a value at the end of the active data.
  6626. * If the data is already present, it won t be added again
  6627. * @param value defines the object to push in the array.
  6628. * @returns true if added false if it was already present
  6629. */
  6630. pushNoDuplicate(value: T): boolean;
  6631. /**
  6632. * Resets the active data to an empty array.
  6633. */
  6634. reset(): void;
  6635. /**
  6636. * Concats the active data with a given array.
  6637. * This ensures no dupplicate will be present in the result.
  6638. * @param array defines the data to concatenate with.
  6639. */
  6640. concatWithNoDuplicate(array: any): void;
  6641. }
  6642. }
  6643. declare module "babylonjs/Cameras/cameraInputsManager" {
  6644. import { Nullable } from "babylonjs/types";
  6645. import { Camera } from "babylonjs/Cameras/camera";
  6646. /**
  6647. * @ignore
  6648. * This is a list of all the different input types that are available in the application.
  6649. * Fo instance: ArcRotateCameraGamepadInput...
  6650. */
  6651. export var CameraInputTypes: {};
  6652. /**
  6653. * This is the contract to implement in order to create a new input class.
  6654. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6655. */
  6656. export interface ICameraInput<TCamera extends Camera> {
  6657. /**
  6658. * Defines the camera the input is attached to.
  6659. */
  6660. camera: Nullable<TCamera>;
  6661. /**
  6662. * Gets the class name of the current intput.
  6663. * @returns the class name
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Get the friendly name associated with the input class.
  6668. * @returns the input friendly name
  6669. */
  6670. getSimpleName(): string;
  6671. /**
  6672. * Attach the input controls to a specific dom element to get the input from.
  6673. * @param element Defines the element the controls should be listened from
  6674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6675. */
  6676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6677. /**
  6678. * Detach the current controls from the specified dom element.
  6679. * @param element Defines the element to stop listening the inputs from
  6680. */
  6681. detachControl(element: Nullable<HTMLElement>): void;
  6682. /**
  6683. * Update the current camera state depending on the inputs that have been used this frame.
  6684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6685. */
  6686. checkInputs?: () => void;
  6687. }
  6688. /**
  6689. * Represents a map of input types to input instance or input index to input instance.
  6690. */
  6691. export interface CameraInputsMap<TCamera extends Camera> {
  6692. /**
  6693. * Accessor to the input by input type.
  6694. */
  6695. [name: string]: ICameraInput<TCamera>;
  6696. /**
  6697. * Accessor to the input by input index.
  6698. */
  6699. [idx: number]: ICameraInput<TCamera>;
  6700. }
  6701. /**
  6702. * This represents the input manager used within a camera.
  6703. * It helps dealing with all the different kind of input attached to a camera.
  6704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6705. */
  6706. export class CameraInputsManager<TCamera extends Camera> {
  6707. /**
  6708. * Defines the list of inputs attahed to the camera.
  6709. */
  6710. attached: CameraInputsMap<TCamera>;
  6711. /**
  6712. * Defines the dom element the camera is collecting inputs from.
  6713. * This is null if the controls have not been attached.
  6714. */
  6715. attachedElement: Nullable<HTMLElement>;
  6716. /**
  6717. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6718. */
  6719. noPreventDefault: boolean;
  6720. /**
  6721. * Defined the camera the input manager belongs to.
  6722. */
  6723. camera: TCamera;
  6724. /**
  6725. * Update the current camera state depending on the inputs that have been used this frame.
  6726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6727. */
  6728. checkInputs: () => void;
  6729. /**
  6730. * Instantiate a new Camera Input Manager.
  6731. * @param camera Defines the camera the input manager blongs to
  6732. */
  6733. constructor(camera: TCamera);
  6734. /**
  6735. * Add an input method to a camera
  6736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6737. * @param input camera input method
  6738. */
  6739. add(input: ICameraInput<TCamera>): void;
  6740. /**
  6741. * Remove a specific input method from a camera
  6742. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6743. * @param inputToRemove camera input method
  6744. */
  6745. remove(inputToRemove: ICameraInput<TCamera>): void;
  6746. /**
  6747. * Remove a specific input type from a camera
  6748. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6749. * @param inputType the type of the input to remove
  6750. */
  6751. removeByType(inputType: string): void;
  6752. private _addCheckInputs;
  6753. /**
  6754. * Attach the input controls to the currently attached dom element to listen the events from.
  6755. * @param input Defines the input to attach
  6756. */
  6757. attachInput(input: ICameraInput<TCamera>): void;
  6758. /**
  6759. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6760. * @param element Defines the dom element to collect the events from
  6761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6762. */
  6763. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6764. /**
  6765. * Detach the current manager inputs controls from a specific dom element.
  6766. * @param element Defines the dom element to collect the events from
  6767. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6768. */
  6769. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6770. /**
  6771. * Rebuild the dynamic inputCheck function from the current list of
  6772. * defined inputs in the manager.
  6773. */
  6774. rebuildInputCheck(): void;
  6775. /**
  6776. * Remove all attached input methods from a camera
  6777. */
  6778. clear(): void;
  6779. /**
  6780. * Serialize the current input manager attached to a camera.
  6781. * This ensures than once parsed,
  6782. * the input associated to the camera will be identical to the current ones
  6783. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6784. */
  6785. serialize(serializedCamera: any): void;
  6786. /**
  6787. * Parses an input manager serialized JSON to restore the previous list of inputs
  6788. * and states associated to a camera.
  6789. * @param parsedCamera Defines the JSON to parse
  6790. */
  6791. parse(parsedCamera: any): void;
  6792. }
  6793. }
  6794. declare module "babylonjs/Collisions/intersectionInfo" {
  6795. import { Nullable } from "babylonjs/types";
  6796. /**
  6797. * @hidden
  6798. */
  6799. export class IntersectionInfo {
  6800. bu: Nullable<number>;
  6801. bv: Nullable<number>;
  6802. distance: number;
  6803. faceId: number;
  6804. subMeshId: number;
  6805. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6806. }
  6807. }
  6808. declare module "babylonjs/Maths/math.plane" {
  6809. import { DeepImmutable } from "babylonjs/types";
  6810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6811. /**
  6812. * Represens a plane by the equation ax + by + cz + d = 0
  6813. */
  6814. export class Plane {
  6815. private static _TmpMatrix;
  6816. /**
  6817. * Normal of the plane (a,b,c)
  6818. */
  6819. normal: Vector3;
  6820. /**
  6821. * d component of the plane
  6822. */
  6823. d: number;
  6824. /**
  6825. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6826. * @param a a component of the plane
  6827. * @param b b component of the plane
  6828. * @param c c component of the plane
  6829. * @param d d component of the plane
  6830. */
  6831. constructor(a: number, b: number, c: number, d: number);
  6832. /**
  6833. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6834. */
  6835. asArray(): number[];
  6836. /**
  6837. * @returns a new plane copied from the current Plane.
  6838. */
  6839. clone(): Plane;
  6840. /**
  6841. * @returns the string "Plane".
  6842. */
  6843. getClassName(): string;
  6844. /**
  6845. * @returns the Plane hash code.
  6846. */
  6847. getHashCode(): number;
  6848. /**
  6849. * Normalize the current Plane in place.
  6850. * @returns the updated Plane.
  6851. */
  6852. normalize(): Plane;
  6853. /**
  6854. * Applies a transformation the plane and returns the result
  6855. * @param transformation the transformation matrix to be applied to the plane
  6856. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6857. */
  6858. transform(transformation: DeepImmutable<Matrix>): Plane;
  6859. /**
  6860. * Calcualtte the dot product between the point and the plane normal
  6861. * @param point point to calculate the dot product with
  6862. * @returns the dot product (float) of the point coordinates and the plane normal.
  6863. */
  6864. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6865. /**
  6866. * Updates the current Plane from the plane defined by the three given points.
  6867. * @param point1 one of the points used to contruct the plane
  6868. * @param point2 one of the points used to contruct the plane
  6869. * @param point3 one of the points used to contruct the plane
  6870. * @returns the updated Plane.
  6871. */
  6872. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6873. /**
  6874. * Checks if the plane is facing a given direction
  6875. * @param direction the direction to check if the plane is facing
  6876. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6877. * @returns True is the vector "direction" is the same side than the plane normal.
  6878. */
  6879. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6880. /**
  6881. * Calculates the distance to a point
  6882. * @param point point to calculate distance to
  6883. * @returns the signed distance (float) from the given point to the Plane.
  6884. */
  6885. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6886. /**
  6887. * Creates a plane from an array
  6888. * @param array the array to create a plane from
  6889. * @returns a new Plane from the given array.
  6890. */
  6891. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6892. /**
  6893. * Creates a plane from three points
  6894. * @param point1 point used to create the plane
  6895. * @param point2 point used to create the plane
  6896. * @param point3 point used to create the plane
  6897. * @returns a new Plane defined by the three given points.
  6898. */
  6899. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6900. /**
  6901. * Creates a plane from an origin point and a normal
  6902. * @param origin origin of the plane to be constructed
  6903. * @param normal normal of the plane to be constructed
  6904. * @returns a new Plane the normal vector to this plane at the given origin point.
  6905. * Note : the vector "normal" is updated because normalized.
  6906. */
  6907. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6908. /**
  6909. * Calculates the distance from a plane and a point
  6910. * @param origin origin of the plane to be constructed
  6911. * @param normal normal of the plane to be constructed
  6912. * @param point point to calculate distance to
  6913. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6914. */
  6915. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6916. }
  6917. }
  6918. declare module "babylonjs/Culling/boundingSphere" {
  6919. import { DeepImmutable } from "babylonjs/types";
  6920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6921. import { Plane } from "babylonjs/Maths/math.plane";
  6922. /**
  6923. * Class used to store bounding sphere information
  6924. */
  6925. export class BoundingSphere {
  6926. /**
  6927. * Gets the center of the bounding sphere in local space
  6928. */
  6929. readonly center: Vector3;
  6930. /**
  6931. * Radius of the bounding sphere in local space
  6932. */
  6933. radius: number;
  6934. /**
  6935. * Gets the center of the bounding sphere in world space
  6936. */
  6937. readonly centerWorld: Vector3;
  6938. /**
  6939. * Radius of the bounding sphere in world space
  6940. */
  6941. radiusWorld: number;
  6942. /**
  6943. * Gets the minimum vector in local space
  6944. */
  6945. readonly minimum: Vector3;
  6946. /**
  6947. * Gets the maximum vector in local space
  6948. */
  6949. readonly maximum: Vector3;
  6950. private _worldMatrix;
  6951. private static readonly TmpVector3;
  6952. /**
  6953. * Creates a new bounding sphere
  6954. * @param min defines the minimum vector (in local space)
  6955. * @param max defines the maximum vector (in local space)
  6956. * @param worldMatrix defines the new world matrix
  6957. */
  6958. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6959. /**
  6960. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6961. * @param min defines the new minimum vector (in local space)
  6962. * @param max defines the new maximum vector (in local space)
  6963. * @param worldMatrix defines the new world matrix
  6964. */
  6965. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Scale the current bounding sphere by applying a scale factor
  6968. * @param factor defines the scale factor to apply
  6969. * @returns the current bounding box
  6970. */
  6971. scale(factor: number): BoundingSphere;
  6972. /**
  6973. * Gets the world matrix of the bounding box
  6974. * @returns a matrix
  6975. */
  6976. getWorldMatrix(): DeepImmutable<Matrix>;
  6977. /** @hidden */
  6978. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6979. /**
  6980. * Tests if the bounding sphere is intersecting the frustum planes
  6981. * @param frustumPlanes defines the frustum planes to test
  6982. * @returns true if there is an intersection
  6983. */
  6984. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6985. /**
  6986. * Tests if the bounding sphere center is in between the frustum planes.
  6987. * Used for optimistic fast inclusion.
  6988. * @param frustumPlanes defines the frustum planes to test
  6989. * @returns true if the sphere center is in between the frustum planes
  6990. */
  6991. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6992. /**
  6993. * Tests if a point is inside the bounding sphere
  6994. * @param point defines the point to test
  6995. * @returns true if the point is inside the bounding sphere
  6996. */
  6997. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Checks if two sphere intersct
  7000. * @param sphere0 sphere 0
  7001. * @param sphere1 sphere 1
  7002. * @returns true if the speres intersect
  7003. */
  7004. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Culling/boundingBox" {
  7008. import { DeepImmutable } from "babylonjs/types";
  7009. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7010. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7011. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7012. import { Plane } from "babylonjs/Maths/math.plane";
  7013. /**
  7014. * Class used to store bounding box information
  7015. */
  7016. export class BoundingBox implements ICullable {
  7017. /**
  7018. * Gets the 8 vectors representing the bounding box in local space
  7019. */
  7020. readonly vectors: Vector3[];
  7021. /**
  7022. * Gets the center of the bounding box in local space
  7023. */
  7024. readonly center: Vector3;
  7025. /**
  7026. * Gets the center of the bounding box in world space
  7027. */
  7028. readonly centerWorld: Vector3;
  7029. /**
  7030. * Gets the extend size in local space
  7031. */
  7032. readonly extendSize: Vector3;
  7033. /**
  7034. * Gets the extend size in world space
  7035. */
  7036. readonly extendSizeWorld: Vector3;
  7037. /**
  7038. * Gets the OBB (object bounding box) directions
  7039. */
  7040. readonly directions: Vector3[];
  7041. /**
  7042. * Gets the 8 vectors representing the bounding box in world space
  7043. */
  7044. readonly vectorsWorld: Vector3[];
  7045. /**
  7046. * Gets the minimum vector in world space
  7047. */
  7048. readonly minimumWorld: Vector3;
  7049. /**
  7050. * Gets the maximum vector in world space
  7051. */
  7052. readonly maximumWorld: Vector3;
  7053. /**
  7054. * Gets the minimum vector in local space
  7055. */
  7056. readonly minimum: Vector3;
  7057. /**
  7058. * Gets the maximum vector in local space
  7059. */
  7060. readonly maximum: Vector3;
  7061. private _worldMatrix;
  7062. private static readonly TmpVector3;
  7063. /**
  7064. * @hidden
  7065. */
  7066. _tag: number;
  7067. /**
  7068. * Creates a new bounding box
  7069. * @param min defines the minimum vector (in local space)
  7070. * @param max defines the maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7074. /**
  7075. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7076. * @param min defines the new minimum vector (in local space)
  7077. * @param max defines the new maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7081. /**
  7082. * Scale the current bounding box by applying a scale factor
  7083. * @param factor defines the scale factor to apply
  7084. * @returns the current bounding box
  7085. */
  7086. scale(factor: number): BoundingBox;
  7087. /**
  7088. * Gets the world matrix of the bounding box
  7089. * @returns a matrix
  7090. */
  7091. getWorldMatrix(): DeepImmutable<Matrix>;
  7092. /** @hidden */
  7093. _update(world: DeepImmutable<Matrix>): void;
  7094. /**
  7095. * Tests if the bounding box is intersecting the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if the bounding box is entirely inside the frustum planes
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @returns true if there is an inclusion
  7104. */
  7105. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. /**
  7107. * Tests if a point is inside the bounding box
  7108. * @param point defines the point to test
  7109. * @returns true if the point is inside the bounding box
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Tests if the bounding box intersects with a bounding sphere
  7114. * @param sphere defines the sphere to test
  7115. * @returns true if there is an intersection
  7116. */
  7117. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7118. /**
  7119. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7120. * @param min defines the min vector to use
  7121. * @param max defines the max vector to use
  7122. * @returns true if there is an intersection
  7123. */
  7124. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7125. /**
  7126. * Tests if two bounding boxes are intersections
  7127. * @param box0 defines the first box to test
  7128. * @param box1 defines the second box to test
  7129. * @returns true if there is an intersection
  7130. */
  7131. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7132. /**
  7133. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7134. * @param minPoint defines the minimum vector of the bounding box
  7135. * @param maxPoint defines the maximum vector of the bounding box
  7136. * @param sphereCenter defines the sphere center
  7137. * @param sphereRadius defines the sphere radius
  7138. * @returns true if there is an intersection
  7139. */
  7140. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7141. /**
  7142. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7143. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7144. * @param frustumPlanes defines the frustum planes to test
  7145. * @return true if there is an inclusion
  7146. */
  7147. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7148. /**
  7149. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7150. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7151. * @param frustumPlanes defines the frustum planes to test
  7152. * @return true if there is an intersection
  7153. */
  7154. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7155. }
  7156. }
  7157. declare module "babylonjs/Collisions/collider" {
  7158. import { Nullable, IndicesArray } from "babylonjs/types";
  7159. import { Vector3 } from "babylonjs/Maths/math.vector";
  7160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7161. import { Plane } from "babylonjs/Maths/math.plane";
  7162. /** @hidden */
  7163. export class Collider {
  7164. /** Define if a collision was found */
  7165. collisionFound: boolean;
  7166. /**
  7167. * Define last intersection point in local space
  7168. */
  7169. intersectionPoint: Vector3;
  7170. /**
  7171. * Define last collided mesh
  7172. */
  7173. collidedMesh: Nullable<AbstractMesh>;
  7174. private _collisionPoint;
  7175. private _planeIntersectionPoint;
  7176. private _tempVector;
  7177. private _tempVector2;
  7178. private _tempVector3;
  7179. private _tempVector4;
  7180. private _edge;
  7181. private _baseToVertex;
  7182. private _destinationPoint;
  7183. private _slidePlaneNormal;
  7184. private _displacementVector;
  7185. /** @hidden */
  7186. _radius: Vector3;
  7187. /** @hidden */
  7188. _retry: number;
  7189. private _velocity;
  7190. private _basePoint;
  7191. private _epsilon;
  7192. /** @hidden */
  7193. _velocityWorldLength: number;
  7194. /** @hidden */
  7195. _basePointWorld: Vector3;
  7196. private _velocityWorld;
  7197. private _normalizedVelocity;
  7198. /** @hidden */
  7199. _initialVelocity: Vector3;
  7200. /** @hidden */
  7201. _initialPosition: Vector3;
  7202. private _nearestDistance;
  7203. private _collisionMask;
  7204. collisionMask: number;
  7205. /**
  7206. * Gets the plane normal used to compute the sliding response (in local space)
  7207. */
  7208. readonly slidePlaneNormal: Vector3;
  7209. /** @hidden */
  7210. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7211. /** @hidden */
  7212. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7213. /** @hidden */
  7214. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7215. /** @hidden */
  7216. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7217. /** @hidden */
  7218. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7219. /** @hidden */
  7220. _getResponse(pos: Vector3, vel: Vector3): void;
  7221. }
  7222. }
  7223. declare module "babylonjs/Culling/boundingInfo" {
  7224. import { DeepImmutable } from "babylonjs/types";
  7225. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7226. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7227. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7228. import { Plane } from "babylonjs/Maths/math.plane";
  7229. import { Collider } from "babylonjs/Collisions/collider";
  7230. /**
  7231. * Interface for cullable objects
  7232. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7233. */
  7234. export interface ICullable {
  7235. /**
  7236. * Checks if the object or part of the object is in the frustum
  7237. * @param frustumPlanes Camera near/planes
  7238. * @returns true if the object is in frustum otherwise false
  7239. */
  7240. isInFrustum(frustumPlanes: Plane[]): boolean;
  7241. /**
  7242. * Checks if a cullable object (mesh...) is in the camera frustum
  7243. * Unlike isInFrustum this cheks the full bounding box
  7244. * @param frustumPlanes Camera near/planes
  7245. * @returns true if the object is in frustum otherwise false
  7246. */
  7247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7248. }
  7249. /**
  7250. * Info for a bounding data of a mesh
  7251. */
  7252. export class BoundingInfo implements ICullable {
  7253. /**
  7254. * Bounding box for the mesh
  7255. */
  7256. readonly boundingBox: BoundingBox;
  7257. /**
  7258. * Bounding sphere for the mesh
  7259. */
  7260. readonly boundingSphere: BoundingSphere;
  7261. private _isLocked;
  7262. private static readonly TmpVector3;
  7263. /**
  7264. * Constructs bounding info
  7265. * @param minimum min vector of the bounding box/sphere
  7266. * @param maximum max vector of the bounding box/sphere
  7267. * @param worldMatrix defines the new world matrix
  7268. */
  7269. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7270. /**
  7271. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7272. * @param min defines the new minimum vector (in local space)
  7273. * @param max defines the new maximum vector (in local space)
  7274. * @param worldMatrix defines the new world matrix
  7275. */
  7276. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7277. /**
  7278. * min vector of the bounding box/sphere
  7279. */
  7280. readonly minimum: Vector3;
  7281. /**
  7282. * max vector of the bounding box/sphere
  7283. */
  7284. readonly maximum: Vector3;
  7285. /**
  7286. * If the info is locked and won't be updated to avoid perf overhead
  7287. */
  7288. isLocked: boolean;
  7289. /**
  7290. * Updates the bounding sphere and box
  7291. * @param world world matrix to be used to update
  7292. */
  7293. update(world: DeepImmutable<Matrix>): void;
  7294. /**
  7295. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7296. * @param center New center of the bounding info
  7297. * @param extend New extend of the bounding info
  7298. * @returns the current bounding info
  7299. */
  7300. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7301. /**
  7302. * Scale the current bounding info by applying a scale factor
  7303. * @param factor defines the scale factor to apply
  7304. * @returns the current bounding info
  7305. */
  7306. scale(factor: number): BoundingInfo;
  7307. /**
  7308. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7309. * @param frustumPlanes defines the frustum to test
  7310. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7311. * @returns true if the bounding info is in the frustum planes
  7312. */
  7313. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7314. /**
  7315. * Gets the world distance between the min and max points of the bounding box
  7316. */
  7317. readonly diagonalLength: number;
  7318. /**
  7319. * Checks if a cullable object (mesh...) is in the camera frustum
  7320. * Unlike isInFrustum this cheks the full bounding box
  7321. * @param frustumPlanes Camera near/planes
  7322. * @returns true if the object is in frustum otherwise false
  7323. */
  7324. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7325. /** @hidden */
  7326. _checkCollision(collider: Collider): boolean;
  7327. /**
  7328. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7329. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7330. * @param point the point to check intersection with
  7331. * @returns if the point intersects
  7332. */
  7333. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7334. /**
  7335. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7336. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7337. * @param boundingInfo the bounding info to check intersection with
  7338. * @param precise if the intersection should be done using OBB
  7339. * @returns if the bounding info intersects
  7340. */
  7341. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7342. }
  7343. }
  7344. declare module "babylonjs/Maths/math.functions" {
  7345. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7346. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7347. /**
  7348. * Extracts minimum and maximum values from a list of indexed positions
  7349. * @param positions defines the positions to use
  7350. * @param indices defines the indices to the positions
  7351. * @param indexStart defines the start index
  7352. * @param indexCount defines the end index
  7353. * @param bias defines bias value to add to the result
  7354. * @return minimum and maximum values
  7355. */
  7356. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7357. minimum: Vector3;
  7358. maximum: Vector3;
  7359. };
  7360. /**
  7361. * Extracts minimum and maximum values from a list of positions
  7362. * @param positions defines the positions to use
  7363. * @param start defines the start index in the positions array
  7364. * @param count defines the number of positions to handle
  7365. * @param bias defines bias value to add to the result
  7366. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7367. * @return minimum and maximum values
  7368. */
  7369. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7370. minimum: Vector3;
  7371. maximum: Vector3;
  7372. };
  7373. }
  7374. declare module "babylonjs/Misc/iInspectable" {
  7375. /**
  7376. * Enum that determines the text-wrapping mode to use.
  7377. */
  7378. export enum InspectableType {
  7379. /**
  7380. * Checkbox for booleans
  7381. */
  7382. Checkbox = 0,
  7383. /**
  7384. * Sliders for numbers
  7385. */
  7386. Slider = 1,
  7387. /**
  7388. * Vector3
  7389. */
  7390. Vector3 = 2,
  7391. /**
  7392. * Quaternions
  7393. */
  7394. Quaternion = 3,
  7395. /**
  7396. * Color3
  7397. */
  7398. Color3 = 4,
  7399. /**
  7400. * String
  7401. */
  7402. String = 5
  7403. }
  7404. /**
  7405. * Interface used to define custom inspectable properties.
  7406. * This interface is used by the inspector to display custom property grids
  7407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7408. */
  7409. export interface IInspectable {
  7410. /**
  7411. * Gets the label to display
  7412. */
  7413. label: string;
  7414. /**
  7415. * Gets the name of the property to edit
  7416. */
  7417. propertyName: string;
  7418. /**
  7419. * Gets the type of the editor to use
  7420. */
  7421. type: InspectableType;
  7422. /**
  7423. * Gets the minimum value of the property when using in "slider" mode
  7424. */
  7425. min?: number;
  7426. /**
  7427. * Gets the maximum value of the property when using in "slider" mode
  7428. */
  7429. max?: number;
  7430. /**
  7431. * Gets the setp to use when using in "slider" mode
  7432. */
  7433. step?: number;
  7434. }
  7435. }
  7436. declare module "babylonjs/Misc/timingTools" {
  7437. /**
  7438. * Class used to provide helper for timing
  7439. */
  7440. export class TimingTools {
  7441. /**
  7442. * Polyfill for setImmediate
  7443. * @param action defines the action to execute after the current execution block
  7444. */
  7445. static SetImmediate(action: () => void): void;
  7446. }
  7447. }
  7448. declare module "babylonjs/Misc/instantiationTools" {
  7449. /**
  7450. * Class used to enable instatition of objects by class name
  7451. */
  7452. export class InstantiationTools {
  7453. /**
  7454. * Use this object to register external classes like custom textures or material
  7455. * to allow the laoders to instantiate them
  7456. */
  7457. static RegisteredExternalClasses: {
  7458. [key: string]: Object;
  7459. };
  7460. /**
  7461. * Tries to instantiate a new object from a given class name
  7462. * @param className defines the class name to instantiate
  7463. * @returns the new object or null if the system was not able to do the instantiation
  7464. */
  7465. static Instantiate(className: string): any;
  7466. }
  7467. }
  7468. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7469. import { Nullable } from "babylonjs/types";
  7470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7471. /**
  7472. * This represents the required contract to create a new type of texture loader.
  7473. */
  7474. export interface IInternalTextureLoader {
  7475. /**
  7476. * Defines wether the loader supports cascade loading the different faces.
  7477. */
  7478. supportCascades: boolean;
  7479. /**
  7480. * This returns if the loader support the current file information.
  7481. * @param extension defines the file extension of the file being loaded
  7482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7483. * @param fallback defines the fallback internal texture if any
  7484. * @param isBase64 defines whether the texture is encoded as a base64
  7485. * @param isBuffer defines whether the texture data are stored as a buffer
  7486. * @returns true if the loader can load the specified file
  7487. */
  7488. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7489. /**
  7490. * Transform the url before loading if required.
  7491. * @param rootUrl the url of the texture
  7492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7493. * @returns the transformed texture
  7494. */
  7495. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7496. /**
  7497. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7498. * @param rootUrl the url of the texture
  7499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7500. * @returns the fallback texture
  7501. */
  7502. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7503. /**
  7504. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7505. * @param data contains the texture data
  7506. * @param texture defines the BabylonJS internal texture
  7507. * @param createPolynomials will be true if polynomials have been requested
  7508. * @param onLoad defines the callback to trigger once the texture is ready
  7509. * @param onError defines the callback to trigger in case of error
  7510. */
  7511. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7512. /**
  7513. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7514. * @param data contains the texture data
  7515. * @param texture defines the BabylonJS internal texture
  7516. * @param callback defines the method to call once ready to upload
  7517. */
  7518. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7519. }
  7520. }
  7521. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7523. import { Nullable } from "babylonjs/types";
  7524. import { Scene } from "babylonjs/scene";
  7525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7526. module "babylonjs/Engines/engine" {
  7527. interface Engine {
  7528. /**
  7529. * Creates a depth stencil cube texture.
  7530. * This is only available in WebGL 2.
  7531. * @param size The size of face edge in the cube texture.
  7532. * @param options The options defining the cube texture.
  7533. * @returns The cube texture
  7534. */
  7535. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7536. /**
  7537. * Creates a cube texture
  7538. * @param rootUrl defines the url where the files to load is located
  7539. * @param scene defines the current scene
  7540. * @param files defines the list of files to load (1 per face)
  7541. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7542. * @param onLoad defines an optional callback raised when the texture is loaded
  7543. * @param onError defines an optional callback raised if there is an issue to load the texture
  7544. * @param format defines the format of the data
  7545. * @param forcedExtension defines the extension to use to pick the right loader
  7546. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7549. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7550. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7551. * @returns the cube texture as an InternalTexture
  7552. */
  7553. 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;
  7554. /**
  7555. * Creates a cube texture
  7556. * @param rootUrl defines the url where the files to load is located
  7557. * @param scene defines the current scene
  7558. * @param files defines the list of files to load (1 per face)
  7559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7560. * @param onLoad defines an optional callback raised when the texture is loaded
  7561. * @param onError defines an optional callback raised if there is an issue to load the texture
  7562. * @param format defines the format of the data
  7563. * @param forcedExtension defines the extension to use to pick the right loader
  7564. * @returns the cube texture as an InternalTexture
  7565. */
  7566. 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;
  7567. /**
  7568. * Creates a cube texture
  7569. * @param rootUrl defines the url where the files to load is located
  7570. * @param scene defines the current scene
  7571. * @param files defines the list of files to load (1 per face)
  7572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7573. * @param onLoad defines an optional callback raised when the texture is loaded
  7574. * @param onError defines an optional callback raised if there is an issue to load the texture
  7575. * @param format defines the format of the data
  7576. * @param forcedExtension defines the extension to use to pick the right loader
  7577. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7580. * @returns the cube texture as an InternalTexture
  7581. */
  7582. 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;
  7583. /** @hidden */
  7584. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7585. /** @hidden */
  7586. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7587. /** @hidden */
  7588. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7589. /** @hidden */
  7590. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7591. }
  7592. }
  7593. }
  7594. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7595. import { Nullable } from "babylonjs/types";
  7596. import { Scene } from "babylonjs/scene";
  7597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7599. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7600. /**
  7601. * Class for creating a cube texture
  7602. */
  7603. export class CubeTexture extends BaseTexture {
  7604. private _delayedOnLoad;
  7605. /**
  7606. * The url of the texture
  7607. */
  7608. url: string;
  7609. /**
  7610. * Gets or sets the center of the bounding box associated with the cube texture.
  7611. * It must define where the camera used to render the texture was set
  7612. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7613. */
  7614. boundingBoxPosition: Vector3;
  7615. private _boundingBoxSize;
  7616. /**
  7617. * Gets or sets the size of the bounding box associated with the cube texture
  7618. * When defined, the cubemap will switch to local mode
  7619. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7620. * @example https://www.babylonjs-playground.com/#RNASML
  7621. */
  7622. /**
  7623. * Returns the bounding box size
  7624. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7625. */
  7626. boundingBoxSize: Vector3;
  7627. protected _rotationY: number;
  7628. /**
  7629. * Sets texture matrix rotation angle around Y axis in radians.
  7630. */
  7631. /**
  7632. * Gets texture matrix rotation angle around Y axis radians.
  7633. */
  7634. rotationY: number;
  7635. /**
  7636. * Are mip maps generated for this texture or not.
  7637. */
  7638. readonly noMipmap: boolean;
  7639. private _noMipmap;
  7640. private _files;
  7641. private _extensions;
  7642. private _textureMatrix;
  7643. private _format;
  7644. private _createPolynomials;
  7645. /** @hidden */
  7646. _prefiltered: boolean;
  7647. /**
  7648. * Creates a cube texture from an array of image urls
  7649. * @param files defines an array of image urls
  7650. * @param scene defines the hosting scene
  7651. * @param noMipmap specifies if mip maps are not used
  7652. * @returns a cube texture
  7653. */
  7654. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7655. /**
  7656. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7657. * @param url defines the url of the prefiltered texture
  7658. * @param scene defines the scene the texture is attached to
  7659. * @param forcedExtension defines the extension of the file if different from the url
  7660. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7661. * @return the prefiltered texture
  7662. */
  7663. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7664. /**
  7665. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7666. * as prefiltered data.
  7667. * @param rootUrl defines the url of the texture or the root name of the six images
  7668. * @param scene defines the scene the texture is attached to
  7669. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7670. * @param noMipmap defines if mipmaps should be created or not
  7671. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7672. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7673. * @param onError defines a callback triggered in case of error during load
  7674. * @param format defines the internal format to use for the texture once loaded
  7675. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7676. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7677. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @return the cube texture
  7681. */
  7682. 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);
  7683. /**
  7684. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7685. */
  7686. readonly isPrefiltered: boolean;
  7687. /**
  7688. * Get the current class name of the texture useful for serialization or dynamic coding.
  7689. * @returns "CubeTexture"
  7690. */
  7691. getClassName(): string;
  7692. /**
  7693. * Update the url (and optional buffer) of this texture if url was null during construction.
  7694. * @param url the url of the texture
  7695. * @param forcedExtension defines the extension to use
  7696. * @param onLoad callback called when the texture is loaded (defaults to null)
  7697. */
  7698. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7699. /**
  7700. * Delays loading of the cube texture
  7701. * @param forcedExtension defines the extension to use
  7702. */
  7703. delayLoad(forcedExtension?: string): void;
  7704. /**
  7705. * Returns the reflection texture matrix
  7706. * @returns the reflection texture matrix
  7707. */
  7708. getReflectionTextureMatrix(): Matrix;
  7709. /**
  7710. * Sets the reflection texture matrix
  7711. * @param value Reflection texture matrix
  7712. */
  7713. setReflectionTextureMatrix(value: Matrix): void;
  7714. /**
  7715. * Parses text to create a cube texture
  7716. * @param parsedTexture define the serialized text to read from
  7717. * @param scene defines the hosting scene
  7718. * @param rootUrl defines the root url of the cube texture
  7719. * @returns a cube texture
  7720. */
  7721. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7722. /**
  7723. * Makes a clone, or deep copy, of the cube texture
  7724. * @returns a new cube texture
  7725. */
  7726. clone(): CubeTexture;
  7727. }
  7728. }
  7729. declare module "babylonjs/Materials/materialDefines" {
  7730. /**
  7731. * Manages the defines for the Material
  7732. */
  7733. export class MaterialDefines {
  7734. /** @hidden */
  7735. protected _keys: string[];
  7736. private _isDirty;
  7737. /** @hidden */
  7738. _renderId: number;
  7739. /** @hidden */
  7740. _areLightsDirty: boolean;
  7741. /** @hidden */
  7742. _areLightsDisposed: boolean;
  7743. /** @hidden */
  7744. _areAttributesDirty: boolean;
  7745. /** @hidden */
  7746. _areTexturesDirty: boolean;
  7747. /** @hidden */
  7748. _areFresnelDirty: boolean;
  7749. /** @hidden */
  7750. _areMiscDirty: boolean;
  7751. /** @hidden */
  7752. _areImageProcessingDirty: boolean;
  7753. /** @hidden */
  7754. _normals: boolean;
  7755. /** @hidden */
  7756. _uvs: boolean;
  7757. /** @hidden */
  7758. _needNormals: boolean;
  7759. /** @hidden */
  7760. _needUVs: boolean;
  7761. [id: string]: any;
  7762. /**
  7763. * Specifies if the material needs to be re-calculated
  7764. */
  7765. readonly isDirty: boolean;
  7766. /**
  7767. * Marks the material to indicate that it has been re-calculated
  7768. */
  7769. markAsProcessed(): void;
  7770. /**
  7771. * Marks the material to indicate that it needs to be re-calculated
  7772. */
  7773. markAsUnprocessed(): void;
  7774. /**
  7775. * Marks the material to indicate all of its defines need to be re-calculated
  7776. */
  7777. markAllAsDirty(): void;
  7778. /**
  7779. * Marks the material to indicate that image processing needs to be re-calculated
  7780. */
  7781. markAsImageProcessingDirty(): void;
  7782. /**
  7783. * Marks the material to indicate the lights need to be re-calculated
  7784. * @param disposed Defines whether the light is dirty due to dispose or not
  7785. */
  7786. markAsLightDirty(disposed?: boolean): void;
  7787. /**
  7788. * Marks the attribute state as changed
  7789. */
  7790. markAsAttributesDirty(): void;
  7791. /**
  7792. * Marks the texture state as changed
  7793. */
  7794. markAsTexturesDirty(): void;
  7795. /**
  7796. * Marks the fresnel state as changed
  7797. */
  7798. markAsFresnelDirty(): void;
  7799. /**
  7800. * Marks the misc state as changed
  7801. */
  7802. markAsMiscDirty(): void;
  7803. /**
  7804. * Rebuilds the material defines
  7805. */
  7806. rebuild(): void;
  7807. /**
  7808. * Specifies if two material defines are equal
  7809. * @param other - A material define instance to compare to
  7810. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7811. */
  7812. isEqual(other: MaterialDefines): boolean;
  7813. /**
  7814. * Clones this instance's defines to another instance
  7815. * @param other - material defines to clone values to
  7816. */
  7817. cloneTo(other: MaterialDefines): void;
  7818. /**
  7819. * Resets the material define values
  7820. */
  7821. reset(): void;
  7822. /**
  7823. * Converts the material define values to a string
  7824. * @returns - String of material define information
  7825. */
  7826. toString(): string;
  7827. }
  7828. }
  7829. declare module "babylonjs/Materials/colorCurves" {
  7830. import { Effect } from "babylonjs/Materials/effect";
  7831. /**
  7832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7834. * 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;
  7835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7836. */
  7837. export class ColorCurves {
  7838. private _dirty;
  7839. private _tempColor;
  7840. private _globalCurve;
  7841. private _highlightsCurve;
  7842. private _midtonesCurve;
  7843. private _shadowsCurve;
  7844. private _positiveCurve;
  7845. private _negativeCurve;
  7846. private _globalHue;
  7847. private _globalDensity;
  7848. private _globalSaturation;
  7849. private _globalExposure;
  7850. /**
  7851. * Gets 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. /**
  7855. * Sets the global Hue value.
  7856. * 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).
  7857. */
  7858. globalHue: number;
  7859. /**
  7860. * Gets the global Density value.
  7861. * 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.
  7862. * Values less than zero provide a filter of opposite hue.
  7863. */
  7864. /**
  7865. * Sets the global Density value.
  7866. * 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.
  7867. * Values less than zero provide a filter of opposite hue.
  7868. */
  7869. globalDensity: number;
  7870. /**
  7871. * Gets 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. /**
  7875. * Sets the global Saturation value.
  7876. * 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.
  7877. */
  7878. globalSaturation: number;
  7879. /**
  7880. * Gets 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. /**
  7884. * Sets the global Exposure value.
  7885. * 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.
  7886. */
  7887. globalExposure: number;
  7888. private _highlightsHue;
  7889. private _highlightsDensity;
  7890. private _highlightsSaturation;
  7891. private _highlightsExposure;
  7892. /**
  7893. * Gets 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. /**
  7897. * Sets the highlights Hue value.
  7898. * 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).
  7899. */
  7900. highlightsHue: number;
  7901. /**
  7902. * Gets the highlights Density value.
  7903. * 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.
  7904. * Values less than zero provide a filter of opposite hue.
  7905. */
  7906. /**
  7907. * Sets the highlights Density value.
  7908. * 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.
  7909. * Values less than zero provide a filter of opposite hue.
  7910. */
  7911. highlightsDensity: number;
  7912. /**
  7913. * Gets 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. /**
  7917. * Sets the highlights Saturation value.
  7918. * 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.
  7919. */
  7920. highlightsSaturation: number;
  7921. /**
  7922. * Gets 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. /**
  7926. * Sets the highlights Exposure value.
  7927. * 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.
  7928. */
  7929. highlightsExposure: number;
  7930. private _midtonesHue;
  7931. private _midtonesDensity;
  7932. private _midtonesSaturation;
  7933. private _midtonesExposure;
  7934. /**
  7935. * Gets 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. /**
  7939. * Sets the midtones Hue value.
  7940. * 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).
  7941. */
  7942. midtonesHue: number;
  7943. /**
  7944. * Gets the midtones Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. /**
  7949. * Sets the midtones Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. midtonesDensity: number;
  7954. /**
  7955. * Gets 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. /**
  7959. * Sets the midtones Saturation value.
  7960. * 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.
  7961. */
  7962. midtonesSaturation: number;
  7963. /**
  7964. * Gets 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. /**
  7968. * Sets the midtones Exposure value.
  7969. * 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.
  7970. */
  7971. midtonesExposure: number;
  7972. private _shadowsHue;
  7973. private _shadowsDensity;
  7974. private _shadowsSaturation;
  7975. private _shadowsExposure;
  7976. /**
  7977. * Gets 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. /**
  7981. * Sets the shadows Hue value.
  7982. * 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).
  7983. */
  7984. shadowsHue: number;
  7985. /**
  7986. * Gets the shadows Density value.
  7987. * 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.
  7988. * Values less than zero provide a filter of opposite hue.
  7989. */
  7990. /**
  7991. * Sets the shadows Density value.
  7992. * 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.
  7993. * Values less than zero provide a filter of opposite hue.
  7994. */
  7995. shadowsDensity: number;
  7996. /**
  7997. * Gets 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. /**
  8001. * Sets the shadows Saturation value.
  8002. * 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.
  8003. */
  8004. shadowsSaturation: number;
  8005. /**
  8006. * Gets 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. /**
  8010. * Sets the shadows Exposure value.
  8011. * 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.
  8012. */
  8013. shadowsExposure: number;
  8014. /**
  8015. * Returns the class name
  8016. * @returns The class name
  8017. */
  8018. getClassName(): string;
  8019. /**
  8020. * Binds the color curves to the shader.
  8021. * @param colorCurves The color curve to bind
  8022. * @param effect The effect to bind to
  8023. * @param positiveUniform The positive uniform shader parameter
  8024. * @param neutralUniform The neutral uniform shader parameter
  8025. * @param negativeUniform The negative uniform shader parameter
  8026. */
  8027. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8028. /**
  8029. * Prepare the list of uniforms associated with the ColorCurves effects.
  8030. * @param uniformsList The list of uniforms used in the effect
  8031. */
  8032. static PrepareUniforms(uniformsList: string[]): void;
  8033. /**
  8034. * Returns color grading data based on a hue, density, saturation and exposure value.
  8035. * @param filterHue The hue of the color filter.
  8036. * @param filterDensity The density of the color filter.
  8037. * @param saturation The saturation.
  8038. * @param exposure The exposure.
  8039. * @param result The result data container.
  8040. */
  8041. private getColorGradingDataToRef;
  8042. /**
  8043. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8044. * @param value The input slider value in range [-100,100].
  8045. * @returns Adjusted value.
  8046. */
  8047. private static applyColorGradingSliderNonlinear;
  8048. /**
  8049. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8050. * @param hue The hue (H) input.
  8051. * @param saturation The saturation (S) input.
  8052. * @param brightness The brightness (B) input.
  8053. * @result An RGBA color represented as Vector4.
  8054. */
  8055. private static fromHSBToRef;
  8056. /**
  8057. * Returns a value clamped between min and max
  8058. * @param value The value to clamp
  8059. * @param min The minimum of value
  8060. * @param max The maximum of value
  8061. * @returns The clamped value.
  8062. */
  8063. private static clamp;
  8064. /**
  8065. * Clones the current color curve instance.
  8066. * @return The cloned curves
  8067. */
  8068. clone(): ColorCurves;
  8069. /**
  8070. * Serializes the current color curve instance to a json representation.
  8071. * @return a JSON representation
  8072. */
  8073. serialize(): any;
  8074. /**
  8075. * Parses the color curve from a json representation.
  8076. * @param source the JSON source to parse
  8077. * @return The parsed curves
  8078. */
  8079. static Parse(source: any): ColorCurves;
  8080. }
  8081. }
  8082. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8083. import { Observable } from "babylonjs/Misc/observable";
  8084. import { Nullable } from "babylonjs/types";
  8085. import { Color4 } from "babylonjs/Maths/math.color";
  8086. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8087. import { Effect } from "babylonjs/Materials/effect";
  8088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8089. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8090. /**
  8091. * Interface to follow in your material defines to integrate easily the
  8092. * Image proccessing functions.
  8093. * @hidden
  8094. */
  8095. export interface IImageProcessingConfigurationDefines {
  8096. IMAGEPROCESSING: boolean;
  8097. VIGNETTE: boolean;
  8098. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8099. VIGNETTEBLENDMODEOPAQUE: boolean;
  8100. TONEMAPPING: boolean;
  8101. TONEMAPPING_ACES: boolean;
  8102. CONTRAST: boolean;
  8103. EXPOSURE: boolean;
  8104. COLORCURVES: boolean;
  8105. COLORGRADING: boolean;
  8106. COLORGRADING3D: boolean;
  8107. SAMPLER3DGREENDEPTH: boolean;
  8108. SAMPLER3DBGRMAP: boolean;
  8109. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8110. }
  8111. /**
  8112. * @hidden
  8113. */
  8114. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8115. IMAGEPROCESSING: boolean;
  8116. VIGNETTE: boolean;
  8117. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8118. VIGNETTEBLENDMODEOPAQUE: boolean;
  8119. TONEMAPPING: boolean;
  8120. TONEMAPPING_ACES: boolean;
  8121. CONTRAST: boolean;
  8122. COLORCURVES: boolean;
  8123. COLORGRADING: boolean;
  8124. COLORGRADING3D: boolean;
  8125. SAMPLER3DGREENDEPTH: boolean;
  8126. SAMPLER3DBGRMAP: boolean;
  8127. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8128. EXPOSURE: boolean;
  8129. constructor();
  8130. }
  8131. /**
  8132. * This groups together the common properties used for image processing either in direct forward pass
  8133. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8134. * or not.
  8135. */
  8136. export class ImageProcessingConfiguration {
  8137. /**
  8138. * Default tone mapping applied in BabylonJS.
  8139. */
  8140. static readonly TONEMAPPING_STANDARD: number;
  8141. /**
  8142. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8143. * to other engines rendering to increase portability.
  8144. */
  8145. static readonly TONEMAPPING_ACES: number;
  8146. /**
  8147. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8148. */
  8149. colorCurves: Nullable<ColorCurves>;
  8150. private _colorCurvesEnabled;
  8151. /**
  8152. * Gets wether the color curves effect is enabled.
  8153. */
  8154. /**
  8155. * Sets wether the color curves effect is enabled.
  8156. */
  8157. colorCurvesEnabled: boolean;
  8158. private _colorGradingTexture;
  8159. /**
  8160. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8161. */
  8162. /**
  8163. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8164. */
  8165. colorGradingTexture: Nullable<BaseTexture>;
  8166. private _colorGradingEnabled;
  8167. /**
  8168. * Gets wether the color grading effect is enabled.
  8169. */
  8170. /**
  8171. * Sets wether the color grading effect is enabled.
  8172. */
  8173. colorGradingEnabled: boolean;
  8174. private _colorGradingWithGreenDepth;
  8175. /**
  8176. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8177. */
  8178. /**
  8179. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8180. */
  8181. colorGradingWithGreenDepth: boolean;
  8182. private _colorGradingBGR;
  8183. /**
  8184. * Gets wether the color grading texture contains BGR values.
  8185. */
  8186. /**
  8187. * Sets wether the color grading texture contains BGR values.
  8188. */
  8189. colorGradingBGR: boolean;
  8190. /** @hidden */
  8191. _exposure: number;
  8192. /**
  8193. * Gets the Exposure used in the effect.
  8194. */
  8195. /**
  8196. * Sets the Exposure used in the effect.
  8197. */
  8198. exposure: number;
  8199. private _toneMappingEnabled;
  8200. /**
  8201. * Gets wether the tone mapping effect is enabled.
  8202. */
  8203. /**
  8204. * Sets wether the tone mapping effect is enabled.
  8205. */
  8206. toneMappingEnabled: boolean;
  8207. private _toneMappingType;
  8208. /**
  8209. * Gets the type of tone mapping effect.
  8210. */
  8211. /**
  8212. * Sets the type of tone mapping effect used in BabylonJS.
  8213. */
  8214. toneMappingType: number;
  8215. protected _contrast: number;
  8216. /**
  8217. * Gets the contrast used in the effect.
  8218. */
  8219. /**
  8220. * Sets the contrast used in the effect.
  8221. */
  8222. contrast: number;
  8223. /**
  8224. * Vignette stretch size.
  8225. */
  8226. vignetteStretch: number;
  8227. /**
  8228. * Vignette centre X Offset.
  8229. */
  8230. vignetteCentreX: number;
  8231. /**
  8232. * Vignette centre Y Offset.
  8233. */
  8234. vignetteCentreY: number;
  8235. /**
  8236. * Vignette weight or intensity of the vignette effect.
  8237. */
  8238. vignetteWeight: number;
  8239. /**
  8240. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8241. * if vignetteEnabled is set to true.
  8242. */
  8243. vignetteColor: Color4;
  8244. /**
  8245. * Camera field of view used by the Vignette effect.
  8246. */
  8247. vignetteCameraFov: number;
  8248. private _vignetteBlendMode;
  8249. /**
  8250. * Gets the vignette blend mode allowing different kind of effect.
  8251. */
  8252. /**
  8253. * Sets the vignette blend mode allowing different kind of effect.
  8254. */
  8255. vignetteBlendMode: number;
  8256. private _vignetteEnabled;
  8257. /**
  8258. * Gets wether the vignette effect is enabled.
  8259. */
  8260. /**
  8261. * Sets wether the vignette effect is enabled.
  8262. */
  8263. vignetteEnabled: boolean;
  8264. private _applyByPostProcess;
  8265. /**
  8266. * Gets wether the image processing is applied through a post process or not.
  8267. */
  8268. /**
  8269. * Sets wether the image processing is applied through a post process or not.
  8270. */
  8271. applyByPostProcess: boolean;
  8272. private _isEnabled;
  8273. /**
  8274. * Gets wether the image processing is enabled or not.
  8275. */
  8276. /**
  8277. * Sets wether the image processing is enabled or not.
  8278. */
  8279. isEnabled: boolean;
  8280. /**
  8281. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8282. */
  8283. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8284. /**
  8285. * Method called each time the image processing information changes requires to recompile the effect.
  8286. */
  8287. protected _updateParameters(): void;
  8288. /**
  8289. * Gets the current class name.
  8290. * @return "ImageProcessingConfiguration"
  8291. */
  8292. getClassName(): string;
  8293. /**
  8294. * Prepare the list of uniforms associated with the Image Processing effects.
  8295. * @param uniforms The list of uniforms used in the effect
  8296. * @param defines the list of defines currently in use
  8297. */
  8298. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8299. /**
  8300. * Prepare the list of samplers associated with the Image Processing effects.
  8301. * @param samplersList The list of uniforms used in the effect
  8302. * @param defines the list of defines currently in use
  8303. */
  8304. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8305. /**
  8306. * Prepare the list of defines associated to the shader.
  8307. * @param defines the list of defines to complete
  8308. * @param forPostProcess Define if we are currently in post process mode or not
  8309. */
  8310. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8311. /**
  8312. * Returns true if all the image processing information are ready.
  8313. * @returns True if ready, otherwise, false
  8314. */
  8315. isReady(): boolean;
  8316. /**
  8317. * Binds the image processing to the shader.
  8318. * @param effect The effect to bind to
  8319. * @param aspectRatio Define the current aspect ratio of the effect
  8320. */
  8321. bind(effect: Effect, aspectRatio?: number): void;
  8322. /**
  8323. * Clones the current image processing instance.
  8324. * @return The cloned image processing
  8325. */
  8326. clone(): ImageProcessingConfiguration;
  8327. /**
  8328. * Serializes the current image processing instance to a json representation.
  8329. * @return a JSON representation
  8330. */
  8331. serialize(): any;
  8332. /**
  8333. * Parses the image processing from a json representation.
  8334. * @param source the JSON source to parse
  8335. * @return The parsed image processing
  8336. */
  8337. static Parse(source: any): ImageProcessingConfiguration;
  8338. private static _VIGNETTEMODE_MULTIPLY;
  8339. private static _VIGNETTEMODE_OPAQUE;
  8340. /**
  8341. * Used to apply the vignette as a mix with the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_MULTIPLY: number;
  8344. /**
  8345. * Used to apply the vignette as a replacement of the pixel color.
  8346. */
  8347. static readonly VIGNETTEMODE_OPAQUE: number;
  8348. }
  8349. }
  8350. declare module "babylonjs/Shaders/postprocess.vertex" {
  8351. /** @hidden */
  8352. export var postprocessVertexShader: {
  8353. name: string;
  8354. shader: string;
  8355. };
  8356. }
  8357. declare module "babylonjs/Maths/math.axis" {
  8358. import { Vector3 } from "babylonjs/Maths/math.vector";
  8359. /** Defines supported spaces */
  8360. export enum Space {
  8361. /** Local (object) space */
  8362. LOCAL = 0,
  8363. /** World space */
  8364. WORLD = 1,
  8365. /** Bone space */
  8366. BONE = 2
  8367. }
  8368. /** Defines the 3 main axes */
  8369. export class Axis {
  8370. /** X axis */
  8371. static X: Vector3;
  8372. /** Y axis */
  8373. static Y: Vector3;
  8374. /** Z axis */
  8375. static Z: Vector3;
  8376. }
  8377. }
  8378. declare module "babylonjs/Cameras/targetCamera" {
  8379. import { Nullable } from "babylonjs/types";
  8380. import { Camera } from "babylonjs/Cameras/camera";
  8381. import { Scene } from "babylonjs/scene";
  8382. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8383. /**
  8384. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8385. * This is the base of the follow, arc rotate cameras and Free camera
  8386. * @see http://doc.babylonjs.com/features/cameras
  8387. */
  8388. export class TargetCamera extends Camera {
  8389. private static _RigCamTransformMatrix;
  8390. private static _TargetTransformMatrix;
  8391. private static _TargetFocalPoint;
  8392. /**
  8393. * Define the current direction the camera is moving to
  8394. */
  8395. cameraDirection: Vector3;
  8396. /**
  8397. * Define the current rotation the camera is rotating to
  8398. */
  8399. cameraRotation: Vector2;
  8400. /**
  8401. * When set, the up vector of the camera will be updated by the rotation of the camera
  8402. */
  8403. updateUpVectorFromRotation: boolean;
  8404. private _tmpQuaternion;
  8405. /**
  8406. * Define the current rotation of the camera
  8407. */
  8408. rotation: Vector3;
  8409. /**
  8410. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8411. */
  8412. rotationQuaternion: Quaternion;
  8413. /**
  8414. * Define the current speed of the camera
  8415. */
  8416. speed: number;
  8417. /**
  8418. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8419. * around all axis.
  8420. */
  8421. noRotationConstraint: boolean;
  8422. /**
  8423. * Define the current target of the camera as an object or a position.
  8424. */
  8425. lockedTarget: any;
  8426. /** @hidden */
  8427. _currentTarget: Vector3;
  8428. /** @hidden */
  8429. _initialFocalDistance: number;
  8430. /** @hidden */
  8431. _viewMatrix: Matrix;
  8432. /** @hidden */
  8433. _camMatrix: Matrix;
  8434. /** @hidden */
  8435. _cameraTransformMatrix: Matrix;
  8436. /** @hidden */
  8437. _cameraRotationMatrix: Matrix;
  8438. /** @hidden */
  8439. _referencePoint: Vector3;
  8440. /** @hidden */
  8441. _transformedReferencePoint: Vector3;
  8442. protected _globalCurrentTarget: Vector3;
  8443. protected _globalCurrentUpVector: Vector3;
  8444. /** @hidden */
  8445. _reset: () => void;
  8446. private _defaultUp;
  8447. /**
  8448. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8449. * This is the base of the follow, arc rotate cameras and Free camera
  8450. * @see http://doc.babylonjs.com/features/cameras
  8451. * @param name Defines the name of the camera in the scene
  8452. * @param position Defines the start position of the camera in the scene
  8453. * @param scene Defines the scene the camera belongs to
  8454. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8455. */
  8456. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8457. /**
  8458. * Gets the position in front of the camera at a given distance.
  8459. * @param distance The distance from the camera we want the position to be
  8460. * @returns the position
  8461. */
  8462. getFrontPosition(distance: number): Vector3;
  8463. /** @hidden */
  8464. _getLockedTargetPosition(): Nullable<Vector3>;
  8465. private _storedPosition;
  8466. private _storedRotation;
  8467. private _storedRotationQuaternion;
  8468. /**
  8469. * Store current camera state of the camera (fov, position, rotation, etc..)
  8470. * @returns the camera
  8471. */
  8472. storeState(): Camera;
  8473. /**
  8474. * Restored camera state. You must call storeState() first
  8475. * @returns whether it was successful or not
  8476. * @hidden
  8477. */
  8478. _restoreStateValues(): boolean;
  8479. /** @hidden */
  8480. _initCache(): void;
  8481. /** @hidden */
  8482. _updateCache(ignoreParentClass?: boolean): void;
  8483. /** @hidden */
  8484. _isSynchronizedViewMatrix(): boolean;
  8485. /** @hidden */
  8486. _computeLocalCameraSpeed(): number;
  8487. /**
  8488. * Defines the target the camera should look at.
  8489. * @param target Defines the new target as a Vector or a mesh
  8490. */
  8491. setTarget(target: Vector3): void;
  8492. /**
  8493. * Return the current target position of the camera. This value is expressed in local space.
  8494. * @returns the target position
  8495. */
  8496. getTarget(): Vector3;
  8497. /** @hidden */
  8498. _decideIfNeedsToMove(): boolean;
  8499. /** @hidden */
  8500. _updatePosition(): void;
  8501. /** @hidden */
  8502. _checkInputs(): void;
  8503. protected _updateCameraRotationMatrix(): void;
  8504. /**
  8505. * 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)
  8506. * @returns the current camera
  8507. */
  8508. private _rotateUpVectorWithCameraRotationMatrix;
  8509. private _cachedRotationZ;
  8510. private _cachedQuaternionRotationZ;
  8511. /** @hidden */
  8512. _getViewMatrix(): Matrix;
  8513. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8514. /**
  8515. * @hidden
  8516. */
  8517. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8518. /**
  8519. * @hidden
  8520. */
  8521. _updateRigCameras(): void;
  8522. private _getRigCamPositionAndTarget;
  8523. /**
  8524. * Gets the current object class name.
  8525. * @return the class name
  8526. */
  8527. getClassName(): string;
  8528. }
  8529. }
  8530. declare module "babylonjs/Events/keyboardEvents" {
  8531. /**
  8532. * Gather the list of keyboard event types as constants.
  8533. */
  8534. export class KeyboardEventTypes {
  8535. /**
  8536. * The keydown event is fired when a key becomes active (pressed).
  8537. */
  8538. static readonly KEYDOWN: number;
  8539. /**
  8540. * The keyup event is fired when a key has been released.
  8541. */
  8542. static readonly KEYUP: number;
  8543. }
  8544. /**
  8545. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8546. */
  8547. export class KeyboardInfo {
  8548. /**
  8549. * Defines the type of event (KeyboardEventTypes)
  8550. */
  8551. type: number;
  8552. /**
  8553. * Defines the related dom event
  8554. */
  8555. event: KeyboardEvent;
  8556. /**
  8557. * Instantiates a new keyboard info.
  8558. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8559. * @param type Defines the type of event (KeyboardEventTypes)
  8560. * @param event Defines the related dom event
  8561. */
  8562. constructor(
  8563. /**
  8564. * Defines the type of event (KeyboardEventTypes)
  8565. */
  8566. type: number,
  8567. /**
  8568. * Defines the related dom event
  8569. */
  8570. event: KeyboardEvent);
  8571. }
  8572. /**
  8573. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8574. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8575. */
  8576. export class KeyboardInfoPre extends KeyboardInfo {
  8577. /**
  8578. * Defines the type of event (KeyboardEventTypes)
  8579. */
  8580. type: number;
  8581. /**
  8582. * Defines the related dom event
  8583. */
  8584. event: KeyboardEvent;
  8585. /**
  8586. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8587. */
  8588. skipOnPointerObservable: boolean;
  8589. /**
  8590. * Instantiates a new keyboard pre info.
  8591. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8592. * @param type Defines the type of event (KeyboardEventTypes)
  8593. * @param event Defines the related dom event
  8594. */
  8595. constructor(
  8596. /**
  8597. * Defines the type of event (KeyboardEventTypes)
  8598. */
  8599. type: number,
  8600. /**
  8601. * Defines the related dom event
  8602. */
  8603. event: KeyboardEvent);
  8604. }
  8605. }
  8606. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8607. import { Nullable } from "babylonjs/types";
  8608. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8609. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8610. /**
  8611. * Manage the keyboard inputs to control the movement of a free camera.
  8612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8613. */
  8614. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8615. /**
  8616. * Defines the camera the input is attached to.
  8617. */
  8618. camera: FreeCamera;
  8619. /**
  8620. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8621. */
  8622. keysUp: number[];
  8623. /**
  8624. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8625. */
  8626. keysDown: number[];
  8627. /**
  8628. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8629. */
  8630. keysLeft: number[];
  8631. /**
  8632. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8633. */
  8634. keysRight: number[];
  8635. private _keys;
  8636. private _onCanvasBlurObserver;
  8637. private _onKeyboardObserver;
  8638. private _engine;
  8639. private _scene;
  8640. /**
  8641. * Attach the input controls to a specific dom element to get the input from.
  8642. * @param element Defines the element the controls should be listened from
  8643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8644. */
  8645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8646. /**
  8647. * Detach the current controls from the specified dom element.
  8648. * @param element Defines the element to stop listening the inputs from
  8649. */
  8650. detachControl(element: Nullable<HTMLElement>): void;
  8651. /**
  8652. * Update the current camera state depending on the inputs that have been used this frame.
  8653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8654. */
  8655. checkInputs(): void;
  8656. /**
  8657. * Gets the class name of the current intput.
  8658. * @returns the class name
  8659. */
  8660. getClassName(): string;
  8661. /** @hidden */
  8662. _onLostFocus(): void;
  8663. /**
  8664. * Get the friendly name associated with the input class.
  8665. * @returns the input friendly name
  8666. */
  8667. getSimpleName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Lights/shadowLight" {
  8671. import { Camera } from "babylonjs/Cameras/camera";
  8672. import { Scene } from "babylonjs/scene";
  8673. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8675. import { Light } from "babylonjs/Lights/light";
  8676. /**
  8677. * Interface describing all the common properties and methods a shadow light needs to implement.
  8678. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8679. * as well as binding the different shadow properties to the effects.
  8680. */
  8681. export interface IShadowLight extends Light {
  8682. /**
  8683. * The light id in the scene (used in scene.findLighById for instance)
  8684. */
  8685. id: string;
  8686. /**
  8687. * The position the shdow will be casted from.
  8688. */
  8689. position: Vector3;
  8690. /**
  8691. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8692. */
  8693. direction: Vector3;
  8694. /**
  8695. * The transformed position. Position of the light in world space taking parenting in account.
  8696. */
  8697. transformedPosition: Vector3;
  8698. /**
  8699. * The transformed direction. Direction of the light in world space taking parenting in account.
  8700. */
  8701. transformedDirection: Vector3;
  8702. /**
  8703. * The friendly name of the light in the scene.
  8704. */
  8705. name: string;
  8706. /**
  8707. * Defines the shadow projection clipping minimum z value.
  8708. */
  8709. shadowMinZ: number;
  8710. /**
  8711. * Defines the shadow projection clipping maximum z value.
  8712. */
  8713. shadowMaxZ: number;
  8714. /**
  8715. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8716. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8717. */
  8718. computeTransformedInformation(): boolean;
  8719. /**
  8720. * Gets the scene the light belongs to.
  8721. * @returns The scene
  8722. */
  8723. getScene(): Scene;
  8724. /**
  8725. * Callback defining a custom Projection Matrix Builder.
  8726. * This can be used to override the default projection matrix computation.
  8727. */
  8728. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8729. /**
  8730. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8731. * @param matrix The materix to updated with the projection information
  8732. * @param viewMatrix The transform matrix of the light
  8733. * @param renderList The list of mesh to render in the map
  8734. * @returns The current light
  8735. */
  8736. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8737. /**
  8738. * Gets the current depth scale used in ESM.
  8739. * @returns The scale
  8740. */
  8741. getDepthScale(): number;
  8742. /**
  8743. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8744. * @returns true if a cube texture needs to be use
  8745. */
  8746. needCube(): boolean;
  8747. /**
  8748. * Detects if the projection matrix requires to be recomputed this frame.
  8749. * @returns true if it requires to be recomputed otherwise, false.
  8750. */
  8751. needProjectionMatrixCompute(): boolean;
  8752. /**
  8753. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8754. */
  8755. forceProjectionMatrixCompute(): void;
  8756. /**
  8757. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8758. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8759. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8760. */
  8761. getShadowDirection(faceIndex?: number): Vector3;
  8762. /**
  8763. * Gets the minZ used for shadow according to both the scene and the light.
  8764. * @param activeCamera The camera we are returning the min for
  8765. * @returns the depth min z
  8766. */
  8767. getDepthMinZ(activeCamera: Camera): number;
  8768. /**
  8769. * Gets the maxZ used for shadow according to both the scene and the light.
  8770. * @param activeCamera The camera we are returning the max for
  8771. * @returns the depth max z
  8772. */
  8773. getDepthMaxZ(activeCamera: Camera): number;
  8774. }
  8775. /**
  8776. * Base implementation IShadowLight
  8777. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8778. */
  8779. export abstract class ShadowLight extends Light implements IShadowLight {
  8780. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8781. protected _position: Vector3;
  8782. protected _setPosition(value: Vector3): void;
  8783. /**
  8784. * Sets the position the shadow will be casted from. Also use as the light position for both
  8785. * point and spot lights.
  8786. */
  8787. /**
  8788. * Sets the position the shadow will be casted from. Also use as the light position for both
  8789. * point and spot lights.
  8790. */
  8791. position: Vector3;
  8792. protected _direction: Vector3;
  8793. protected _setDirection(value: Vector3): void;
  8794. /**
  8795. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8796. * Also use as the light direction on spot and directional lights.
  8797. */
  8798. /**
  8799. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8800. * Also use as the light direction on spot and directional lights.
  8801. */
  8802. direction: Vector3;
  8803. private _shadowMinZ;
  8804. /**
  8805. * Gets the shadow projection clipping minimum z value.
  8806. */
  8807. /**
  8808. * Sets the shadow projection clipping minimum z value.
  8809. */
  8810. shadowMinZ: number;
  8811. private _shadowMaxZ;
  8812. /**
  8813. * Sets the shadow projection clipping maximum z value.
  8814. */
  8815. /**
  8816. * Gets the shadow projection clipping maximum z value.
  8817. */
  8818. shadowMaxZ: number;
  8819. /**
  8820. * Callback defining a custom Projection Matrix Builder.
  8821. * This can be used to override the default projection matrix computation.
  8822. */
  8823. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8824. /**
  8825. * The transformed position. Position of the light in world space taking parenting in account.
  8826. */
  8827. transformedPosition: Vector3;
  8828. /**
  8829. * The transformed direction. Direction of the light in world space taking parenting in account.
  8830. */
  8831. transformedDirection: Vector3;
  8832. private _needProjectionMatrixCompute;
  8833. /**
  8834. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8835. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8836. */
  8837. computeTransformedInformation(): boolean;
  8838. /**
  8839. * Return the depth scale used for the shadow map.
  8840. * @returns the depth scale.
  8841. */
  8842. getDepthScale(): number;
  8843. /**
  8844. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8845. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8846. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8847. */
  8848. getShadowDirection(faceIndex?: number): Vector3;
  8849. /**
  8850. * Returns the ShadowLight absolute position in the World.
  8851. * @returns the position vector in world space
  8852. */
  8853. getAbsolutePosition(): Vector3;
  8854. /**
  8855. * Sets the ShadowLight direction toward the passed target.
  8856. * @param target The point to target in local space
  8857. * @returns the updated ShadowLight direction
  8858. */
  8859. setDirectionToTarget(target: Vector3): Vector3;
  8860. /**
  8861. * Returns the light rotation in euler definition.
  8862. * @returns the x y z rotation in local space.
  8863. */
  8864. getRotation(): Vector3;
  8865. /**
  8866. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8867. * @returns true if a cube texture needs to be use
  8868. */
  8869. needCube(): boolean;
  8870. /**
  8871. * Detects if the projection matrix requires to be recomputed this frame.
  8872. * @returns true if it requires to be recomputed otherwise, false.
  8873. */
  8874. needProjectionMatrixCompute(): boolean;
  8875. /**
  8876. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8877. */
  8878. forceProjectionMatrixCompute(): void;
  8879. /** @hidden */
  8880. _initCache(): void;
  8881. /** @hidden */
  8882. _isSynchronized(): boolean;
  8883. /**
  8884. * Computes the world matrix of the node
  8885. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8886. * @returns the world matrix
  8887. */
  8888. computeWorldMatrix(force?: boolean): Matrix;
  8889. /**
  8890. * Gets the minZ used for shadow according to both the scene and the light.
  8891. * @param activeCamera The camera we are returning the min for
  8892. * @returns the depth min z
  8893. */
  8894. getDepthMinZ(activeCamera: Camera): number;
  8895. /**
  8896. * Gets the maxZ used for shadow according to both the scene and the light.
  8897. * @param activeCamera The camera we are returning the max for
  8898. * @returns the depth max z
  8899. */
  8900. getDepthMaxZ(activeCamera: Camera): number;
  8901. /**
  8902. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8903. * @param matrix The materix to updated with the projection information
  8904. * @param viewMatrix The transform matrix of the light
  8905. * @param renderList The list of mesh to render in the map
  8906. * @returns The current light
  8907. */
  8908. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8909. }
  8910. }
  8911. declare module "babylonjs/Materials/materialHelper" {
  8912. import { Nullable } from "babylonjs/types";
  8913. import { Scene } from "babylonjs/scene";
  8914. import { Engine } from "babylonjs/Engines/engine";
  8915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8916. import { Light } from "babylonjs/Lights/light";
  8917. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8918. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8920. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8921. /**
  8922. * "Static Class" containing the most commonly used helper while dealing with material for
  8923. * rendering purpose.
  8924. *
  8925. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8926. *
  8927. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8928. */
  8929. export class MaterialHelper {
  8930. /**
  8931. * Bind the current view position to an effect.
  8932. * @param effect The effect to be bound
  8933. * @param scene The scene the eyes position is used from
  8934. */
  8935. static BindEyePosition(effect: Effect, scene: Scene): void;
  8936. /**
  8937. * Helps preparing the defines values about the UVs in used in the effect.
  8938. * UVs are shared as much as we can accross channels in the shaders.
  8939. * @param texture The texture we are preparing the UVs for
  8940. * @param defines The defines to update
  8941. * @param key The channel key "diffuse", "specular"... used in the shader
  8942. */
  8943. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8944. /**
  8945. * Binds a texture matrix value to its corrsponding uniform
  8946. * @param texture The texture to bind the matrix for
  8947. * @param uniformBuffer The uniform buffer receivin the data
  8948. * @param key The channel key "diffuse", "specular"... used in the shader
  8949. */
  8950. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8951. /**
  8952. * Gets the current status of the fog (should it be enabled?)
  8953. * @param mesh defines the mesh to evaluate for fog support
  8954. * @param scene defines the hosting scene
  8955. * @returns true if fog must be enabled
  8956. */
  8957. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8958. /**
  8959. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8960. * @param mesh defines the current mesh
  8961. * @param scene defines the current scene
  8962. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8963. * @param pointsCloud defines if point cloud rendering has to be turned on
  8964. * @param fogEnabled defines if fog has to be turned on
  8965. * @param alphaTest defines if alpha testing has to be turned on
  8966. * @param defines defines the current list of defines
  8967. */
  8968. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8969. /**
  8970. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8971. * @param scene defines the current scene
  8972. * @param engine defines the current engine
  8973. * @param defines specifies the list of active defines
  8974. * @param useInstances defines if instances have to be turned on
  8975. * @param useClipPlane defines if clip plane have to be turned on
  8976. */
  8977. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8978. /**
  8979. * Prepares the defines for bones
  8980. * @param mesh The mesh containing the geometry data we will draw
  8981. * @param defines The defines to update
  8982. */
  8983. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8984. /**
  8985. * Prepares the defines for morph targets
  8986. * @param mesh The mesh containing the geometry data we will draw
  8987. * @param defines The defines to update
  8988. */
  8989. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8990. /**
  8991. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8992. * @param mesh The mesh containing the geometry data we will draw
  8993. * @param defines The defines to update
  8994. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8995. * @param useBones Precise whether bones should be used or not (override mesh info)
  8996. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8997. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8998. * @returns false if defines are considered not dirty and have not been checked
  8999. */
  9000. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9001. /**
  9002. * Prepares the defines related to multiview
  9003. * @param scene The scene we are intending to draw
  9004. * @param defines The defines to update
  9005. */
  9006. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9007. /**
  9008. * Prepares the defines related to the light information passed in parameter
  9009. * @param scene The scene we are intending to draw
  9010. * @param mesh The mesh the effect is compiling for
  9011. * @param light The light the effect is compiling for
  9012. * @param lightIndex The index of the light
  9013. * @param defines The defines to update
  9014. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9015. * @param state Defines the current state regarding what is needed (normals, etc...)
  9016. */
  9017. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9018. needNormals: boolean;
  9019. needRebuild: boolean;
  9020. shadowEnabled: boolean;
  9021. specularEnabled: boolean;
  9022. lightmapMode: boolean;
  9023. }): void;
  9024. /**
  9025. * Prepares the defines related to the light information passed in parameter
  9026. * @param scene The scene we are intending to draw
  9027. * @param mesh The mesh the effect is compiling for
  9028. * @param defines The defines to update
  9029. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9030. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9031. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9032. * @returns true if normals will be required for the rest of the effect
  9033. */
  9034. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9037. * @param lightIndex defines the light index
  9038. * @param uniformsList The uniform list
  9039. * @param samplersList The sampler list
  9040. * @param projectedLightTexture defines if projected texture must be used
  9041. * @param uniformBuffersList defines an optional list of uniform buffers
  9042. */
  9043. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9044. /**
  9045. * Prepares the uniforms and samplers list to be used in the effect
  9046. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9047. * @param samplersList The sampler list
  9048. * @param defines The defines helping in the list generation
  9049. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9050. */
  9051. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9052. /**
  9053. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9054. * @param defines The defines to update while falling back
  9055. * @param fallbacks The authorized effect fallbacks
  9056. * @param maxSimultaneousLights The maximum number of lights allowed
  9057. * @param rank the current rank of the Effect
  9058. * @returns The newly affected rank
  9059. */
  9060. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9061. private static _TmpMorphInfluencers;
  9062. /**
  9063. * Prepares the list of attributes required for morph targets according to the effect defines.
  9064. * @param attribs The current list of supported attribs
  9065. * @param mesh The mesh to prepare the morph targets attributes for
  9066. * @param influencers The number of influencers
  9067. */
  9068. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9069. /**
  9070. * Prepares the list of attributes required for morph targets according to the effect defines.
  9071. * @param attribs The current list of supported attribs
  9072. * @param mesh The mesh to prepare the morph targets attributes for
  9073. * @param defines The current Defines of the effect
  9074. */
  9075. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9076. /**
  9077. * Prepares the list of attributes required for bones according to the effect defines.
  9078. * @param attribs The current list of supported attribs
  9079. * @param mesh The mesh to prepare the bones attributes for
  9080. * @param defines The current Defines of the effect
  9081. * @param fallbacks The current efffect fallback strategy
  9082. */
  9083. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9084. /**
  9085. * Check and prepare the list of attributes required for instances according to the effect defines.
  9086. * @param attribs The current list of supported attribs
  9087. * @param defines The current MaterialDefines of the effect
  9088. */
  9089. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9090. /**
  9091. * Add the list of attributes required for instances to the attribs array.
  9092. * @param attribs The current list of supported attribs
  9093. */
  9094. static PushAttributesForInstances(attribs: string[]): void;
  9095. /**
  9096. * Binds the light shadow information to the effect for the given mesh.
  9097. * @param light The light containing the generator
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param lightIndex The light index in the effect used to render the mesh
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9104. /**
  9105. * Binds the light information to the effect.
  9106. * @param light The light containing the generator
  9107. * @param effect The effect we are binding the data to
  9108. * @param lightIndex The light index in the effect used to render
  9109. */
  9110. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9111. /**
  9112. * Binds the lights information from the scene to the effect for the given mesh.
  9113. * @param light Light to bind
  9114. * @param lightIndex Light index
  9115. * @param scene The scene where the light belongs to
  9116. * @param mesh The mesh we are binding the information to render
  9117. * @param effect The effect we are binding the data to
  9118. * @param useSpecular Defines if specular is supported
  9119. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9120. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9121. */
  9122. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9123. /**
  9124. * Binds the lights information from the scene to the effect for the given mesh.
  9125. * @param scene The scene the lights belongs to
  9126. * @param mesh The mesh we are binding the information to render
  9127. * @param effect The effect we are binding the data to
  9128. * @param defines The generated defines for the effect
  9129. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9130. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9131. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9132. */
  9133. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9134. private static _tempFogColor;
  9135. /**
  9136. * Binds the fog information from the scene to the effect for the given mesh.
  9137. * @param scene The scene the lights belongs to
  9138. * @param mesh The mesh we are binding the information to render
  9139. * @param effect The effect we are binding the data to
  9140. * @param linearSpace Defines if the fog effect is applied in linear space
  9141. */
  9142. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9143. /**
  9144. * Binds the bones information from the mesh to the effect.
  9145. * @param mesh The mesh we are binding the information to render
  9146. * @param effect The effect we are binding the data to
  9147. */
  9148. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9149. /**
  9150. * Binds the morph targets information from the mesh to the effect.
  9151. * @param abstractMesh The mesh we are binding the information to render
  9152. * @param effect The effect we are binding the data to
  9153. */
  9154. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9155. /**
  9156. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9157. * @param defines The generated defines used in the effect
  9158. * @param effect The effect we are binding the data to
  9159. * @param scene The scene we are willing to render with logarithmic scale for
  9160. */
  9161. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Binds the clip plane information from the scene to the effect.
  9164. * @param scene The scene the clip plane information are extracted from
  9165. * @param effect The effect we are binding the data to
  9166. */
  9167. static BindClipPlane(effect: Effect, scene: Scene): void;
  9168. }
  9169. }
  9170. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9171. /** @hidden */
  9172. export var packingFunctions: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9178. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9179. /** @hidden */
  9180. export var shadowMapPixelShader: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9186. /** @hidden */
  9187. export var bonesDeclaration: {
  9188. name: string;
  9189. shader: string;
  9190. };
  9191. }
  9192. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9193. /** @hidden */
  9194. export var morphTargetsVertexGlobalDeclaration: {
  9195. name: string;
  9196. shader: string;
  9197. };
  9198. }
  9199. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9200. /** @hidden */
  9201. export var morphTargetsVertexDeclaration: {
  9202. name: string;
  9203. shader: string;
  9204. };
  9205. }
  9206. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9207. /** @hidden */
  9208. export var instancesDeclaration: {
  9209. name: string;
  9210. shader: string;
  9211. };
  9212. }
  9213. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9214. /** @hidden */
  9215. export var helperFunctions: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9221. /** @hidden */
  9222. export var morphTargetsVertex: {
  9223. name: string;
  9224. shader: string;
  9225. };
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9228. /** @hidden */
  9229. export var instancesVertex: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9235. /** @hidden */
  9236. export var bonesVertex: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9242. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9244. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9245. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9246. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9247. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9248. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9249. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9250. /** @hidden */
  9251. export var shadowMapVertexShader: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9257. /** @hidden */
  9258. export var depthBoxBlurPixelShader: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9264. import { Nullable } from "babylonjs/types";
  9265. import { Scene } from "babylonjs/scene";
  9266. import { Matrix } from "babylonjs/Maths/math.vector";
  9267. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9269. import { Mesh } from "babylonjs/Meshes/mesh";
  9270. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9271. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9272. import { Effect } from "babylonjs/Materials/effect";
  9273. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9274. import "babylonjs/Shaders/shadowMap.fragment";
  9275. import "babylonjs/Shaders/shadowMap.vertex";
  9276. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9277. import { Observable } from "babylonjs/Misc/observable";
  9278. /**
  9279. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9280. */
  9281. export interface ICustomShaderOptions {
  9282. /**
  9283. * Gets or sets the custom shader name to use
  9284. */
  9285. shaderName: string;
  9286. /**
  9287. * The list of attribute names used in the shader
  9288. */
  9289. attributes?: string[];
  9290. /**
  9291. * The list of unifrom names used in the shader
  9292. */
  9293. uniforms?: string[];
  9294. /**
  9295. * The list of sampler names used in the shader
  9296. */
  9297. samplers?: string[];
  9298. /**
  9299. * The list of defines used in the shader
  9300. */
  9301. defines?: string[];
  9302. }
  9303. /**
  9304. * Interface to implement to create a shadow generator compatible with BJS.
  9305. */
  9306. export interface IShadowGenerator {
  9307. /**
  9308. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9309. * @returns The render target texture if present otherwise, null
  9310. */
  9311. getShadowMap(): Nullable<RenderTargetTexture>;
  9312. /**
  9313. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9314. * @returns The render target texture if the shadow map is present otherwise, null
  9315. */
  9316. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9317. /**
  9318. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9319. * @param subMesh The submesh we want to render in the shadow map
  9320. * @param useInstances Defines wether will draw in the map using instances
  9321. * @returns true if ready otherwise, false
  9322. */
  9323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9324. /**
  9325. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9326. * @param defines Defines of the material we want to update
  9327. * @param lightIndex Index of the light in the enabled light list of the material
  9328. */
  9329. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9330. /**
  9331. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9332. * defined in the generator but impacting the effect).
  9333. * It implies the unifroms available on the materials are the standard BJS ones.
  9334. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9335. * @param effect The effect we are binfing the information for
  9336. */
  9337. bindShadowLight(lightIndex: string, effect: Effect): void;
  9338. /**
  9339. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9340. * (eq to shadow prjection matrix * light transform matrix)
  9341. * @returns The transform matrix used to create the shadow map
  9342. */
  9343. getTransformMatrix(): Matrix;
  9344. /**
  9345. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9346. * Cube and 2D textures for instance.
  9347. */
  9348. recreateShadowMap(): void;
  9349. /**
  9350. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9351. * @param onCompiled Callback triggered at the and of the effects compilation
  9352. * @param options Sets of optional options forcing the compilation with different modes
  9353. */
  9354. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9355. useInstances: boolean;
  9356. }>): void;
  9357. /**
  9358. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9359. * @param options Sets of optional options forcing the compilation with different modes
  9360. * @returns A promise that resolves when the compilation completes
  9361. */
  9362. forceCompilationAsync(options?: Partial<{
  9363. useInstances: boolean;
  9364. }>): Promise<void>;
  9365. /**
  9366. * Serializes the shadow generator setup to a json object.
  9367. * @returns The serialized JSON object
  9368. */
  9369. serialize(): any;
  9370. /**
  9371. * Disposes the Shadow map and related Textures and effects.
  9372. */
  9373. dispose(): void;
  9374. }
  9375. /**
  9376. * Default implementation IShadowGenerator.
  9377. * This is the main object responsible of generating shadows in the framework.
  9378. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9379. */
  9380. export class ShadowGenerator implements IShadowGenerator {
  9381. /**
  9382. * Shadow generator mode None: no filtering applied.
  9383. */
  9384. static readonly FILTER_NONE: number;
  9385. /**
  9386. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9387. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9388. */
  9389. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9390. /**
  9391. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9392. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9393. */
  9394. static readonly FILTER_POISSONSAMPLING: number;
  9395. /**
  9396. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9397. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9398. */
  9399. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9400. /**
  9401. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9402. * edge artifacts on steep falloff.
  9403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9404. */
  9405. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9406. /**
  9407. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9408. * edge artifacts on steep falloff.
  9409. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9410. */
  9411. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9412. /**
  9413. * Shadow generator mode PCF: Percentage Closer Filtering
  9414. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9415. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9416. */
  9417. static readonly FILTER_PCF: number;
  9418. /**
  9419. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9420. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9421. * Contact Hardening
  9422. */
  9423. static readonly FILTER_PCSS: number;
  9424. /**
  9425. * Reserved for PCF and PCSS
  9426. * Highest Quality.
  9427. *
  9428. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9429. *
  9430. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9431. */
  9432. static readonly QUALITY_HIGH: number;
  9433. /**
  9434. * Reserved for PCF and PCSS
  9435. * Good tradeoff for quality/perf cross devices
  9436. *
  9437. * Execute PCF on a 3*3 kernel.
  9438. *
  9439. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9440. */
  9441. static readonly QUALITY_MEDIUM: number;
  9442. /**
  9443. * Reserved for PCF and PCSS
  9444. * The lowest quality but the fastest.
  9445. *
  9446. * Execute PCF on a 1*1 kernel.
  9447. *
  9448. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9449. */
  9450. static readonly QUALITY_LOW: number;
  9451. /** Gets or sets the custom shader name to use */
  9452. customShaderOptions: ICustomShaderOptions;
  9453. /**
  9454. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9455. */
  9456. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9457. /**
  9458. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9459. */
  9460. onAfterShadowMapRenderObservable: Observable<Effect>;
  9461. /**
  9462. * Observable triggered before a mesh is rendered in the shadow map.
  9463. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9464. */
  9465. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9466. /**
  9467. * Observable triggered after a mesh is rendered in the shadow map.
  9468. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9469. */
  9470. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9471. private _bias;
  9472. /**
  9473. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9474. */
  9475. /**
  9476. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9477. */
  9478. bias: number;
  9479. private _normalBias;
  9480. /**
  9481. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9482. */
  9483. /**
  9484. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9485. */
  9486. normalBias: number;
  9487. private _blurBoxOffset;
  9488. /**
  9489. * Gets the blur box offset: offset applied during the blur pass.
  9490. * Only useful if useKernelBlur = false
  9491. */
  9492. /**
  9493. * Sets the blur box offset: offset applied during the blur pass.
  9494. * Only useful if useKernelBlur = false
  9495. */
  9496. blurBoxOffset: number;
  9497. private _blurScale;
  9498. /**
  9499. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9500. * 2 means half of the size.
  9501. */
  9502. /**
  9503. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9504. * 2 means half of the size.
  9505. */
  9506. blurScale: number;
  9507. private _blurKernel;
  9508. /**
  9509. * Gets the blur kernel: kernel size of the blur pass.
  9510. * Only useful if useKernelBlur = true
  9511. */
  9512. /**
  9513. * Sets the blur kernel: kernel size of the blur pass.
  9514. * Only useful if useKernelBlur = true
  9515. */
  9516. blurKernel: number;
  9517. private _useKernelBlur;
  9518. /**
  9519. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9520. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9521. */
  9522. /**
  9523. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9524. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9525. */
  9526. useKernelBlur: boolean;
  9527. private _depthScale;
  9528. /**
  9529. * Gets the depth scale used in ESM mode.
  9530. */
  9531. /**
  9532. * Sets the depth scale used in ESM mode.
  9533. * This can override the scale stored on the light.
  9534. */
  9535. depthScale: number;
  9536. private _filter;
  9537. /**
  9538. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9539. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9540. */
  9541. /**
  9542. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9543. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9544. */
  9545. filter: number;
  9546. /**
  9547. * Gets if the current filter is set to Poisson Sampling.
  9548. */
  9549. /**
  9550. * Sets the current filter to Poisson Sampling.
  9551. */
  9552. usePoissonSampling: boolean;
  9553. /**
  9554. * Gets if the current filter is set to ESM.
  9555. */
  9556. /**
  9557. * Sets the current filter is to ESM.
  9558. */
  9559. useExponentialShadowMap: boolean;
  9560. /**
  9561. * Gets if the current filter is set to filtered ESM.
  9562. */
  9563. /**
  9564. * Gets if the current filter is set to filtered ESM.
  9565. */
  9566. useBlurExponentialShadowMap: boolean;
  9567. /**
  9568. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. /**
  9572. * Sets the current filter to "close ESM" (using the inverse of the
  9573. * exponential to prevent steep falloff artifacts).
  9574. */
  9575. useCloseExponentialShadowMap: boolean;
  9576. /**
  9577. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9578. * exponential to prevent steep falloff artifacts).
  9579. */
  9580. /**
  9581. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9582. * exponential to prevent steep falloff artifacts).
  9583. */
  9584. useBlurCloseExponentialShadowMap: boolean;
  9585. /**
  9586. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9587. */
  9588. /**
  9589. * Sets the current filter to "PCF" (percentage closer filtering).
  9590. */
  9591. usePercentageCloserFiltering: boolean;
  9592. private _filteringQuality;
  9593. /**
  9594. * Gets the PCF or PCSS Quality.
  9595. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9596. */
  9597. /**
  9598. * Sets the PCF or PCSS Quality.
  9599. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9600. */
  9601. filteringQuality: number;
  9602. /**
  9603. * Gets if the current filter is set to "PCSS" (contact hardening).
  9604. */
  9605. /**
  9606. * Sets the current filter to "PCSS" (contact hardening).
  9607. */
  9608. useContactHardeningShadow: boolean;
  9609. private _contactHardeningLightSizeUVRatio;
  9610. /**
  9611. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9612. * Using a ratio helps keeping shape stability independently of the map size.
  9613. *
  9614. * It does not account for the light projection as it was having too much
  9615. * instability during the light setup or during light position changes.
  9616. *
  9617. * Only valid if useContactHardeningShadow is true.
  9618. */
  9619. /**
  9620. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9621. * Using a ratio helps keeping shape stability independently of the map size.
  9622. *
  9623. * It does not account for the light projection as it was having too much
  9624. * instability during the light setup or during light position changes.
  9625. *
  9626. * Only valid if useContactHardeningShadow is true.
  9627. */
  9628. contactHardeningLightSizeUVRatio: number;
  9629. private _darkness;
  9630. /** Gets or sets the actual darkness of a shadow */
  9631. darkness: number;
  9632. /**
  9633. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9634. * 0 means strongest and 1 would means no shadow.
  9635. * @returns the darkness.
  9636. */
  9637. getDarkness(): number;
  9638. /**
  9639. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9640. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9641. * @returns the shadow generator allowing fluent coding.
  9642. */
  9643. setDarkness(darkness: number): ShadowGenerator;
  9644. private _transparencyShadow;
  9645. /** Gets or sets the ability to have transparent shadow */
  9646. transparencyShadow: boolean;
  9647. /**
  9648. * Sets the ability to have transparent shadow (boolean).
  9649. * @param transparent True if transparent else False
  9650. * @returns the shadow generator allowing fluent coding
  9651. */
  9652. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9653. private _shadowMap;
  9654. private _shadowMap2;
  9655. /**
  9656. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9657. * @returns The render target texture if present otherwise, null
  9658. */
  9659. getShadowMap(): Nullable<RenderTargetTexture>;
  9660. /**
  9661. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9662. * @returns The render target texture if the shadow map is present otherwise, null
  9663. */
  9664. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9665. /**
  9666. * Gets the class name of that object
  9667. * @returns "ShadowGenerator"
  9668. */
  9669. getClassName(): string;
  9670. /**
  9671. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9672. * @param mesh Mesh to add
  9673. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9674. * @returns the Shadow Generator itself
  9675. */
  9676. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9677. /**
  9678. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9679. * @param mesh Mesh to remove
  9680. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9681. * @returns the Shadow Generator itself
  9682. */
  9683. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9684. /**
  9685. * Controls the extent to which the shadows fade out at the edge of the frustum
  9686. * Used only by directionals and spots
  9687. */
  9688. frustumEdgeFalloff: number;
  9689. private _light;
  9690. /**
  9691. * Returns the associated light object.
  9692. * @returns the light generating the shadow
  9693. */
  9694. getLight(): IShadowLight;
  9695. /**
  9696. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9697. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9698. * It might on the other hand introduce peter panning.
  9699. */
  9700. forceBackFacesOnly: boolean;
  9701. private _scene;
  9702. private _lightDirection;
  9703. private _effect;
  9704. private _viewMatrix;
  9705. private _projectionMatrix;
  9706. private _transformMatrix;
  9707. private _cachedPosition;
  9708. private _cachedDirection;
  9709. private _cachedDefines;
  9710. private _currentRenderID;
  9711. private _boxBlurPostprocess;
  9712. private _kernelBlurXPostprocess;
  9713. private _kernelBlurYPostprocess;
  9714. private _blurPostProcesses;
  9715. private _mapSize;
  9716. private _currentFaceIndex;
  9717. private _currentFaceIndexCache;
  9718. private _textureType;
  9719. private _defaultTextureMatrix;
  9720. /** @hidden */
  9721. static _SceneComponentInitialization: (scene: Scene) => void;
  9722. /**
  9723. * Creates a ShadowGenerator object.
  9724. * A ShadowGenerator is the required tool to use the shadows.
  9725. * Each light casting shadows needs to use its own ShadowGenerator.
  9726. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9727. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9728. * @param light The light object generating the shadows.
  9729. * @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.
  9730. */
  9731. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9732. private _initializeGenerator;
  9733. private _initializeShadowMap;
  9734. private _initializeBlurRTTAndPostProcesses;
  9735. private _renderForShadowMap;
  9736. private _renderSubMeshForShadowMap;
  9737. private _applyFilterValues;
  9738. /**
  9739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9740. * @param onCompiled Callback triggered at the and of the effects compilation
  9741. * @param options Sets of optional options forcing the compilation with different modes
  9742. */
  9743. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9744. useInstances: boolean;
  9745. }>): void;
  9746. /**
  9747. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9748. * @param options Sets of optional options forcing the compilation with different modes
  9749. * @returns A promise that resolves when the compilation completes
  9750. */
  9751. forceCompilationAsync(options?: Partial<{
  9752. useInstances: boolean;
  9753. }>): Promise<void>;
  9754. /**
  9755. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9756. * @param subMesh The submesh we want to render in the shadow map
  9757. * @param useInstances Defines wether will draw in the map using instances
  9758. * @returns true if ready otherwise, false
  9759. */
  9760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9761. /**
  9762. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9763. * @param defines Defines of the material we want to update
  9764. * @param lightIndex Index of the light in the enabled light list of the material
  9765. */
  9766. prepareDefines(defines: any, lightIndex: number): void;
  9767. /**
  9768. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9769. * defined in the generator but impacting the effect).
  9770. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9771. * @param effect The effect we are binfing the information for
  9772. */
  9773. bindShadowLight(lightIndex: string, effect: Effect): void;
  9774. /**
  9775. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9776. * (eq to shadow prjection matrix * light transform matrix)
  9777. * @returns The transform matrix used to create the shadow map
  9778. */
  9779. getTransformMatrix(): Matrix;
  9780. /**
  9781. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9782. * Cube and 2D textures for instance.
  9783. */
  9784. recreateShadowMap(): void;
  9785. private _disposeBlurPostProcesses;
  9786. private _disposeRTTandPostProcesses;
  9787. /**
  9788. * Disposes the ShadowGenerator.
  9789. * Returns nothing.
  9790. */
  9791. dispose(): void;
  9792. /**
  9793. * Serializes the shadow generator setup to a json object.
  9794. * @returns The serialized JSON object
  9795. */
  9796. serialize(): any;
  9797. /**
  9798. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9799. * @param parsedShadowGenerator The JSON object to parse
  9800. * @param scene The scene to create the shadow map for
  9801. * @returns The parsed shadow generator
  9802. */
  9803. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9804. }
  9805. }
  9806. declare module "babylonjs/Lights/light" {
  9807. import { Nullable } from "babylonjs/types";
  9808. import { Scene } from "babylonjs/scene";
  9809. import { Vector3 } from "babylonjs/Maths/math.vector";
  9810. import { Color3 } from "babylonjs/Maths/math.color";
  9811. import { Node } from "babylonjs/node";
  9812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9813. import { Effect } from "babylonjs/Materials/effect";
  9814. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9815. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9816. /**
  9817. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9818. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9819. * 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.
  9820. */
  9821. export abstract class Light extends Node {
  9822. /**
  9823. * Falloff Default: light is falling off following the material specification:
  9824. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9825. */
  9826. static readonly FALLOFF_DEFAULT: number;
  9827. /**
  9828. * Falloff Physical: light is falling off following the inverse squared distance law.
  9829. */
  9830. static readonly FALLOFF_PHYSICAL: number;
  9831. /**
  9832. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9833. * to enhance interoperability with other engines.
  9834. */
  9835. static readonly FALLOFF_GLTF: number;
  9836. /**
  9837. * Falloff Standard: light is falling off like in the standard material
  9838. * to enhance interoperability with other materials.
  9839. */
  9840. static readonly FALLOFF_STANDARD: number;
  9841. /**
  9842. * If every light affecting the material is in this lightmapMode,
  9843. * material.lightmapTexture adds or multiplies
  9844. * (depends on material.useLightmapAsShadowmap)
  9845. * after every other light calculations.
  9846. */
  9847. static readonly LIGHTMAP_DEFAULT: number;
  9848. /**
  9849. * material.lightmapTexture as only diffuse lighting from this light
  9850. * adds only specular lighting from this light
  9851. * adds dynamic shadows
  9852. */
  9853. static readonly LIGHTMAP_SPECULAR: number;
  9854. /**
  9855. * material.lightmapTexture as only lighting
  9856. * no light calculation from this light
  9857. * only adds dynamic shadows from this light
  9858. */
  9859. static readonly LIGHTMAP_SHADOWSONLY: number;
  9860. /**
  9861. * Each light type uses the default quantity according to its type:
  9862. * point/spot lights use luminous intensity
  9863. * directional lights use illuminance
  9864. */
  9865. static readonly INTENSITYMODE_AUTOMATIC: number;
  9866. /**
  9867. * lumen (lm)
  9868. */
  9869. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9870. /**
  9871. * candela (lm/sr)
  9872. */
  9873. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9874. /**
  9875. * lux (lm/m^2)
  9876. */
  9877. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9878. /**
  9879. * nit (cd/m^2)
  9880. */
  9881. static readonly INTENSITYMODE_LUMINANCE: number;
  9882. /**
  9883. * Light type const id of the point light.
  9884. */
  9885. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9886. /**
  9887. * Light type const id of the directional light.
  9888. */
  9889. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9890. /**
  9891. * Light type const id of the spot light.
  9892. */
  9893. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9894. /**
  9895. * Light type const id of the hemispheric light.
  9896. */
  9897. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9898. /**
  9899. * Diffuse gives the basic color to an object.
  9900. */
  9901. diffuse: Color3;
  9902. /**
  9903. * Specular produces a highlight color on an object.
  9904. * Note: This is note affecting PBR materials.
  9905. */
  9906. specular: Color3;
  9907. /**
  9908. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9909. * falling off base on range or angle.
  9910. * This can be set to any values in Light.FALLOFF_x.
  9911. *
  9912. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9913. * other types of materials.
  9914. */
  9915. falloffType: number;
  9916. /**
  9917. * Strength of the light.
  9918. * Note: By default it is define in the framework own unit.
  9919. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9920. */
  9921. intensity: number;
  9922. private _range;
  9923. protected _inverseSquaredRange: number;
  9924. /**
  9925. * Defines how far from the source the light is impacting in scene units.
  9926. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9927. */
  9928. /**
  9929. * Defines how far from the source the light is impacting in scene units.
  9930. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9931. */
  9932. range: number;
  9933. /**
  9934. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9935. * of light.
  9936. */
  9937. private _photometricScale;
  9938. private _intensityMode;
  9939. /**
  9940. * Gets the photometric scale used to interpret the intensity.
  9941. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9942. */
  9943. /**
  9944. * Sets the photometric scale used to interpret the intensity.
  9945. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9946. */
  9947. intensityMode: number;
  9948. private _radius;
  9949. /**
  9950. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9951. */
  9952. /**
  9953. * sets the light radius used by PBR Materials to simulate soft area lights.
  9954. */
  9955. radius: number;
  9956. private _renderPriority;
  9957. /**
  9958. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9959. * exceeding the number allowed of the materials.
  9960. */
  9961. renderPriority: number;
  9962. private _shadowEnabled;
  9963. /**
  9964. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9965. * the current shadow generator.
  9966. */
  9967. /**
  9968. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9969. * the current shadow generator.
  9970. */
  9971. shadowEnabled: boolean;
  9972. private _includedOnlyMeshes;
  9973. /**
  9974. * Gets the only meshes impacted by this light.
  9975. */
  9976. /**
  9977. * Sets the only meshes impacted by this light.
  9978. */
  9979. includedOnlyMeshes: AbstractMesh[];
  9980. private _excludedMeshes;
  9981. /**
  9982. * Gets the meshes not impacted by this light.
  9983. */
  9984. /**
  9985. * Sets the meshes not impacted by this light.
  9986. */
  9987. excludedMeshes: AbstractMesh[];
  9988. private _excludeWithLayerMask;
  9989. /**
  9990. * Gets the layer id use to find what meshes are not impacted by the light.
  9991. * Inactive if 0
  9992. */
  9993. /**
  9994. * Sets the layer id use to find what meshes are not impacted by the light.
  9995. * Inactive if 0
  9996. */
  9997. excludeWithLayerMask: number;
  9998. private _includeOnlyWithLayerMask;
  9999. /**
  10000. * Gets the layer id use to find what meshes are impacted by the light.
  10001. * Inactive if 0
  10002. */
  10003. /**
  10004. * Sets the layer id use to find what meshes are impacted by the light.
  10005. * Inactive if 0
  10006. */
  10007. includeOnlyWithLayerMask: number;
  10008. private _lightmapMode;
  10009. /**
  10010. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10011. */
  10012. /**
  10013. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10014. */
  10015. lightmapMode: number;
  10016. /**
  10017. * Shadow generator associted to the light.
  10018. * @hidden Internal use only.
  10019. */
  10020. _shadowGenerator: Nullable<IShadowGenerator>;
  10021. /**
  10022. * @hidden Internal use only.
  10023. */
  10024. _excludedMeshesIds: string[];
  10025. /**
  10026. * @hidden Internal use only.
  10027. */
  10028. _includedOnlyMeshesIds: string[];
  10029. /**
  10030. * The current light unifom buffer.
  10031. * @hidden Internal use only.
  10032. */
  10033. _uniformBuffer: UniformBuffer;
  10034. /**
  10035. * Creates a Light object in the scene.
  10036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10037. * @param name The firendly name of the light
  10038. * @param scene The scene the light belongs too
  10039. */
  10040. constructor(name: string, scene: Scene);
  10041. protected abstract _buildUniformLayout(): void;
  10042. /**
  10043. * Sets the passed Effect "effect" with the Light information.
  10044. * @param effect The effect to update
  10045. * @param lightIndex The index of the light in the effect to update
  10046. * @returns The light
  10047. */
  10048. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10049. /**
  10050. * Sets the passed Effect "effect" with the Light information.
  10051. * @param effect The effect to update
  10052. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10053. * @returns The light
  10054. */
  10055. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10056. /**
  10057. * Returns the string "Light".
  10058. * @returns the class name
  10059. */
  10060. getClassName(): string;
  10061. /** @hidden */
  10062. readonly _isLight: boolean;
  10063. /**
  10064. * Converts the light information to a readable string for debug purpose.
  10065. * @param fullDetails Supports for multiple levels of logging within scene loading
  10066. * @returns the human readable light info
  10067. */
  10068. toString(fullDetails?: boolean): string;
  10069. /** @hidden */
  10070. protected _syncParentEnabledState(): void;
  10071. /**
  10072. * Set the enabled state of this node.
  10073. * @param value - the new enabled state
  10074. */
  10075. setEnabled(value: boolean): void;
  10076. /**
  10077. * Returns the Light associated shadow generator if any.
  10078. * @return the associated shadow generator.
  10079. */
  10080. getShadowGenerator(): Nullable<IShadowGenerator>;
  10081. /**
  10082. * Returns a Vector3, the absolute light position in the World.
  10083. * @returns the world space position of the light
  10084. */
  10085. getAbsolutePosition(): Vector3;
  10086. /**
  10087. * Specifies if the light will affect the passed mesh.
  10088. * @param mesh The mesh to test against the light
  10089. * @return true the mesh is affected otherwise, false.
  10090. */
  10091. canAffectMesh(mesh: AbstractMesh): boolean;
  10092. /**
  10093. * Sort function to order lights for rendering.
  10094. * @param a First Light object to compare to second.
  10095. * @param b Second Light object to compare first.
  10096. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10097. */
  10098. static CompareLightsPriority(a: Light, b: Light): number;
  10099. /**
  10100. * Releases resources associated with this node.
  10101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10103. */
  10104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10105. /**
  10106. * Returns the light type ID (integer).
  10107. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10108. */
  10109. getTypeID(): number;
  10110. /**
  10111. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10112. * @returns the scaled intensity in intensity mode unit
  10113. */
  10114. getScaledIntensity(): number;
  10115. /**
  10116. * Returns a new Light object, named "name", from the current one.
  10117. * @param name The name of the cloned light
  10118. * @returns the new created light
  10119. */
  10120. clone(name: string): Nullable<Light>;
  10121. /**
  10122. * Serializes the current light into a Serialization object.
  10123. * @returns the serialized object.
  10124. */
  10125. serialize(): any;
  10126. /**
  10127. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10128. * This new light is named "name" and added to the passed scene.
  10129. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10130. * @param name The friendly name of the light
  10131. * @param scene The scene the new light will belong to
  10132. * @returns the constructor function
  10133. */
  10134. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10135. /**
  10136. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10137. * @param parsedLight The JSON representation of the light
  10138. * @param scene The scene to create the parsed light in
  10139. * @returns the created light after parsing
  10140. */
  10141. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10142. private _hookArrayForExcluded;
  10143. private _hookArrayForIncludedOnly;
  10144. private _resyncMeshes;
  10145. /**
  10146. * Forces the meshes to update their light related information in their rendering used effects
  10147. * @hidden Internal Use Only
  10148. */
  10149. _markMeshesAsLightDirty(): void;
  10150. /**
  10151. * Recomputes the cached photometric scale if needed.
  10152. */
  10153. private _computePhotometricScale;
  10154. /**
  10155. * Returns the Photometric Scale according to the light type and intensity mode.
  10156. */
  10157. private _getPhotometricScale;
  10158. /**
  10159. * Reorder the light in the scene according to their defined priority.
  10160. * @hidden Internal Use Only
  10161. */
  10162. _reorderLightsInScene(): void;
  10163. /**
  10164. * Prepares the list of defines specific to the light type.
  10165. * @param defines the list of defines
  10166. * @param lightIndex defines the index of the light for the effect
  10167. */
  10168. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10169. }
  10170. }
  10171. declare module "babylonjs/Actions/action" {
  10172. import { Observable } from "babylonjs/Misc/observable";
  10173. import { Condition } from "babylonjs/Actions/condition";
  10174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10175. import { ActionManager } from "babylonjs/Actions/actionManager";
  10176. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10177. /**
  10178. * Interface used to define Action
  10179. */
  10180. export interface IAction {
  10181. /**
  10182. * Trigger for the action
  10183. */
  10184. trigger: number;
  10185. /** Options of the trigger */
  10186. triggerOptions: any;
  10187. /**
  10188. * Gets the trigger parameters
  10189. * @returns the trigger parameters
  10190. */
  10191. getTriggerParameter(): any;
  10192. /**
  10193. * Internal only - executes current action event
  10194. * @hidden
  10195. */
  10196. _executeCurrent(evt?: ActionEvent): void;
  10197. /**
  10198. * Serialize placeholder for child classes
  10199. * @param parent of child
  10200. * @returns the serialized object
  10201. */
  10202. serialize(parent: any): any;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. _prepare(): void;
  10208. /**
  10209. * Internal only - manager for action
  10210. * @hidden
  10211. */
  10212. _actionManager: AbstractActionManager;
  10213. /**
  10214. * Adds action to chain of actions, may be a DoNothingAction
  10215. * @param action defines the next action to execute
  10216. * @returns The action passed in
  10217. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10218. */
  10219. then(action: IAction): IAction;
  10220. }
  10221. /**
  10222. * The action to be carried out following a trigger
  10223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10224. */
  10225. export class Action implements IAction {
  10226. /** the trigger, with or without parameters, for the action */
  10227. triggerOptions: any;
  10228. /**
  10229. * Trigger for the action
  10230. */
  10231. trigger: number;
  10232. /**
  10233. * Internal only - manager for action
  10234. * @hidden
  10235. */
  10236. _actionManager: ActionManager;
  10237. private _nextActiveAction;
  10238. private _child;
  10239. private _condition?;
  10240. private _triggerParameter;
  10241. /**
  10242. * An event triggered prior to action being executed.
  10243. */
  10244. onBeforeExecuteObservable: Observable<Action>;
  10245. /**
  10246. * Creates a new Action
  10247. * @param triggerOptions the trigger, with or without parameters, for the action
  10248. * @param condition an optional determinant of action
  10249. */
  10250. constructor(
  10251. /** the trigger, with or without parameters, for the action */
  10252. triggerOptions: any, condition?: Condition);
  10253. /**
  10254. * Internal only
  10255. * @hidden
  10256. */
  10257. _prepare(): void;
  10258. /**
  10259. * Gets the trigger parameters
  10260. * @returns the trigger parameters
  10261. */
  10262. getTriggerParameter(): any;
  10263. /**
  10264. * Internal only - executes current action event
  10265. * @hidden
  10266. */
  10267. _executeCurrent(evt?: ActionEvent): void;
  10268. /**
  10269. * Execute placeholder for child classes
  10270. * @param evt optional action event
  10271. */
  10272. execute(evt?: ActionEvent): void;
  10273. /**
  10274. * Skips to next active action
  10275. */
  10276. skipToNextActiveAction(): void;
  10277. /**
  10278. * Adds action to chain of actions, may be a DoNothingAction
  10279. * @param action defines the next action to execute
  10280. * @returns The action passed in
  10281. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10282. */
  10283. then(action: Action): Action;
  10284. /**
  10285. * Internal only
  10286. * @hidden
  10287. */
  10288. _getProperty(propertyPath: string): string;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getEffectiveTarget(target: any, propertyPath: string): any;
  10294. /**
  10295. * Serialize placeholder for child classes
  10296. * @param parent of child
  10297. * @returns the serialized object
  10298. */
  10299. serialize(parent: any): any;
  10300. /**
  10301. * Internal only called by serialize
  10302. * @hidden
  10303. */
  10304. protected _serialize(serializedAction: any, parent?: any): any;
  10305. /**
  10306. * Internal only
  10307. * @hidden
  10308. */
  10309. static _SerializeValueAsString: (value: any) => string;
  10310. /**
  10311. * Internal only
  10312. * @hidden
  10313. */
  10314. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10315. name: string;
  10316. targetType: string;
  10317. value: string;
  10318. };
  10319. }
  10320. }
  10321. declare module "babylonjs/Actions/condition" {
  10322. import { ActionManager } from "babylonjs/Actions/actionManager";
  10323. /**
  10324. * A Condition applied to an Action
  10325. */
  10326. export class Condition {
  10327. /**
  10328. * Internal only - manager for action
  10329. * @hidden
  10330. */
  10331. _actionManager: ActionManager;
  10332. /**
  10333. * Internal only
  10334. * @hidden
  10335. */
  10336. _evaluationId: number;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. _currentResult: boolean;
  10342. /**
  10343. * Creates a new Condition
  10344. * @param actionManager the manager of the action the condition is applied to
  10345. */
  10346. constructor(actionManager: ActionManager);
  10347. /**
  10348. * Check if the current condition is valid
  10349. * @returns a boolean
  10350. */
  10351. isValid(): boolean;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. _getProperty(propertyPath: string): string;
  10357. /**
  10358. * Internal only
  10359. * @hidden
  10360. */
  10361. _getEffectiveTarget(target: any, propertyPath: string): any;
  10362. /**
  10363. * Serialize placeholder for child classes
  10364. * @returns the serialized object
  10365. */
  10366. serialize(): any;
  10367. /**
  10368. * Internal only
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedCondition: any): any;
  10372. }
  10373. /**
  10374. * Defines specific conditional operators as extensions of Condition
  10375. */
  10376. export class ValueCondition extends Condition {
  10377. /** path to specify the property of the target the conditional operator uses */
  10378. propertyPath: string;
  10379. /** the value compared by the conditional operator against the current value of the property */
  10380. value: any;
  10381. /** the conditional operator, default ValueCondition.IsEqual */
  10382. operator: number;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private static _IsEqual;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. private static _IsDifferent;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. private static _IsGreater;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. private static _IsLesser;
  10403. /**
  10404. * returns the number for IsEqual
  10405. */
  10406. static readonly IsEqual: number;
  10407. /**
  10408. * Returns the number for IsDifferent
  10409. */
  10410. static readonly IsDifferent: number;
  10411. /**
  10412. * Returns the number for IsGreater
  10413. */
  10414. static readonly IsGreater: number;
  10415. /**
  10416. * Returns the number for IsLesser
  10417. */
  10418. static readonly IsLesser: number;
  10419. /**
  10420. * Internal only The action manager for the condition
  10421. * @hidden
  10422. */
  10423. _actionManager: ActionManager;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private _target;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private _effectiveTarget;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. private _property;
  10439. /**
  10440. * Creates a new ValueCondition
  10441. * @param actionManager manager for the action the condition applies to
  10442. * @param target for the action
  10443. * @param propertyPath path to specify the property of the target the conditional operator uses
  10444. * @param value the value compared by the conditional operator against the current value of the property
  10445. * @param operator the conditional operator, default ValueCondition.IsEqual
  10446. */
  10447. constructor(actionManager: ActionManager, target: any,
  10448. /** path to specify the property of the target the conditional operator uses */
  10449. propertyPath: string,
  10450. /** the value compared by the conditional operator against the current value of the property */
  10451. value: any,
  10452. /** the conditional operator, default ValueCondition.IsEqual */
  10453. operator?: number);
  10454. /**
  10455. * Compares the given value with the property value for the specified conditional operator
  10456. * @returns the result of the comparison
  10457. */
  10458. isValid(): boolean;
  10459. /**
  10460. * Serialize the ValueCondition into a JSON compatible object
  10461. * @returns serialization object
  10462. */
  10463. serialize(): any;
  10464. /**
  10465. * Gets the name of the conditional operator for the ValueCondition
  10466. * @param operator the conditional operator
  10467. * @returns the name
  10468. */
  10469. static GetOperatorName(operator: number): string;
  10470. }
  10471. /**
  10472. * Defines a predicate condition as an extension of Condition
  10473. */
  10474. export class PredicateCondition extends Condition {
  10475. /** defines the predicate function used to validate the condition */
  10476. predicate: () => boolean;
  10477. /**
  10478. * Internal only - manager for action
  10479. * @hidden
  10480. */
  10481. _actionManager: ActionManager;
  10482. /**
  10483. * Creates a new PredicateCondition
  10484. * @param actionManager manager for the action the condition applies to
  10485. * @param predicate defines the predicate function used to validate the condition
  10486. */
  10487. constructor(actionManager: ActionManager,
  10488. /** defines the predicate function used to validate the condition */
  10489. predicate: () => boolean);
  10490. /**
  10491. * @returns the validity of the predicate condition
  10492. */
  10493. isValid(): boolean;
  10494. }
  10495. /**
  10496. * Defines a state condition as an extension of Condition
  10497. */
  10498. export class StateCondition extends Condition {
  10499. /** Value to compare with target state */
  10500. value: string;
  10501. /**
  10502. * Internal only - manager for action
  10503. * @hidden
  10504. */
  10505. _actionManager: ActionManager;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private _target;
  10511. /**
  10512. * Creates a new StateCondition
  10513. * @param actionManager manager for the action the condition applies to
  10514. * @param target of the condition
  10515. * @param value to compare with target state
  10516. */
  10517. constructor(actionManager: ActionManager, target: any,
  10518. /** Value to compare with target state */
  10519. value: string);
  10520. /**
  10521. * Gets a boolean indicating if the current condition is met
  10522. * @returns the validity of the state
  10523. */
  10524. isValid(): boolean;
  10525. /**
  10526. * Serialize the StateCondition into a JSON compatible object
  10527. * @returns serialization object
  10528. */
  10529. serialize(): any;
  10530. }
  10531. }
  10532. declare module "babylonjs/Actions/directActions" {
  10533. import { Action } from "babylonjs/Actions/action";
  10534. import { Condition } from "babylonjs/Actions/condition";
  10535. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10536. /**
  10537. * This defines an action responsible to toggle a boolean once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class SwitchBooleanAction extends Action {
  10541. /**
  10542. * The path to the boolean property in the target object
  10543. */
  10544. propertyPath: string;
  10545. private _target;
  10546. private _effectiveTarget;
  10547. private _property;
  10548. /**
  10549. * Instantiate the action
  10550. * @param triggerOptions defines the trigger options
  10551. * @param target defines the object containing the boolean
  10552. * @param propertyPath defines the path to the boolean property in the target object
  10553. * @param condition defines the trigger related conditions
  10554. */
  10555. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10556. /** @hidden */
  10557. _prepare(): void;
  10558. /**
  10559. * Execute the action toggle the boolean value.
  10560. */
  10561. execute(): void;
  10562. /**
  10563. * Serializes the actions and its related information.
  10564. * @param parent defines the object to serialize in
  10565. * @returns the serialized object
  10566. */
  10567. serialize(parent: any): any;
  10568. }
  10569. /**
  10570. * This defines an action responsible to set a the state field of the target
  10571. * to a desired value once triggered.
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10573. */
  10574. export class SetStateAction extends Action {
  10575. /**
  10576. * The value to store in the state field.
  10577. */
  10578. value: string;
  10579. private _target;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the state property
  10584. * @param value defines the value to store in the state field
  10585. * @param condition defines the trigger related conditions
  10586. */
  10587. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10588. /**
  10589. * Execute the action and store the value on the target state property.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to set a property of the target
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class SetValueAction extends Action {
  10605. /**
  10606. * The path of the property to set in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value to set in the property
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to set in the target
  10621. * @param value defines the value to set in the property
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and set the targetted property to the desired value.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to increment the target value
  10640. * to a desired value once triggered.
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10642. */
  10643. export class IncrementValueAction extends Action {
  10644. /**
  10645. * The path of the property to increment in the target.
  10646. */
  10647. propertyPath: string;
  10648. /**
  10649. * The value we should increment the property by.
  10650. */
  10651. value: any;
  10652. private _target;
  10653. private _effectiveTarget;
  10654. private _property;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param target defines the object containing the property
  10659. * @param propertyPath defines the path of the property to increment in the target
  10660. * @param value defines the value value we should increment the property by
  10661. * @param condition defines the trigger related conditions
  10662. */
  10663. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10664. /** @hidden */
  10665. _prepare(): void;
  10666. /**
  10667. * Execute the action and increment the target of the value amount.
  10668. */
  10669. execute(): void;
  10670. /**
  10671. * Serializes the actions and its related information.
  10672. * @param parent defines the object to serialize in
  10673. * @returns the serialized object
  10674. */
  10675. serialize(parent: any): any;
  10676. }
  10677. /**
  10678. * This defines an action responsible to start an animation once triggered.
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10680. */
  10681. export class PlayAnimationAction extends Action {
  10682. /**
  10683. * Where the animation should start (animation frame)
  10684. */
  10685. from: number;
  10686. /**
  10687. * Where the animation should stop (animation frame)
  10688. */
  10689. to: number;
  10690. /**
  10691. * Define if the animation should loop or stop after the first play.
  10692. */
  10693. loop?: boolean;
  10694. private _target;
  10695. /**
  10696. * Instantiate the action
  10697. * @param triggerOptions defines the trigger options
  10698. * @param target defines the target animation or animation name
  10699. * @param from defines from where the animation should start (animation frame)
  10700. * @param end defines where the animation should stop (animation frame)
  10701. * @param loop defines if the animation should loop or stop after the first play
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action and play the animation.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to stop an animation once triggered.
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10721. */
  10722. export class StopAnimationAction extends Action {
  10723. private _target;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the target animation or animation name
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and stop the animation.
  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 that does nothing once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class DoNothingAction extends Action {
  10749. /**
  10750. * Instantiate the action
  10751. * @param triggerOptions defines the trigger options
  10752. * @param condition defines the trigger related conditions
  10753. */
  10754. constructor(triggerOptions?: any, condition?: Condition);
  10755. /**
  10756. * Execute the action and do nothing.
  10757. */
  10758. execute(): void;
  10759. /**
  10760. * Serializes the actions and its related information.
  10761. * @param parent defines the object to serialize in
  10762. * @returns the serialized object
  10763. */
  10764. serialize(parent: any): any;
  10765. }
  10766. /**
  10767. * This defines an action responsible to trigger several actions once triggered.
  10768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10769. */
  10770. export class CombineAction extends Action {
  10771. /**
  10772. * The list of aggregated animations to run.
  10773. */
  10774. children: Action[];
  10775. /**
  10776. * Instantiate the action
  10777. * @param triggerOptions defines the trigger options
  10778. * @param children defines the list of aggregated animations to run
  10779. * @param condition defines the trigger related conditions
  10780. */
  10781. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10782. /** @hidden */
  10783. _prepare(): void;
  10784. /**
  10785. * Execute the action and executes all the aggregated actions.
  10786. */
  10787. execute(evt: ActionEvent): void;
  10788. /**
  10789. * Serializes the actions and its related information.
  10790. * @param parent defines the object to serialize in
  10791. * @returns the serialized object
  10792. */
  10793. serialize(parent: any): any;
  10794. }
  10795. /**
  10796. * This defines an action responsible to run code (external event) once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class ExecuteCodeAction extends Action {
  10800. /**
  10801. * The callback function to run.
  10802. */
  10803. func: (evt: ActionEvent) => void;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param func defines the callback function to run
  10808. * @param condition defines the trigger related conditions
  10809. */
  10810. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10811. /**
  10812. * Execute the action and run the attached code.
  10813. */
  10814. execute(evt: ActionEvent): void;
  10815. }
  10816. /**
  10817. * This defines an action responsible to set the parent property of the target once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class SetParentAction extends Action {
  10821. private _parent;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the target containing the parent property
  10827. * @param parent defines from where the animation should start (animation frame)
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and set the parent property.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. }
  10845. declare module "babylonjs/Actions/actionManager" {
  10846. import { Nullable } from "babylonjs/types";
  10847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10848. import { Scene } from "babylonjs/scene";
  10849. import { IAction } from "babylonjs/Actions/action";
  10850. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10852. /**
  10853. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10854. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10856. */
  10857. export class ActionManager extends AbstractActionManager {
  10858. /**
  10859. * Nothing
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly NothingTrigger: number;
  10863. /**
  10864. * On pick
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPickTrigger: number;
  10868. /**
  10869. * On left pick
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnLeftPickTrigger: number;
  10873. /**
  10874. * On right pick
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnRightPickTrigger: number;
  10878. /**
  10879. * On center pick
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnCenterPickTrigger: number;
  10883. /**
  10884. * On pick down
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnPickDownTrigger: number;
  10888. /**
  10889. * On double pick
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnDoublePickTrigger: number;
  10893. /**
  10894. * On pick up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnPickUpTrigger: number;
  10898. /**
  10899. * On pick out.
  10900. * This trigger will only be raised if you also declared a OnPickDown
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10902. */
  10903. static readonly OnPickOutTrigger: number;
  10904. /**
  10905. * On long press
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly OnLongPressTrigger: number;
  10909. /**
  10910. * On pointer over
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnPointerOverTrigger: number;
  10914. /**
  10915. * On pointer out
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnPointerOutTrigger: number;
  10919. /**
  10920. * On every frame
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnEveryFrameTrigger: number;
  10924. /**
  10925. * On intersection enter
  10926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10927. */
  10928. static readonly OnIntersectionEnterTrigger: number;
  10929. /**
  10930. * On intersection exit
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10932. */
  10933. static readonly OnIntersectionExitTrigger: number;
  10934. /**
  10935. * On key down
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10937. */
  10938. static readonly OnKeyDownTrigger: number;
  10939. /**
  10940. * On key up
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10942. */
  10943. static readonly OnKeyUpTrigger: number;
  10944. private _scene;
  10945. /**
  10946. * Creates a new action manager
  10947. * @param scene defines the hosting scene
  10948. */
  10949. constructor(scene: Scene);
  10950. /**
  10951. * Releases all associated resources
  10952. */
  10953. dispose(): void;
  10954. /**
  10955. * Gets hosting scene
  10956. * @returns the hosting scene
  10957. */
  10958. getScene(): Scene;
  10959. /**
  10960. * Does this action manager handles actions of any of the given triggers
  10961. * @param triggers defines the triggers to be tested
  10962. * @return a boolean indicating whether one (or more) of the triggers is handled
  10963. */
  10964. hasSpecificTriggers(triggers: number[]): boolean;
  10965. /**
  10966. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10967. * speed.
  10968. * @param triggerA defines the trigger to be tested
  10969. * @param triggerB defines the trigger to be tested
  10970. * @return a boolean indicating whether one (or more) of the triggers is handled
  10971. */
  10972. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10973. /**
  10974. * Does this action manager handles actions of a given trigger
  10975. * @param trigger defines the trigger to be tested
  10976. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10977. * @return whether the trigger is handled
  10978. */
  10979. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10980. /**
  10981. * Does this action manager has pointer triggers
  10982. */
  10983. readonly hasPointerTriggers: boolean;
  10984. /**
  10985. * Does this action manager has pick triggers
  10986. */
  10987. readonly hasPickTriggers: boolean;
  10988. /**
  10989. * Registers an action to this action manager
  10990. * @param action defines the action to be registered
  10991. * @return the action amended (prepared) after registration
  10992. */
  10993. registerAction(action: IAction): Nullable<IAction>;
  10994. /**
  10995. * Unregisters an action to this action manager
  10996. * @param action defines the action to be unregistered
  10997. * @return a boolean indicating whether the action has been unregistered
  10998. */
  10999. unregisterAction(action: IAction): Boolean;
  11000. /**
  11001. * Process a specific trigger
  11002. * @param trigger defines the trigger to process
  11003. * @param evt defines the event details to be processed
  11004. */
  11005. processTrigger(trigger: number, evt?: IActionEvent): void;
  11006. /** @hidden */
  11007. _getEffectiveTarget(target: any, propertyPath: string): any;
  11008. /** @hidden */
  11009. _getProperty(propertyPath: string): string;
  11010. /**
  11011. * Serialize this manager to a JSON object
  11012. * @param name defines the property name to store this manager
  11013. * @returns a JSON representation of this manager
  11014. */
  11015. serialize(name: string): any;
  11016. /**
  11017. * Creates a new ActionManager from a JSON data
  11018. * @param parsedActions defines the JSON data to read from
  11019. * @param object defines the hosting mesh
  11020. * @param scene defines the hosting scene
  11021. */
  11022. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11023. /**
  11024. * Get a trigger name by index
  11025. * @param trigger defines the trigger index
  11026. * @returns a trigger name
  11027. */
  11028. static GetTriggerName(trigger: number): string;
  11029. }
  11030. }
  11031. declare module "babylonjs/Culling/ray" {
  11032. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11033. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11035. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11036. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11037. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11038. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11039. import { Plane } from "babylonjs/Maths/math.plane";
  11040. /**
  11041. * Class representing a ray with position and direction
  11042. */
  11043. export class Ray {
  11044. /** origin point */
  11045. origin: Vector3;
  11046. /** direction */
  11047. direction: Vector3;
  11048. /** length of the ray */
  11049. length: number;
  11050. private static readonly TmpVector3;
  11051. private _tmpRay;
  11052. /**
  11053. * Creates a new ray
  11054. * @param origin origin point
  11055. * @param direction direction
  11056. * @param length length of the ray
  11057. */
  11058. constructor(
  11059. /** origin point */
  11060. origin: Vector3,
  11061. /** direction */
  11062. direction: Vector3,
  11063. /** length of the ray */
  11064. length?: number);
  11065. /**
  11066. * Checks if the ray intersects a box
  11067. * @param minimum bound of the box
  11068. * @param maximum bound of the box
  11069. * @param intersectionTreshold extra extend to be added to the box in all direction
  11070. * @returns if the box was hit
  11071. */
  11072. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11073. /**
  11074. * Checks if the ray intersects a box
  11075. * @param box the bounding box to check
  11076. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11077. * @returns if the box was hit
  11078. */
  11079. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11080. /**
  11081. * If the ray hits a sphere
  11082. * @param sphere the bounding sphere to check
  11083. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11084. * @returns true if it hits the sphere
  11085. */
  11086. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11087. /**
  11088. * If the ray hits a triange
  11089. * @param vertex0 triangle vertex
  11090. * @param vertex1 triangle vertex
  11091. * @param vertex2 triangle vertex
  11092. * @returns intersection information if hit
  11093. */
  11094. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11095. /**
  11096. * Checks if ray intersects a plane
  11097. * @param plane the plane to check
  11098. * @returns the distance away it was hit
  11099. */
  11100. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11101. /**
  11102. * Calculate the intercept of a ray on a given axis
  11103. * @param axis to check 'x' | 'y' | 'z'
  11104. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11105. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11106. */
  11107. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11108. /**
  11109. * Checks if ray intersects a mesh
  11110. * @param mesh the mesh to check
  11111. * @param fastCheck if only the bounding box should checked
  11112. * @returns picking info of the intersecton
  11113. */
  11114. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11115. /**
  11116. * Checks if ray intersects a mesh
  11117. * @param meshes the meshes to check
  11118. * @param fastCheck if only the bounding box should checked
  11119. * @param results array to store result in
  11120. * @returns Array of picking infos
  11121. */
  11122. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11123. private _comparePickingInfo;
  11124. private static smallnum;
  11125. private static rayl;
  11126. /**
  11127. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11128. * @param sega the first point of the segment to test the intersection against
  11129. * @param segb the second point of the segment to test the intersection against
  11130. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11131. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11132. */
  11133. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11134. /**
  11135. * Update the ray from viewport position
  11136. * @param x position
  11137. * @param y y position
  11138. * @param viewportWidth viewport width
  11139. * @param viewportHeight viewport height
  11140. * @param world world matrix
  11141. * @param view view matrix
  11142. * @param projection projection matrix
  11143. * @returns this ray updated
  11144. */
  11145. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11146. /**
  11147. * Creates a ray with origin and direction of 0,0,0
  11148. * @returns the new ray
  11149. */
  11150. static Zero(): Ray;
  11151. /**
  11152. * Creates a new ray from screen space and viewport
  11153. * @param x position
  11154. * @param y y position
  11155. * @param viewportWidth viewport width
  11156. * @param viewportHeight viewport height
  11157. * @param world world matrix
  11158. * @param view view matrix
  11159. * @param projection projection matrix
  11160. * @returns new ray
  11161. */
  11162. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11163. /**
  11164. * 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
  11165. * transformed to the given world matrix.
  11166. * @param origin The origin point
  11167. * @param end The end point
  11168. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11169. * @returns the new ray
  11170. */
  11171. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11172. /**
  11173. * Transforms a ray by a matrix
  11174. * @param ray ray to transform
  11175. * @param matrix matrix to apply
  11176. * @returns the resulting new ray
  11177. */
  11178. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11179. /**
  11180. * Transforms a ray by a matrix
  11181. * @param ray ray to transform
  11182. * @param matrix matrix to apply
  11183. * @param result ray to store result in
  11184. */
  11185. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11186. /**
  11187. * Unproject a ray from screen space to object space
  11188. * @param sourceX defines the screen space x coordinate to use
  11189. * @param sourceY defines the screen space y coordinate to use
  11190. * @param viewportWidth defines the current width of the viewport
  11191. * @param viewportHeight defines the current height of the viewport
  11192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11193. * @param view defines the view matrix to use
  11194. * @param projection defines the projection matrix to use
  11195. */
  11196. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11197. }
  11198. /**
  11199. * Type used to define predicate used to select faces when a mesh intersection is detected
  11200. */
  11201. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11202. module "babylonjs/scene" {
  11203. interface Scene {
  11204. /** @hidden */
  11205. _tempPickingRay: Nullable<Ray>;
  11206. /** @hidden */
  11207. _cachedRayForTransform: Ray;
  11208. /** @hidden */
  11209. _pickWithRayInverseMatrix: Matrix;
  11210. /** @hidden */
  11211. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11212. /** @hidden */
  11213. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11214. }
  11215. }
  11216. }
  11217. declare module "babylonjs/sceneComponent" {
  11218. import { Scene } from "babylonjs/scene";
  11219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11221. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11222. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11223. import { Nullable } from "babylonjs/types";
  11224. import { Camera } from "babylonjs/Cameras/camera";
  11225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11226. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11227. import { AbstractScene } from "babylonjs/abstractScene";
  11228. /**
  11229. * Groups all the scene component constants in one place to ease maintenance.
  11230. * @hidden
  11231. */
  11232. export class SceneComponentConstants {
  11233. static readonly NAME_EFFECTLAYER: string;
  11234. static readonly NAME_LAYER: string;
  11235. static readonly NAME_LENSFLARESYSTEM: string;
  11236. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11237. static readonly NAME_PARTICLESYSTEM: string;
  11238. static readonly NAME_GAMEPAD: string;
  11239. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11240. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11241. static readonly NAME_DEPTHRENDERER: string;
  11242. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11243. static readonly NAME_SPRITE: string;
  11244. static readonly NAME_OUTLINERENDERER: string;
  11245. static readonly NAME_PROCEDURALTEXTURE: string;
  11246. static readonly NAME_SHADOWGENERATOR: string;
  11247. static readonly NAME_OCTREE: string;
  11248. static readonly NAME_PHYSICSENGINE: string;
  11249. static readonly NAME_AUDIO: string;
  11250. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11251. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11252. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11253. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11255. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11256. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11257. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11259. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11260. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11262. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11263. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11264. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11265. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11266. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11267. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11269. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11270. static readonly STEP_AFTERRENDER_AUDIO: number;
  11271. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11272. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11273. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11274. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11275. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11276. static readonly STEP_POINTERMOVE_SPRITE: number;
  11277. static readonly STEP_POINTERDOWN_SPRITE: number;
  11278. static readonly STEP_POINTERUP_SPRITE: number;
  11279. }
  11280. /**
  11281. * This represents a scene component.
  11282. *
  11283. * This is used to decouple the dependency the scene is having on the different workloads like
  11284. * layers, post processes...
  11285. */
  11286. export interface ISceneComponent {
  11287. /**
  11288. * The name of the component. Each component must have a unique name.
  11289. */
  11290. name: string;
  11291. /**
  11292. * The scene the component belongs to.
  11293. */
  11294. scene: Scene;
  11295. /**
  11296. * Register the component to one instance of a scene.
  11297. */
  11298. register(): void;
  11299. /**
  11300. * Rebuilds the elements related to this component in case of
  11301. * context lost for instance.
  11302. */
  11303. rebuild(): void;
  11304. /**
  11305. * Disposes the component and the associated ressources.
  11306. */
  11307. dispose(): void;
  11308. }
  11309. /**
  11310. * This represents a SERIALIZABLE scene component.
  11311. *
  11312. * This extends Scene Component to add Serialization methods on top.
  11313. */
  11314. export interface ISceneSerializableComponent extends ISceneComponent {
  11315. /**
  11316. * Adds all the elements from the container to the scene
  11317. * @param container the container holding the elements
  11318. */
  11319. addFromContainer(container: AbstractScene): void;
  11320. /**
  11321. * Removes all the elements in the container from the scene
  11322. * @param container contains the elements to remove
  11323. * @param dispose if the removed element should be disposed (default: false)
  11324. */
  11325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11326. /**
  11327. * Serializes the component data to the specified json object
  11328. * @param serializationObject The object to serialize to
  11329. */
  11330. serialize(serializationObject: any): void;
  11331. }
  11332. /**
  11333. * Strong typing of a Mesh related stage step action
  11334. */
  11335. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11336. /**
  11337. * Strong typing of a Evaluate Sub Mesh related stage step action
  11338. */
  11339. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11340. /**
  11341. * Strong typing of a Active Mesh related stage step action
  11342. */
  11343. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11344. /**
  11345. * Strong typing of a Camera related stage step action
  11346. */
  11347. export type CameraStageAction = (camera: Camera) => void;
  11348. /**
  11349. * Strong typing of a Camera Frame buffer related stage step action
  11350. */
  11351. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11352. /**
  11353. * Strong typing of a Render Target related stage step action
  11354. */
  11355. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11356. /**
  11357. * Strong typing of a RenderingGroup related stage step action
  11358. */
  11359. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11360. /**
  11361. * Strong typing of a Mesh Render related stage step action
  11362. */
  11363. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11364. /**
  11365. * Strong typing of a simple stage step action
  11366. */
  11367. export type SimpleStageAction = () => void;
  11368. /**
  11369. * Strong typing of a render target action.
  11370. */
  11371. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11372. /**
  11373. * Strong typing of a pointer move action.
  11374. */
  11375. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11376. /**
  11377. * Strong typing of a pointer up/down action.
  11378. */
  11379. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11380. /**
  11381. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11382. * @hidden
  11383. */
  11384. export class Stage<T extends Function> extends Array<{
  11385. index: number;
  11386. component: ISceneComponent;
  11387. action: T;
  11388. }> {
  11389. /**
  11390. * Hide ctor from the rest of the world.
  11391. * @param items The items to add.
  11392. */
  11393. private constructor();
  11394. /**
  11395. * Creates a new Stage.
  11396. * @returns A new instance of a Stage
  11397. */
  11398. static Create<T extends Function>(): Stage<T>;
  11399. /**
  11400. * Registers a step in an ordered way in the targeted stage.
  11401. * @param index Defines the position to register the step in
  11402. * @param component Defines the component attached to the step
  11403. * @param action Defines the action to launch during the step
  11404. */
  11405. registerStep(index: number, component: ISceneComponent, action: T): void;
  11406. /**
  11407. * Clears all the steps from the stage.
  11408. */
  11409. clear(): void;
  11410. }
  11411. }
  11412. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11413. import { Nullable } from "babylonjs/types";
  11414. import { Observable } from "babylonjs/Misc/observable";
  11415. import { Scene } from "babylonjs/scene";
  11416. import { Sprite } from "babylonjs/Sprites/sprite";
  11417. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11418. import { Ray } from "babylonjs/Culling/ray";
  11419. import { Camera } from "babylonjs/Cameras/camera";
  11420. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11421. import { ISceneComponent } from "babylonjs/sceneComponent";
  11422. module "babylonjs/scene" {
  11423. interface Scene {
  11424. /** @hidden */
  11425. _pointerOverSprite: Nullable<Sprite>;
  11426. /** @hidden */
  11427. _pickedDownSprite: Nullable<Sprite>;
  11428. /** @hidden */
  11429. _tempSpritePickingRay: Nullable<Ray>;
  11430. /**
  11431. * All of the sprite managers added to this scene
  11432. * @see http://doc.babylonjs.com/babylon101/sprites
  11433. */
  11434. spriteManagers: Array<ISpriteManager>;
  11435. /**
  11436. * An event triggered when sprites rendering is about to start
  11437. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11438. */
  11439. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11440. /**
  11441. * An event triggered when sprites rendering is done
  11442. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11443. */
  11444. onAfterSpritesRenderingObservable: Observable<Scene>;
  11445. /** @hidden */
  11446. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11447. /** Launch a ray to try to pick a sprite in the scene
  11448. * @param x position on screen
  11449. * @param y position on screen
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** Use the given ray to pick a sprite in the scene
  11457. * @param ray The ray (in world space) to use to pick meshes
  11458. * @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
  11459. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11460. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11461. * @returns a PickingInfo
  11462. */
  11463. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11464. /** @hidden */
  11465. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Launch a ray to try to pick sprites in the scene
  11467. * @param x position on screen
  11468. * @param y position on screen
  11469. * @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
  11470. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11471. * @returns a PickingInfo array
  11472. */
  11473. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11474. /** Use the given ray to pick sprites in the scene
  11475. * @param ray The ray (in world space) to use to pick meshes
  11476. * @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
  11477. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11478. * @returns a PickingInfo array
  11479. */
  11480. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11481. /**
  11482. * Force the sprite under the pointer
  11483. * @param sprite defines the sprite to use
  11484. */
  11485. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11486. /**
  11487. * Gets the sprite under the pointer
  11488. * @returns a Sprite or null if no sprite is under the pointer
  11489. */
  11490. getPointerOverSprite(): Nullable<Sprite>;
  11491. }
  11492. }
  11493. /**
  11494. * Defines the sprite scene component responsible to manage sprites
  11495. * in a given scene.
  11496. */
  11497. export class SpriteSceneComponent implements ISceneComponent {
  11498. /**
  11499. * The component name helpfull to identify the component in the list of scene components.
  11500. */
  11501. readonly name: string;
  11502. /**
  11503. * The scene the component belongs to.
  11504. */
  11505. scene: Scene;
  11506. /** @hidden */
  11507. private _spritePredicate;
  11508. /**
  11509. * Creates a new instance of the component for the given scene
  11510. * @param scene Defines the scene to register the component in
  11511. */
  11512. constructor(scene: Scene);
  11513. /**
  11514. * Registers the component in a given scene
  11515. */
  11516. register(): void;
  11517. /**
  11518. * Rebuilds the elements related to this component in case of
  11519. * context lost for instance.
  11520. */
  11521. rebuild(): void;
  11522. /**
  11523. * Disposes the component and the associated ressources.
  11524. */
  11525. dispose(): void;
  11526. private _pickSpriteButKeepRay;
  11527. private _pointerMove;
  11528. private _pointerDown;
  11529. private _pointerUp;
  11530. }
  11531. }
  11532. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11533. /** @hidden */
  11534. export var fogFragmentDeclaration: {
  11535. name: string;
  11536. shader: string;
  11537. };
  11538. }
  11539. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11540. /** @hidden */
  11541. export var fogFragment: {
  11542. name: string;
  11543. shader: string;
  11544. };
  11545. }
  11546. declare module "babylonjs/Shaders/sprites.fragment" {
  11547. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11548. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11549. /** @hidden */
  11550. export var spritesPixelShader: {
  11551. name: string;
  11552. shader: string;
  11553. };
  11554. }
  11555. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11556. /** @hidden */
  11557. export var fogVertexDeclaration: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Shaders/sprites.vertex" {
  11563. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11564. /** @hidden */
  11565. export var spritesVertexShader: {
  11566. name: string;
  11567. shader: string;
  11568. };
  11569. }
  11570. declare module "babylonjs/Sprites/spriteManager" {
  11571. import { IDisposable, Scene } from "babylonjs/scene";
  11572. import { Nullable } from "babylonjs/types";
  11573. import { Observable } from "babylonjs/Misc/observable";
  11574. import { Sprite } from "babylonjs/Sprites/sprite";
  11575. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { Texture } from "babylonjs/Materials/Textures/texture";
  11578. import "babylonjs/Shaders/sprites.fragment";
  11579. import "babylonjs/Shaders/sprites.vertex";
  11580. import { Ray } from "babylonjs/Culling/ray";
  11581. /**
  11582. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11583. */
  11584. export interface ISpriteManager extends IDisposable {
  11585. /**
  11586. * Restricts the camera to viewing objects with the same layerMask.
  11587. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11588. */
  11589. layerMask: number;
  11590. /**
  11591. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11592. */
  11593. isPickable: boolean;
  11594. /**
  11595. * Specifies the rendering group id for this mesh (0 by default)
  11596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11597. */
  11598. renderingGroupId: number;
  11599. /**
  11600. * Defines the list of sprites managed by the manager.
  11601. */
  11602. sprites: Array<Sprite>;
  11603. /**
  11604. * Tests the intersection of a sprite with a specific ray.
  11605. * @param ray The ray we are sending to test the collision
  11606. * @param camera The camera space we are sending rays in
  11607. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11608. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11609. * @returns picking info or null.
  11610. */
  11611. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11612. /**
  11613. * Intersects the sprites with a ray
  11614. * @param ray defines the ray to intersect with
  11615. * @param camera defines the current active camera
  11616. * @param predicate defines a predicate used to select candidate sprites
  11617. * @returns null if no hit or a PickingInfo array
  11618. */
  11619. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11620. /**
  11621. * Renders the list of sprites on screen.
  11622. */
  11623. render(): void;
  11624. }
  11625. /**
  11626. * Class used to manage multiple sprites on the same spritesheet
  11627. * @see http://doc.babylonjs.com/babylon101/sprites
  11628. */
  11629. export class SpriteManager implements ISpriteManager {
  11630. /** defines the manager's name */
  11631. name: string;
  11632. /** Gets the list of sprites */
  11633. sprites: Sprite[];
  11634. /** Gets or sets the rendering group id (0 by default) */
  11635. renderingGroupId: number;
  11636. /** Gets or sets camera layer mask */
  11637. layerMask: number;
  11638. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11639. fogEnabled: boolean;
  11640. /** Gets or sets a boolean indicating if the sprites are pickable */
  11641. isPickable: boolean;
  11642. /** Defines the default width of a cell in the spritesheet */
  11643. cellWidth: number;
  11644. /** Defines the default height of a cell in the spritesheet */
  11645. cellHeight: number;
  11646. /** Associative array from JSON sprite data file */
  11647. private _cellData;
  11648. /** Array of sprite names from JSON sprite data file */
  11649. private _spriteMap;
  11650. /** True when packed cell data from JSON file is ready*/
  11651. private _packedAndReady;
  11652. /**
  11653. * An event triggered when the manager is disposed.
  11654. */
  11655. onDisposeObservable: Observable<SpriteManager>;
  11656. private _onDisposeObserver;
  11657. /**
  11658. * Callback called when the manager is disposed
  11659. */
  11660. onDispose: () => void;
  11661. private _capacity;
  11662. private _fromPacked;
  11663. private _spriteTexture;
  11664. private _epsilon;
  11665. private _scene;
  11666. private _vertexData;
  11667. private _buffer;
  11668. private _vertexBuffers;
  11669. private _indexBuffer;
  11670. private _effectBase;
  11671. private _effectFog;
  11672. /**
  11673. * Gets or sets the spritesheet texture
  11674. */
  11675. texture: Texture;
  11676. /**
  11677. * Creates a new sprite manager
  11678. * @param name defines the manager's name
  11679. * @param imgUrl defines the sprite sheet url
  11680. * @param capacity defines the maximum allowed number of sprites
  11681. * @param cellSize defines the size of a sprite cell
  11682. * @param scene defines the hosting scene
  11683. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11684. * @param samplingMode defines the smapling mode to use with spritesheet
  11685. * @param fromPacked set to false; do not alter
  11686. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11687. */
  11688. constructor(
  11689. /** defines the manager's name */
  11690. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11691. private _makePacked;
  11692. private _appendSpriteVertex;
  11693. /**
  11694. * Intersects the sprites with a ray
  11695. * @param ray defines the ray to intersect with
  11696. * @param camera defines the current active camera
  11697. * @param predicate defines a predicate used to select candidate sprites
  11698. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11699. * @returns null if no hit or a PickingInfo
  11700. */
  11701. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11702. /**
  11703. * Intersects the sprites with a ray
  11704. * @param ray defines the ray to intersect with
  11705. * @param camera defines the current active camera
  11706. * @param predicate defines a predicate used to select candidate sprites
  11707. * @returns null if no hit or a PickingInfo array
  11708. */
  11709. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11710. /**
  11711. * Render all child sprites
  11712. */
  11713. render(): void;
  11714. /**
  11715. * Release associated resources
  11716. */
  11717. dispose(): void;
  11718. }
  11719. }
  11720. declare module "babylonjs/Sprites/sprite" {
  11721. import { Vector3 } from "babylonjs/Maths/math.vector";
  11722. import { Nullable } from "babylonjs/types";
  11723. import { ActionManager } from "babylonjs/Actions/actionManager";
  11724. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11725. import { Color4 } from "babylonjs/Maths/math.color";
  11726. /**
  11727. * Class used to represent a sprite
  11728. * @see http://doc.babylonjs.com/babylon101/sprites
  11729. */
  11730. export class Sprite {
  11731. /** defines the name */
  11732. name: string;
  11733. /** Gets or sets the current world position */
  11734. position: Vector3;
  11735. /** Gets or sets the main color */
  11736. color: Color4;
  11737. /** Gets or sets the width */
  11738. width: number;
  11739. /** Gets or sets the height */
  11740. height: number;
  11741. /** Gets or sets rotation angle */
  11742. angle: number;
  11743. /** Gets or sets the cell index in the sprite sheet */
  11744. cellIndex: number;
  11745. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11746. cellRef: string;
  11747. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11748. invertU: number;
  11749. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11750. invertV: number;
  11751. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11752. disposeWhenFinishedAnimating: boolean;
  11753. /** Gets the list of attached animations */
  11754. animations: Animation[];
  11755. /** Gets or sets a boolean indicating if the sprite can be picked */
  11756. isPickable: boolean;
  11757. /**
  11758. * Gets or sets the associated action manager
  11759. */
  11760. actionManager: Nullable<ActionManager>;
  11761. private _animationStarted;
  11762. private _loopAnimation;
  11763. private _fromIndex;
  11764. private _toIndex;
  11765. private _delay;
  11766. private _direction;
  11767. private _manager;
  11768. private _time;
  11769. private _onAnimationEnd;
  11770. /**
  11771. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11772. */
  11773. isVisible: boolean;
  11774. /**
  11775. * Gets or sets the sprite size
  11776. */
  11777. size: number;
  11778. /**
  11779. * Creates a new Sprite
  11780. * @param name defines the name
  11781. * @param manager defines the manager
  11782. */
  11783. constructor(
  11784. /** defines the name */
  11785. name: string, manager: ISpriteManager);
  11786. /**
  11787. * Starts an animation
  11788. * @param from defines the initial key
  11789. * @param to defines the end key
  11790. * @param loop defines if the animation must loop
  11791. * @param delay defines the start delay (in ms)
  11792. * @param onAnimationEnd defines a callback to call when animation ends
  11793. */
  11794. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11795. /** Stops current animation (if any) */
  11796. stopAnimation(): void;
  11797. /** @hidden */
  11798. _animate(deltaTime: number): void;
  11799. /** Release associated resources */
  11800. dispose(): void;
  11801. }
  11802. }
  11803. declare module "babylonjs/Collisions/pickingInfo" {
  11804. import { Nullable } from "babylonjs/types";
  11805. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11807. import { Sprite } from "babylonjs/Sprites/sprite";
  11808. import { Ray } from "babylonjs/Culling/ray";
  11809. /**
  11810. * Information about the result of picking within a scene
  11811. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11812. */
  11813. export class PickingInfo {
  11814. /** @hidden */
  11815. _pickingUnavailable: boolean;
  11816. /**
  11817. * If the pick collided with an object
  11818. */
  11819. hit: boolean;
  11820. /**
  11821. * Distance away where the pick collided
  11822. */
  11823. distance: number;
  11824. /**
  11825. * The location of pick collision
  11826. */
  11827. pickedPoint: Nullable<Vector3>;
  11828. /**
  11829. * The mesh corresponding the the pick collision
  11830. */
  11831. pickedMesh: Nullable<AbstractMesh>;
  11832. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11833. bu: number;
  11834. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11835. bv: number;
  11836. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11837. faceId: number;
  11838. /** Id of the the submesh that was picked */
  11839. subMeshId: number;
  11840. /** If a sprite was picked, this will be the sprite the pick collided with */
  11841. pickedSprite: Nullable<Sprite>;
  11842. /**
  11843. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11844. */
  11845. originMesh: Nullable<AbstractMesh>;
  11846. /**
  11847. * The ray that was used to perform the picking.
  11848. */
  11849. ray: Nullable<Ray>;
  11850. /**
  11851. * Gets the normal correspodning to the face the pick collided with
  11852. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11853. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11854. * @returns The normal correspodning to the face the pick collided with
  11855. */
  11856. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11857. /**
  11858. * Gets the texture coordinates of where the pick occured
  11859. * @returns the vector containing the coordnates of the texture
  11860. */
  11861. getTextureCoordinates(): Nullable<Vector2>;
  11862. }
  11863. }
  11864. declare module "babylonjs/Events/pointerEvents" {
  11865. import { Nullable } from "babylonjs/types";
  11866. import { Vector2 } from "babylonjs/Maths/math.vector";
  11867. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11868. import { Ray } from "babylonjs/Culling/ray";
  11869. /**
  11870. * Gather the list of pointer event types as constants.
  11871. */
  11872. export class PointerEventTypes {
  11873. /**
  11874. * 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.
  11875. */
  11876. static readonly POINTERDOWN: number;
  11877. /**
  11878. * The pointerup event is fired when a pointer is no longer active.
  11879. */
  11880. static readonly POINTERUP: number;
  11881. /**
  11882. * The pointermove event is fired when a pointer changes coordinates.
  11883. */
  11884. static readonly POINTERMOVE: number;
  11885. /**
  11886. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11887. */
  11888. static readonly POINTERWHEEL: number;
  11889. /**
  11890. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11891. */
  11892. static readonly POINTERPICK: number;
  11893. /**
  11894. * The pointertap event is fired when a the object has been touched and released without drag.
  11895. */
  11896. static readonly POINTERTAP: number;
  11897. /**
  11898. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11899. */
  11900. static readonly POINTERDOUBLETAP: number;
  11901. }
  11902. /**
  11903. * Base class of pointer info types.
  11904. */
  11905. export class PointerInfoBase {
  11906. /**
  11907. * Defines the type of event (PointerEventTypes)
  11908. */
  11909. type: number;
  11910. /**
  11911. * Defines the related dom event
  11912. */
  11913. event: PointerEvent | MouseWheelEvent;
  11914. /**
  11915. * Instantiates the base class of pointers info.
  11916. * @param type Defines the type of event (PointerEventTypes)
  11917. * @param event Defines the related dom event
  11918. */
  11919. constructor(
  11920. /**
  11921. * Defines the type of event (PointerEventTypes)
  11922. */
  11923. type: number,
  11924. /**
  11925. * Defines the related dom event
  11926. */
  11927. event: PointerEvent | MouseWheelEvent);
  11928. }
  11929. /**
  11930. * This class is used to store pointer related info for the onPrePointerObservable event.
  11931. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11932. */
  11933. export class PointerInfoPre extends PointerInfoBase {
  11934. /**
  11935. * Ray from a pointer if availible (eg. 6dof controller)
  11936. */
  11937. ray: Nullable<Ray>;
  11938. /**
  11939. * Defines the local position of the pointer on the canvas.
  11940. */
  11941. localPosition: Vector2;
  11942. /**
  11943. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11944. */
  11945. skipOnPointerObservable: boolean;
  11946. /**
  11947. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11948. * @param type Defines the type of event (PointerEventTypes)
  11949. * @param event Defines the related dom event
  11950. * @param localX Defines the local x coordinates of the pointer when the event occured
  11951. * @param localY Defines the local y coordinates of the pointer when the event occured
  11952. */
  11953. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11954. }
  11955. /**
  11956. * This type contains all the data related to a pointer event in Babylon.js.
  11957. * 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.
  11958. */
  11959. export class PointerInfo extends PointerInfoBase {
  11960. /**
  11961. * Defines the picking info associated to the info (if any)\
  11962. */
  11963. pickInfo: Nullable<PickingInfo>;
  11964. /**
  11965. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11966. * @param type Defines the type of event (PointerEventTypes)
  11967. * @param event Defines the related dom event
  11968. * @param pickInfo Defines the picking info associated to the info (if any)\
  11969. */
  11970. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11971. /**
  11972. * Defines the picking info associated to the info (if any)\
  11973. */
  11974. pickInfo: Nullable<PickingInfo>);
  11975. }
  11976. /**
  11977. * Data relating to a touch event on the screen.
  11978. */
  11979. export interface PointerTouch {
  11980. /**
  11981. * X coordinate of touch.
  11982. */
  11983. x: number;
  11984. /**
  11985. * Y coordinate of touch.
  11986. */
  11987. y: number;
  11988. /**
  11989. * Id of touch. Unique for each finger.
  11990. */
  11991. pointerId: number;
  11992. /**
  11993. * Event type passed from DOM.
  11994. */
  11995. type: any;
  11996. }
  11997. }
  11998. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11999. import { Observable } from "babylonjs/Misc/observable";
  12000. import { Nullable } from "babylonjs/types";
  12001. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12002. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12003. /**
  12004. * Manage the mouse inputs to control the movement of a free camera.
  12005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12006. */
  12007. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12008. /**
  12009. * Define if touch is enabled in the mouse input
  12010. */
  12011. touchEnabled: boolean;
  12012. /**
  12013. * Defines the camera the input is attached to.
  12014. */
  12015. camera: FreeCamera;
  12016. /**
  12017. * Defines the buttons associated with the input to handle camera move.
  12018. */
  12019. buttons: number[];
  12020. /**
  12021. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12022. */
  12023. angularSensibility: number;
  12024. private _pointerInput;
  12025. private _onMouseMove;
  12026. private _observer;
  12027. private previousPosition;
  12028. /**
  12029. * Observable for when a pointer move event occurs containing the move offset
  12030. */
  12031. onPointerMovedObservable: Observable<{
  12032. offsetX: number;
  12033. offsetY: number;
  12034. }>;
  12035. /**
  12036. * @hidden
  12037. * If the camera should be rotated automatically based on pointer movement
  12038. */
  12039. _allowCameraRotation: boolean;
  12040. /**
  12041. * Manage the mouse inputs to control the movement of a free camera.
  12042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12043. * @param touchEnabled Defines if touch is enabled or not
  12044. */
  12045. constructor(
  12046. /**
  12047. * Define if touch is enabled in the mouse input
  12048. */
  12049. touchEnabled?: boolean);
  12050. /**
  12051. * Attach the input controls to a specific dom element to get the input from.
  12052. * @param element Defines the element the controls should be listened from
  12053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12054. */
  12055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12056. /**
  12057. * Called on JS contextmenu event.
  12058. * Override this method to provide functionality.
  12059. */
  12060. protected onContextMenu(evt: PointerEvent): void;
  12061. /**
  12062. * Detach the current controls from the specified dom element.
  12063. * @param element Defines the element to stop listening the inputs from
  12064. */
  12065. detachControl(element: Nullable<HTMLElement>): void;
  12066. /**
  12067. * Gets the class name of the current intput.
  12068. * @returns the class name
  12069. */
  12070. getClassName(): string;
  12071. /**
  12072. * Get the friendly name associated with the input class.
  12073. * @returns the input friendly name
  12074. */
  12075. getSimpleName(): string;
  12076. }
  12077. }
  12078. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12079. import { Nullable } from "babylonjs/types";
  12080. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12082. /**
  12083. * Manage the touch inputs to control the movement of a free camera.
  12084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12085. */
  12086. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12087. /**
  12088. * Defines the camera the input is attached to.
  12089. */
  12090. camera: FreeCamera;
  12091. /**
  12092. * Defines the touch sensibility for rotation.
  12093. * The higher the faster.
  12094. */
  12095. touchAngularSensibility: number;
  12096. /**
  12097. * Defines the touch sensibility for move.
  12098. * The higher the faster.
  12099. */
  12100. touchMoveSensibility: number;
  12101. private _offsetX;
  12102. private _offsetY;
  12103. private _pointerPressed;
  12104. private _pointerInput;
  12105. private _observer;
  12106. private _onLostFocus;
  12107. /**
  12108. * Attach the input controls to a specific dom element to get the input from.
  12109. * @param element Defines the element the controls should be listened from
  12110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12111. */
  12112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12113. /**
  12114. * Detach the current controls from the specified dom element.
  12115. * @param element Defines the element to stop listening the inputs from
  12116. */
  12117. detachControl(element: Nullable<HTMLElement>): void;
  12118. /**
  12119. * Update the current camera state depending on the inputs that have been used this frame.
  12120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12121. */
  12122. checkInputs(): void;
  12123. /**
  12124. * Gets the class name of the current intput.
  12125. * @returns the class name
  12126. */
  12127. getClassName(): string;
  12128. /**
  12129. * Get the friendly name associated with the input class.
  12130. * @returns the input friendly name
  12131. */
  12132. getSimpleName(): string;
  12133. }
  12134. }
  12135. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12136. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12138. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12139. import { Nullable } from "babylonjs/types";
  12140. /**
  12141. * Default Inputs manager for the FreeCamera.
  12142. * It groups all the default supported inputs for ease of use.
  12143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12144. */
  12145. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12146. /**
  12147. * @hidden
  12148. */
  12149. _mouseInput: Nullable<FreeCameraMouseInput>;
  12150. /**
  12151. * Instantiates a new FreeCameraInputsManager.
  12152. * @param camera Defines the camera the inputs belong to
  12153. */
  12154. constructor(camera: FreeCamera);
  12155. /**
  12156. * Add keyboard input support to the input manager.
  12157. * @returns the current input manager
  12158. */
  12159. addKeyboard(): FreeCameraInputsManager;
  12160. /**
  12161. * Add mouse input support to the input manager.
  12162. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12163. * @returns the current input manager
  12164. */
  12165. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12166. /**
  12167. * Removes the mouse input support from the manager
  12168. * @returns the current input manager
  12169. */
  12170. removeMouse(): FreeCameraInputsManager;
  12171. /**
  12172. * Add touch input support to the input manager.
  12173. * @returns the current input manager
  12174. */
  12175. addTouch(): FreeCameraInputsManager;
  12176. /**
  12177. * Remove all attached input methods from a camera
  12178. */
  12179. clear(): void;
  12180. }
  12181. }
  12182. declare module "babylonjs/Cameras/freeCamera" {
  12183. import { Vector3 } from "babylonjs/Maths/math.vector";
  12184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12185. import { Scene } from "babylonjs/scene";
  12186. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12187. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12188. /**
  12189. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12190. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12192. */
  12193. export class FreeCamera extends TargetCamera {
  12194. /**
  12195. * Define the collision ellipsoid of the camera.
  12196. * This is helpful to simulate a camera body like the player body around the camera
  12197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12198. */
  12199. ellipsoid: Vector3;
  12200. /**
  12201. * Define an offset for the position of the ellipsoid around the camera.
  12202. * This can be helpful to determine the center of the body near the gravity center of the body
  12203. * instead of its head.
  12204. */
  12205. ellipsoidOffset: Vector3;
  12206. /**
  12207. * Enable or disable collisions of the camera with the rest of the scene objects.
  12208. */
  12209. checkCollisions: boolean;
  12210. /**
  12211. * Enable or disable gravity on the camera.
  12212. */
  12213. applyGravity: boolean;
  12214. /**
  12215. * Define the input manager associated to the camera.
  12216. */
  12217. inputs: FreeCameraInputsManager;
  12218. /**
  12219. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12220. * Higher values reduce sensitivity.
  12221. */
  12222. /**
  12223. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12224. * Higher values reduce sensitivity.
  12225. */
  12226. angularSensibility: number;
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12229. */
  12230. keysUp: number[];
  12231. /**
  12232. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12233. */
  12234. keysDown: number[];
  12235. /**
  12236. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12237. */
  12238. keysLeft: number[];
  12239. /**
  12240. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12241. */
  12242. keysRight: number[];
  12243. /**
  12244. * Event raised when the camera collide with a mesh in the scene.
  12245. */
  12246. onCollide: (collidedMesh: AbstractMesh) => void;
  12247. private _collider;
  12248. private _needMoveForGravity;
  12249. private _oldPosition;
  12250. private _diffPosition;
  12251. private _newPosition;
  12252. /** @hidden */
  12253. _localDirection: Vector3;
  12254. /** @hidden */
  12255. _transformedDirection: Vector3;
  12256. /**
  12257. * Instantiates a Free Camera.
  12258. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12259. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12260. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12261. * @param name Define the name of the camera in the scene
  12262. * @param position Define the start position of the camera in the scene
  12263. * @param scene Define the scene the camera belongs to
  12264. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12265. */
  12266. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12267. /**
  12268. * Attached controls to the current camera.
  12269. * @param element Defines the element the controls should be listened from
  12270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12271. */
  12272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12273. /**
  12274. * Detach the current controls from the camera.
  12275. * The camera will stop reacting to inputs.
  12276. * @param element Defines the element to stop listening the inputs from
  12277. */
  12278. detachControl(element: HTMLElement): void;
  12279. private _collisionMask;
  12280. /**
  12281. * Define a collision mask to limit the list of object the camera can collide with
  12282. */
  12283. collisionMask: number;
  12284. /** @hidden */
  12285. _collideWithWorld(displacement: Vector3): void;
  12286. private _onCollisionPositionChange;
  12287. /** @hidden */
  12288. _checkInputs(): void;
  12289. /** @hidden */
  12290. _decideIfNeedsToMove(): boolean;
  12291. /** @hidden */
  12292. _updatePosition(): void;
  12293. /**
  12294. * Destroy the camera and release the current resources hold by it.
  12295. */
  12296. dispose(): void;
  12297. /**
  12298. * Gets the current object class name.
  12299. * @return the class name
  12300. */
  12301. getClassName(): string;
  12302. }
  12303. }
  12304. declare module "babylonjs/Gamepads/gamepad" {
  12305. import { Observable } from "babylonjs/Misc/observable";
  12306. /**
  12307. * Represents a gamepad control stick position
  12308. */
  12309. export class StickValues {
  12310. /**
  12311. * The x component of the control stick
  12312. */
  12313. x: number;
  12314. /**
  12315. * The y component of the control stick
  12316. */
  12317. y: number;
  12318. /**
  12319. * Initializes the gamepad x and y control stick values
  12320. * @param x The x component of the gamepad control stick value
  12321. * @param y The y component of the gamepad control stick value
  12322. */
  12323. constructor(
  12324. /**
  12325. * The x component of the control stick
  12326. */
  12327. x: number,
  12328. /**
  12329. * The y component of the control stick
  12330. */
  12331. y: number);
  12332. }
  12333. /**
  12334. * An interface which manages callbacks for gamepad button changes
  12335. */
  12336. export interface GamepadButtonChanges {
  12337. /**
  12338. * Called when a gamepad has been changed
  12339. */
  12340. changed: boolean;
  12341. /**
  12342. * Called when a gamepad press event has been triggered
  12343. */
  12344. pressChanged: boolean;
  12345. /**
  12346. * Called when a touch event has been triggered
  12347. */
  12348. touchChanged: boolean;
  12349. /**
  12350. * Called when a value has changed
  12351. */
  12352. valueChanged: boolean;
  12353. }
  12354. /**
  12355. * Represents a gamepad
  12356. */
  12357. export class Gamepad {
  12358. /**
  12359. * The id of the gamepad
  12360. */
  12361. id: string;
  12362. /**
  12363. * The index of the gamepad
  12364. */
  12365. index: number;
  12366. /**
  12367. * The browser gamepad
  12368. */
  12369. browserGamepad: any;
  12370. /**
  12371. * Specifies what type of gamepad this represents
  12372. */
  12373. type: number;
  12374. private _leftStick;
  12375. private _rightStick;
  12376. /** @hidden */
  12377. _isConnected: boolean;
  12378. private _leftStickAxisX;
  12379. private _leftStickAxisY;
  12380. private _rightStickAxisX;
  12381. private _rightStickAxisY;
  12382. /**
  12383. * Triggered when the left control stick has been changed
  12384. */
  12385. private _onleftstickchanged;
  12386. /**
  12387. * Triggered when the right control stick has been changed
  12388. */
  12389. private _onrightstickchanged;
  12390. /**
  12391. * Represents a gamepad controller
  12392. */
  12393. static GAMEPAD: number;
  12394. /**
  12395. * Represents a generic controller
  12396. */
  12397. static GENERIC: number;
  12398. /**
  12399. * Represents an XBox controller
  12400. */
  12401. static XBOX: number;
  12402. /**
  12403. * Represents a pose-enabled controller
  12404. */
  12405. static POSE_ENABLED: number;
  12406. /**
  12407. * Represents an Dual Shock controller
  12408. */
  12409. static DUALSHOCK: number;
  12410. /**
  12411. * Specifies whether the left control stick should be Y-inverted
  12412. */
  12413. protected _invertLeftStickY: boolean;
  12414. /**
  12415. * Specifies if the gamepad has been connected
  12416. */
  12417. readonly isConnected: boolean;
  12418. /**
  12419. * Initializes the gamepad
  12420. * @param id The id of the gamepad
  12421. * @param index The index of the gamepad
  12422. * @param browserGamepad The browser gamepad
  12423. * @param leftStickX The x component of the left joystick
  12424. * @param leftStickY The y component of the left joystick
  12425. * @param rightStickX The x component of the right joystick
  12426. * @param rightStickY The y component of the right joystick
  12427. */
  12428. constructor(
  12429. /**
  12430. * The id of the gamepad
  12431. */
  12432. id: string,
  12433. /**
  12434. * The index of the gamepad
  12435. */
  12436. index: number,
  12437. /**
  12438. * The browser gamepad
  12439. */
  12440. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12441. /**
  12442. * Callback triggered when the left joystick has changed
  12443. * @param callback
  12444. */
  12445. onleftstickchanged(callback: (values: StickValues) => void): void;
  12446. /**
  12447. * Callback triggered when the right joystick has changed
  12448. * @param callback
  12449. */
  12450. onrightstickchanged(callback: (values: StickValues) => void): void;
  12451. /**
  12452. * Gets the left joystick
  12453. */
  12454. /**
  12455. * Sets the left joystick values
  12456. */
  12457. leftStick: StickValues;
  12458. /**
  12459. * Gets the right joystick
  12460. */
  12461. /**
  12462. * Sets the right joystick value
  12463. */
  12464. rightStick: StickValues;
  12465. /**
  12466. * Updates the gamepad joystick positions
  12467. */
  12468. update(): void;
  12469. /**
  12470. * Disposes the gamepad
  12471. */
  12472. dispose(): void;
  12473. }
  12474. /**
  12475. * Represents a generic gamepad
  12476. */
  12477. export class GenericPad extends Gamepad {
  12478. private _buttons;
  12479. private _onbuttondown;
  12480. private _onbuttonup;
  12481. /**
  12482. * Observable triggered when a button has been pressed
  12483. */
  12484. onButtonDownObservable: Observable<number>;
  12485. /**
  12486. * Observable triggered when a button has been released
  12487. */
  12488. onButtonUpObservable: Observable<number>;
  12489. /**
  12490. * Callback triggered when a button has been pressed
  12491. * @param callback Called when a button has been pressed
  12492. */
  12493. onbuttondown(callback: (buttonPressed: number) => void): void;
  12494. /**
  12495. * Callback triggered when a button has been released
  12496. * @param callback Called when a button has been released
  12497. */
  12498. onbuttonup(callback: (buttonReleased: number) => void): void;
  12499. /**
  12500. * Initializes the generic gamepad
  12501. * @param id The id of the generic gamepad
  12502. * @param index The index of the generic gamepad
  12503. * @param browserGamepad The browser gamepad
  12504. */
  12505. constructor(id: string, index: number, browserGamepad: any);
  12506. private _setButtonValue;
  12507. /**
  12508. * Updates the generic gamepad
  12509. */
  12510. update(): void;
  12511. /**
  12512. * Disposes the generic gamepad
  12513. */
  12514. dispose(): void;
  12515. }
  12516. }
  12517. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12518. import { Nullable } from "babylonjs/types";
  12519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12520. import { Scene } from "babylonjs/scene";
  12521. module "babylonjs/Engines/engine" {
  12522. interface Engine {
  12523. /**
  12524. * Creates a raw texture
  12525. * @param data defines the data to store in the texture
  12526. * @param width defines the width of the texture
  12527. * @param height defines the height of the texture
  12528. * @param format defines the format of the data
  12529. * @param generateMipMaps defines if the engine should generate the mip levels
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12532. * @param compression defines the compression used (null by default)
  12533. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12534. * @returns the raw texture inside an InternalTexture
  12535. */
  12536. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12537. /**
  12538. * Update a raw texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store in the texture
  12541. * @param format defines the format of the data
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. */
  12544. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12545. /**
  12546. * Update a raw texture
  12547. * @param texture defines the texture to update
  12548. * @param data defines the data to store in the texture
  12549. * @param format defines the format of the data
  12550. * @param invertY defines if data must be stored with Y axis inverted
  12551. * @param compression defines the compression used (null by default)
  12552. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12553. */
  12554. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12555. /**
  12556. * Creates a new raw cube texture
  12557. * @param data defines the array of data to use to create each face
  12558. * @param size defines the size of the textures
  12559. * @param format defines the format of the data
  12560. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12561. * @param generateMipMaps defines if the engine should generate the mip levels
  12562. * @param invertY defines if data must be stored with Y axis inverted
  12563. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12564. * @param compression defines the compression used (null by default)
  12565. * @returns the cube texture as an InternalTexture
  12566. */
  12567. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12568. /**
  12569. * Update a raw cube texture
  12570. * @param texture defines the texture to udpdate
  12571. * @param data defines the data to store
  12572. * @param format defines the data format
  12573. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12574. * @param invertY defines if data must be stored with Y axis inverted
  12575. */
  12576. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12577. /**
  12578. * Update a raw cube texture
  12579. * @param texture defines the texture to udpdate
  12580. * @param data defines the data to store
  12581. * @param format defines the data format
  12582. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12583. * @param invertY defines if data must be stored with Y axis inverted
  12584. * @param compression defines the compression used (null by default)
  12585. */
  12586. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12587. /**
  12588. * Update a raw cube texture
  12589. * @param texture defines the texture to udpdate
  12590. * @param data defines the data to store
  12591. * @param format defines the data format
  12592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12593. * @param invertY defines if data must be stored with Y axis inverted
  12594. * @param compression defines the compression used (null by default)
  12595. * @param level defines which level of the texture to update
  12596. */
  12597. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12598. /**
  12599. * Creates a new raw cube texture from a specified url
  12600. * @param url defines the url where the data is located
  12601. * @param scene defines the current scene
  12602. * @param size defines the size of the textures
  12603. * @param format defines the format of the data
  12604. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12605. * @param noMipmap defines if the engine should avoid generating the mip levels
  12606. * @param callback defines a callback used to extract texture data from loaded data
  12607. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12608. * @param onLoad defines a callback called when texture is loaded
  12609. * @param onError defines a callback called if there is an error
  12610. * @returns the cube texture as an InternalTexture
  12611. */
  12612. 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;
  12613. /**
  12614. * Creates a new raw cube texture from a specified url
  12615. * @param url defines the url where the data is located
  12616. * @param scene defines the current scene
  12617. * @param size defines the size of the textures
  12618. * @param format defines the format of the data
  12619. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12620. * @param noMipmap defines if the engine should avoid generating the mip levels
  12621. * @param callback defines a callback used to extract texture data from loaded data
  12622. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12623. * @param onLoad defines a callback called when texture is loaded
  12624. * @param onError defines a callback called if there is an error
  12625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12626. * @param invertY defines if data must be stored with Y axis inverted
  12627. * @returns the cube texture as an InternalTexture
  12628. */
  12629. 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;
  12630. /**
  12631. * Creates a new raw 3D texture
  12632. * @param data defines the data used to create the texture
  12633. * @param width defines the width of the texture
  12634. * @param height defines the height of the texture
  12635. * @param depth defines the depth of the texture
  12636. * @param format defines the format of the texture
  12637. * @param generateMipMaps defines if the engine must generate mip levels
  12638. * @param invertY defines if data must be stored with Y axis inverted
  12639. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12640. * @param compression defines the compressed used (can be null)
  12641. * @param textureType defines the compressed used (can be null)
  12642. * @returns a new raw 3D texture (stored in an InternalTexture)
  12643. */
  12644. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12645. /**
  12646. * Update a raw 3D texture
  12647. * @param texture defines the texture to update
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param invertY defines if data must be stored with Y axis inverted
  12651. */
  12652. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12653. /**
  12654. * Update a raw 3D texture
  12655. * @param texture defines the texture to update
  12656. * @param data defines the data to store
  12657. * @param format defines the data format
  12658. * @param invertY defines if data must be stored with Y axis inverted
  12659. * @param compression defines the used compression (can be null)
  12660. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12661. */
  12662. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12663. }
  12664. }
  12665. }
  12666. declare module "babylonjs/Materials/Textures/rawTexture" {
  12667. import { Scene } from "babylonjs/scene";
  12668. import { Texture } from "babylonjs/Materials/Textures/texture";
  12669. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12670. /**
  12671. * Raw texture can help creating a texture directly from an array of data.
  12672. * This can be super useful if you either get the data from an uncompressed source or
  12673. * if you wish to create your texture pixel by pixel.
  12674. */
  12675. export class RawTexture extends Texture {
  12676. /**
  12677. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12678. */
  12679. format: number;
  12680. private _engine;
  12681. /**
  12682. * Instantiates a new RawTexture.
  12683. * Raw texture can help creating a texture directly from an array of data.
  12684. * This can be super useful if you either get the data from an uncompressed source or
  12685. * if you wish to create your texture pixel by pixel.
  12686. * @param data define the array of data to use to create the texture
  12687. * @param width define the width of the texture
  12688. * @param height define the height of the texture
  12689. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12690. * @param scene define the scene the texture belongs to
  12691. * @param generateMipMaps define whether mip maps should be generated or not
  12692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12695. */
  12696. constructor(data: ArrayBufferView, width: number, height: number,
  12697. /**
  12698. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12699. */
  12700. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12701. /**
  12702. * Updates the texture underlying data.
  12703. * @param data Define the new data of the texture
  12704. */
  12705. update(data: ArrayBufferView): void;
  12706. /**
  12707. * Creates a luminance texture from some data.
  12708. * @param data Define the texture data
  12709. * @param width Define the width of the texture
  12710. * @param height Define the height of the texture
  12711. * @param scene Define the scene the texture belongs to
  12712. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12715. * @returns the luminance texture
  12716. */
  12717. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12718. /**
  12719. * Creates a luminance alpha texture from some data.
  12720. * @param data Define the texture data
  12721. * @param width Define the width of the texture
  12722. * @param height Define the height of the texture
  12723. * @param scene Define the scene the texture belongs to
  12724. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12727. * @returns the luminance alpha texture
  12728. */
  12729. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12730. /**
  12731. * Creates an alpha texture from some data.
  12732. * @param data Define the texture data
  12733. * @param width Define the width of the texture
  12734. * @param height Define the height of the texture
  12735. * @param scene Define the scene the texture belongs to
  12736. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12737. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12738. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12739. * @returns the alpha texture
  12740. */
  12741. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12742. /**
  12743. * Creates a RGB texture from some data.
  12744. * @param data Define the texture data
  12745. * @param width Define the width of the texture
  12746. * @param height Define the height of the texture
  12747. * @param scene Define the scene the texture belongs to
  12748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12752. * @returns the RGB alpha texture
  12753. */
  12754. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12755. /**
  12756. * Creates a RGBA texture from some data.
  12757. * @param data Define the texture data
  12758. * @param width Define the width of the texture
  12759. * @param height Define the height of the texture
  12760. * @param scene Define the scene the texture belongs to
  12761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12765. * @returns the RGBA texture
  12766. */
  12767. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12768. /**
  12769. * Creates a R texture from some data.
  12770. * @param data Define the texture data
  12771. * @param width Define the width of the texture
  12772. * @param height Define the height of the texture
  12773. * @param scene Define the scene the texture belongs to
  12774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12778. * @returns the R texture
  12779. */
  12780. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12781. }
  12782. }
  12783. declare module "babylonjs/Maths/math.size" {
  12784. /**
  12785. * Interface for the size containing width and height
  12786. */
  12787. export interface ISize {
  12788. /**
  12789. * Width
  12790. */
  12791. width: number;
  12792. /**
  12793. * Heighht
  12794. */
  12795. height: number;
  12796. }
  12797. /**
  12798. * Size containing widht and height
  12799. */
  12800. export class Size implements ISize {
  12801. /**
  12802. * Width
  12803. */
  12804. width: number;
  12805. /**
  12806. * Height
  12807. */
  12808. height: number;
  12809. /**
  12810. * Creates a Size object from the given width and height (floats).
  12811. * @param width width of the new size
  12812. * @param height height of the new size
  12813. */
  12814. constructor(width: number, height: number);
  12815. /**
  12816. * Returns a string with the Size width and height
  12817. * @returns a string with the Size width and height
  12818. */
  12819. toString(): string;
  12820. /**
  12821. * "Size"
  12822. * @returns the string "Size"
  12823. */
  12824. getClassName(): string;
  12825. /**
  12826. * Returns the Size hash code.
  12827. * @returns a hash code for a unique width and height
  12828. */
  12829. getHashCode(): number;
  12830. /**
  12831. * Updates the current size from the given one.
  12832. * @param src the given size
  12833. */
  12834. copyFrom(src: Size): void;
  12835. /**
  12836. * Updates in place the current Size from the given floats.
  12837. * @param width width of the new size
  12838. * @param height height of the new size
  12839. * @returns the updated Size.
  12840. */
  12841. copyFromFloats(width: number, height: number): Size;
  12842. /**
  12843. * Updates in place the current Size from the given floats.
  12844. * @param width width to set
  12845. * @param height height to set
  12846. * @returns the updated Size.
  12847. */
  12848. set(width: number, height: number): Size;
  12849. /**
  12850. * Multiplies the width and height by numbers
  12851. * @param w factor to multiple the width by
  12852. * @param h factor to multiple the height by
  12853. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12854. */
  12855. multiplyByFloats(w: number, h: number): Size;
  12856. /**
  12857. * Clones the size
  12858. * @returns a new Size copied from the given one.
  12859. */
  12860. clone(): Size;
  12861. /**
  12862. * True if the current Size and the given one width and height are strictly equal.
  12863. * @param other the other size to compare against
  12864. * @returns True if the current Size and the given one width and height are strictly equal.
  12865. */
  12866. equals(other: Size): boolean;
  12867. /**
  12868. * The surface of the Size : width * height (float).
  12869. */
  12870. readonly surface: number;
  12871. /**
  12872. * Create a new size of zero
  12873. * @returns a new Size set to (0.0, 0.0)
  12874. */
  12875. static Zero(): Size;
  12876. /**
  12877. * Sums the width and height of two sizes
  12878. * @param otherSize size to add to this size
  12879. * @returns a new Size set as the addition result of the current Size and the given one.
  12880. */
  12881. add(otherSize: Size): Size;
  12882. /**
  12883. * Subtracts the width and height of two
  12884. * @param otherSize size to subtract to this size
  12885. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12886. */
  12887. subtract(otherSize: Size): Size;
  12888. /**
  12889. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12890. * @param start starting size to lerp between
  12891. * @param end end size to lerp between
  12892. * @param amount amount to lerp between the start and end values
  12893. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12894. */
  12895. static Lerp(start: Size, end: Size, amount: number): Size;
  12896. }
  12897. }
  12898. declare module "babylonjs/Animations/runtimeAnimation" {
  12899. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12900. import { Animatable } from "babylonjs/Animations/animatable";
  12901. import { Scene } from "babylonjs/scene";
  12902. /**
  12903. * Defines a runtime animation
  12904. */
  12905. export class RuntimeAnimation {
  12906. private _events;
  12907. /**
  12908. * The current frame of the runtime animation
  12909. */
  12910. private _currentFrame;
  12911. /**
  12912. * The animation used by the runtime animation
  12913. */
  12914. private _animation;
  12915. /**
  12916. * The target of the runtime animation
  12917. */
  12918. private _target;
  12919. /**
  12920. * The initiating animatable
  12921. */
  12922. private _host;
  12923. /**
  12924. * The original value of the runtime animation
  12925. */
  12926. private _originalValue;
  12927. /**
  12928. * The original blend value of the runtime animation
  12929. */
  12930. private _originalBlendValue;
  12931. /**
  12932. * The offsets cache of the runtime animation
  12933. */
  12934. private _offsetsCache;
  12935. /**
  12936. * The high limits cache of the runtime animation
  12937. */
  12938. private _highLimitsCache;
  12939. /**
  12940. * Specifies if the runtime animation has been stopped
  12941. */
  12942. private _stopped;
  12943. /**
  12944. * The blending factor of the runtime animation
  12945. */
  12946. private _blendingFactor;
  12947. /**
  12948. * The BabylonJS scene
  12949. */
  12950. private _scene;
  12951. /**
  12952. * The current value of the runtime animation
  12953. */
  12954. private _currentValue;
  12955. /** @hidden */
  12956. _animationState: _IAnimationState;
  12957. /**
  12958. * The active target of the runtime animation
  12959. */
  12960. private _activeTargets;
  12961. private _currentActiveTarget;
  12962. private _directTarget;
  12963. /**
  12964. * The target path of the runtime animation
  12965. */
  12966. private _targetPath;
  12967. /**
  12968. * The weight of the runtime animation
  12969. */
  12970. private _weight;
  12971. /**
  12972. * The ratio offset of the runtime animation
  12973. */
  12974. private _ratioOffset;
  12975. /**
  12976. * The previous delay of the runtime animation
  12977. */
  12978. private _previousDelay;
  12979. /**
  12980. * The previous ratio of the runtime animation
  12981. */
  12982. private _previousRatio;
  12983. private _enableBlending;
  12984. private _keys;
  12985. private _minFrame;
  12986. private _maxFrame;
  12987. private _minValue;
  12988. private _maxValue;
  12989. private _targetIsArray;
  12990. /**
  12991. * Gets the current frame of the runtime animation
  12992. */
  12993. readonly currentFrame: number;
  12994. /**
  12995. * Gets the weight of the runtime animation
  12996. */
  12997. readonly weight: number;
  12998. /**
  12999. * Gets the current value of the runtime animation
  13000. */
  13001. readonly currentValue: any;
  13002. /**
  13003. * Gets the target path of the runtime animation
  13004. */
  13005. readonly targetPath: string;
  13006. /**
  13007. * Gets the actual target of the runtime animation
  13008. */
  13009. readonly target: any;
  13010. /** @hidden */
  13011. _onLoop: () => void;
  13012. /**
  13013. * Create a new RuntimeAnimation object
  13014. * @param target defines the target of the animation
  13015. * @param animation defines the source animation object
  13016. * @param scene defines the hosting scene
  13017. * @param host defines the initiating Animatable
  13018. */
  13019. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13020. private _preparePath;
  13021. /**
  13022. * Gets the animation from the runtime animation
  13023. */
  13024. readonly animation: Animation;
  13025. /**
  13026. * Resets the runtime animation to the beginning
  13027. * @param restoreOriginal defines whether to restore the target property to the original value
  13028. */
  13029. reset(restoreOriginal?: boolean): void;
  13030. /**
  13031. * Specifies if the runtime animation is stopped
  13032. * @returns Boolean specifying if the runtime animation is stopped
  13033. */
  13034. isStopped(): boolean;
  13035. /**
  13036. * Disposes of the runtime animation
  13037. */
  13038. dispose(): void;
  13039. /**
  13040. * Apply the interpolated value to the target
  13041. * @param currentValue defines the value computed by the animation
  13042. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13043. */
  13044. setValue(currentValue: any, weight: number): void;
  13045. private _getOriginalValues;
  13046. private _setValue;
  13047. /**
  13048. * Gets the loop pmode of the runtime animation
  13049. * @returns Loop Mode
  13050. */
  13051. private _getCorrectLoopMode;
  13052. /**
  13053. * Move the current animation to a given frame
  13054. * @param frame defines the frame to move to
  13055. */
  13056. goToFrame(frame: number): void;
  13057. /**
  13058. * @hidden Internal use only
  13059. */
  13060. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13061. /**
  13062. * Execute the current animation
  13063. * @param delay defines the delay to add to the current frame
  13064. * @param from defines the lower bound of the animation range
  13065. * @param to defines the upper bound of the animation range
  13066. * @param loop defines if the current animation must loop
  13067. * @param speedRatio defines the current speed ratio
  13068. * @param weight defines the weight of the animation (default is -1 so no weight)
  13069. * @param onLoop optional callback called when animation loops
  13070. * @returns a boolean indicating if the animation is running
  13071. */
  13072. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13073. }
  13074. }
  13075. declare module "babylonjs/Animations/animatable" {
  13076. import { Animation } from "babylonjs/Animations/animation";
  13077. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13078. import { Nullable } from "babylonjs/types";
  13079. import { Observable } from "babylonjs/Misc/observable";
  13080. import { Scene } from "babylonjs/scene";
  13081. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13082. import { Node } from "babylonjs/node";
  13083. /**
  13084. * Class used to store an actual running animation
  13085. */
  13086. export class Animatable {
  13087. /** defines the target object */
  13088. target: any;
  13089. /** defines the starting frame number (default is 0) */
  13090. fromFrame: number;
  13091. /** defines the ending frame number (default is 100) */
  13092. toFrame: number;
  13093. /** defines if the animation must loop (default is false) */
  13094. loopAnimation: boolean;
  13095. /** defines a callback to call when animation ends if it is not looping */
  13096. onAnimationEnd?: (() => void) | null | undefined;
  13097. /** defines a callback to call when animation loops */
  13098. onAnimationLoop?: (() => void) | null | undefined;
  13099. private _localDelayOffset;
  13100. private _pausedDelay;
  13101. private _runtimeAnimations;
  13102. private _paused;
  13103. private _scene;
  13104. private _speedRatio;
  13105. private _weight;
  13106. private _syncRoot;
  13107. /**
  13108. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13109. * This will only apply for non looping animation (default is true)
  13110. */
  13111. disposeOnEnd: boolean;
  13112. /**
  13113. * Gets a boolean indicating if the animation has started
  13114. */
  13115. animationStarted: boolean;
  13116. /**
  13117. * Observer raised when the animation ends
  13118. */
  13119. onAnimationEndObservable: Observable<Animatable>;
  13120. /**
  13121. * Observer raised when the animation loops
  13122. */
  13123. onAnimationLoopObservable: Observable<Animatable>;
  13124. /**
  13125. * Gets the root Animatable used to synchronize and normalize animations
  13126. */
  13127. readonly syncRoot: Nullable<Animatable>;
  13128. /**
  13129. * Gets the current frame of the first RuntimeAnimation
  13130. * Used to synchronize Animatables
  13131. */
  13132. readonly masterFrame: number;
  13133. /**
  13134. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13135. */
  13136. weight: number;
  13137. /**
  13138. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13139. */
  13140. speedRatio: number;
  13141. /**
  13142. * Creates a new Animatable
  13143. * @param scene defines the hosting scene
  13144. * @param target defines the target object
  13145. * @param fromFrame defines the starting frame number (default is 0)
  13146. * @param toFrame defines the ending frame number (default is 100)
  13147. * @param loopAnimation defines if the animation must loop (default is false)
  13148. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13149. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13150. * @param animations defines a group of animation to add to the new Animatable
  13151. * @param onAnimationLoop defines a callback to call when animation loops
  13152. */
  13153. constructor(scene: Scene,
  13154. /** defines the target object */
  13155. target: any,
  13156. /** defines the starting frame number (default is 0) */
  13157. fromFrame?: number,
  13158. /** defines the ending frame number (default is 100) */
  13159. toFrame?: number,
  13160. /** defines if the animation must loop (default is false) */
  13161. loopAnimation?: boolean, speedRatio?: number,
  13162. /** defines a callback to call when animation ends if it is not looping */
  13163. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13164. /** defines a callback to call when animation loops */
  13165. onAnimationLoop?: (() => void) | null | undefined);
  13166. /**
  13167. * Synchronize and normalize current Animatable with a source Animatable
  13168. * This is useful when using animation weights and when animations are not of the same length
  13169. * @param root defines the root Animatable to synchronize with
  13170. * @returns the current Animatable
  13171. */
  13172. syncWith(root: Animatable): Animatable;
  13173. /**
  13174. * Gets the list of runtime animations
  13175. * @returns an array of RuntimeAnimation
  13176. */
  13177. getAnimations(): RuntimeAnimation[];
  13178. /**
  13179. * Adds more animations to the current animatable
  13180. * @param target defines the target of the animations
  13181. * @param animations defines the new animations to add
  13182. */
  13183. appendAnimations(target: any, animations: Animation[]): void;
  13184. /**
  13185. * Gets the source animation for a specific property
  13186. * @param property defines the propertyu to look for
  13187. * @returns null or the source animation for the given property
  13188. */
  13189. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13190. /**
  13191. * Gets the runtime animation for a specific property
  13192. * @param property defines the propertyu to look for
  13193. * @returns null or the runtime animation for the given property
  13194. */
  13195. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13196. /**
  13197. * Resets the animatable to its original state
  13198. */
  13199. reset(): void;
  13200. /**
  13201. * Allows the animatable to blend with current running animations
  13202. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13203. * @param blendingSpeed defines the blending speed to use
  13204. */
  13205. enableBlending(blendingSpeed: number): void;
  13206. /**
  13207. * Disable animation blending
  13208. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13209. */
  13210. disableBlending(): void;
  13211. /**
  13212. * Jump directly to a given frame
  13213. * @param frame defines the frame to jump to
  13214. */
  13215. goToFrame(frame: number): void;
  13216. /**
  13217. * Pause the animation
  13218. */
  13219. pause(): void;
  13220. /**
  13221. * Restart the animation
  13222. */
  13223. restart(): void;
  13224. private _raiseOnAnimationEnd;
  13225. /**
  13226. * Stop and delete the current animation
  13227. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13228. * @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)
  13229. */
  13230. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13231. /**
  13232. * Wait asynchronously for the animation to end
  13233. * @returns a promise which will be fullfilled when the animation ends
  13234. */
  13235. waitAsync(): Promise<Animatable>;
  13236. /** @hidden */
  13237. _animate(delay: number): boolean;
  13238. }
  13239. module "babylonjs/scene" {
  13240. interface Scene {
  13241. /** @hidden */
  13242. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13243. /** @hidden */
  13244. _processLateAnimationBindingsForMatrices(holder: {
  13245. totalWeight: number;
  13246. animations: RuntimeAnimation[];
  13247. originalValue: Matrix;
  13248. }): any;
  13249. /** @hidden */
  13250. _processLateAnimationBindingsForQuaternions(holder: {
  13251. totalWeight: number;
  13252. animations: RuntimeAnimation[];
  13253. originalValue: Quaternion;
  13254. }, refQuaternion: Quaternion): Quaternion;
  13255. /** @hidden */
  13256. _processLateAnimationBindings(): void;
  13257. /**
  13258. * Will start the animation sequence of a given target
  13259. * @param target defines the target
  13260. * @param from defines from which frame should animation start
  13261. * @param to defines until which frame should animation run.
  13262. * @param weight defines the weight to apply to the animation (1.0 by default)
  13263. * @param loop defines if the animation loops
  13264. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13265. * @param onAnimationEnd defines the function to be executed when the animation ends
  13266. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13267. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13268. * @param onAnimationLoop defines the callback to call when an animation loops
  13269. * @returns the animatable object created for this animation
  13270. */
  13271. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13272. /**
  13273. * Will start the animation sequence of a given target
  13274. * @param target defines the target
  13275. * @param from defines from which frame should animation start
  13276. * @param to defines until which frame should animation run.
  13277. * @param loop defines if the animation loops
  13278. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13279. * @param onAnimationEnd defines the function to be executed when the animation ends
  13280. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13281. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13282. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13283. * @param onAnimationLoop defines the callback to call when an animation loops
  13284. * @returns the animatable object created for this animation
  13285. */
  13286. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13287. /**
  13288. * Will start the animation sequence of a given target and its hierarchy
  13289. * @param target defines the target
  13290. * @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.
  13291. * @param from defines from which frame should animation start
  13292. * @param to defines until which frame should animation run.
  13293. * @param loop defines if the animation loops
  13294. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13295. * @param onAnimationEnd defines the function to be executed when the animation ends
  13296. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13297. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13298. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13299. * @param onAnimationLoop defines the callback to call when an animation loops
  13300. * @returns the list of created animatables
  13301. */
  13302. 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[];
  13303. /**
  13304. * Begin a new animation on a given node
  13305. * @param target defines the target where the animation will take place
  13306. * @param animations defines the list of animations to start
  13307. * @param from defines the initial value
  13308. * @param to defines the final value
  13309. * @param loop defines if you want animation to loop (off by default)
  13310. * @param speedRatio defines the speed ratio to apply to all animations
  13311. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13312. * @param onAnimationLoop defines the callback to call when an animation loops
  13313. * @returns the list of created animatables
  13314. */
  13315. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13316. /**
  13317. * Begin a new animation on a given node and its hierarchy
  13318. * @param target defines the root node where the animation will take place
  13319. * @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.
  13320. * @param animations defines the list of animations to start
  13321. * @param from defines the initial value
  13322. * @param to defines the final value
  13323. * @param loop defines if you want animation to loop (off by default)
  13324. * @param speedRatio defines the speed ratio to apply to all animations
  13325. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13326. * @param onAnimationLoop defines the callback to call when an animation loops
  13327. * @returns the list of animatables created for all nodes
  13328. */
  13329. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13330. /**
  13331. * Gets the animatable associated with a specific target
  13332. * @param target defines the target of the animatable
  13333. * @returns the required animatable if found
  13334. */
  13335. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13336. /**
  13337. * Gets all animatables associated with a given target
  13338. * @param target defines the target to look animatables for
  13339. * @returns an array of Animatables
  13340. */
  13341. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13342. /**
  13343. * Stops and removes all animations that have been applied to the scene
  13344. */
  13345. stopAllAnimations(): void;
  13346. }
  13347. }
  13348. module "babylonjs/Bones/bone" {
  13349. interface Bone {
  13350. /**
  13351. * Copy an animation range from another bone
  13352. * @param source defines the source bone
  13353. * @param rangeName defines the range name to copy
  13354. * @param frameOffset defines the frame offset
  13355. * @param rescaleAsRequired defines if rescaling must be applied if required
  13356. * @param skelDimensionsRatio defines the scaling ratio
  13357. * @returns true if operation was successful
  13358. */
  13359. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13360. }
  13361. }
  13362. }
  13363. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13364. /**
  13365. * Class used to override all child animations of a given target
  13366. */
  13367. export class AnimationPropertiesOverride {
  13368. /**
  13369. * Gets or sets a value indicating if animation blending must be used
  13370. */
  13371. enableBlending: boolean;
  13372. /**
  13373. * Gets or sets the blending speed to use when enableBlending is true
  13374. */
  13375. blendingSpeed: number;
  13376. /**
  13377. * Gets or sets the default loop mode to use
  13378. */
  13379. loopMode: number;
  13380. }
  13381. }
  13382. declare module "babylonjs/Bones/skeleton" {
  13383. import { Bone } from "babylonjs/Bones/bone";
  13384. import { Observable } from "babylonjs/Misc/observable";
  13385. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13386. import { Scene } from "babylonjs/scene";
  13387. import { Nullable } from "babylonjs/types";
  13388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13389. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13390. import { Animatable } from "babylonjs/Animations/animatable";
  13391. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13392. import { Animation } from "babylonjs/Animations/animation";
  13393. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13394. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13396. /**
  13397. * Class used to handle skinning animations
  13398. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13399. */
  13400. export class Skeleton implements IAnimatable {
  13401. /** defines the skeleton name */
  13402. name: string;
  13403. /** defines the skeleton Id */
  13404. id: string;
  13405. /**
  13406. * Defines the list of child bones
  13407. */
  13408. bones: Bone[];
  13409. /**
  13410. * Defines an estimate of the dimension of the skeleton at rest
  13411. */
  13412. dimensionsAtRest: Vector3;
  13413. /**
  13414. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13415. */
  13416. needInitialSkinMatrix: boolean;
  13417. /**
  13418. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13419. */
  13420. overrideMesh: Nullable<AbstractMesh>;
  13421. /**
  13422. * Gets the list of animations attached to this skeleton
  13423. */
  13424. animations: Array<Animation>;
  13425. private _scene;
  13426. private _isDirty;
  13427. private _transformMatrices;
  13428. private _transformMatrixTexture;
  13429. private _meshesWithPoseMatrix;
  13430. private _animatables;
  13431. private _identity;
  13432. private _synchronizedWithMesh;
  13433. private _ranges;
  13434. private _lastAbsoluteTransformsUpdateId;
  13435. private _canUseTextureForBones;
  13436. private _uniqueId;
  13437. /** @hidden */
  13438. _numBonesWithLinkedTransformNode: number;
  13439. /** @hidden */
  13440. _hasWaitingData: Nullable<boolean>;
  13441. /**
  13442. * Specifies if the skeleton should be serialized
  13443. */
  13444. doNotSerialize: boolean;
  13445. private _useTextureToStoreBoneMatrices;
  13446. /**
  13447. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13448. * Please note that this option is not available if the hardware does not support it
  13449. */
  13450. useTextureToStoreBoneMatrices: boolean;
  13451. private _animationPropertiesOverride;
  13452. /**
  13453. * Gets or sets the animation properties override
  13454. */
  13455. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13456. /**
  13457. * List of inspectable custom properties (used by the Inspector)
  13458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13459. */
  13460. inspectableCustomProperties: IInspectable[];
  13461. /**
  13462. * An observable triggered before computing the skeleton's matrices
  13463. */
  13464. onBeforeComputeObservable: Observable<Skeleton>;
  13465. /**
  13466. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13467. */
  13468. readonly isUsingTextureForMatrices: boolean;
  13469. /**
  13470. * Gets the unique ID of this skeleton
  13471. */
  13472. readonly uniqueId: number;
  13473. /**
  13474. * Creates a new skeleton
  13475. * @param name defines the skeleton name
  13476. * @param id defines the skeleton Id
  13477. * @param scene defines the hosting scene
  13478. */
  13479. constructor(
  13480. /** defines the skeleton name */
  13481. name: string,
  13482. /** defines the skeleton Id */
  13483. id: string, scene: Scene);
  13484. /**
  13485. * Gets the current object class name.
  13486. * @return the class name
  13487. */
  13488. getClassName(): string;
  13489. /**
  13490. * Returns an array containing the root bones
  13491. * @returns an array containing the root bones
  13492. */
  13493. getChildren(): Array<Bone>;
  13494. /**
  13495. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13496. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13497. * @returns a Float32Array containing matrices data
  13498. */
  13499. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13500. /**
  13501. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13502. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13503. * @returns a raw texture containing the data
  13504. */
  13505. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13506. /**
  13507. * Gets the current hosting scene
  13508. * @returns a scene object
  13509. */
  13510. getScene(): Scene;
  13511. /**
  13512. * Gets a string representing the current skeleton data
  13513. * @param fullDetails defines a boolean indicating if we want a verbose version
  13514. * @returns a string representing the current skeleton data
  13515. */
  13516. toString(fullDetails?: boolean): string;
  13517. /**
  13518. * Get bone's index searching by name
  13519. * @param name defines bone's name to search for
  13520. * @return the indice of the bone. Returns -1 if not found
  13521. */
  13522. getBoneIndexByName(name: string): number;
  13523. /**
  13524. * Creater a new animation range
  13525. * @param name defines the name of the range
  13526. * @param from defines the start key
  13527. * @param to defines the end key
  13528. */
  13529. createAnimationRange(name: string, from: number, to: number): void;
  13530. /**
  13531. * Delete a specific animation range
  13532. * @param name defines the name of the range
  13533. * @param deleteFrames defines if frames must be removed as well
  13534. */
  13535. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13536. /**
  13537. * Gets a specific animation range
  13538. * @param name defines the name of the range to look for
  13539. * @returns the requested animation range or null if not found
  13540. */
  13541. getAnimationRange(name: string): Nullable<AnimationRange>;
  13542. /**
  13543. * Gets the list of all animation ranges defined on this skeleton
  13544. * @returns an array
  13545. */
  13546. getAnimationRanges(): Nullable<AnimationRange>[];
  13547. /**
  13548. * Copy animation range from a source skeleton.
  13549. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13550. * @param source defines the source skeleton
  13551. * @param name defines the name of the range to copy
  13552. * @param rescaleAsRequired defines if rescaling must be applied if required
  13553. * @returns true if operation was successful
  13554. */
  13555. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13556. /**
  13557. * Forces the skeleton to go to rest pose
  13558. */
  13559. returnToRest(): void;
  13560. private _getHighestAnimationFrame;
  13561. /**
  13562. * Begin a specific animation range
  13563. * @param name defines the name of the range to start
  13564. * @param loop defines if looping must be turned on (false by default)
  13565. * @param speedRatio defines the speed ratio to apply (1 by default)
  13566. * @param onAnimationEnd defines a callback which will be called when animation will end
  13567. * @returns a new animatable
  13568. */
  13569. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13570. /** @hidden */
  13571. _markAsDirty(): void;
  13572. /** @hidden */
  13573. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13574. /** @hidden */
  13575. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13576. private _computeTransformMatrices;
  13577. /**
  13578. * Build all resources required to render a skeleton
  13579. */
  13580. prepare(): void;
  13581. /**
  13582. * Gets the list of animatables currently running for this skeleton
  13583. * @returns an array of animatables
  13584. */
  13585. getAnimatables(): IAnimatable[];
  13586. /**
  13587. * Clone the current skeleton
  13588. * @param name defines the name of the new skeleton
  13589. * @param id defines the id of the new skeleton
  13590. * @returns the new skeleton
  13591. */
  13592. clone(name: string, id: string): Skeleton;
  13593. /**
  13594. * Enable animation blending for this skeleton
  13595. * @param blendingSpeed defines the blending speed to apply
  13596. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13597. */
  13598. enableBlending(blendingSpeed?: number): void;
  13599. /**
  13600. * Releases all resources associated with the current skeleton
  13601. */
  13602. dispose(): void;
  13603. /**
  13604. * Serialize the skeleton in a JSON object
  13605. * @returns a JSON object
  13606. */
  13607. serialize(): any;
  13608. /**
  13609. * Creates a new skeleton from serialized data
  13610. * @param parsedSkeleton defines the serialized data
  13611. * @param scene defines the hosting scene
  13612. * @returns a new skeleton
  13613. */
  13614. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13615. /**
  13616. * Compute all node absolute transforms
  13617. * @param forceUpdate defines if computation must be done even if cache is up to date
  13618. */
  13619. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13620. /**
  13621. * Gets the root pose matrix
  13622. * @returns a matrix
  13623. */
  13624. getPoseMatrix(): Nullable<Matrix>;
  13625. /**
  13626. * Sorts bones per internal index
  13627. */
  13628. sortBones(): void;
  13629. private _sortBones;
  13630. }
  13631. }
  13632. declare module "babylonjs/Bones/bone" {
  13633. import { Skeleton } from "babylonjs/Bones/skeleton";
  13634. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13635. import { Nullable } from "babylonjs/types";
  13636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13638. import { Node } from "babylonjs/node";
  13639. import { Space } from "babylonjs/Maths/math.axis";
  13640. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13641. /**
  13642. * Class used to store bone information
  13643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13644. */
  13645. export class Bone extends Node {
  13646. /**
  13647. * defines the bone name
  13648. */
  13649. name: string;
  13650. private static _tmpVecs;
  13651. private static _tmpQuat;
  13652. private static _tmpMats;
  13653. /**
  13654. * Gets the list of child bones
  13655. */
  13656. children: Bone[];
  13657. /** Gets the animations associated with this bone */
  13658. animations: import("babylonjs/Animations/animation").Animation[];
  13659. /**
  13660. * Gets or sets bone length
  13661. */
  13662. length: number;
  13663. /**
  13664. * @hidden Internal only
  13665. * Set this value to map this bone to a different index in the transform matrices
  13666. * Set this value to -1 to exclude the bone from the transform matrices
  13667. */
  13668. _index: Nullable<number>;
  13669. private _skeleton;
  13670. private _localMatrix;
  13671. private _restPose;
  13672. private _baseMatrix;
  13673. private _absoluteTransform;
  13674. private _invertedAbsoluteTransform;
  13675. private _parent;
  13676. private _scalingDeterminant;
  13677. private _worldTransform;
  13678. private _localScaling;
  13679. private _localRotation;
  13680. private _localPosition;
  13681. private _needToDecompose;
  13682. private _needToCompose;
  13683. /** @hidden */
  13684. _linkedTransformNode: Nullable<TransformNode>;
  13685. /** @hidden */
  13686. _waitingTransformNodeId: Nullable<string>;
  13687. /** @hidden */
  13688. /** @hidden */
  13689. _matrix: Matrix;
  13690. /**
  13691. * Create a new bone
  13692. * @param name defines the bone name
  13693. * @param skeleton defines the parent skeleton
  13694. * @param parentBone defines the parent (can be null if the bone is the root)
  13695. * @param localMatrix defines the local matrix
  13696. * @param restPose defines the rest pose matrix
  13697. * @param baseMatrix defines the base matrix
  13698. * @param index defines index of the bone in the hiearchy
  13699. */
  13700. constructor(
  13701. /**
  13702. * defines the bone name
  13703. */
  13704. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13705. /**
  13706. * Gets the current object class name.
  13707. * @return the class name
  13708. */
  13709. getClassName(): string;
  13710. /**
  13711. * Gets the parent skeleton
  13712. * @returns a skeleton
  13713. */
  13714. getSkeleton(): Skeleton;
  13715. /**
  13716. * Gets parent bone
  13717. * @returns a bone or null if the bone is the root of the bone hierarchy
  13718. */
  13719. getParent(): Nullable<Bone>;
  13720. /**
  13721. * Returns an array containing the root bones
  13722. * @returns an array containing the root bones
  13723. */
  13724. getChildren(): Array<Bone>;
  13725. /**
  13726. * Sets the parent bone
  13727. * @param parent defines the parent (can be null if the bone is the root)
  13728. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13729. */
  13730. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13731. /**
  13732. * Gets the local matrix
  13733. * @returns a matrix
  13734. */
  13735. getLocalMatrix(): Matrix;
  13736. /**
  13737. * Gets the base matrix (initial matrix which remains unchanged)
  13738. * @returns a matrix
  13739. */
  13740. getBaseMatrix(): Matrix;
  13741. /**
  13742. * Gets the rest pose matrix
  13743. * @returns a matrix
  13744. */
  13745. getRestPose(): Matrix;
  13746. /**
  13747. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13748. */
  13749. getWorldMatrix(): Matrix;
  13750. /**
  13751. * Sets the local matrix to rest pose matrix
  13752. */
  13753. returnToRest(): void;
  13754. /**
  13755. * Gets the inverse of the absolute transform matrix.
  13756. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13757. * @returns a matrix
  13758. */
  13759. getInvertedAbsoluteTransform(): Matrix;
  13760. /**
  13761. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13762. * @returns a matrix
  13763. */
  13764. getAbsoluteTransform(): Matrix;
  13765. /**
  13766. * Links with the given transform node.
  13767. * The local matrix of this bone is copied from the transform node every frame.
  13768. * @param transformNode defines the transform node to link to
  13769. */
  13770. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13771. /**
  13772. * Gets the node used to drive the bone's transformation
  13773. * @returns a transform node or null
  13774. */
  13775. getTransformNode(): Nullable<TransformNode>;
  13776. /** Gets or sets current position (in local space) */
  13777. position: Vector3;
  13778. /** Gets or sets current rotation (in local space) */
  13779. rotation: Vector3;
  13780. /** Gets or sets current rotation quaternion (in local space) */
  13781. rotationQuaternion: Quaternion;
  13782. /** Gets or sets current scaling (in local space) */
  13783. scaling: Vector3;
  13784. /**
  13785. * Gets the animation properties override
  13786. */
  13787. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13788. private _decompose;
  13789. private _compose;
  13790. /**
  13791. * Update the base and local matrices
  13792. * @param matrix defines the new base or local matrix
  13793. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13794. * @param updateLocalMatrix defines if the local matrix should be updated
  13795. */
  13796. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13797. /** @hidden */
  13798. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13799. /**
  13800. * Flag the bone as dirty (Forcing it to update everything)
  13801. */
  13802. markAsDirty(): void;
  13803. /** @hidden */
  13804. _markAsDirtyAndCompose(): void;
  13805. private _markAsDirtyAndDecompose;
  13806. /**
  13807. * Translate the bone in local or world space
  13808. * @param vec The amount to translate the bone
  13809. * @param space The space that the translation is in
  13810. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13811. */
  13812. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13813. /**
  13814. * Set the postion of the bone in local or world space
  13815. * @param position The position to set the bone
  13816. * @param space The space that the position is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the absolute position of the bone (world space)
  13822. * @param position The position to set the bone
  13823. * @param mesh The mesh that this bone is attached to
  13824. */
  13825. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13826. /**
  13827. * Scale the bone on the x, y and z axes (in local space)
  13828. * @param x The amount to scale the bone on the x axis
  13829. * @param y The amount to scale the bone on the y axis
  13830. * @param z The amount to scale the bone on the z axis
  13831. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13832. */
  13833. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13834. /**
  13835. * Set the bone scaling in local space
  13836. * @param scale defines the scaling vector
  13837. */
  13838. setScale(scale: Vector3): void;
  13839. /**
  13840. * Gets the current scaling in local space
  13841. * @returns the current scaling vector
  13842. */
  13843. getScale(): Vector3;
  13844. /**
  13845. * Gets the current scaling in local space and stores it in a target vector
  13846. * @param result defines the target vector
  13847. */
  13848. getScaleToRef(result: Vector3): void;
  13849. /**
  13850. * Set the yaw, pitch, and roll of the bone in local or world space
  13851. * @param yaw The rotation of the bone on the y axis
  13852. * @param pitch The rotation of the bone on the x axis
  13853. * @param roll The rotation of the bone on the z axis
  13854. * @param space The space that the axes of rotation are in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. */
  13857. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13858. /**
  13859. * Add a rotation to the bone on an axis in local or world space
  13860. * @param axis The axis to rotate the bone on
  13861. * @param amount The amount to rotate the bone
  13862. * @param space The space that the axis is in
  13863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13864. */
  13865. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13866. /**
  13867. * Set the rotation of the bone to a particular axis angle in local or world space
  13868. * @param axis The axis to rotate the bone on
  13869. * @param angle The angle that the bone should be rotated to
  13870. * @param space The space that the axis is in
  13871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13872. */
  13873. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13874. /**
  13875. * Set the euler rotation of the bone in local of world space
  13876. * @param rotation The euler rotation that the bone should be set to
  13877. * @param space The space that the rotation is in
  13878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13879. */
  13880. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13881. /**
  13882. * Set the quaternion rotation of the bone in local of world space
  13883. * @param quat The quaternion rotation that the bone should be set to
  13884. * @param space The space that the rotation is in
  13885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13886. */
  13887. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13888. /**
  13889. * Set the rotation matrix of the bone in local of world space
  13890. * @param rotMat The rotation matrix that the bone should be set to
  13891. * @param space The space that the rotation is in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. */
  13894. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13895. private _rotateWithMatrix;
  13896. private _getNegativeRotationToRef;
  13897. /**
  13898. * Get the position of the bone in local or world space
  13899. * @param space The space that the returned position is in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. * @returns The position of the bone
  13902. */
  13903. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13904. /**
  13905. * Copy the position of the bone to a vector3 in local or world space
  13906. * @param space The space that the returned position is in
  13907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13908. * @param result The vector3 to copy the position to
  13909. */
  13910. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13911. /**
  13912. * Get the absolute position of the bone (world space)
  13913. * @param mesh The mesh that this bone is attached to
  13914. * @returns The absolute position of the bone
  13915. */
  13916. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13917. /**
  13918. * Copy the absolute position of the bone (world space) to the result param
  13919. * @param mesh The mesh that this bone is attached to
  13920. * @param result The vector3 to copy the absolute position to
  13921. */
  13922. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13923. /**
  13924. * Compute the absolute transforms of this bone and its children
  13925. */
  13926. computeAbsoluteTransforms(): void;
  13927. /**
  13928. * Get the world direction from an axis that is in the local space of the bone
  13929. * @param localAxis The local direction that is used to compute the world direction
  13930. * @param mesh The mesh that this bone is attached to
  13931. * @returns The world direction
  13932. */
  13933. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13934. /**
  13935. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13936. * @param localAxis The local direction that is used to compute the world direction
  13937. * @param mesh The mesh that this bone is attached to
  13938. * @param result The vector3 that the world direction will be copied to
  13939. */
  13940. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13941. /**
  13942. * Get the euler rotation of the bone in local or world space
  13943. * @param space The space that the rotation should be in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. * @returns The euler rotation
  13946. */
  13947. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13948. /**
  13949. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13950. * @param space The space that the rotation should be in
  13951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13952. * @param result The vector3 that the rotation should be copied to
  13953. */
  13954. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13955. /**
  13956. * Get the quaternion rotation of the bone in either local or world space
  13957. * @param space The space that the rotation should be in
  13958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13959. * @returns The quaternion rotation
  13960. */
  13961. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13962. /**
  13963. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13964. * @param space The space that the rotation should be in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. * @param result The quaternion that the rotation should be copied to
  13967. */
  13968. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13969. /**
  13970. * Get the rotation matrix of the bone in local or world space
  13971. * @param space The space that the rotation should be in
  13972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13973. * @returns The rotation matrix
  13974. */
  13975. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13976. /**
  13977. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13978. * @param space The space that the rotation should be in
  13979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13980. * @param result The quaternion that the rotation should be copied to
  13981. */
  13982. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13983. /**
  13984. * Get the world position of a point that is in the local space of the bone
  13985. * @param position The local position
  13986. * @param mesh The mesh that this bone is attached to
  13987. * @returns The world position
  13988. */
  13989. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13990. /**
  13991. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13992. * @param position The local position
  13993. * @param mesh The mesh that this bone is attached to
  13994. * @param result The vector3 that the world position should be copied to
  13995. */
  13996. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13997. /**
  13998. * Get the local position of a point that is in world space
  13999. * @param position The world position
  14000. * @param mesh The mesh that this bone is attached to
  14001. * @returns The local position
  14002. */
  14003. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14004. /**
  14005. * Get the local position of a point that is in world space and copy it to the result param
  14006. * @param position The world position
  14007. * @param mesh The mesh that this bone is attached to
  14008. * @param result The vector3 that the local position should be copied to
  14009. */
  14010. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14011. }
  14012. }
  14013. declare module "babylonjs/Meshes/transformNode" {
  14014. import { DeepImmutable } from "babylonjs/types";
  14015. import { Observable } from "babylonjs/Misc/observable";
  14016. import { Nullable } from "babylonjs/types";
  14017. import { Camera } from "babylonjs/Cameras/camera";
  14018. import { Scene } from "babylonjs/scene";
  14019. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14020. import { Node } from "babylonjs/node";
  14021. import { Bone } from "babylonjs/Bones/bone";
  14022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14023. import { Space } from "babylonjs/Maths/math.axis";
  14024. /**
  14025. * 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.
  14026. * @see https://doc.babylonjs.com/how_to/transformnode
  14027. */
  14028. export class TransformNode extends Node {
  14029. /**
  14030. * Object will not rotate to face the camera
  14031. */
  14032. static BILLBOARDMODE_NONE: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the x axis
  14035. */
  14036. static BILLBOARDMODE_X: number;
  14037. /**
  14038. * Object will rotate to face the camera but only on the y axis
  14039. */
  14040. static BILLBOARDMODE_Y: number;
  14041. /**
  14042. * Object will rotate to face the camera but only on the z axis
  14043. */
  14044. static BILLBOARDMODE_Z: number;
  14045. /**
  14046. * Object will rotate to face the camera
  14047. */
  14048. static BILLBOARDMODE_ALL: number;
  14049. /**
  14050. * Object will rotate to face the camera's position instead of orientation
  14051. */
  14052. static BILLBOARDMODE_USE_POSITION: number;
  14053. private _forward;
  14054. private _forwardInverted;
  14055. private _up;
  14056. private _right;
  14057. private _rightInverted;
  14058. private _position;
  14059. private _rotation;
  14060. private _rotationQuaternion;
  14061. protected _scaling: Vector3;
  14062. protected _isDirty: boolean;
  14063. private _transformToBoneReferal;
  14064. private _isAbsoluteSynced;
  14065. private _billboardMode;
  14066. /**
  14067. * Gets or sets the billboard mode. Default is 0.
  14068. *
  14069. * | Value | Type | Description |
  14070. * | --- | --- | --- |
  14071. * | 0 | BILLBOARDMODE_NONE | |
  14072. * | 1 | BILLBOARDMODE_X | |
  14073. * | 2 | BILLBOARDMODE_Y | |
  14074. * | 4 | BILLBOARDMODE_Z | |
  14075. * | 7 | BILLBOARDMODE_ALL | |
  14076. *
  14077. */
  14078. billboardMode: number;
  14079. private _preserveParentRotationForBillboard;
  14080. /**
  14081. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14082. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14083. */
  14084. preserveParentRotationForBillboard: boolean;
  14085. /**
  14086. * 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
  14087. */
  14088. scalingDeterminant: number;
  14089. private _infiniteDistance;
  14090. /**
  14091. * Gets or sets the distance of the object to max, often used by skybox
  14092. */
  14093. infiniteDistance: boolean;
  14094. /**
  14095. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14096. * By default the system will update normals to compensate
  14097. */
  14098. ignoreNonUniformScaling: boolean;
  14099. /**
  14100. * 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
  14101. */
  14102. reIntegrateRotationIntoRotationQuaternion: boolean;
  14103. /** @hidden */
  14104. _poseMatrix: Nullable<Matrix>;
  14105. /** @hidden */
  14106. _localMatrix: Matrix;
  14107. private _usePivotMatrix;
  14108. private _absolutePosition;
  14109. private _absoluteScaling;
  14110. private _absoluteRotationQuaternion;
  14111. private _pivotMatrix;
  14112. private _pivotMatrixInverse;
  14113. protected _postMultiplyPivotMatrix: boolean;
  14114. protected _isWorldMatrixFrozen: boolean;
  14115. /** @hidden */
  14116. _indexInSceneTransformNodesArray: number;
  14117. /**
  14118. * An event triggered after the world matrix is updated
  14119. */
  14120. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14121. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14122. /**
  14123. * Gets a string identifying the name of the class
  14124. * @returns "TransformNode" string
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14129. */
  14130. position: Vector3;
  14131. /**
  14132. * 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)).
  14133. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14134. */
  14135. rotation: Vector3;
  14136. /**
  14137. * 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)).
  14138. */
  14139. scaling: Vector3;
  14140. /**
  14141. * 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).
  14142. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14143. */
  14144. rotationQuaternion: Nullable<Quaternion>;
  14145. /**
  14146. * The forward direction of that transform in world space.
  14147. */
  14148. readonly forward: Vector3;
  14149. /**
  14150. * The up direction of that transform in world space.
  14151. */
  14152. readonly up: Vector3;
  14153. /**
  14154. * The right direction of that transform in world space.
  14155. */
  14156. readonly right: Vector3;
  14157. /**
  14158. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14159. * @param matrix the matrix to copy the pose from
  14160. * @returns this TransformNode.
  14161. */
  14162. updatePoseMatrix(matrix: Matrix): TransformNode;
  14163. /**
  14164. * Returns the mesh Pose matrix.
  14165. * @returns the pose matrix
  14166. */
  14167. getPoseMatrix(): Matrix;
  14168. /** @hidden */
  14169. _isSynchronized(): boolean;
  14170. /** @hidden */
  14171. _initCache(): void;
  14172. /**
  14173. * Flag the transform node as dirty (Forcing it to update everything)
  14174. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14175. * @returns this transform node
  14176. */
  14177. markAsDirty(property: string): TransformNode;
  14178. /**
  14179. * Returns the current mesh absolute position.
  14180. * Returns a Vector3.
  14181. */
  14182. readonly absolutePosition: Vector3;
  14183. /**
  14184. * Returns the current mesh absolute scaling.
  14185. * Returns a Vector3.
  14186. */
  14187. readonly absoluteScaling: Vector3;
  14188. /**
  14189. * Returns the current mesh absolute rotation.
  14190. * Returns a Quaternion.
  14191. */
  14192. readonly absoluteRotationQuaternion: Quaternion;
  14193. /**
  14194. * Sets a new matrix to apply before all other transformation
  14195. * @param matrix defines the transform matrix
  14196. * @returns the current TransformNode
  14197. */
  14198. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14199. /**
  14200. * Sets a new pivot matrix to the current node
  14201. * @param matrix defines the new pivot matrix to use
  14202. * @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
  14203. * @returns the current TransformNode
  14204. */
  14205. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14206. /**
  14207. * Returns the mesh pivot matrix.
  14208. * Default : Identity.
  14209. * @returns the matrix
  14210. */
  14211. getPivotMatrix(): Matrix;
  14212. /**
  14213. * Instantiate (when possible) or clone that node with its hierarchy
  14214. * @param newParent defines the new parent to use for the instance (or clone)
  14215. * @returns an instance (or a clone) of the current node with its hiearchy
  14216. */
  14217. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14218. /**
  14219. * Prevents the World matrix to be computed any longer
  14220. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14221. * @returns the TransformNode.
  14222. */
  14223. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14224. /**
  14225. * Allows back the World matrix computation.
  14226. * @returns the TransformNode.
  14227. */
  14228. unfreezeWorldMatrix(): this;
  14229. /**
  14230. * True if the World matrix has been frozen.
  14231. */
  14232. readonly isWorldMatrixFrozen: boolean;
  14233. /**
  14234. * Retuns the mesh absolute position in the World.
  14235. * @returns a Vector3.
  14236. */
  14237. getAbsolutePosition(): Vector3;
  14238. /**
  14239. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14240. * @param absolutePosition the absolute position to set
  14241. * @returns the TransformNode.
  14242. */
  14243. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14244. /**
  14245. * Sets the mesh position in its local space.
  14246. * @param vector3 the position to set in localspace
  14247. * @returns the TransformNode.
  14248. */
  14249. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14250. /**
  14251. * Returns the mesh position in the local space from the current World matrix values.
  14252. * @returns a new Vector3.
  14253. */
  14254. getPositionExpressedInLocalSpace(): Vector3;
  14255. /**
  14256. * Translates the mesh along the passed Vector3 in its local space.
  14257. * @param vector3 the distance to translate in localspace
  14258. * @returns the TransformNode.
  14259. */
  14260. locallyTranslate(vector3: Vector3): TransformNode;
  14261. private static _lookAtVectorCache;
  14262. /**
  14263. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14264. * @param targetPoint the position (must be in same space as current mesh) to look at
  14265. * @param yawCor optional yaw (y-axis) correction in radians
  14266. * @param pitchCor optional pitch (x-axis) correction in radians
  14267. * @param rollCor optional roll (z-axis) correction in radians
  14268. * @param space the choosen space of the target
  14269. * @returns the TransformNode.
  14270. */
  14271. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14272. /**
  14273. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14274. * This Vector3 is expressed in the World space.
  14275. * @param localAxis axis to rotate
  14276. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14277. */
  14278. getDirection(localAxis: Vector3): Vector3;
  14279. /**
  14280. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14281. * localAxis is expressed in the mesh local space.
  14282. * result is computed in the Wordl space from the mesh World matrix.
  14283. * @param localAxis axis to rotate
  14284. * @param result the resulting transformnode
  14285. * @returns this TransformNode.
  14286. */
  14287. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14288. /**
  14289. * Sets this transform node rotation to the given local axis.
  14290. * @param localAxis the axis in local space
  14291. * @param yawCor optional yaw (y-axis) correction in radians
  14292. * @param pitchCor optional pitch (x-axis) correction in radians
  14293. * @param rollCor optional roll (z-axis) correction in radians
  14294. * @returns this TransformNode
  14295. */
  14296. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14297. /**
  14298. * Sets a new pivot point to the current node
  14299. * @param point defines the new pivot point to use
  14300. * @param space defines if the point is in world or local space (local by default)
  14301. * @returns the current TransformNode
  14302. */
  14303. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14304. /**
  14305. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14306. * @returns the pivot point
  14307. */
  14308. getPivotPoint(): Vector3;
  14309. /**
  14310. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14311. * @param result the vector3 to store the result
  14312. * @returns this TransformNode.
  14313. */
  14314. getPivotPointToRef(result: Vector3): TransformNode;
  14315. /**
  14316. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14317. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14318. */
  14319. getAbsolutePivotPoint(): Vector3;
  14320. /**
  14321. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14322. * @param result vector3 to store the result
  14323. * @returns this TransformNode.
  14324. */
  14325. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14326. /**
  14327. * Defines the passed node as the parent of the current node.
  14328. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14329. * @see https://doc.babylonjs.com/how_to/parenting
  14330. * @param node the node ot set as the parent
  14331. * @returns this TransformNode.
  14332. */
  14333. setParent(node: Nullable<Node>): TransformNode;
  14334. private _nonUniformScaling;
  14335. /**
  14336. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14337. */
  14338. readonly nonUniformScaling: boolean;
  14339. /** @hidden */
  14340. _updateNonUniformScalingState(value: boolean): boolean;
  14341. /**
  14342. * Attach the current TransformNode to another TransformNode associated with a bone
  14343. * @param bone Bone affecting the TransformNode
  14344. * @param affectedTransformNode TransformNode associated with the bone
  14345. * @returns this object
  14346. */
  14347. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14348. /**
  14349. * Detach the transform node if its associated with a bone
  14350. * @returns this object
  14351. */
  14352. detachFromBone(): TransformNode;
  14353. private static _rotationAxisCache;
  14354. /**
  14355. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14356. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14357. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14358. * The passed axis is also normalized.
  14359. * @param axis the axis to rotate around
  14360. * @param amount the amount to rotate in radians
  14361. * @param space Space to rotate in (Default: local)
  14362. * @returns the TransformNode.
  14363. */
  14364. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14365. /**
  14366. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14367. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14368. * The passed axis is also normalized. .
  14369. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14370. * @param point the point to rotate around
  14371. * @param axis the axis to rotate around
  14372. * @param amount the amount to rotate in radians
  14373. * @returns the TransformNode
  14374. */
  14375. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14376. /**
  14377. * Translates the mesh along the axis vector for the passed distance in the given space.
  14378. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14379. * @param axis the axis to translate in
  14380. * @param distance the distance to translate
  14381. * @param space Space to rotate in (Default: local)
  14382. * @returns the TransformNode.
  14383. */
  14384. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14385. /**
  14386. * Adds a rotation step to the mesh current rotation.
  14387. * x, y, z are Euler angles expressed in radians.
  14388. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14389. * This means this rotation is made in the mesh local space only.
  14390. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14391. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14392. * ```javascript
  14393. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14394. * ```
  14395. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14396. * 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.
  14397. * @param x Rotation to add
  14398. * @param y Rotation to add
  14399. * @param z Rotation to add
  14400. * @returns the TransformNode.
  14401. */
  14402. addRotation(x: number, y: number, z: number): TransformNode;
  14403. /**
  14404. * @hidden
  14405. */
  14406. protected _getEffectiveParent(): Nullable<Node>;
  14407. /**
  14408. * Computes the world matrix of the node
  14409. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14410. * @returns the world matrix
  14411. */
  14412. computeWorldMatrix(force?: boolean): Matrix;
  14413. protected _afterComputeWorldMatrix(): void;
  14414. /**
  14415. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14416. * @param func callback function to add
  14417. *
  14418. * @returns the TransformNode.
  14419. */
  14420. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14421. /**
  14422. * Removes a registered callback function.
  14423. * @param func callback function to remove
  14424. * @returns the TransformNode.
  14425. */
  14426. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14427. /**
  14428. * Gets the position of the current mesh in camera space
  14429. * @param camera defines the camera to use
  14430. * @returns a position
  14431. */
  14432. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14433. /**
  14434. * Returns the distance from the mesh to the active camera
  14435. * @param camera defines the camera to use
  14436. * @returns the distance
  14437. */
  14438. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14439. /**
  14440. * Clone the current transform node
  14441. * @param name Name of the new clone
  14442. * @param newParent New parent for the clone
  14443. * @param doNotCloneChildren Do not clone children hierarchy
  14444. * @returns the new transform node
  14445. */
  14446. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14447. /**
  14448. * Serializes the objects information.
  14449. * @param currentSerializationObject defines the object to serialize in
  14450. * @returns the serialized object
  14451. */
  14452. serialize(currentSerializationObject?: any): any;
  14453. /**
  14454. * Returns a new TransformNode object parsed from the source provided.
  14455. * @param parsedTransformNode is the source.
  14456. * @param scene the scne the object belongs to
  14457. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14458. * @returns a new TransformNode object parsed from the source provided.
  14459. */
  14460. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14461. /**
  14462. * Get all child-transformNodes of this node
  14463. * @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
  14464. * @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
  14465. * @returns an array of TransformNode
  14466. */
  14467. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14468. /**
  14469. * Releases resources associated with this transform node.
  14470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14472. */
  14473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14474. /**
  14475. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14476. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14477. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14478. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14479. * @returns the current mesh
  14480. */
  14481. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14482. private _syncAbsoluteScalingAndRotation;
  14483. }
  14484. }
  14485. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14486. import { Observable } from "babylonjs/Misc/observable";
  14487. import { Nullable } from "babylonjs/types";
  14488. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14489. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14491. import { Ray } from "babylonjs/Culling/ray";
  14492. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14493. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14494. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14495. /**
  14496. * Defines the types of pose enabled controllers that are supported
  14497. */
  14498. export enum PoseEnabledControllerType {
  14499. /**
  14500. * HTC Vive
  14501. */
  14502. VIVE = 0,
  14503. /**
  14504. * Oculus Rift
  14505. */
  14506. OCULUS = 1,
  14507. /**
  14508. * Windows mixed reality
  14509. */
  14510. WINDOWS = 2,
  14511. /**
  14512. * Samsung gear VR
  14513. */
  14514. GEAR_VR = 3,
  14515. /**
  14516. * Google Daydream
  14517. */
  14518. DAYDREAM = 4,
  14519. /**
  14520. * Generic
  14521. */
  14522. GENERIC = 5
  14523. }
  14524. /**
  14525. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14526. */
  14527. export interface MutableGamepadButton {
  14528. /**
  14529. * Value of the button/trigger
  14530. */
  14531. value: number;
  14532. /**
  14533. * If the button/trigger is currently touched
  14534. */
  14535. touched: boolean;
  14536. /**
  14537. * If the button/trigger is currently pressed
  14538. */
  14539. pressed: boolean;
  14540. }
  14541. /**
  14542. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14543. * @hidden
  14544. */
  14545. export interface ExtendedGamepadButton extends GamepadButton {
  14546. /**
  14547. * If the button/trigger is currently pressed
  14548. */
  14549. readonly pressed: boolean;
  14550. /**
  14551. * If the button/trigger is currently touched
  14552. */
  14553. readonly touched: boolean;
  14554. /**
  14555. * Value of the button/trigger
  14556. */
  14557. readonly value: number;
  14558. }
  14559. /** @hidden */
  14560. export interface _GamePadFactory {
  14561. /**
  14562. * Returns wether or not the current gamepad can be created for this type of controller.
  14563. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14564. * @returns true if it can be created, otherwise false
  14565. */
  14566. canCreate(gamepadInfo: any): boolean;
  14567. /**
  14568. * Creates a new instance of the Gamepad.
  14569. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14570. * @returns the new gamepad instance
  14571. */
  14572. create(gamepadInfo: any): Gamepad;
  14573. }
  14574. /**
  14575. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14576. */
  14577. export class PoseEnabledControllerHelper {
  14578. /** @hidden */
  14579. static _ControllerFactories: _GamePadFactory[];
  14580. /** @hidden */
  14581. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14582. /**
  14583. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14584. * @param vrGamepad the gamepad to initialized
  14585. * @returns a vr controller of the type the gamepad identified as
  14586. */
  14587. static InitiateController(vrGamepad: any): Gamepad;
  14588. }
  14589. /**
  14590. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14591. */
  14592. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14593. /**
  14594. * If the controller is used in a webXR session
  14595. */
  14596. isXR: boolean;
  14597. private _deviceRoomPosition;
  14598. private _deviceRoomRotationQuaternion;
  14599. /**
  14600. * The device position in babylon space
  14601. */
  14602. devicePosition: Vector3;
  14603. /**
  14604. * The device rotation in babylon space
  14605. */
  14606. deviceRotationQuaternion: Quaternion;
  14607. /**
  14608. * The scale factor of the device in babylon space
  14609. */
  14610. deviceScaleFactor: number;
  14611. /**
  14612. * (Likely devicePosition should be used instead) The device position in its room space
  14613. */
  14614. position: Vector3;
  14615. /**
  14616. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14617. */
  14618. rotationQuaternion: Quaternion;
  14619. /**
  14620. * The type of controller (Eg. Windows mixed reality)
  14621. */
  14622. controllerType: PoseEnabledControllerType;
  14623. protected _calculatedPosition: Vector3;
  14624. private _calculatedRotation;
  14625. /**
  14626. * The raw pose from the device
  14627. */
  14628. rawPose: DevicePose;
  14629. private _trackPosition;
  14630. private _maxRotationDistFromHeadset;
  14631. private _draggedRoomRotation;
  14632. /**
  14633. * @hidden
  14634. */
  14635. _disableTrackPosition(fixedPosition: Vector3): void;
  14636. /**
  14637. * Internal, the mesh attached to the controller
  14638. * @hidden
  14639. */
  14640. _mesh: Nullable<AbstractMesh>;
  14641. private _poseControlledCamera;
  14642. private _leftHandSystemQuaternion;
  14643. /**
  14644. * Internal, matrix used to convert room space to babylon space
  14645. * @hidden
  14646. */
  14647. _deviceToWorld: Matrix;
  14648. /**
  14649. * Node to be used when casting a ray from the controller
  14650. * @hidden
  14651. */
  14652. _pointingPoseNode: Nullable<TransformNode>;
  14653. /**
  14654. * Name of the child mesh that can be used to cast a ray from the controller
  14655. */
  14656. static readonly POINTING_POSE: string;
  14657. /**
  14658. * Creates a new PoseEnabledController from a gamepad
  14659. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14660. */
  14661. constructor(browserGamepad: any);
  14662. private _workingMatrix;
  14663. /**
  14664. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14665. */
  14666. update(): void;
  14667. /**
  14668. * Updates only the pose device and mesh without doing any button event checking
  14669. */
  14670. protected _updatePoseAndMesh(): void;
  14671. /**
  14672. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14673. * @param poseData raw pose fromthe device
  14674. */
  14675. updateFromDevice(poseData: DevicePose): void;
  14676. /**
  14677. * @hidden
  14678. */
  14679. _meshAttachedObservable: Observable<AbstractMesh>;
  14680. /**
  14681. * Attaches a mesh to the controller
  14682. * @param mesh the mesh to be attached
  14683. */
  14684. attachToMesh(mesh: AbstractMesh): void;
  14685. /**
  14686. * Attaches the controllers mesh to a camera
  14687. * @param camera the camera the mesh should be attached to
  14688. */
  14689. attachToPoseControlledCamera(camera: TargetCamera): void;
  14690. /**
  14691. * Disposes of the controller
  14692. */
  14693. dispose(): void;
  14694. /**
  14695. * The mesh that is attached to the controller
  14696. */
  14697. readonly mesh: Nullable<AbstractMesh>;
  14698. /**
  14699. * Gets the ray of the controller in the direction the controller is pointing
  14700. * @param length the length the resulting ray should be
  14701. * @returns a ray in the direction the controller is pointing
  14702. */
  14703. getForwardRay(length?: number): Ray;
  14704. }
  14705. }
  14706. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14707. import { Observable } from "babylonjs/Misc/observable";
  14708. import { Scene } from "babylonjs/scene";
  14709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14710. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14711. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14712. /**
  14713. * Defines the WebVRController object that represents controllers tracked in 3D space
  14714. */
  14715. export abstract class WebVRController extends PoseEnabledController {
  14716. /**
  14717. * Internal, the default controller model for the controller
  14718. */
  14719. protected _defaultModel: AbstractMesh;
  14720. /**
  14721. * Fired when the trigger state has changed
  14722. */
  14723. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14724. /**
  14725. * Fired when the main button state has changed
  14726. */
  14727. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14728. /**
  14729. * Fired when the secondary button state has changed
  14730. */
  14731. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14732. /**
  14733. * Fired when the pad state has changed
  14734. */
  14735. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14736. /**
  14737. * Fired when controllers stick values have changed
  14738. */
  14739. onPadValuesChangedObservable: Observable<StickValues>;
  14740. /**
  14741. * Array of button availible on the controller
  14742. */
  14743. protected _buttons: Array<MutableGamepadButton>;
  14744. private _onButtonStateChange;
  14745. /**
  14746. * Fired when a controller button's state has changed
  14747. * @param callback the callback containing the button that was modified
  14748. */
  14749. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14750. /**
  14751. * X and Y axis corresponding to the controllers joystick
  14752. */
  14753. pad: StickValues;
  14754. /**
  14755. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14756. */
  14757. hand: string;
  14758. /**
  14759. * The default controller model for the controller
  14760. */
  14761. readonly defaultModel: AbstractMesh;
  14762. /**
  14763. * Creates a new WebVRController from a gamepad
  14764. * @param vrGamepad the gamepad that the WebVRController should be created from
  14765. */
  14766. constructor(vrGamepad: any);
  14767. /**
  14768. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14769. */
  14770. update(): void;
  14771. /**
  14772. * Function to be called when a button is modified
  14773. */
  14774. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14775. /**
  14776. * Loads a mesh and attaches it to the controller
  14777. * @param scene the scene the mesh should be added to
  14778. * @param meshLoaded callback for when the mesh has been loaded
  14779. */
  14780. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14781. private _setButtonValue;
  14782. private _changes;
  14783. private _checkChanges;
  14784. /**
  14785. * Disposes of th webVRCOntroller
  14786. */
  14787. dispose(): void;
  14788. }
  14789. }
  14790. declare module "babylonjs/Lights/hemisphericLight" {
  14791. import { Nullable } from "babylonjs/types";
  14792. import { Scene } from "babylonjs/scene";
  14793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14794. import { Color3 } from "babylonjs/Maths/math.color";
  14795. import { Effect } from "babylonjs/Materials/effect";
  14796. import { Light } from "babylonjs/Lights/light";
  14797. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14798. /**
  14799. * The HemisphericLight simulates the ambient environment light,
  14800. * so the passed direction is the light reflection direction, not the incoming direction.
  14801. */
  14802. export class HemisphericLight extends Light {
  14803. /**
  14804. * The groundColor is the light in the opposite direction to the one specified during creation.
  14805. * 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.
  14806. */
  14807. groundColor: Color3;
  14808. /**
  14809. * The light reflection direction, not the incoming direction.
  14810. */
  14811. direction: Vector3;
  14812. /**
  14813. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14814. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14815. * The HemisphericLight can't cast shadows.
  14816. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14817. * @param name The friendly name of the light
  14818. * @param direction The direction of the light reflection
  14819. * @param scene The scene the light belongs to
  14820. */
  14821. constructor(name: string, direction: Vector3, scene: Scene);
  14822. protected _buildUniformLayout(): void;
  14823. /**
  14824. * Returns the string "HemisphericLight".
  14825. * @return The class name
  14826. */
  14827. getClassName(): string;
  14828. /**
  14829. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14830. * Returns the updated direction.
  14831. * @param target The target the direction should point to
  14832. * @return The computed direction
  14833. */
  14834. setDirectionToTarget(target: Vector3): Vector3;
  14835. /**
  14836. * Returns the shadow generator associated to the light.
  14837. * @returns Always null for hemispheric lights because it does not support shadows.
  14838. */
  14839. getShadowGenerator(): Nullable<IShadowGenerator>;
  14840. /**
  14841. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14842. * @param effect The effect to update
  14843. * @param lightIndex The index of the light in the effect to update
  14844. * @returns The hemispheric light
  14845. */
  14846. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14847. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14848. /**
  14849. * Computes the world matrix of the node
  14850. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14851. * @param useWasUpdatedFlag defines a reserved property
  14852. * @returns the world matrix
  14853. */
  14854. computeWorldMatrix(): Matrix;
  14855. /**
  14856. * Returns the integer 3.
  14857. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14858. */
  14859. getTypeID(): number;
  14860. /**
  14861. * Prepares the list of defines specific to the light type.
  14862. * @param defines the list of defines
  14863. * @param lightIndex defines the index of the light for the effect
  14864. */
  14865. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14866. }
  14867. }
  14868. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14869. /** @hidden */
  14870. export var vrMultiviewToSingleviewPixelShader: {
  14871. name: string;
  14872. shader: string;
  14873. };
  14874. }
  14875. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14877. import { Scene } from "babylonjs/scene";
  14878. /**
  14879. * Renders to multiple views with a single draw call
  14880. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14881. */
  14882. export class MultiviewRenderTarget extends RenderTargetTexture {
  14883. /**
  14884. * Creates a multiview render target
  14885. * @param scene scene used with the render target
  14886. * @param size the size of the render target (used for each view)
  14887. */
  14888. constructor(scene: Scene, size?: number | {
  14889. width: number;
  14890. height: number;
  14891. } | {
  14892. ratio: number;
  14893. });
  14894. /**
  14895. * @hidden
  14896. * @param faceIndex the face index, if its a cube texture
  14897. */
  14898. _bindFrameBuffer(faceIndex?: number): void;
  14899. /**
  14900. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14901. * @returns the view count
  14902. */
  14903. getViewCount(): number;
  14904. }
  14905. }
  14906. declare module "babylonjs/Maths/math.frustum" {
  14907. import { Matrix } from "babylonjs/Maths/math.vector";
  14908. import { DeepImmutable } from "babylonjs/types";
  14909. import { Plane } from "babylonjs/Maths/math.plane";
  14910. /**
  14911. * Represents a camera frustum
  14912. */
  14913. export class Frustum {
  14914. /**
  14915. * Gets the planes representing the frustum
  14916. * @param transform matrix to be applied to the returned planes
  14917. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14918. */
  14919. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14920. /**
  14921. * Gets the near frustum plane transformed by the transform matrix
  14922. * @param transform transformation matrix to be applied to the resulting frustum plane
  14923. * @param frustumPlane the resuling frustum plane
  14924. */
  14925. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14926. /**
  14927. * Gets the far frustum plane transformed by the transform matrix
  14928. * @param transform transformation matrix to be applied to the resulting frustum plane
  14929. * @param frustumPlane the resuling frustum plane
  14930. */
  14931. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14932. /**
  14933. * Gets the left frustum plane transformed by the transform matrix
  14934. * @param transform transformation matrix to be applied to the resulting frustum plane
  14935. * @param frustumPlane the resuling frustum plane
  14936. */
  14937. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14938. /**
  14939. * Gets the right frustum plane transformed by the transform matrix
  14940. * @param transform transformation matrix to be applied to the resulting frustum plane
  14941. * @param frustumPlane the resuling frustum plane
  14942. */
  14943. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14944. /**
  14945. * Gets the top frustum plane transformed by the transform matrix
  14946. * @param transform transformation matrix to be applied to the resulting frustum plane
  14947. * @param frustumPlane the resuling frustum plane
  14948. */
  14949. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14950. /**
  14951. * Gets the bottom frustum plane transformed by the transform matrix
  14952. * @param transform transformation matrix to be applied to the resulting frustum plane
  14953. * @param frustumPlane the resuling frustum plane
  14954. */
  14955. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14956. /**
  14957. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14958. * @param transform transformation matrix to be applied to the resulting frustum planes
  14959. * @param frustumPlanes the resuling frustum planes
  14960. */
  14961. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14962. }
  14963. }
  14964. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14965. import { Camera } from "babylonjs/Cameras/camera";
  14966. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14967. import { Nullable } from "babylonjs/types";
  14968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14969. import { Matrix } from "babylonjs/Maths/math.vector";
  14970. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14971. module "babylonjs/Engines/engine" {
  14972. interface Engine {
  14973. /**
  14974. * Creates a new multiview render target
  14975. * @param width defines the width of the texture
  14976. * @param height defines the height of the texture
  14977. * @returns the created multiview texture
  14978. */
  14979. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14980. /**
  14981. * Binds a multiview framebuffer to be drawn to
  14982. * @param multiviewTexture texture to bind
  14983. */
  14984. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14985. }
  14986. }
  14987. module "babylonjs/Cameras/camera" {
  14988. interface Camera {
  14989. /**
  14990. * @hidden
  14991. * 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)
  14992. */
  14993. _useMultiviewToSingleView: boolean;
  14994. /**
  14995. * @hidden
  14996. * 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)
  14997. */
  14998. _multiviewTexture: Nullable<RenderTargetTexture>;
  14999. /**
  15000. * @hidden
  15001. * ensures the multiview texture of the camera exists and has the specified width/height
  15002. * @param width height to set on the multiview texture
  15003. * @param height width to set on the multiview texture
  15004. */
  15005. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15006. }
  15007. }
  15008. module "babylonjs/scene" {
  15009. interface Scene {
  15010. /** @hidden */
  15011. _transformMatrixR: Matrix;
  15012. /** @hidden */
  15013. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15014. /** @hidden */
  15015. _createMultiviewUbo(): void;
  15016. /** @hidden */
  15017. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15018. /** @hidden */
  15019. _renderMultiviewToSingleView(camera: Camera): void;
  15020. }
  15021. }
  15022. }
  15023. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15024. import { Camera } from "babylonjs/Cameras/camera";
  15025. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15026. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15027. import "babylonjs/Engines/Extensions/engine.multiview";
  15028. /**
  15029. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15030. * This will not be used for webXR as it supports displaying texture arrays directly
  15031. */
  15032. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15033. /**
  15034. * Initializes a VRMultiviewToSingleview
  15035. * @param name name of the post process
  15036. * @param camera camera to be applied to
  15037. * @param scaleFactor scaling factor to the size of the output texture
  15038. */
  15039. constructor(name: string, camera: Camera, scaleFactor: number);
  15040. }
  15041. }
  15042. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15043. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15044. import { Nullable } from "babylonjs/types";
  15045. import { Size } from "babylonjs/Maths/math.size";
  15046. import { Observable } from "babylonjs/Misc/observable";
  15047. module "babylonjs/Engines/engine" {
  15048. interface Engine {
  15049. /** @hidden */
  15050. _vrDisplay: any;
  15051. /** @hidden */
  15052. _vrSupported: boolean;
  15053. /** @hidden */
  15054. _oldSize: Size;
  15055. /** @hidden */
  15056. _oldHardwareScaleFactor: number;
  15057. /** @hidden */
  15058. _vrExclusivePointerMode: boolean;
  15059. /** @hidden */
  15060. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15061. /** @hidden */
  15062. _onVRDisplayPointerRestricted: () => void;
  15063. /** @hidden */
  15064. _onVRDisplayPointerUnrestricted: () => void;
  15065. /** @hidden */
  15066. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15067. /** @hidden */
  15068. _onVrDisplayDisconnect: Nullable<() => void>;
  15069. /** @hidden */
  15070. _onVrDisplayPresentChange: Nullable<() => void>;
  15071. /**
  15072. * Observable signaled when VR display mode changes
  15073. */
  15074. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15075. /**
  15076. * Observable signaled when VR request present is complete
  15077. */
  15078. onVRRequestPresentComplete: Observable<boolean>;
  15079. /**
  15080. * Observable signaled when VR request present starts
  15081. */
  15082. onVRRequestPresentStart: Observable<Engine>;
  15083. /**
  15084. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15085. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15086. */
  15087. isInVRExclusivePointerMode: boolean;
  15088. /**
  15089. * Gets a boolean indicating if a webVR device was detected
  15090. * @returns true if a webVR device was detected
  15091. */
  15092. isVRDevicePresent(): boolean;
  15093. /**
  15094. * Gets the current webVR device
  15095. * @returns the current webVR device (or null)
  15096. */
  15097. getVRDevice(): any;
  15098. /**
  15099. * Initializes a webVR display and starts listening to display change events
  15100. * The onVRDisplayChangedObservable will be notified upon these changes
  15101. * @returns A promise containing a VRDisplay and if vr is supported
  15102. */
  15103. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15104. /** @hidden */
  15105. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15106. /**
  15107. * Call this function to switch to webVR mode
  15108. * Will do nothing if webVR is not supported or if there is no webVR device
  15109. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15110. */
  15111. enableVR(): void;
  15112. /** @hidden */
  15113. _onVRFullScreenTriggered(): void;
  15114. }
  15115. }
  15116. }
  15117. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15118. import { Nullable } from "babylonjs/types";
  15119. import { Observable } from "babylonjs/Misc/observable";
  15120. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15121. import { Scene } from "babylonjs/scene";
  15122. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15123. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15124. import { Node } from "babylonjs/node";
  15125. import { Ray } from "babylonjs/Culling/ray";
  15126. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15127. import "babylonjs/Engines/Extensions/engine.webVR";
  15128. /**
  15129. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15130. * IMPORTANT!! The data is right-hand data.
  15131. * @export
  15132. * @interface DevicePose
  15133. */
  15134. export interface DevicePose {
  15135. /**
  15136. * The position of the device, values in array are [x,y,z].
  15137. */
  15138. readonly position: Nullable<Float32Array>;
  15139. /**
  15140. * The linearVelocity of the device, values in array are [x,y,z].
  15141. */
  15142. readonly linearVelocity: Nullable<Float32Array>;
  15143. /**
  15144. * The linearAcceleration of the device, values in array are [x,y,z].
  15145. */
  15146. readonly linearAcceleration: Nullable<Float32Array>;
  15147. /**
  15148. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15149. */
  15150. readonly orientation: Nullable<Float32Array>;
  15151. /**
  15152. * The angularVelocity of the device, values in array are [x,y,z].
  15153. */
  15154. readonly angularVelocity: Nullable<Float32Array>;
  15155. /**
  15156. * The angularAcceleration of the device, values in array are [x,y,z].
  15157. */
  15158. readonly angularAcceleration: Nullable<Float32Array>;
  15159. }
  15160. /**
  15161. * Interface representing a pose controlled object in Babylon.
  15162. * A pose controlled object has both regular pose values as well as pose values
  15163. * from an external device such as a VR head mounted display
  15164. */
  15165. export interface PoseControlled {
  15166. /**
  15167. * The position of the object in babylon space.
  15168. */
  15169. position: Vector3;
  15170. /**
  15171. * The rotation quaternion of the object in babylon space.
  15172. */
  15173. rotationQuaternion: Quaternion;
  15174. /**
  15175. * The position of the device in babylon space.
  15176. */
  15177. devicePosition?: Vector3;
  15178. /**
  15179. * The rotation quaternion of the device in babylon space.
  15180. */
  15181. deviceRotationQuaternion: Quaternion;
  15182. /**
  15183. * The raw pose coming from the device.
  15184. */
  15185. rawPose: Nullable<DevicePose>;
  15186. /**
  15187. * The scale of the device to be used when translating from device space to babylon space.
  15188. */
  15189. deviceScaleFactor: number;
  15190. /**
  15191. * Updates the poseControlled values based on the input device pose.
  15192. * @param poseData the pose data to update the object with
  15193. */
  15194. updateFromDevice(poseData: DevicePose): void;
  15195. }
  15196. /**
  15197. * Set of options to customize the webVRCamera
  15198. */
  15199. export interface WebVROptions {
  15200. /**
  15201. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15202. */
  15203. trackPosition?: boolean;
  15204. /**
  15205. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15206. */
  15207. positionScale?: number;
  15208. /**
  15209. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15210. */
  15211. displayName?: string;
  15212. /**
  15213. * Should the native controller meshes be initialized. (default: true)
  15214. */
  15215. controllerMeshes?: boolean;
  15216. /**
  15217. * Creating a default HemiLight only on controllers. (default: true)
  15218. */
  15219. defaultLightingOnControllers?: boolean;
  15220. /**
  15221. * If you don't want to use the default VR button of the helper. (default: false)
  15222. */
  15223. useCustomVRButton?: boolean;
  15224. /**
  15225. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15226. */
  15227. customVRButton?: HTMLButtonElement;
  15228. /**
  15229. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15230. */
  15231. rayLength?: number;
  15232. /**
  15233. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15234. */
  15235. defaultHeight?: number;
  15236. /**
  15237. * If multiview should be used if availible (default: false)
  15238. */
  15239. useMultiview?: boolean;
  15240. }
  15241. /**
  15242. * This represents a WebVR camera.
  15243. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15244. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15245. */
  15246. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15247. private webVROptions;
  15248. /**
  15249. * @hidden
  15250. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15251. */
  15252. _vrDevice: any;
  15253. /**
  15254. * The rawPose of the vrDevice.
  15255. */
  15256. rawPose: Nullable<DevicePose>;
  15257. private _onVREnabled;
  15258. private _specsVersion;
  15259. private _attached;
  15260. private _frameData;
  15261. protected _descendants: Array<Node>;
  15262. private _deviceRoomPosition;
  15263. /** @hidden */
  15264. _deviceRoomRotationQuaternion: Quaternion;
  15265. private _standingMatrix;
  15266. /**
  15267. * Represents device position in babylon space.
  15268. */
  15269. devicePosition: Vector3;
  15270. /**
  15271. * Represents device rotation in babylon space.
  15272. */
  15273. deviceRotationQuaternion: Quaternion;
  15274. /**
  15275. * The scale of the device to be used when translating from device space to babylon space.
  15276. */
  15277. deviceScaleFactor: number;
  15278. private _deviceToWorld;
  15279. private _worldToDevice;
  15280. /**
  15281. * References to the webVR controllers for the vrDevice.
  15282. */
  15283. controllers: Array<WebVRController>;
  15284. /**
  15285. * Emits an event when a controller is attached.
  15286. */
  15287. onControllersAttachedObservable: Observable<WebVRController[]>;
  15288. /**
  15289. * Emits an event when a controller's mesh has been loaded;
  15290. */
  15291. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15292. /**
  15293. * Emits an event when the HMD's pose has been updated.
  15294. */
  15295. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15296. private _poseSet;
  15297. /**
  15298. * If the rig cameras be used as parent instead of this camera.
  15299. */
  15300. rigParenting: boolean;
  15301. private _lightOnControllers;
  15302. private _defaultHeight?;
  15303. /**
  15304. * Instantiates a WebVRFreeCamera.
  15305. * @param name The name of the WebVRFreeCamera
  15306. * @param position The starting anchor position for the camera
  15307. * @param scene The scene the camera belongs to
  15308. * @param webVROptions a set of customizable options for the webVRCamera
  15309. */
  15310. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15311. /**
  15312. * Gets the device distance from the ground in meters.
  15313. * @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.
  15314. */
  15315. deviceDistanceToRoomGround(): number;
  15316. /**
  15317. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15318. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15319. */
  15320. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15321. /**
  15322. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15323. * @returns A promise with a boolean set to if the standing matrix is supported.
  15324. */
  15325. useStandingMatrixAsync(): Promise<boolean>;
  15326. /**
  15327. * Disposes the camera
  15328. */
  15329. dispose(): void;
  15330. /**
  15331. * Gets a vrController by name.
  15332. * @param name The name of the controller to retreive
  15333. * @returns the controller matching the name specified or null if not found
  15334. */
  15335. getControllerByName(name: string): Nullable<WebVRController>;
  15336. private _leftController;
  15337. /**
  15338. * The controller corresponding to the users left hand.
  15339. */
  15340. readonly leftController: Nullable<WebVRController>;
  15341. private _rightController;
  15342. /**
  15343. * The controller corresponding to the users right hand.
  15344. */
  15345. readonly rightController: Nullable<WebVRController>;
  15346. /**
  15347. * Casts a ray forward from the vrCamera's gaze.
  15348. * @param length Length of the ray (default: 100)
  15349. * @returns the ray corresponding to the gaze
  15350. */
  15351. getForwardRay(length?: number): Ray;
  15352. /**
  15353. * @hidden
  15354. * Updates the camera based on device's frame data
  15355. */
  15356. _checkInputs(): void;
  15357. /**
  15358. * Updates the poseControlled values based on the input device pose.
  15359. * @param poseData Pose coming from the device
  15360. */
  15361. updateFromDevice(poseData: DevicePose): void;
  15362. private _htmlElementAttached;
  15363. private _detachIfAttached;
  15364. /**
  15365. * WebVR's attach control will start broadcasting frames to the device.
  15366. * Note that in certain browsers (chrome for example) this function must be called
  15367. * within a user-interaction callback. Example:
  15368. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15369. *
  15370. * @param element html element to attach the vrDevice to
  15371. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15372. */
  15373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15374. /**
  15375. * Detaches the camera from the html element and disables VR
  15376. *
  15377. * @param element html element to detach from
  15378. */
  15379. detachControl(element: HTMLElement): void;
  15380. /**
  15381. * @returns the name of this class
  15382. */
  15383. getClassName(): string;
  15384. /**
  15385. * Calls resetPose on the vrDisplay
  15386. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15387. */
  15388. resetToCurrentRotation(): void;
  15389. /**
  15390. * @hidden
  15391. * Updates the rig cameras (left and right eye)
  15392. */
  15393. _updateRigCameras(): void;
  15394. private _workingVector;
  15395. private _oneVector;
  15396. private _workingMatrix;
  15397. private updateCacheCalled;
  15398. private _correctPositionIfNotTrackPosition;
  15399. /**
  15400. * @hidden
  15401. * Updates the cached values of the camera
  15402. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15403. */
  15404. _updateCache(ignoreParentClass?: boolean): void;
  15405. /**
  15406. * @hidden
  15407. * Get current device position in babylon world
  15408. */
  15409. _computeDevicePosition(): void;
  15410. /**
  15411. * Updates the current device position and rotation in the babylon world
  15412. */
  15413. update(): void;
  15414. /**
  15415. * @hidden
  15416. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15417. * @returns an identity matrix
  15418. */
  15419. _getViewMatrix(): Matrix;
  15420. private _tmpMatrix;
  15421. /**
  15422. * This function is called by the two RIG cameras.
  15423. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15424. * @hidden
  15425. */
  15426. _getWebVRViewMatrix(): Matrix;
  15427. /** @hidden */
  15428. _getWebVRProjectionMatrix(): Matrix;
  15429. private _onGamepadConnectedObserver;
  15430. private _onGamepadDisconnectedObserver;
  15431. private _updateCacheWhenTrackingDisabledObserver;
  15432. /**
  15433. * Initializes the controllers and their meshes
  15434. */
  15435. initControllers(): void;
  15436. }
  15437. }
  15438. declare module "babylonjs/PostProcesses/postProcess" {
  15439. import { Nullable } from "babylonjs/types";
  15440. import { SmartArray } from "babylonjs/Misc/smartArray";
  15441. import { Observable } from "babylonjs/Misc/observable";
  15442. import { Vector2 } from "babylonjs/Maths/math.vector";
  15443. import { Camera } from "babylonjs/Cameras/camera";
  15444. import { Effect } from "babylonjs/Materials/effect";
  15445. import "babylonjs/Shaders/postprocess.vertex";
  15446. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15447. import { Engine } from "babylonjs/Engines/engine";
  15448. import { Color4 } from "babylonjs/Maths/math.color";
  15449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15450. /**
  15451. * Size options for a post process
  15452. */
  15453. export type PostProcessOptions = {
  15454. width: number;
  15455. height: number;
  15456. };
  15457. /**
  15458. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15459. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15460. */
  15461. export class PostProcess {
  15462. /** Name of the PostProcess. */
  15463. name: string;
  15464. /**
  15465. * Gets or sets the unique id of the post process
  15466. */
  15467. uniqueId: number;
  15468. /**
  15469. * Width of the texture to apply the post process on
  15470. */
  15471. width: number;
  15472. /**
  15473. * Height of the texture to apply the post process on
  15474. */
  15475. height: number;
  15476. /**
  15477. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15478. * @hidden
  15479. */
  15480. _outputTexture: Nullable<InternalTexture>;
  15481. /**
  15482. * Sampling mode used by the shader
  15483. * See https://doc.babylonjs.com/classes/3.1/texture
  15484. */
  15485. renderTargetSamplingMode: number;
  15486. /**
  15487. * Clear color to use when screen clearing
  15488. */
  15489. clearColor: Color4;
  15490. /**
  15491. * If the buffer needs to be cleared before applying the post process. (default: true)
  15492. * Should be set to false if shader will overwrite all previous pixels.
  15493. */
  15494. autoClear: boolean;
  15495. /**
  15496. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15497. */
  15498. alphaMode: number;
  15499. /**
  15500. * Sets the setAlphaBlendConstants of the babylon engine
  15501. */
  15502. alphaConstants: Color4;
  15503. /**
  15504. * Animations to be used for the post processing
  15505. */
  15506. animations: import("babylonjs/Animations/animation").Animation[];
  15507. /**
  15508. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15509. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15510. */
  15511. enablePixelPerfectMode: boolean;
  15512. /**
  15513. * Force the postprocess to be applied without taking in account viewport
  15514. */
  15515. forceFullscreenViewport: boolean;
  15516. /**
  15517. * List of inspectable custom properties (used by the Inspector)
  15518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15519. */
  15520. inspectableCustomProperties: IInspectable[];
  15521. /**
  15522. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15523. *
  15524. * | Value | Type | Description |
  15525. * | ----- | ----------------------------------- | ----------- |
  15526. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15527. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15528. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15529. *
  15530. */
  15531. scaleMode: number;
  15532. /**
  15533. * Force textures to be a power of two (default: false)
  15534. */
  15535. alwaysForcePOT: boolean;
  15536. private _samples;
  15537. /**
  15538. * Number of sample textures (default: 1)
  15539. */
  15540. samples: number;
  15541. /**
  15542. * Modify the scale of the post process to be the same as the viewport (default: false)
  15543. */
  15544. adaptScaleToCurrentViewport: boolean;
  15545. private _camera;
  15546. private _scene;
  15547. private _engine;
  15548. private _options;
  15549. private _reusable;
  15550. private _textureType;
  15551. /**
  15552. * Smart array of input and output textures for the post process.
  15553. * @hidden
  15554. */
  15555. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15556. /**
  15557. * The index in _textures that corresponds to the output texture.
  15558. * @hidden
  15559. */
  15560. _currentRenderTextureInd: number;
  15561. private _effect;
  15562. private _samplers;
  15563. private _fragmentUrl;
  15564. private _vertexUrl;
  15565. private _parameters;
  15566. private _scaleRatio;
  15567. protected _indexParameters: any;
  15568. private _shareOutputWithPostProcess;
  15569. private _texelSize;
  15570. private _forcedOutputTexture;
  15571. /**
  15572. * Returns the fragment url or shader name used in the post process.
  15573. * @returns the fragment url or name in the shader store.
  15574. */
  15575. getEffectName(): string;
  15576. /**
  15577. * An event triggered when the postprocess is activated.
  15578. */
  15579. onActivateObservable: Observable<Camera>;
  15580. private _onActivateObserver;
  15581. /**
  15582. * A function that is added to the onActivateObservable
  15583. */
  15584. onActivate: Nullable<(camera: Camera) => void>;
  15585. /**
  15586. * An event triggered when the postprocess changes its size.
  15587. */
  15588. onSizeChangedObservable: Observable<PostProcess>;
  15589. private _onSizeChangedObserver;
  15590. /**
  15591. * A function that is added to the onSizeChangedObservable
  15592. */
  15593. onSizeChanged: (postProcess: PostProcess) => void;
  15594. /**
  15595. * An event triggered when the postprocess applies its effect.
  15596. */
  15597. onApplyObservable: Observable<Effect>;
  15598. private _onApplyObserver;
  15599. /**
  15600. * A function that is added to the onApplyObservable
  15601. */
  15602. onApply: (effect: Effect) => void;
  15603. /**
  15604. * An event triggered before rendering the postprocess
  15605. */
  15606. onBeforeRenderObservable: Observable<Effect>;
  15607. private _onBeforeRenderObserver;
  15608. /**
  15609. * A function that is added to the onBeforeRenderObservable
  15610. */
  15611. onBeforeRender: (effect: Effect) => void;
  15612. /**
  15613. * An event triggered after rendering the postprocess
  15614. */
  15615. onAfterRenderObservable: Observable<Effect>;
  15616. private _onAfterRenderObserver;
  15617. /**
  15618. * A function that is added to the onAfterRenderObservable
  15619. */
  15620. onAfterRender: (efect: Effect) => void;
  15621. /**
  15622. * 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
  15623. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15624. */
  15625. inputTexture: InternalTexture;
  15626. /**
  15627. * Gets the camera which post process is applied to.
  15628. * @returns The camera the post process is applied to.
  15629. */
  15630. getCamera(): Camera;
  15631. /**
  15632. * Gets the texel size of the postprocess.
  15633. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15634. */
  15635. readonly texelSize: Vector2;
  15636. /**
  15637. * Creates a new instance PostProcess
  15638. * @param name The name of the PostProcess.
  15639. * @param fragmentUrl The url of the fragment shader to be used.
  15640. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15641. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15642. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15643. * @param camera The camera to apply the render pass to.
  15644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15645. * @param engine The engine which the post process will be applied. (default: current engine)
  15646. * @param reusable If the post process can be reused on the same frame. (default: false)
  15647. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15648. * @param textureType Type of textures used when performing the post process. (default: 0)
  15649. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15650. * @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
  15651. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15652. */
  15653. constructor(
  15654. /** Name of the PostProcess. */
  15655. 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);
  15656. /**
  15657. * Gets a string idenfifying the name of the class
  15658. * @returns "PostProcess" string
  15659. */
  15660. getClassName(): string;
  15661. /**
  15662. * Gets the engine which this post process belongs to.
  15663. * @returns The engine the post process was enabled with.
  15664. */
  15665. getEngine(): Engine;
  15666. /**
  15667. * The effect that is created when initializing the post process.
  15668. * @returns The created effect corresponding the the postprocess.
  15669. */
  15670. getEffect(): Effect;
  15671. /**
  15672. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15673. * @param postProcess The post process to share the output with.
  15674. * @returns This post process.
  15675. */
  15676. shareOutputWith(postProcess: PostProcess): PostProcess;
  15677. /**
  15678. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15679. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15680. */
  15681. useOwnOutput(): void;
  15682. /**
  15683. * Updates the effect with the current post process compile time values and recompiles the shader.
  15684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15687. * @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
  15688. * @param onCompiled Called when the shader has been compiled.
  15689. * @param onError Called if there is an error when compiling a shader.
  15690. */
  15691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15692. /**
  15693. * The post process is reusable if it can be used multiple times within one frame.
  15694. * @returns If the post process is reusable
  15695. */
  15696. isReusable(): boolean;
  15697. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15698. markTextureDirty(): void;
  15699. /**
  15700. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15701. * 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.
  15702. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15703. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15704. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15705. * @returns The target texture that was bound to be written to.
  15706. */
  15707. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15708. /**
  15709. * If the post process is supported.
  15710. */
  15711. readonly isSupported: boolean;
  15712. /**
  15713. * The aspect ratio of the output texture.
  15714. */
  15715. readonly aspectRatio: number;
  15716. /**
  15717. * Get a value indicating if the post-process is ready to be used
  15718. * @returns true if the post-process is ready (shader is compiled)
  15719. */
  15720. isReady(): boolean;
  15721. /**
  15722. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15723. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15724. */
  15725. apply(): Nullable<Effect>;
  15726. private _disposeTextures;
  15727. /**
  15728. * Disposes the post process.
  15729. * @param camera The camera to dispose the post process on.
  15730. */
  15731. dispose(camera?: Camera): void;
  15732. }
  15733. }
  15734. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15735. /** @hidden */
  15736. export var kernelBlurVaryingDeclaration: {
  15737. name: string;
  15738. shader: string;
  15739. };
  15740. }
  15741. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15742. /** @hidden */
  15743. export var kernelBlurFragment: {
  15744. name: string;
  15745. shader: string;
  15746. };
  15747. }
  15748. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15749. /** @hidden */
  15750. export var kernelBlurFragment2: {
  15751. name: string;
  15752. shader: string;
  15753. };
  15754. }
  15755. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15757. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15758. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15759. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15760. /** @hidden */
  15761. export var kernelBlurPixelShader: {
  15762. name: string;
  15763. shader: string;
  15764. };
  15765. }
  15766. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15767. /** @hidden */
  15768. export var kernelBlurVertex: {
  15769. name: string;
  15770. shader: string;
  15771. };
  15772. }
  15773. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15774. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15775. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15776. /** @hidden */
  15777. export var kernelBlurVertexShader: {
  15778. name: string;
  15779. shader: string;
  15780. };
  15781. }
  15782. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15783. import { Vector2 } from "babylonjs/Maths/math.vector";
  15784. import { Nullable } from "babylonjs/types";
  15785. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15786. import { Camera } from "babylonjs/Cameras/camera";
  15787. import { Effect } from "babylonjs/Materials/effect";
  15788. import { Engine } from "babylonjs/Engines/engine";
  15789. import "babylonjs/Shaders/kernelBlur.fragment";
  15790. import "babylonjs/Shaders/kernelBlur.vertex";
  15791. /**
  15792. * The Blur Post Process which blurs an image based on a kernel and direction.
  15793. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15794. */
  15795. export class BlurPostProcess extends PostProcess {
  15796. /** The direction in which to blur the image. */
  15797. direction: Vector2;
  15798. private blockCompilation;
  15799. protected _kernel: number;
  15800. protected _idealKernel: number;
  15801. protected _packedFloat: boolean;
  15802. private _staticDefines;
  15803. /**
  15804. * Sets the length in pixels of the blur sample region
  15805. */
  15806. /**
  15807. * Gets the length in pixels of the blur sample region
  15808. */
  15809. kernel: number;
  15810. /**
  15811. * Sets wether or not the blur needs to unpack/repack floats
  15812. */
  15813. /**
  15814. * Gets wether or not the blur is unpacking/repacking floats
  15815. */
  15816. packedFloat: boolean;
  15817. /**
  15818. * Creates a new instance BlurPostProcess
  15819. * @param name The name of the effect.
  15820. * @param direction The direction in which to blur the image.
  15821. * @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.
  15822. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15823. * @param camera The camera to apply the render pass to.
  15824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15825. * @param engine The engine which the post process will be applied. (default: current engine)
  15826. * @param reusable If the post process can be reused on the same frame. (default: false)
  15827. * @param textureType Type of textures used when performing the post process. (default: 0)
  15828. * @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)
  15829. */
  15830. constructor(name: string,
  15831. /** The direction in which to blur the image. */
  15832. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15833. /**
  15834. * Updates the effect with the current post process compile time values and recompiles the shader.
  15835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15838. * @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
  15839. * @param onCompiled Called when the shader has been compiled.
  15840. * @param onError Called if there is an error when compiling a shader.
  15841. */
  15842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15843. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15844. /**
  15845. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15846. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15847. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15848. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15849. * The gaps between physical kernels are compensated for in the weighting of the samples
  15850. * @param idealKernel Ideal blur kernel.
  15851. * @return Nearest best kernel.
  15852. */
  15853. protected _nearestBestKernel(idealKernel: number): number;
  15854. /**
  15855. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15856. * @param x The point on the Gaussian distribution to sample.
  15857. * @return the value of the Gaussian function at x.
  15858. */
  15859. protected _gaussianWeight(x: number): number;
  15860. /**
  15861. * Generates a string that can be used as a floating point number in GLSL.
  15862. * @param x Value to print.
  15863. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15864. * @return GLSL float string.
  15865. */
  15866. protected _glslFloat(x: number, decimalFigures?: number): string;
  15867. }
  15868. }
  15869. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15870. import { Scene } from "babylonjs/scene";
  15871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15872. import { Plane } from "babylonjs/Maths/math.plane";
  15873. /**
  15874. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15875. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15876. * You can then easily use it as a reflectionTexture on a flat surface.
  15877. * In case the surface is not a plane, please consider relying on reflection probes.
  15878. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15879. */
  15880. export class MirrorTexture extends RenderTargetTexture {
  15881. private scene;
  15882. /**
  15883. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15884. * 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.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. */
  15887. mirrorPlane: Plane;
  15888. /**
  15889. * Define the blur ratio used to blur the reflection if needed.
  15890. */
  15891. blurRatio: number;
  15892. /**
  15893. * Define the adaptive blur kernel used to blur the reflection if needed.
  15894. * This will autocompute the closest best match for the `blurKernel`
  15895. */
  15896. adaptiveBlurKernel: number;
  15897. /**
  15898. * Define the blur kernel used to blur the reflection if needed.
  15899. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15900. */
  15901. blurKernel: number;
  15902. /**
  15903. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15904. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15905. */
  15906. blurKernelX: number;
  15907. /**
  15908. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15909. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15910. */
  15911. blurKernelY: number;
  15912. private _autoComputeBlurKernel;
  15913. protected _onRatioRescale(): void;
  15914. private _updateGammaSpace;
  15915. private _imageProcessingConfigChangeObserver;
  15916. private _transformMatrix;
  15917. private _mirrorMatrix;
  15918. private _savedViewMatrix;
  15919. private _blurX;
  15920. private _blurY;
  15921. private _adaptiveBlurKernel;
  15922. private _blurKernelX;
  15923. private _blurKernelY;
  15924. private _blurRatio;
  15925. /**
  15926. * Instantiates a Mirror Texture.
  15927. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15928. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15929. * You can then easily use it as a reflectionTexture on a flat surface.
  15930. * In case the surface is not a plane, please consider relying on reflection probes.
  15931. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15932. * @param name
  15933. * @param size
  15934. * @param scene
  15935. * @param generateMipMaps
  15936. * @param type
  15937. * @param samplingMode
  15938. * @param generateDepthBuffer
  15939. */
  15940. constructor(name: string, size: number | {
  15941. width: number;
  15942. height: number;
  15943. } | {
  15944. ratio: number;
  15945. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15946. private _preparePostProcesses;
  15947. /**
  15948. * Clone the mirror texture.
  15949. * @returns the cloned texture
  15950. */
  15951. clone(): MirrorTexture;
  15952. /**
  15953. * Serialize the texture to a JSON representation you could use in Parse later on
  15954. * @returns the serialized JSON representation
  15955. */
  15956. serialize(): any;
  15957. /**
  15958. * Dispose the texture and release its associated resources.
  15959. */
  15960. dispose(): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Materials/Textures/texture" {
  15964. import { Observable } from "babylonjs/Misc/observable";
  15965. import { Nullable } from "babylonjs/types";
  15966. import { Scene } from "babylonjs/scene";
  15967. import { Matrix } from "babylonjs/Maths/math.vector";
  15968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15969. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15970. import { Engine } from "babylonjs/Engines/engine";
  15971. /**
  15972. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15973. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15974. */
  15975. export class Texture extends BaseTexture {
  15976. /**
  15977. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15978. */
  15979. static SerializeBuffers: boolean;
  15980. /** @hidden */
  15981. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15982. /** @hidden */
  15983. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15984. /** @hidden */
  15985. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_SAMPLINGMODE: number;
  15988. /** nearest is mag = nearest and min = nearest and mip = linear */
  15989. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly BILINEAR_SAMPLINGMODE: number;
  15992. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15993. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly TRILINEAR_SAMPLINGMODE: number;
  15996. /** Trilinear is mag = linear and min = linear and mip = linear */
  15997. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15998. /** mag = nearest and min = nearest and mip = nearest */
  15999. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = nearest */
  16001. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16002. /** mag = nearest and min = linear and mip = linear */
  16003. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16004. /** mag = nearest and min = linear and mip = none */
  16005. static readonly NEAREST_LINEAR: number;
  16006. /** mag = nearest and min = nearest and mip = none */
  16007. static readonly NEAREST_NEAREST: number;
  16008. /** mag = linear and min = nearest and mip = nearest */
  16009. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16010. /** mag = linear and min = nearest and mip = linear */
  16011. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16012. /** mag = linear and min = linear and mip = none */
  16013. static readonly LINEAR_LINEAR: number;
  16014. /** mag = linear and min = nearest and mip = none */
  16015. static readonly LINEAR_NEAREST: number;
  16016. /** Explicit coordinates mode */
  16017. static readonly EXPLICIT_MODE: number;
  16018. /** Spherical coordinates mode */
  16019. static readonly SPHERICAL_MODE: number;
  16020. /** Planar coordinates mode */
  16021. static readonly PLANAR_MODE: number;
  16022. /** Cubic coordinates mode */
  16023. static readonly CUBIC_MODE: number;
  16024. /** Projection coordinates mode */
  16025. static readonly PROJECTION_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly SKYBOX_MODE: number;
  16028. /** Inverse Cubic coordinates mode */
  16029. static readonly INVCUBIC_MODE: number;
  16030. /** Equirectangular coordinates mode */
  16031. static readonly EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16034. /** Equirectangular Fixed Mirrored coordinates mode */
  16035. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16036. /** Texture is not repeating outside of 0..1 UVs */
  16037. static readonly CLAMP_ADDRESSMODE: number;
  16038. /** Texture is repeating outside of 0..1 UVs */
  16039. static readonly WRAP_ADDRESSMODE: number;
  16040. /** Texture is repeating and mirrored */
  16041. static readonly MIRROR_ADDRESSMODE: number;
  16042. /**
  16043. * 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
  16044. */
  16045. static UseSerializedUrlIfAny: boolean;
  16046. /**
  16047. * Define the url of the texture.
  16048. */
  16049. url: Nullable<string>;
  16050. /**
  16051. * Define an offset on the texture to offset the u coordinates of the UVs
  16052. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16053. */
  16054. uOffset: number;
  16055. /**
  16056. * Define an offset on the texture to offset the v coordinates of the UVs
  16057. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16058. */
  16059. vOffset: number;
  16060. /**
  16061. * Define an offset on the texture to scale the u coordinates of the UVs
  16062. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16063. */
  16064. uScale: number;
  16065. /**
  16066. * Define an offset on the texture to scale the v coordinates of the UVs
  16067. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16068. */
  16069. vScale: number;
  16070. /**
  16071. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16072. * @see http://doc.babylonjs.com/how_to/more_materials
  16073. */
  16074. uAng: number;
  16075. /**
  16076. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16077. * @see http://doc.babylonjs.com/how_to/more_materials
  16078. */
  16079. vAng: number;
  16080. /**
  16081. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16082. * @see http://doc.babylonjs.com/how_to/more_materials
  16083. */
  16084. wAng: number;
  16085. /**
  16086. * Defines the center of rotation (U)
  16087. */
  16088. uRotationCenter: number;
  16089. /**
  16090. * Defines the center of rotation (V)
  16091. */
  16092. vRotationCenter: number;
  16093. /**
  16094. * Defines the center of rotation (W)
  16095. */
  16096. wRotationCenter: number;
  16097. /**
  16098. * Are mip maps generated for this texture or not.
  16099. */
  16100. readonly noMipmap: boolean;
  16101. /**
  16102. * List of inspectable custom properties (used by the Inspector)
  16103. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16104. */
  16105. inspectableCustomProperties: Nullable<IInspectable[]>;
  16106. private _noMipmap;
  16107. /** @hidden */
  16108. _invertY: boolean;
  16109. private _rowGenerationMatrix;
  16110. private _cachedTextureMatrix;
  16111. private _projectionModeMatrix;
  16112. private _t0;
  16113. private _t1;
  16114. private _t2;
  16115. private _cachedUOffset;
  16116. private _cachedVOffset;
  16117. private _cachedUScale;
  16118. private _cachedVScale;
  16119. private _cachedUAng;
  16120. private _cachedVAng;
  16121. private _cachedWAng;
  16122. private _cachedProjectionMatrixId;
  16123. private _cachedCoordinatesMode;
  16124. /** @hidden */
  16125. protected _initialSamplingMode: number;
  16126. /** @hidden */
  16127. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16128. private _deleteBuffer;
  16129. protected _format: Nullable<number>;
  16130. private _delayedOnLoad;
  16131. private _delayedOnError;
  16132. /**
  16133. * Observable triggered once the texture has been loaded.
  16134. */
  16135. onLoadObservable: Observable<Texture>;
  16136. protected _isBlocking: boolean;
  16137. /**
  16138. * Is the texture preventing material to render while loading.
  16139. * If false, a default texture will be used instead of the loading one during the preparation step.
  16140. */
  16141. isBlocking: boolean;
  16142. /**
  16143. * Get the current sampling mode associated with the texture.
  16144. */
  16145. readonly samplingMode: number;
  16146. /**
  16147. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16148. */
  16149. readonly invertY: boolean;
  16150. /**
  16151. * Instantiates a new texture.
  16152. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16153. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16154. * @param url define the url of the picture to load as a texture
  16155. * @param scene define the scene or engine the texture will belong to
  16156. * @param noMipmap define if the texture will require mip maps or not
  16157. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16158. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16159. * @param onLoad define a callback triggered when the texture has been loaded
  16160. * @param onError define a callback triggered when an error occurred during the loading session
  16161. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16162. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16164. */
  16165. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16166. /**
  16167. * Update the url (and optional buffer) of this texture if url was null during construction.
  16168. * @param url the url of the texture
  16169. * @param buffer the buffer of the texture (defaults to null)
  16170. * @param onLoad callback called when the texture is loaded (defaults to null)
  16171. */
  16172. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16173. /**
  16174. * Finish the loading sequence of a texture flagged as delayed load.
  16175. * @hidden
  16176. */
  16177. delayLoad(): void;
  16178. private _prepareRowForTextureGeneration;
  16179. /**
  16180. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16181. * @returns the transform matrix of the texture.
  16182. */
  16183. getTextureMatrix(): Matrix;
  16184. /**
  16185. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16186. * @returns The reflection texture transform
  16187. */
  16188. getReflectionTextureMatrix(): Matrix;
  16189. /**
  16190. * Clones the texture.
  16191. * @returns the cloned texture
  16192. */
  16193. clone(): Texture;
  16194. /**
  16195. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16196. * @returns The JSON representation of the texture
  16197. */
  16198. serialize(): any;
  16199. /**
  16200. * Get the current class name of the texture useful for serialization or dynamic coding.
  16201. * @returns "Texture"
  16202. */
  16203. getClassName(): string;
  16204. /**
  16205. * Dispose the texture and release its associated resources.
  16206. */
  16207. dispose(): void;
  16208. /**
  16209. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16210. * @param parsedTexture Define the JSON representation of the texture
  16211. * @param scene Define the scene the parsed texture should be instantiated in
  16212. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16213. * @returns The parsed texture if successful
  16214. */
  16215. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16216. /**
  16217. * Creates a texture from its base 64 representation.
  16218. * @param data Define the base64 payload without the data: prefix
  16219. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16220. * @param scene Define the scene the texture should belong to
  16221. * @param noMipmap Forces the texture to not create mip map information if true
  16222. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16223. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16224. * @param onLoad define a callback triggered when the texture has been loaded
  16225. * @param onError define a callback triggered when an error occurred during the loading session
  16226. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16227. * @returns the created texture
  16228. */
  16229. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16230. /**
  16231. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16232. * @param data Define the base64 payload without the data: prefix
  16233. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16234. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16235. * @param scene Define the scene the texture should belong to
  16236. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16237. * @param noMipmap Forces the texture to not create mip map information if true
  16238. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16239. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16240. * @param onLoad define a callback triggered when the texture has been loaded
  16241. * @param onError define a callback triggered when an error occurred during the loading session
  16242. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16243. * @returns the created texture
  16244. */
  16245. 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;
  16246. }
  16247. }
  16248. declare module "babylonjs/PostProcesses/postProcessManager" {
  16249. import { Nullable } from "babylonjs/types";
  16250. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16252. import { Scene } from "babylonjs/scene";
  16253. /**
  16254. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16255. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16256. */
  16257. export class PostProcessManager {
  16258. private _scene;
  16259. private _indexBuffer;
  16260. private _vertexBuffers;
  16261. /**
  16262. * Creates a new instance PostProcess
  16263. * @param scene The scene that the post process is associated with.
  16264. */
  16265. constructor(scene: Scene);
  16266. private _prepareBuffers;
  16267. private _buildIndexBuffer;
  16268. /**
  16269. * Rebuilds the vertex buffers of the manager.
  16270. * @hidden
  16271. */
  16272. _rebuild(): void;
  16273. /**
  16274. * Prepares a frame to be run through a post process.
  16275. * @param sourceTexture The input texture to the post procesess. (default: null)
  16276. * @param postProcesses An array of post processes to be run. (default: null)
  16277. * @returns True if the post processes were able to be run.
  16278. * @hidden
  16279. */
  16280. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16281. /**
  16282. * Manually render a set of post processes to a texture.
  16283. * @param postProcesses An array of post processes to be run.
  16284. * @param targetTexture The target texture to render to.
  16285. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16286. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16287. * @param lodLevel defines which lod of the texture to render to
  16288. */
  16289. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16290. /**
  16291. * Finalize the result of the output of the postprocesses.
  16292. * @param doNotPresent If true the result will not be displayed to the screen.
  16293. * @param targetTexture The target texture to render to.
  16294. * @param faceIndex The index of the face to bind the target texture to.
  16295. * @param postProcesses The array of post processes to render.
  16296. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16297. * @hidden
  16298. */
  16299. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16300. /**
  16301. * Disposes of the post process manager.
  16302. */
  16303. dispose(): void;
  16304. }
  16305. }
  16306. declare module "babylonjs/Misc/gradients" {
  16307. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16308. /** Interface used by value gradients (color, factor, ...) */
  16309. export interface IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. }
  16315. /** Class used to store color4 gradient */
  16316. export class ColorGradient implements IValueGradient {
  16317. /**
  16318. * Gets or sets the gradient value (between 0 and 1)
  16319. */
  16320. gradient: number;
  16321. /**
  16322. * Gets or sets first associated color
  16323. */
  16324. color1: Color4;
  16325. /**
  16326. * Gets or sets second associated color
  16327. */
  16328. color2?: Color4;
  16329. /**
  16330. * Will get a color picked randomly between color1 and color2.
  16331. * If color2 is undefined then color1 will be used
  16332. * @param result defines the target Color4 to store the result in
  16333. */
  16334. getColorToRef(result: Color4): void;
  16335. }
  16336. /** Class used to store color 3 gradient */
  16337. export class Color3Gradient implements IValueGradient {
  16338. /**
  16339. * Gets or sets the gradient value (between 0 and 1)
  16340. */
  16341. gradient: number;
  16342. /**
  16343. * Gets or sets the associated color
  16344. */
  16345. color: Color3;
  16346. }
  16347. /** Class used to store factor gradient */
  16348. export class FactorGradient implements IValueGradient {
  16349. /**
  16350. * Gets or sets the gradient value (between 0 and 1)
  16351. */
  16352. gradient: number;
  16353. /**
  16354. * Gets or sets first associated factor
  16355. */
  16356. factor1: number;
  16357. /**
  16358. * Gets or sets second associated factor
  16359. */
  16360. factor2?: number;
  16361. /**
  16362. * Will get a number picked randomly between factor1 and factor2.
  16363. * If factor2 is undefined then factor1 will be used
  16364. * @returns the picked number
  16365. */
  16366. getFactor(): number;
  16367. }
  16368. /**
  16369. * Helper used to simplify some generic gradient tasks
  16370. */
  16371. export class GradientHelper {
  16372. /**
  16373. * Gets the current gradient from an array of IValueGradient
  16374. * @param ratio defines the current ratio to get
  16375. * @param gradients defines the array of IValueGradient
  16376. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16377. */
  16378. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16379. }
  16380. }
  16381. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16382. import { Scene } from "babylonjs/scene";
  16383. import { Texture } from "babylonjs/Materials/Textures/texture";
  16384. /**
  16385. * A class extending Texture allowing drawing on a texture
  16386. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16387. */
  16388. export class DynamicTexture extends Texture {
  16389. private _generateMipMaps;
  16390. private _canvas;
  16391. private _context;
  16392. private _engine;
  16393. /**
  16394. * Creates a DynamicTexture
  16395. * @param name defines the name of the texture
  16396. * @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
  16397. * @param scene defines the scene where you want the texture
  16398. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16399. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16400. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16401. */
  16402. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16403. /**
  16404. * Get the current class name of the texture useful for serialization or dynamic coding.
  16405. * @returns "DynamicTexture"
  16406. */
  16407. getClassName(): string;
  16408. /**
  16409. * Gets the current state of canRescale
  16410. */
  16411. readonly canRescale: boolean;
  16412. private _recreate;
  16413. /**
  16414. * Scales the texture
  16415. * @param ratio the scale factor to apply to both width and height
  16416. */
  16417. scale(ratio: number): void;
  16418. /**
  16419. * Resizes the texture
  16420. * @param width the new width
  16421. * @param height the new height
  16422. */
  16423. scaleTo(width: number, height: number): void;
  16424. /**
  16425. * Gets the context of the canvas used by the texture
  16426. * @returns the canvas context of the dynamic texture
  16427. */
  16428. getContext(): CanvasRenderingContext2D;
  16429. /**
  16430. * Clears the texture
  16431. */
  16432. clear(): void;
  16433. /**
  16434. * Updates the texture
  16435. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16436. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16437. */
  16438. update(invertY?: boolean, premulAlpha?: boolean): void;
  16439. /**
  16440. * Draws text onto the texture
  16441. * @param text defines the text to be drawn
  16442. * @param x defines the placement of the text from the left
  16443. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16444. * @param font defines the font to be used with font-style, font-size, font-name
  16445. * @param color defines the color used for the text
  16446. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16447. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16448. * @param update defines whether texture is immediately update (default is true)
  16449. */
  16450. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16451. /**
  16452. * Clones the texture
  16453. * @returns the clone of the texture.
  16454. */
  16455. clone(): DynamicTexture;
  16456. /**
  16457. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16458. * @returns a serialized dynamic texture object
  16459. */
  16460. serialize(): any;
  16461. /** @hidden */
  16462. _rebuild(): void;
  16463. }
  16464. }
  16465. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16466. import { Scene } from "babylonjs/scene";
  16467. import { ISceneComponent } from "babylonjs/sceneComponent";
  16468. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16469. module "babylonjs/abstractScene" {
  16470. interface AbstractScene {
  16471. /**
  16472. * The list of procedural textures added to the scene
  16473. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16474. */
  16475. proceduralTextures: Array<ProceduralTexture>;
  16476. }
  16477. }
  16478. /**
  16479. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16480. * in a given scene.
  16481. */
  16482. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16483. /**
  16484. * The component name helpfull to identify the component in the list of scene components.
  16485. */
  16486. readonly name: string;
  16487. /**
  16488. * The scene the component belongs to.
  16489. */
  16490. scene: Scene;
  16491. /**
  16492. * Creates a new instance of the component for the given scene
  16493. * @param scene Defines the scene to register the component in
  16494. */
  16495. constructor(scene: Scene);
  16496. /**
  16497. * Registers the component in a given scene
  16498. */
  16499. register(): void;
  16500. /**
  16501. * Rebuilds the elements related to this component in case of
  16502. * context lost for instance.
  16503. */
  16504. rebuild(): void;
  16505. /**
  16506. * Disposes the component and the associated ressources.
  16507. */
  16508. dispose(): void;
  16509. private _beforeClear;
  16510. }
  16511. }
  16512. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16514. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16515. module "babylonjs/Engines/engine" {
  16516. interface Engine {
  16517. /**
  16518. * Creates a new render target cube texture
  16519. * @param size defines the size of the texture
  16520. * @param options defines the options used to create the texture
  16521. * @returns a new render target cube texture stored in an InternalTexture
  16522. */
  16523. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16524. }
  16525. }
  16526. }
  16527. declare module "babylonjs/Shaders/procedural.vertex" {
  16528. /** @hidden */
  16529. export var proceduralVertexShader: {
  16530. name: string;
  16531. shader: string;
  16532. };
  16533. }
  16534. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16535. import { Observable } from "babylonjs/Misc/observable";
  16536. import { Nullable } from "babylonjs/types";
  16537. import { Scene } from "babylonjs/scene";
  16538. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16539. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16540. import { Effect } from "babylonjs/Materials/effect";
  16541. import { Texture } from "babylonjs/Materials/Textures/texture";
  16542. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16543. import "babylonjs/Shaders/procedural.vertex";
  16544. /**
  16545. * 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.
  16546. * This is the base class of any Procedural texture and contains most of the shareable code.
  16547. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16548. */
  16549. export class ProceduralTexture extends Texture {
  16550. isCube: boolean;
  16551. /**
  16552. * Define if the texture is enabled or not (disabled texture will not render)
  16553. */
  16554. isEnabled: boolean;
  16555. /**
  16556. * Define if the texture must be cleared before rendering (default is true)
  16557. */
  16558. autoClear: boolean;
  16559. /**
  16560. * Callback called when the texture is generated
  16561. */
  16562. onGenerated: () => void;
  16563. /**
  16564. * Event raised when the texture is generated
  16565. */
  16566. onGeneratedObservable: Observable<ProceduralTexture>;
  16567. /** @hidden */
  16568. _generateMipMaps: boolean;
  16569. /** @hidden **/
  16570. _effect: Effect;
  16571. /** @hidden */
  16572. _textures: {
  16573. [key: string]: Texture;
  16574. };
  16575. private _size;
  16576. private _currentRefreshId;
  16577. private _refreshRate;
  16578. private _vertexBuffers;
  16579. private _indexBuffer;
  16580. private _uniforms;
  16581. private _samplers;
  16582. private _fragment;
  16583. private _floats;
  16584. private _ints;
  16585. private _floatsArrays;
  16586. private _colors3;
  16587. private _colors4;
  16588. private _vectors2;
  16589. private _vectors3;
  16590. private _matrices;
  16591. private _fallbackTexture;
  16592. private _fallbackTextureUsed;
  16593. private _engine;
  16594. private _cachedDefines;
  16595. private _contentUpdateId;
  16596. private _contentData;
  16597. /**
  16598. * Instantiates a new procedural texture.
  16599. * 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.
  16600. * This is the base class of any Procedural texture and contains most of the shareable code.
  16601. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16602. * @param name Define the name of the texture
  16603. * @param size Define the size of the texture to create
  16604. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16605. * @param scene Define the scene the texture belongs to
  16606. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16607. * @param generateMipMaps Define if the texture should creates mip maps or not
  16608. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16609. */
  16610. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16611. /**
  16612. * The effect that is created when initializing the post process.
  16613. * @returns The created effect corresponding the the postprocess.
  16614. */
  16615. getEffect(): Effect;
  16616. /**
  16617. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16618. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16619. */
  16620. getContent(): Nullable<ArrayBufferView>;
  16621. private _createIndexBuffer;
  16622. /** @hidden */
  16623. _rebuild(): void;
  16624. /**
  16625. * Resets the texture in order to recreate its associated resources.
  16626. * This can be called in case of context loss
  16627. */
  16628. reset(): void;
  16629. protected _getDefines(): string;
  16630. /**
  16631. * Is the texture ready to be used ? (rendered at least once)
  16632. * @returns true if ready, otherwise, false.
  16633. */
  16634. isReady(): boolean;
  16635. /**
  16636. * Resets the refresh counter of the texture and start bak from scratch.
  16637. * Could be useful to regenerate the texture if it is setup to render only once.
  16638. */
  16639. resetRefreshCounter(): void;
  16640. /**
  16641. * Set the fragment shader to use in order to render the texture.
  16642. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16643. */
  16644. setFragment(fragment: any): void;
  16645. /**
  16646. * Define the refresh rate of the texture or the rendering frequency.
  16647. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16648. */
  16649. refreshRate: number;
  16650. /** @hidden */
  16651. _shouldRender(): boolean;
  16652. /**
  16653. * Get the size the texture is rendering at.
  16654. * @returns the size (texture is always squared)
  16655. */
  16656. getRenderSize(): number;
  16657. /**
  16658. * Resize the texture to new value.
  16659. * @param size Define the new size the texture should have
  16660. * @param generateMipMaps Define whether the new texture should create mip maps
  16661. */
  16662. resize(size: number, generateMipMaps: boolean): void;
  16663. private _checkUniform;
  16664. /**
  16665. * Set a texture in the shader program used to render.
  16666. * @param name Define the name of the uniform samplers as defined in the shader
  16667. * @param texture Define the texture to bind to this sampler
  16668. * @return the texture itself allowing "fluent" like uniform updates
  16669. */
  16670. setTexture(name: string, texture: Texture): ProceduralTexture;
  16671. /**
  16672. * Set a float in the shader.
  16673. * @param name Define the name of the uniform as defined in the shader
  16674. * @param value Define the value to give to the uniform
  16675. * @return the texture itself allowing "fluent" like uniform updates
  16676. */
  16677. setFloat(name: string, value: number): ProceduralTexture;
  16678. /**
  16679. * Set a int in the shader.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the texture itself allowing "fluent" like uniform updates
  16683. */
  16684. setInt(name: string, value: number): ProceduralTexture;
  16685. /**
  16686. * Set an array of floats in the shader.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the texture itself allowing "fluent" like uniform updates
  16690. */
  16691. setFloats(name: string, value: number[]): ProceduralTexture;
  16692. /**
  16693. * Set a vec3 in the shader from a Color3.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the texture itself allowing "fluent" like uniform updates
  16697. */
  16698. setColor3(name: string, value: Color3): ProceduralTexture;
  16699. /**
  16700. * Set a vec4 in the shader from a Color4.
  16701. * @param name Define the name of the uniform as defined in the shader
  16702. * @param value Define the value to give to the uniform
  16703. * @return the texture itself allowing "fluent" like uniform updates
  16704. */
  16705. setColor4(name: string, value: Color4): ProceduralTexture;
  16706. /**
  16707. * Set a vec2 in the shader from a Vector2.
  16708. * @param name Define the name of the uniform as defined in the shader
  16709. * @param value Define the value to give to the uniform
  16710. * @return the texture itself allowing "fluent" like uniform updates
  16711. */
  16712. setVector2(name: string, value: Vector2): ProceduralTexture;
  16713. /**
  16714. * Set a vec3 in the shader from a Vector3.
  16715. * @param name Define the name of the uniform as defined in the shader
  16716. * @param value Define the value to give to the uniform
  16717. * @return the texture itself allowing "fluent" like uniform updates
  16718. */
  16719. setVector3(name: string, value: Vector3): ProceduralTexture;
  16720. /**
  16721. * Set a mat4 in the shader from a MAtrix.
  16722. * @param name Define the name of the uniform as defined in the shader
  16723. * @param value Define the value to give to the uniform
  16724. * @return the texture itself allowing "fluent" like uniform updates
  16725. */
  16726. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16727. /**
  16728. * Render the texture to its associated render target.
  16729. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16730. */
  16731. render(useCameraPostProcess?: boolean): void;
  16732. /**
  16733. * Clone the texture.
  16734. * @returns the cloned texture
  16735. */
  16736. clone(): ProceduralTexture;
  16737. /**
  16738. * Dispose the texture and release its asoociated resources.
  16739. */
  16740. dispose(): void;
  16741. }
  16742. }
  16743. declare module "babylonjs/Particles/baseParticleSystem" {
  16744. import { Nullable } from "babylonjs/types";
  16745. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16747. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16748. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16749. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16750. import { Scene } from "babylonjs/scene";
  16751. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16752. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16753. import { Texture } from "babylonjs/Materials/Textures/texture";
  16754. import { Color4 } from "babylonjs/Maths/math.color";
  16755. import { Animation } from "babylonjs/Animations/animation";
  16756. /**
  16757. * This represents the base class for particle system in Babylon.
  16758. * 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.
  16759. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16760. * @example https://doc.babylonjs.com/babylon101/particles
  16761. */
  16762. export class BaseParticleSystem {
  16763. /**
  16764. * Source color is added to the destination color without alpha affecting the result
  16765. */
  16766. static BLENDMODE_ONEONE: number;
  16767. /**
  16768. * Blend current color and particle color using particle’s alpha
  16769. */
  16770. static BLENDMODE_STANDARD: number;
  16771. /**
  16772. * Add current color and particle color multiplied by particle’s alpha
  16773. */
  16774. static BLENDMODE_ADD: number;
  16775. /**
  16776. * Multiply current color with particle color
  16777. */
  16778. static BLENDMODE_MULTIPLY: number;
  16779. /**
  16780. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16781. */
  16782. static BLENDMODE_MULTIPLYADD: number;
  16783. /**
  16784. * List of animations used by the particle system.
  16785. */
  16786. animations: Animation[];
  16787. /**
  16788. * The id of the Particle system.
  16789. */
  16790. id: string;
  16791. /**
  16792. * The friendly name of the Particle system.
  16793. */
  16794. name: string;
  16795. /**
  16796. * The rendering group used by the Particle system to chose when to render.
  16797. */
  16798. renderingGroupId: number;
  16799. /**
  16800. * The emitter represents the Mesh or position we are attaching the particle system to.
  16801. */
  16802. emitter: Nullable<AbstractMesh | Vector3>;
  16803. /**
  16804. * The maximum number of particles to emit per frame
  16805. */
  16806. emitRate: number;
  16807. /**
  16808. * If you want to launch only a few particles at once, that can be done, as well.
  16809. */
  16810. manualEmitCount: number;
  16811. /**
  16812. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16813. */
  16814. updateSpeed: number;
  16815. /**
  16816. * The amount of time the particle system is running (depends of the overall update speed).
  16817. */
  16818. targetStopDuration: number;
  16819. /**
  16820. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16821. */
  16822. disposeOnStop: boolean;
  16823. /**
  16824. * Minimum power of emitting particles.
  16825. */
  16826. minEmitPower: number;
  16827. /**
  16828. * Maximum power of emitting particles.
  16829. */
  16830. maxEmitPower: number;
  16831. /**
  16832. * Minimum life time of emitting particles.
  16833. */
  16834. minLifeTime: number;
  16835. /**
  16836. * Maximum life time of emitting particles.
  16837. */
  16838. maxLifeTime: number;
  16839. /**
  16840. * Minimum Size of emitting particles.
  16841. */
  16842. minSize: number;
  16843. /**
  16844. * Maximum Size of emitting particles.
  16845. */
  16846. maxSize: number;
  16847. /**
  16848. * Minimum scale of emitting particles on X axis.
  16849. */
  16850. minScaleX: number;
  16851. /**
  16852. * Maximum scale of emitting particles on X axis.
  16853. */
  16854. maxScaleX: number;
  16855. /**
  16856. * Minimum scale of emitting particles on Y axis.
  16857. */
  16858. minScaleY: number;
  16859. /**
  16860. * Maximum scale of emitting particles on Y axis.
  16861. */
  16862. maxScaleY: number;
  16863. /**
  16864. * Gets or sets the minimal initial rotation in radians.
  16865. */
  16866. minInitialRotation: number;
  16867. /**
  16868. * Gets or sets the maximal initial rotation in radians.
  16869. */
  16870. maxInitialRotation: number;
  16871. /**
  16872. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16873. */
  16874. minAngularSpeed: number;
  16875. /**
  16876. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16877. */
  16878. maxAngularSpeed: number;
  16879. /**
  16880. * The texture used to render each particle. (this can be a spritesheet)
  16881. */
  16882. particleTexture: Nullable<Texture>;
  16883. /**
  16884. * The layer mask we are rendering the particles through.
  16885. */
  16886. layerMask: number;
  16887. /**
  16888. * This can help using your own shader to render the particle system.
  16889. * The according effect will be created
  16890. */
  16891. customShader: any;
  16892. /**
  16893. * By default particle system starts as soon as they are created. This prevents the
  16894. * automatic start to happen and let you decide when to start emitting particles.
  16895. */
  16896. preventAutoStart: boolean;
  16897. private _noiseTexture;
  16898. /**
  16899. * Gets or sets a texture used to add random noise to particle positions
  16900. */
  16901. noiseTexture: Nullable<ProceduralTexture>;
  16902. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16903. noiseStrength: Vector3;
  16904. /**
  16905. * Callback triggered when the particle animation is ending.
  16906. */
  16907. onAnimationEnd: Nullable<() => void>;
  16908. /**
  16909. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16910. */
  16911. blendMode: number;
  16912. /**
  16913. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16914. * to override the particles.
  16915. */
  16916. forceDepthWrite: boolean;
  16917. /** 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 */
  16918. preWarmCycles: number;
  16919. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16920. preWarmStepOffset: number;
  16921. /**
  16922. * 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)
  16923. */
  16924. spriteCellChangeSpeed: number;
  16925. /**
  16926. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16927. */
  16928. startSpriteCellID: number;
  16929. /**
  16930. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16931. */
  16932. endSpriteCellID: number;
  16933. /**
  16934. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16935. */
  16936. spriteCellWidth: number;
  16937. /**
  16938. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16939. */
  16940. spriteCellHeight: number;
  16941. /**
  16942. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16943. */
  16944. spriteRandomStartCell: boolean;
  16945. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16946. translationPivot: Vector2;
  16947. /** @hidden */
  16948. protected _isAnimationSheetEnabled: boolean;
  16949. /**
  16950. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16951. */
  16952. beginAnimationOnStart: boolean;
  16953. /**
  16954. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16955. */
  16956. beginAnimationFrom: number;
  16957. /**
  16958. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16959. */
  16960. beginAnimationTo: number;
  16961. /**
  16962. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16963. */
  16964. beginAnimationLoop: boolean;
  16965. /**
  16966. * Gets or sets a world offset applied to all particles
  16967. */
  16968. worldOffset: Vector3;
  16969. /**
  16970. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16971. */
  16972. isAnimationSheetEnabled: boolean;
  16973. /**
  16974. * Get hosting scene
  16975. * @returns the scene
  16976. */
  16977. getScene(): Scene;
  16978. /**
  16979. * You can use gravity if you want to give an orientation to your particles.
  16980. */
  16981. gravity: Vector3;
  16982. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16983. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16984. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16985. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16986. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16987. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16988. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16989. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16990. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16991. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16992. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16993. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16994. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16995. /**
  16996. * Defines the delay in milliseconds before starting the system (0 by default)
  16997. */
  16998. startDelay: number;
  16999. /**
  17000. * Gets the current list of drag gradients.
  17001. * You must use addDragGradient and removeDragGradient to udpate this list
  17002. * @returns the list of drag gradients
  17003. */
  17004. getDragGradients(): Nullable<Array<FactorGradient>>;
  17005. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17006. limitVelocityDamping: number;
  17007. /**
  17008. * Gets the current list of limit velocity gradients.
  17009. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17010. * @returns the list of limit velocity gradients
  17011. */
  17012. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17013. /**
  17014. * Gets the current list of color gradients.
  17015. * You must use addColorGradient and removeColorGradient to udpate this list
  17016. * @returns the list of color gradients
  17017. */
  17018. getColorGradients(): Nullable<Array<ColorGradient>>;
  17019. /**
  17020. * Gets the current list of size gradients.
  17021. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17022. * @returns the list of size gradients
  17023. */
  17024. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17025. /**
  17026. * Gets the current list of color remap gradients.
  17027. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17028. * @returns the list of color remap gradients
  17029. */
  17030. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17031. /**
  17032. * Gets the current list of alpha remap gradients.
  17033. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17034. * @returns the list of alpha remap gradients
  17035. */
  17036. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17037. /**
  17038. * Gets the current list of life time gradients.
  17039. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17040. * @returns the list of life time gradients
  17041. */
  17042. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17043. /**
  17044. * Gets the current list of angular speed gradients.
  17045. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17046. * @returns the list of angular speed gradients
  17047. */
  17048. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17049. /**
  17050. * Gets the current list of velocity gradients.
  17051. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17052. * @returns the list of velocity gradients
  17053. */
  17054. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17055. /**
  17056. * Gets the current list of start size gradients.
  17057. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17058. * @returns the list of start size gradients
  17059. */
  17060. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17061. /**
  17062. * Gets the current list of emit rate gradients.
  17063. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17064. * @returns the list of emit rate gradients
  17065. */
  17066. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17067. /**
  17068. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17069. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17070. */
  17071. direction1: Vector3;
  17072. /**
  17073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17074. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17075. */
  17076. direction2: Vector3;
  17077. /**
  17078. * 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.
  17079. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17080. */
  17081. minEmitBox: Vector3;
  17082. /**
  17083. * 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.
  17084. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17085. */
  17086. maxEmitBox: Vector3;
  17087. /**
  17088. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17089. */
  17090. color1: Color4;
  17091. /**
  17092. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17093. */
  17094. color2: Color4;
  17095. /**
  17096. * Color the particle will have at the end of its lifetime
  17097. */
  17098. colorDead: Color4;
  17099. /**
  17100. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17101. */
  17102. textureMask: Color4;
  17103. /**
  17104. * The particle emitter type defines the emitter used by the particle system.
  17105. * It can be for example box, sphere, or cone...
  17106. */
  17107. particleEmitterType: IParticleEmitterType;
  17108. /** @hidden */
  17109. _isSubEmitter: boolean;
  17110. /**
  17111. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17112. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17113. */
  17114. billboardMode: number;
  17115. protected _isBillboardBased: boolean;
  17116. /**
  17117. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17118. */
  17119. isBillboardBased: boolean;
  17120. /**
  17121. * The scene the particle system belongs to.
  17122. */
  17123. protected _scene: Scene;
  17124. /**
  17125. * Local cache of defines for image processing.
  17126. */
  17127. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17128. /**
  17129. * Default configuration related to image processing available in the standard Material.
  17130. */
  17131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17132. /**
  17133. * Gets the image processing configuration used either in this material.
  17134. */
  17135. /**
  17136. * Sets the Default image processing configuration used either in the this material.
  17137. *
  17138. * If sets to null, the scene one is in use.
  17139. */
  17140. imageProcessingConfiguration: ImageProcessingConfiguration;
  17141. /**
  17142. * Attaches a new image processing configuration to the Standard Material.
  17143. * @param configuration
  17144. */
  17145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17146. /** @hidden */
  17147. protected _reset(): void;
  17148. /** @hidden */
  17149. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17150. /**
  17151. * Instantiates a particle system.
  17152. * 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.
  17153. * @param name The name of the particle system
  17154. */
  17155. constructor(name: string);
  17156. /**
  17157. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17160. * @returns the emitter
  17161. */
  17162. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17163. /**
  17164. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17165. * @param radius The radius of the hemisphere to emit from
  17166. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17167. * @returns the emitter
  17168. */
  17169. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17170. /**
  17171. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17172. * @param radius The radius of the sphere to emit from
  17173. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17174. * @returns the emitter
  17175. */
  17176. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17177. /**
  17178. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17179. * @param radius The radius of the sphere to emit from
  17180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17182. * @returns the emitter
  17183. */
  17184. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17185. /**
  17186. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17187. * @param radius The radius of the emission cylinder
  17188. * @param height The height of the emission cylinder
  17189. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17190. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17191. * @returns the emitter
  17192. */
  17193. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17194. /**
  17195. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17196. * @param radius The radius of the cylinder to emit from
  17197. * @param height The height of the emission cylinder
  17198. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17199. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17200. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17201. * @returns the emitter
  17202. */
  17203. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17204. /**
  17205. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17206. * @param radius The radius of the cone to emit from
  17207. * @param angle The base angle of the cone
  17208. * @returns the emitter
  17209. */
  17210. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17211. /**
  17212. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17215. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17216. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17217. * @returns the emitter
  17218. */
  17219. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17220. }
  17221. }
  17222. declare module "babylonjs/Particles/subEmitter" {
  17223. import { Scene } from "babylonjs/scene";
  17224. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17225. /**
  17226. * Type of sub emitter
  17227. */
  17228. export enum SubEmitterType {
  17229. /**
  17230. * Attached to the particle over it's lifetime
  17231. */
  17232. ATTACHED = 0,
  17233. /**
  17234. * Created when the particle dies
  17235. */
  17236. END = 1
  17237. }
  17238. /**
  17239. * Sub emitter class used to emit particles from an existing particle
  17240. */
  17241. export class SubEmitter {
  17242. /**
  17243. * the particle system to be used by the sub emitter
  17244. */
  17245. particleSystem: ParticleSystem;
  17246. /**
  17247. * Type of the submitter (Default: END)
  17248. */
  17249. type: SubEmitterType;
  17250. /**
  17251. * 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)
  17252. * Note: This only is supported when using an emitter of type Mesh
  17253. */
  17254. inheritDirection: boolean;
  17255. /**
  17256. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17257. */
  17258. inheritedVelocityAmount: number;
  17259. /**
  17260. * Creates a sub emitter
  17261. * @param particleSystem the particle system to be used by the sub emitter
  17262. */
  17263. constructor(
  17264. /**
  17265. * the particle system to be used by the sub emitter
  17266. */
  17267. particleSystem: ParticleSystem);
  17268. /**
  17269. * Clones the sub emitter
  17270. * @returns the cloned sub emitter
  17271. */
  17272. clone(): SubEmitter;
  17273. /**
  17274. * Serialize current object to a JSON object
  17275. * @returns the serialized object
  17276. */
  17277. serialize(): any;
  17278. /** @hidden */
  17279. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17280. /**
  17281. * Creates a new SubEmitter from a serialized JSON version
  17282. * @param serializationObject defines the JSON object to read from
  17283. * @param scene defines the hosting scene
  17284. * @param rootUrl defines the rootUrl for data loading
  17285. * @returns a new SubEmitter
  17286. */
  17287. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17288. /** Release associated resources */
  17289. dispose(): void;
  17290. }
  17291. }
  17292. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17293. /** @hidden */
  17294. export var clipPlaneFragmentDeclaration: {
  17295. name: string;
  17296. shader: string;
  17297. };
  17298. }
  17299. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17300. /** @hidden */
  17301. export var imageProcessingDeclaration: {
  17302. name: string;
  17303. shader: string;
  17304. };
  17305. }
  17306. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17307. /** @hidden */
  17308. export var imageProcessingFunctions: {
  17309. name: string;
  17310. shader: string;
  17311. };
  17312. }
  17313. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17314. /** @hidden */
  17315. export var clipPlaneFragment: {
  17316. name: string;
  17317. shader: string;
  17318. };
  17319. }
  17320. declare module "babylonjs/Shaders/particles.fragment" {
  17321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17322. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17323. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17324. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17326. /** @hidden */
  17327. export var particlesPixelShader: {
  17328. name: string;
  17329. shader: string;
  17330. };
  17331. }
  17332. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17333. /** @hidden */
  17334. export var clipPlaneVertexDeclaration: {
  17335. name: string;
  17336. shader: string;
  17337. };
  17338. }
  17339. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17340. /** @hidden */
  17341. export var clipPlaneVertex: {
  17342. name: string;
  17343. shader: string;
  17344. };
  17345. }
  17346. declare module "babylonjs/Shaders/particles.vertex" {
  17347. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17348. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17349. /** @hidden */
  17350. export var particlesVertexShader: {
  17351. name: string;
  17352. shader: string;
  17353. };
  17354. }
  17355. declare module "babylonjs/Particles/particleSystem" {
  17356. import { Nullable } from "babylonjs/types";
  17357. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17358. import { Observable } from "babylonjs/Misc/observable";
  17359. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17360. import { Effect } from "babylonjs/Materials/effect";
  17361. import { Scene, IDisposable } from "babylonjs/scene";
  17362. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17363. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17364. import { Particle } from "babylonjs/Particles/particle";
  17365. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17366. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17367. import "babylonjs/Shaders/particles.fragment";
  17368. import "babylonjs/Shaders/particles.vertex";
  17369. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17370. /**
  17371. * This represents a particle system in Babylon.
  17372. * 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.
  17373. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17374. * @example https://doc.babylonjs.com/babylon101/particles
  17375. */
  17376. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17377. /**
  17378. * Billboard mode will only apply to Y axis
  17379. */
  17380. static readonly BILLBOARDMODE_Y: number;
  17381. /**
  17382. * Billboard mode will apply to all axes
  17383. */
  17384. static readonly BILLBOARDMODE_ALL: number;
  17385. /**
  17386. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17387. */
  17388. static readonly BILLBOARDMODE_STRETCHED: number;
  17389. /**
  17390. * This function can be defined to provide custom update for active particles.
  17391. * This function will be called instead of regular update (age, position, color, etc.).
  17392. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17393. */
  17394. updateFunction: (particles: Particle[]) => void;
  17395. private _emitterWorldMatrix;
  17396. /**
  17397. * This function can be defined to specify initial direction for every new particle.
  17398. * It by default use the emitterType defined function
  17399. */
  17400. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17401. /**
  17402. * This function can be defined to specify initial position for every new particle.
  17403. * It by default use the emitterType defined function
  17404. */
  17405. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17406. /**
  17407. * @hidden
  17408. */
  17409. _inheritedVelocityOffset: Vector3;
  17410. /**
  17411. * An event triggered when the system is disposed
  17412. */
  17413. onDisposeObservable: Observable<ParticleSystem>;
  17414. private _onDisposeObserver;
  17415. /**
  17416. * Sets a callback that will be triggered when the system is disposed
  17417. */
  17418. onDispose: () => void;
  17419. private _particles;
  17420. private _epsilon;
  17421. private _capacity;
  17422. private _stockParticles;
  17423. private _newPartsExcess;
  17424. private _vertexData;
  17425. private _vertexBuffer;
  17426. private _vertexBuffers;
  17427. private _spriteBuffer;
  17428. private _indexBuffer;
  17429. private _effect;
  17430. private _customEffect;
  17431. private _cachedDefines;
  17432. private _scaledColorStep;
  17433. private _colorDiff;
  17434. private _scaledDirection;
  17435. private _scaledGravity;
  17436. private _currentRenderId;
  17437. private _alive;
  17438. private _useInstancing;
  17439. private _started;
  17440. private _stopped;
  17441. private _actualFrame;
  17442. private _scaledUpdateSpeed;
  17443. private _vertexBufferSize;
  17444. /** @hidden */
  17445. _currentEmitRateGradient: Nullable<FactorGradient>;
  17446. /** @hidden */
  17447. _currentEmitRate1: number;
  17448. /** @hidden */
  17449. _currentEmitRate2: number;
  17450. /** @hidden */
  17451. _currentStartSizeGradient: Nullable<FactorGradient>;
  17452. /** @hidden */
  17453. _currentStartSize1: number;
  17454. /** @hidden */
  17455. _currentStartSize2: number;
  17456. private readonly _rawTextureWidth;
  17457. private _rampGradientsTexture;
  17458. private _useRampGradients;
  17459. /** Gets or sets a boolean indicating that ramp gradients must be used
  17460. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17461. */
  17462. useRampGradients: boolean;
  17463. /**
  17464. * 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.
  17465. * 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: [])
  17466. */
  17467. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17468. private _subEmitters;
  17469. /**
  17470. * @hidden
  17471. * If the particle systems emitter should be disposed when the particle system is disposed
  17472. */
  17473. _disposeEmitterOnDispose: boolean;
  17474. /**
  17475. * The current active Sub-systems, this property is used by the root particle system only.
  17476. */
  17477. activeSubSystems: Array<ParticleSystem>;
  17478. private _rootParticleSystem;
  17479. /**
  17480. * Gets the current list of active particles
  17481. */
  17482. readonly particles: Particle[];
  17483. /**
  17484. * Returns the string "ParticleSystem"
  17485. * @returns a string containing the class name
  17486. */
  17487. getClassName(): string;
  17488. /**
  17489. * Instantiates a particle system.
  17490. * 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.
  17491. * @param name The name of the particle system
  17492. * @param capacity The max number of particles alive at the same time
  17493. * @param scene The scene the particle system belongs to
  17494. * @param customEffect a custom effect used to change the way particles are rendered by default
  17495. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17496. * @param epsilon Offset used to render the particles
  17497. */
  17498. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17499. private _addFactorGradient;
  17500. private _removeFactorGradient;
  17501. /**
  17502. * Adds a new life time gradient
  17503. * @param gradient defines the gradient to use (between 0 and 1)
  17504. * @param factor defines the life time factor to affect to the specified gradient
  17505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17506. * @returns the current particle system
  17507. */
  17508. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17509. /**
  17510. * Remove a specific life time gradient
  17511. * @param gradient defines the gradient to remove
  17512. * @returns the current particle system
  17513. */
  17514. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17515. /**
  17516. * Adds a new size gradient
  17517. * @param gradient defines the gradient to use (between 0 and 1)
  17518. * @param factor defines the size factor to affect to the specified gradient
  17519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17520. * @returns the current particle system
  17521. */
  17522. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17523. /**
  17524. * Remove a specific size gradient
  17525. * @param gradient defines the gradient to remove
  17526. * @returns the current particle system
  17527. */
  17528. removeSizeGradient(gradient: number): IParticleSystem;
  17529. /**
  17530. * Adds a new color remap gradient
  17531. * @param gradient defines the gradient to use (between 0 and 1)
  17532. * @param min defines the color remap minimal range
  17533. * @param max defines the color remap maximal range
  17534. * @returns the current particle system
  17535. */
  17536. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17537. /**
  17538. * Remove a specific color remap gradient
  17539. * @param gradient defines the gradient to remove
  17540. * @returns the current particle system
  17541. */
  17542. removeColorRemapGradient(gradient: number): IParticleSystem;
  17543. /**
  17544. * Adds a new alpha remap gradient
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param min defines the alpha remap minimal range
  17547. * @param max defines the alpha remap maximal range
  17548. * @returns the current particle system
  17549. */
  17550. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17551. /**
  17552. * Remove a specific alpha remap gradient
  17553. * @param gradient defines the gradient to remove
  17554. * @returns the current particle system
  17555. */
  17556. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17557. /**
  17558. * Adds a new angular speed gradient
  17559. * @param gradient defines the gradient to use (between 0 and 1)
  17560. * @param factor defines the angular speed to affect to the specified gradient
  17561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17562. * @returns the current particle system
  17563. */
  17564. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17565. /**
  17566. * Remove a specific angular speed gradient
  17567. * @param gradient defines the gradient to remove
  17568. * @returns the current particle system
  17569. */
  17570. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17571. /**
  17572. * Adds a new velocity gradient
  17573. * @param gradient defines the gradient to use (between 0 and 1)
  17574. * @param factor defines the velocity to affect to the specified gradient
  17575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17576. * @returns the current particle system
  17577. */
  17578. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17579. /**
  17580. * Remove a specific velocity gradient
  17581. * @param gradient defines the gradient to remove
  17582. * @returns the current particle system
  17583. */
  17584. removeVelocityGradient(gradient: number): IParticleSystem;
  17585. /**
  17586. * Adds a new limit velocity gradient
  17587. * @param gradient defines the gradient to use (between 0 and 1)
  17588. * @param factor defines the limit velocity value to affect to the specified gradient
  17589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17590. * @returns the current particle system
  17591. */
  17592. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17593. /**
  17594. * Remove a specific limit velocity gradient
  17595. * @param gradient defines the gradient to remove
  17596. * @returns the current particle system
  17597. */
  17598. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17599. /**
  17600. * Adds a new drag gradient
  17601. * @param gradient defines the gradient to use (between 0 and 1)
  17602. * @param factor defines the drag value to affect to the specified gradient
  17603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17604. * @returns the current particle system
  17605. */
  17606. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17607. /**
  17608. * Remove a specific drag gradient
  17609. * @param gradient defines the gradient to remove
  17610. * @returns the current particle system
  17611. */
  17612. removeDragGradient(gradient: number): IParticleSystem;
  17613. /**
  17614. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17615. * @param gradient defines the gradient to use (between 0 and 1)
  17616. * @param factor defines the emit rate value to affect to the specified gradient
  17617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17618. * @returns the current particle system
  17619. */
  17620. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17621. /**
  17622. * Remove a specific emit rate gradient
  17623. * @param gradient defines the gradient to remove
  17624. * @returns the current particle system
  17625. */
  17626. removeEmitRateGradient(gradient: number): IParticleSystem;
  17627. /**
  17628. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17629. * @param gradient defines the gradient to use (between 0 and 1)
  17630. * @param factor defines the start size value to affect to the specified gradient
  17631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17632. * @returns the current particle system
  17633. */
  17634. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17635. /**
  17636. * Remove a specific start size gradient
  17637. * @param gradient defines the gradient to remove
  17638. * @returns the current particle system
  17639. */
  17640. removeStartSizeGradient(gradient: number): IParticleSystem;
  17641. private _createRampGradientTexture;
  17642. /**
  17643. * Gets the current list of ramp gradients.
  17644. * You must use addRampGradient and removeRampGradient to udpate this list
  17645. * @returns the list of ramp gradients
  17646. */
  17647. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17648. /**
  17649. * Adds a new ramp gradient used to remap particle colors
  17650. * @param gradient defines the gradient to use (between 0 and 1)
  17651. * @param color defines the color to affect to the specified gradient
  17652. * @returns the current particle system
  17653. */
  17654. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17655. /**
  17656. * Remove a specific ramp gradient
  17657. * @param gradient defines the gradient to remove
  17658. * @returns the current particle system
  17659. */
  17660. removeRampGradient(gradient: number): ParticleSystem;
  17661. /**
  17662. * Adds a new color gradient
  17663. * @param gradient defines the gradient to use (between 0 and 1)
  17664. * @param color1 defines the color to affect to the specified gradient
  17665. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17666. * @returns this particle system
  17667. */
  17668. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17669. /**
  17670. * Remove a specific color gradient
  17671. * @param gradient defines the gradient to remove
  17672. * @returns this particle system
  17673. */
  17674. removeColorGradient(gradient: number): IParticleSystem;
  17675. private _fetchR;
  17676. protected _reset(): void;
  17677. private _resetEffect;
  17678. private _createVertexBuffers;
  17679. private _createIndexBuffer;
  17680. /**
  17681. * Gets the maximum number of particles active at the same time.
  17682. * @returns The max number of active particles.
  17683. */
  17684. getCapacity(): number;
  17685. /**
  17686. * Gets whether there are still active particles in the system.
  17687. * @returns True if it is alive, otherwise false.
  17688. */
  17689. isAlive(): boolean;
  17690. /**
  17691. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17692. * @returns True if it has been started, otherwise false.
  17693. */
  17694. isStarted(): boolean;
  17695. private _prepareSubEmitterInternalArray;
  17696. /**
  17697. * Starts the particle system and begins to emit
  17698. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17699. */
  17700. start(delay?: number): void;
  17701. /**
  17702. * Stops the particle system.
  17703. * @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.
  17704. */
  17705. stop(stopSubEmitters?: boolean): void;
  17706. /**
  17707. * Remove all active particles
  17708. */
  17709. reset(): void;
  17710. /**
  17711. * @hidden (for internal use only)
  17712. */
  17713. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17714. /**
  17715. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17716. * Its lifetime will start back at 0.
  17717. */
  17718. recycleParticle: (particle: Particle) => void;
  17719. private _stopSubEmitters;
  17720. private _createParticle;
  17721. private _removeFromRoot;
  17722. private _emitFromParticle;
  17723. private _update;
  17724. /** @hidden */
  17725. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17726. /** @hidden */
  17727. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17728. /** @hidden */
  17729. private _getEffect;
  17730. /**
  17731. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17732. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17733. */
  17734. animate(preWarmOnly?: boolean): void;
  17735. private _appendParticleVertices;
  17736. /**
  17737. * Rebuilds the particle system.
  17738. */
  17739. rebuild(): void;
  17740. /**
  17741. * Is this system ready to be used/rendered
  17742. * @return true if the system is ready
  17743. */
  17744. isReady(): boolean;
  17745. private _render;
  17746. /**
  17747. * Renders the particle system in its current state.
  17748. * @returns the current number of particles
  17749. */
  17750. render(): number;
  17751. /**
  17752. * Disposes the particle system and free the associated resources
  17753. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17754. */
  17755. dispose(disposeTexture?: boolean): void;
  17756. /**
  17757. * Clones the particle system.
  17758. * @param name The name of the cloned object
  17759. * @param newEmitter The new emitter to use
  17760. * @returns the cloned particle system
  17761. */
  17762. clone(name: string, newEmitter: any): ParticleSystem;
  17763. /**
  17764. * Serializes the particle system to a JSON object.
  17765. * @returns the JSON object
  17766. */
  17767. serialize(): any;
  17768. /** @hidden */
  17769. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17770. /** @hidden */
  17771. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17772. /**
  17773. * Parses a JSON object to create a particle system.
  17774. * @param parsedParticleSystem The JSON object to parse
  17775. * @param scene The scene to create the particle system in
  17776. * @param rootUrl The root url to use to load external dependencies like texture
  17777. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17778. * @returns the Parsed particle system
  17779. */
  17780. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17781. }
  17782. }
  17783. declare module "babylonjs/Particles/particle" {
  17784. import { Nullable } from "babylonjs/types";
  17785. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17786. import { Color4 } from "babylonjs/Maths/math.color";
  17787. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17788. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17789. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17790. /**
  17791. * A particle represents one of the element emitted by a particle system.
  17792. * This is mainly define by its coordinates, direction, velocity and age.
  17793. */
  17794. export class Particle {
  17795. /**
  17796. * The particle system the particle belongs to.
  17797. */
  17798. particleSystem: ParticleSystem;
  17799. private static _Count;
  17800. /**
  17801. * Unique ID of the particle
  17802. */
  17803. id: number;
  17804. /**
  17805. * The world position of the particle in the scene.
  17806. */
  17807. position: Vector3;
  17808. /**
  17809. * The world direction of the particle in the scene.
  17810. */
  17811. direction: Vector3;
  17812. /**
  17813. * The color of the particle.
  17814. */
  17815. color: Color4;
  17816. /**
  17817. * The color change of the particle per step.
  17818. */
  17819. colorStep: Color4;
  17820. /**
  17821. * Defines how long will the life of the particle be.
  17822. */
  17823. lifeTime: number;
  17824. /**
  17825. * The current age of the particle.
  17826. */
  17827. age: number;
  17828. /**
  17829. * The current size of the particle.
  17830. */
  17831. size: number;
  17832. /**
  17833. * The current scale of the particle.
  17834. */
  17835. scale: Vector2;
  17836. /**
  17837. * The current angle of the particle.
  17838. */
  17839. angle: number;
  17840. /**
  17841. * Defines how fast is the angle changing.
  17842. */
  17843. angularSpeed: number;
  17844. /**
  17845. * Defines the cell index used by the particle to be rendered from a sprite.
  17846. */
  17847. cellIndex: number;
  17848. /**
  17849. * The information required to support color remapping
  17850. */
  17851. remapData: Vector4;
  17852. /** @hidden */
  17853. _randomCellOffset?: number;
  17854. /** @hidden */
  17855. _initialDirection: Nullable<Vector3>;
  17856. /** @hidden */
  17857. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17858. /** @hidden */
  17859. _initialStartSpriteCellID: number;
  17860. /** @hidden */
  17861. _initialEndSpriteCellID: number;
  17862. /** @hidden */
  17863. _currentColorGradient: Nullable<ColorGradient>;
  17864. /** @hidden */
  17865. _currentColor1: Color4;
  17866. /** @hidden */
  17867. _currentColor2: Color4;
  17868. /** @hidden */
  17869. _currentSizeGradient: Nullable<FactorGradient>;
  17870. /** @hidden */
  17871. _currentSize1: number;
  17872. /** @hidden */
  17873. _currentSize2: number;
  17874. /** @hidden */
  17875. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17876. /** @hidden */
  17877. _currentAngularSpeed1: number;
  17878. /** @hidden */
  17879. _currentAngularSpeed2: number;
  17880. /** @hidden */
  17881. _currentVelocityGradient: Nullable<FactorGradient>;
  17882. /** @hidden */
  17883. _currentVelocity1: number;
  17884. /** @hidden */
  17885. _currentVelocity2: number;
  17886. /** @hidden */
  17887. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17888. /** @hidden */
  17889. _currentLimitVelocity1: number;
  17890. /** @hidden */
  17891. _currentLimitVelocity2: number;
  17892. /** @hidden */
  17893. _currentDragGradient: Nullable<FactorGradient>;
  17894. /** @hidden */
  17895. _currentDrag1: number;
  17896. /** @hidden */
  17897. _currentDrag2: number;
  17898. /** @hidden */
  17899. _randomNoiseCoordinates1: Vector3;
  17900. /** @hidden */
  17901. _randomNoiseCoordinates2: Vector3;
  17902. /**
  17903. * Creates a new instance Particle
  17904. * @param particleSystem the particle system the particle belongs to
  17905. */
  17906. constructor(
  17907. /**
  17908. * The particle system the particle belongs to.
  17909. */
  17910. particleSystem: ParticleSystem);
  17911. private updateCellInfoFromSystem;
  17912. /**
  17913. * Defines how the sprite cell index is updated for the particle
  17914. */
  17915. updateCellIndex(): void;
  17916. /** @hidden */
  17917. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17918. /** @hidden */
  17919. _inheritParticleInfoToSubEmitters(): void;
  17920. /** @hidden */
  17921. _reset(): void;
  17922. /**
  17923. * Copy the properties of particle to another one.
  17924. * @param other the particle to copy the information to.
  17925. */
  17926. copyTo(other: Particle): void;
  17927. }
  17928. }
  17929. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17930. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17931. import { Effect } from "babylonjs/Materials/effect";
  17932. import { Particle } from "babylonjs/Particles/particle";
  17933. /**
  17934. * Particle emitter represents a volume emitting particles.
  17935. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17936. */
  17937. export interface IParticleEmitterType {
  17938. /**
  17939. * Called by the particle System when the direction is computed for the created particle.
  17940. * @param worldMatrix is the world matrix of the particle system
  17941. * @param directionToUpdate is the direction vector to update with the result
  17942. * @param particle is the particle we are computed the direction for
  17943. */
  17944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17945. /**
  17946. * Called by the particle System when the position is computed for the created particle.
  17947. * @param worldMatrix is the world matrix of the particle system
  17948. * @param positionToUpdate is the position vector to update with the result
  17949. * @param particle is the particle we are computed the position for
  17950. */
  17951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17952. /**
  17953. * Clones the current emitter and returns a copy of it
  17954. * @returns the new emitter
  17955. */
  17956. clone(): IParticleEmitterType;
  17957. /**
  17958. * Called by the GPUParticleSystem to setup the update shader
  17959. * @param effect defines the update shader
  17960. */
  17961. applyToShader(effect: Effect): void;
  17962. /**
  17963. * Returns a string to use to update the GPU particles update shader
  17964. * @returns the effect defines string
  17965. */
  17966. getEffectDefines(): string;
  17967. /**
  17968. * Returns a string representing the class name
  17969. * @returns a string containing the class name
  17970. */
  17971. getClassName(): string;
  17972. /**
  17973. * Serializes the particle system to a JSON object.
  17974. * @returns the JSON object
  17975. */
  17976. serialize(): any;
  17977. /**
  17978. * Parse properties from a JSON object
  17979. * @param serializationObject defines the JSON object
  17980. */
  17981. parse(serializationObject: any): void;
  17982. }
  17983. }
  17984. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17985. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17986. import { Effect } from "babylonjs/Materials/effect";
  17987. import { Particle } from "babylonjs/Particles/particle";
  17988. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17989. /**
  17990. * Particle emitter emitting particles from the inside of a box.
  17991. * It emits the particles randomly between 2 given directions.
  17992. */
  17993. export class BoxParticleEmitter implements IParticleEmitterType {
  17994. /**
  17995. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17996. */
  17997. direction1: Vector3;
  17998. /**
  17999. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18000. */
  18001. direction2: Vector3;
  18002. /**
  18003. * 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.
  18004. */
  18005. minEmitBox: Vector3;
  18006. /**
  18007. * 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.
  18008. */
  18009. maxEmitBox: Vector3;
  18010. /**
  18011. * Creates a new instance BoxParticleEmitter
  18012. */
  18013. constructor();
  18014. /**
  18015. * Called by the particle System when the direction is computed for the created particle.
  18016. * @param worldMatrix is the world matrix of the particle system
  18017. * @param directionToUpdate is the direction vector to update with the result
  18018. * @param particle is the particle we are computed the direction for
  18019. */
  18020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18021. /**
  18022. * Called by the particle System when the position is computed for the created particle.
  18023. * @param worldMatrix is the world matrix of the particle system
  18024. * @param positionToUpdate is the position vector to update with the result
  18025. * @param particle is the particle we are computed the position for
  18026. */
  18027. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18028. /**
  18029. * Clones the current emitter and returns a copy of it
  18030. * @returns the new emitter
  18031. */
  18032. clone(): BoxParticleEmitter;
  18033. /**
  18034. * Called by the GPUParticleSystem to setup the update shader
  18035. * @param effect defines the update shader
  18036. */
  18037. applyToShader(effect: Effect): void;
  18038. /**
  18039. * Returns a string to use to update the GPU particles update shader
  18040. * @returns a string containng the defines string
  18041. */
  18042. getEffectDefines(): string;
  18043. /**
  18044. * Returns the string "BoxParticleEmitter"
  18045. * @returns a string containing the class name
  18046. */
  18047. getClassName(): string;
  18048. /**
  18049. * Serializes the particle system to a JSON object.
  18050. * @returns the JSON object
  18051. */
  18052. serialize(): any;
  18053. /**
  18054. * Parse properties from a JSON object
  18055. * @param serializationObject defines the JSON object
  18056. */
  18057. parse(serializationObject: any): void;
  18058. }
  18059. }
  18060. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18061. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18062. import { Effect } from "babylonjs/Materials/effect";
  18063. import { Particle } from "babylonjs/Particles/particle";
  18064. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18065. /**
  18066. * Particle emitter emitting particles from the inside of a cone.
  18067. * It emits the particles alongside the cone volume from the base to the particle.
  18068. * The emission direction might be randomized.
  18069. */
  18070. export class ConeParticleEmitter implements IParticleEmitterType {
  18071. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18072. directionRandomizer: number;
  18073. private _radius;
  18074. private _angle;
  18075. private _height;
  18076. /**
  18077. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18078. */
  18079. radiusRange: number;
  18080. /**
  18081. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18082. */
  18083. heightRange: number;
  18084. /**
  18085. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18086. */
  18087. emitFromSpawnPointOnly: boolean;
  18088. /**
  18089. * Gets or sets the radius of the emission cone
  18090. */
  18091. radius: number;
  18092. /**
  18093. * Gets or sets the angle of the emission cone
  18094. */
  18095. angle: number;
  18096. private _buildHeight;
  18097. /**
  18098. * Creates a new instance ConeParticleEmitter
  18099. * @param radius the radius of the emission cone (1 by default)
  18100. * @param angle the cone base angle (PI by default)
  18101. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18102. */
  18103. constructor(radius?: number, angle?: number,
  18104. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18105. directionRandomizer?: number);
  18106. /**
  18107. * Called by the particle System when the direction is computed for the created particle.
  18108. * @param worldMatrix is the world matrix of the particle system
  18109. * @param directionToUpdate is the direction vector to update with the result
  18110. * @param particle is the particle we are computed the direction for
  18111. */
  18112. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18113. /**
  18114. * Called by the particle System when the position is computed for the created particle.
  18115. * @param worldMatrix is the world matrix of the particle system
  18116. * @param positionToUpdate is the position vector to update with the result
  18117. * @param particle is the particle we are computed the position for
  18118. */
  18119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18120. /**
  18121. * Clones the current emitter and returns a copy of it
  18122. * @returns the new emitter
  18123. */
  18124. clone(): ConeParticleEmitter;
  18125. /**
  18126. * Called by the GPUParticleSystem to setup the update shader
  18127. * @param effect defines the update shader
  18128. */
  18129. applyToShader(effect: Effect): void;
  18130. /**
  18131. * Returns a string to use to update the GPU particles update shader
  18132. * @returns a string containng the defines string
  18133. */
  18134. getEffectDefines(): string;
  18135. /**
  18136. * Returns the string "ConeParticleEmitter"
  18137. * @returns a string containing the class name
  18138. */
  18139. getClassName(): string;
  18140. /**
  18141. * Serializes the particle system to a JSON object.
  18142. * @returns the JSON object
  18143. */
  18144. serialize(): any;
  18145. /**
  18146. * Parse properties from a JSON object
  18147. * @param serializationObject defines the JSON object
  18148. */
  18149. parse(serializationObject: any): void;
  18150. }
  18151. }
  18152. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18154. import { Effect } from "babylonjs/Materials/effect";
  18155. import { Particle } from "babylonjs/Particles/particle";
  18156. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18157. /**
  18158. * Particle emitter emitting particles from the inside of a cylinder.
  18159. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18160. */
  18161. export class CylinderParticleEmitter implements IParticleEmitterType {
  18162. /**
  18163. * The radius of the emission cylinder.
  18164. */
  18165. radius: number;
  18166. /**
  18167. * The height of the emission cylinder.
  18168. */
  18169. height: number;
  18170. /**
  18171. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18172. */
  18173. radiusRange: number;
  18174. /**
  18175. * How much to randomize the particle direction [0-1].
  18176. */
  18177. directionRandomizer: number;
  18178. /**
  18179. * Creates a new instance CylinderParticleEmitter
  18180. * @param radius the radius of the emission cylinder (1 by default)
  18181. * @param height the height of the emission cylinder (1 by default)
  18182. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18183. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18184. */
  18185. constructor(
  18186. /**
  18187. * The radius of the emission cylinder.
  18188. */
  18189. radius?: number,
  18190. /**
  18191. * The height of the emission cylinder.
  18192. */
  18193. height?: number,
  18194. /**
  18195. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18196. */
  18197. radiusRange?: number,
  18198. /**
  18199. * How much to randomize the particle direction [0-1].
  18200. */
  18201. directionRandomizer?: number);
  18202. /**
  18203. * Called by the particle System when the direction is computed for the created particle.
  18204. * @param worldMatrix is the world matrix of the particle system
  18205. * @param directionToUpdate is the direction vector to update with the result
  18206. * @param particle is the particle we are computed the direction for
  18207. */
  18208. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18209. /**
  18210. * Called by the particle System when the position is computed for the created particle.
  18211. * @param worldMatrix is the world matrix of the particle system
  18212. * @param positionToUpdate is the position vector to update with the result
  18213. * @param particle is the particle we are computed the position for
  18214. */
  18215. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18216. /**
  18217. * Clones the current emitter and returns a copy of it
  18218. * @returns the new emitter
  18219. */
  18220. clone(): CylinderParticleEmitter;
  18221. /**
  18222. * Called by the GPUParticleSystem to setup the update shader
  18223. * @param effect defines the update shader
  18224. */
  18225. applyToShader(effect: Effect): void;
  18226. /**
  18227. * Returns a string to use to update the GPU particles update shader
  18228. * @returns a string containng the defines string
  18229. */
  18230. getEffectDefines(): string;
  18231. /**
  18232. * Returns the string "CylinderParticleEmitter"
  18233. * @returns a string containing the class name
  18234. */
  18235. getClassName(): string;
  18236. /**
  18237. * Serializes the particle system to a JSON object.
  18238. * @returns the JSON object
  18239. */
  18240. serialize(): any;
  18241. /**
  18242. * Parse properties from a JSON object
  18243. * @param serializationObject defines the JSON object
  18244. */
  18245. parse(serializationObject: any): void;
  18246. }
  18247. /**
  18248. * Particle emitter emitting particles from the inside of a cylinder.
  18249. * It emits the particles randomly between two vectors.
  18250. */
  18251. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18252. /**
  18253. * The min limit of the emission direction.
  18254. */
  18255. direction1: Vector3;
  18256. /**
  18257. * The max limit of the emission direction.
  18258. */
  18259. direction2: Vector3;
  18260. /**
  18261. * Creates a new instance CylinderDirectedParticleEmitter
  18262. * @param radius the radius of the emission cylinder (1 by default)
  18263. * @param height the height of the emission cylinder (1 by default)
  18264. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18265. * @param direction1 the min limit of the emission direction (up vector by default)
  18266. * @param direction2 the max limit of the emission direction (up vector by default)
  18267. */
  18268. constructor(radius?: number, height?: number, radiusRange?: number,
  18269. /**
  18270. * The min limit of the emission direction.
  18271. */
  18272. direction1?: Vector3,
  18273. /**
  18274. * The max limit of the emission direction.
  18275. */
  18276. direction2?: Vector3);
  18277. /**
  18278. * Called by the particle System when the direction is computed for the created particle.
  18279. * @param worldMatrix is the world matrix of the particle system
  18280. * @param directionToUpdate is the direction vector to update with the result
  18281. * @param particle is the particle we are computed the direction for
  18282. */
  18283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18284. /**
  18285. * Clones the current emitter and returns a copy of it
  18286. * @returns the new emitter
  18287. */
  18288. clone(): CylinderDirectedParticleEmitter;
  18289. /**
  18290. * Called by the GPUParticleSystem to setup the update shader
  18291. * @param effect defines the update shader
  18292. */
  18293. applyToShader(effect: Effect): void;
  18294. /**
  18295. * Returns a string to use to update the GPU particles update shader
  18296. * @returns a string containng the defines string
  18297. */
  18298. getEffectDefines(): string;
  18299. /**
  18300. * Returns the string "CylinderDirectedParticleEmitter"
  18301. * @returns a string containing the class name
  18302. */
  18303. getClassName(): string;
  18304. /**
  18305. * Serializes the particle system to a JSON object.
  18306. * @returns the JSON object
  18307. */
  18308. serialize(): any;
  18309. /**
  18310. * Parse properties from a JSON object
  18311. * @param serializationObject defines the JSON object
  18312. */
  18313. parse(serializationObject: any): void;
  18314. }
  18315. }
  18316. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18317. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18318. import { Effect } from "babylonjs/Materials/effect";
  18319. import { Particle } from "babylonjs/Particles/particle";
  18320. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18321. /**
  18322. * Particle emitter emitting particles from the inside of a hemisphere.
  18323. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18324. */
  18325. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18326. /**
  18327. * The radius of the emission hemisphere.
  18328. */
  18329. radius: number;
  18330. /**
  18331. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18332. */
  18333. radiusRange: number;
  18334. /**
  18335. * How much to randomize the particle direction [0-1].
  18336. */
  18337. directionRandomizer: number;
  18338. /**
  18339. * Creates a new instance HemisphericParticleEmitter
  18340. * @param radius the radius of the emission hemisphere (1 by default)
  18341. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18342. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18343. */
  18344. constructor(
  18345. /**
  18346. * The radius of the emission hemisphere.
  18347. */
  18348. radius?: number,
  18349. /**
  18350. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18351. */
  18352. radiusRange?: number,
  18353. /**
  18354. * How much to randomize the particle direction [0-1].
  18355. */
  18356. directionRandomizer?: number);
  18357. /**
  18358. * Called by the particle System when the direction is computed for the created particle.
  18359. * @param worldMatrix is the world matrix of the particle system
  18360. * @param directionToUpdate is the direction vector to update with the result
  18361. * @param particle is the particle we are computed the direction for
  18362. */
  18363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18364. /**
  18365. * Called by the particle System when the position is computed for the created particle.
  18366. * @param worldMatrix is the world matrix of the particle system
  18367. * @param positionToUpdate is the position vector to update with the result
  18368. * @param particle is the particle we are computed the position for
  18369. */
  18370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18371. /**
  18372. * Clones the current emitter and returns a copy of it
  18373. * @returns the new emitter
  18374. */
  18375. clone(): HemisphericParticleEmitter;
  18376. /**
  18377. * Called by the GPUParticleSystem to setup the update shader
  18378. * @param effect defines the update shader
  18379. */
  18380. applyToShader(effect: Effect): void;
  18381. /**
  18382. * Returns a string to use to update the GPU particles update shader
  18383. * @returns a string containng the defines string
  18384. */
  18385. getEffectDefines(): string;
  18386. /**
  18387. * Returns the string "HemisphericParticleEmitter"
  18388. * @returns a string containing the class name
  18389. */
  18390. getClassName(): string;
  18391. /**
  18392. * Serializes the particle system to a JSON object.
  18393. * @returns the JSON object
  18394. */
  18395. serialize(): any;
  18396. /**
  18397. * Parse properties from a JSON object
  18398. * @param serializationObject defines the JSON object
  18399. */
  18400. parse(serializationObject: any): void;
  18401. }
  18402. }
  18403. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18404. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18405. import { Effect } from "babylonjs/Materials/effect";
  18406. import { Particle } from "babylonjs/Particles/particle";
  18407. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18408. /**
  18409. * Particle emitter emitting particles from a point.
  18410. * It emits the particles randomly between 2 given directions.
  18411. */
  18412. export class PointParticleEmitter implements IParticleEmitterType {
  18413. /**
  18414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18415. */
  18416. direction1: Vector3;
  18417. /**
  18418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18419. */
  18420. direction2: Vector3;
  18421. /**
  18422. * Creates a new instance PointParticleEmitter
  18423. */
  18424. constructor();
  18425. /**
  18426. * Called by the particle System when the direction is computed for the created particle.
  18427. * @param worldMatrix is the world matrix of the particle system
  18428. * @param directionToUpdate is the direction vector to update with the result
  18429. * @param particle is the particle we are computed the direction for
  18430. */
  18431. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18432. /**
  18433. * Called by the particle System when the position is computed for the created particle.
  18434. * @param worldMatrix is the world matrix of the particle system
  18435. * @param positionToUpdate is the position vector to update with the result
  18436. * @param particle is the particle we are computed the position for
  18437. */
  18438. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18439. /**
  18440. * Clones the current emitter and returns a copy of it
  18441. * @returns the new emitter
  18442. */
  18443. clone(): PointParticleEmitter;
  18444. /**
  18445. * Called by the GPUParticleSystem to setup the update shader
  18446. * @param effect defines the update shader
  18447. */
  18448. applyToShader(effect: Effect): void;
  18449. /**
  18450. * Returns a string to use to update the GPU particles update shader
  18451. * @returns a string containng the defines string
  18452. */
  18453. getEffectDefines(): string;
  18454. /**
  18455. * Returns the string "PointParticleEmitter"
  18456. * @returns a string containing the class name
  18457. */
  18458. getClassName(): string;
  18459. /**
  18460. * Serializes the particle system to a JSON object.
  18461. * @returns the JSON object
  18462. */
  18463. serialize(): any;
  18464. /**
  18465. * Parse properties from a JSON object
  18466. * @param serializationObject defines the JSON object
  18467. */
  18468. parse(serializationObject: any): void;
  18469. }
  18470. }
  18471. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18472. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18473. import { Effect } from "babylonjs/Materials/effect";
  18474. import { Particle } from "babylonjs/Particles/particle";
  18475. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18476. /**
  18477. * Particle emitter emitting particles from the inside of a sphere.
  18478. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18479. */
  18480. export class SphereParticleEmitter implements IParticleEmitterType {
  18481. /**
  18482. * The radius of the emission sphere.
  18483. */
  18484. radius: number;
  18485. /**
  18486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18487. */
  18488. radiusRange: number;
  18489. /**
  18490. * How much to randomize the particle direction [0-1].
  18491. */
  18492. directionRandomizer: number;
  18493. /**
  18494. * Creates a new instance SphereParticleEmitter
  18495. * @param radius the radius of the emission sphere (1 by default)
  18496. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18498. */
  18499. constructor(
  18500. /**
  18501. * The radius of the emission sphere.
  18502. */
  18503. radius?: number,
  18504. /**
  18505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18506. */
  18507. radiusRange?: number,
  18508. /**
  18509. * How much to randomize the particle direction [0-1].
  18510. */
  18511. directionRandomizer?: number);
  18512. /**
  18513. * Called by the particle System when the direction is computed for the created particle.
  18514. * @param worldMatrix is the world matrix of the particle system
  18515. * @param directionToUpdate is the direction vector to update with the result
  18516. * @param particle is the particle we are computed the direction for
  18517. */
  18518. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18519. /**
  18520. * Called by the particle System when the position is computed for the created particle.
  18521. * @param worldMatrix is the world matrix of the particle system
  18522. * @param positionToUpdate is the position vector to update with the result
  18523. * @param particle is the particle we are computed the position for
  18524. */
  18525. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18526. /**
  18527. * Clones the current emitter and returns a copy of it
  18528. * @returns the new emitter
  18529. */
  18530. clone(): SphereParticleEmitter;
  18531. /**
  18532. * Called by the GPUParticleSystem to setup the update shader
  18533. * @param effect defines the update shader
  18534. */
  18535. applyToShader(effect: Effect): void;
  18536. /**
  18537. * Returns a string to use to update the GPU particles update shader
  18538. * @returns a string containng the defines string
  18539. */
  18540. getEffectDefines(): string;
  18541. /**
  18542. * Returns the string "SphereParticleEmitter"
  18543. * @returns a string containing the class name
  18544. */
  18545. getClassName(): string;
  18546. /**
  18547. * Serializes the particle system to a JSON object.
  18548. * @returns the JSON object
  18549. */
  18550. serialize(): any;
  18551. /**
  18552. * Parse properties from a JSON object
  18553. * @param serializationObject defines the JSON object
  18554. */
  18555. parse(serializationObject: any): void;
  18556. }
  18557. /**
  18558. * Particle emitter emitting particles from the inside of a sphere.
  18559. * It emits the particles randomly between two vectors.
  18560. */
  18561. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18562. /**
  18563. * The min limit of the emission direction.
  18564. */
  18565. direction1: Vector3;
  18566. /**
  18567. * The max limit of the emission direction.
  18568. */
  18569. direction2: Vector3;
  18570. /**
  18571. * Creates a new instance SphereDirectedParticleEmitter
  18572. * @param radius the radius of the emission sphere (1 by default)
  18573. * @param direction1 the min limit of the emission direction (up vector by default)
  18574. * @param direction2 the max limit of the emission direction (up vector by default)
  18575. */
  18576. constructor(radius?: number,
  18577. /**
  18578. * The min limit of the emission direction.
  18579. */
  18580. direction1?: Vector3,
  18581. /**
  18582. * The max limit of the emission direction.
  18583. */
  18584. direction2?: Vector3);
  18585. /**
  18586. * Called by the particle System when the direction is computed for the created particle.
  18587. * @param worldMatrix is the world matrix of the particle system
  18588. * @param directionToUpdate is the direction vector to update with the result
  18589. * @param particle is the particle we are computed the direction for
  18590. */
  18591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18592. /**
  18593. * Clones the current emitter and returns a copy of it
  18594. * @returns the new emitter
  18595. */
  18596. clone(): SphereDirectedParticleEmitter;
  18597. /**
  18598. * Called by the GPUParticleSystem to setup the update shader
  18599. * @param effect defines the update shader
  18600. */
  18601. applyToShader(effect: Effect): void;
  18602. /**
  18603. * Returns a string to use to update the GPU particles update shader
  18604. * @returns a string containng the defines string
  18605. */
  18606. getEffectDefines(): string;
  18607. /**
  18608. * Returns the string "SphereDirectedParticleEmitter"
  18609. * @returns a string containing the class name
  18610. */
  18611. getClassName(): string;
  18612. /**
  18613. * Serializes the particle system to a JSON object.
  18614. * @returns the JSON object
  18615. */
  18616. serialize(): any;
  18617. /**
  18618. * Parse properties from a JSON object
  18619. * @param serializationObject defines the JSON object
  18620. */
  18621. parse(serializationObject: any): void;
  18622. }
  18623. }
  18624. declare module "babylonjs/Particles/EmitterTypes/index" {
  18625. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18626. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18627. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18628. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18629. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18630. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18631. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18632. }
  18633. declare module "babylonjs/Particles/IParticleSystem" {
  18634. import { Nullable } from "babylonjs/types";
  18635. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18636. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18639. import { Texture } from "babylonjs/Materials/Textures/texture";
  18640. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18641. import { Scene } from "babylonjs/scene";
  18642. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18643. import { Animation } from "babylonjs/Animations/animation";
  18644. /**
  18645. * Interface representing a particle system in Babylon.js.
  18646. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18647. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18648. */
  18649. export interface IParticleSystem {
  18650. /**
  18651. * List of animations used by the particle system.
  18652. */
  18653. animations: Animation[];
  18654. /**
  18655. * The id of the Particle system.
  18656. */
  18657. id: string;
  18658. /**
  18659. * The name of the Particle system.
  18660. */
  18661. name: string;
  18662. /**
  18663. * The emitter represents the Mesh or position we are attaching the particle system to.
  18664. */
  18665. emitter: Nullable<AbstractMesh | Vector3>;
  18666. /**
  18667. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18668. */
  18669. isBillboardBased: boolean;
  18670. /**
  18671. * The rendering group used by the Particle system to chose when to render.
  18672. */
  18673. renderingGroupId: number;
  18674. /**
  18675. * The layer mask we are rendering the particles through.
  18676. */
  18677. layerMask: number;
  18678. /**
  18679. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18680. */
  18681. updateSpeed: number;
  18682. /**
  18683. * The amount of time the particle system is running (depends of the overall update speed).
  18684. */
  18685. targetStopDuration: number;
  18686. /**
  18687. * The texture used to render each particle. (this can be a spritesheet)
  18688. */
  18689. particleTexture: Nullable<Texture>;
  18690. /**
  18691. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18692. */
  18693. blendMode: number;
  18694. /**
  18695. * Minimum life time of emitting particles.
  18696. */
  18697. minLifeTime: number;
  18698. /**
  18699. * Maximum life time of emitting particles.
  18700. */
  18701. maxLifeTime: number;
  18702. /**
  18703. * Minimum Size of emitting particles.
  18704. */
  18705. minSize: number;
  18706. /**
  18707. * Maximum Size of emitting particles.
  18708. */
  18709. maxSize: number;
  18710. /**
  18711. * Minimum scale of emitting particles on X axis.
  18712. */
  18713. minScaleX: number;
  18714. /**
  18715. * Maximum scale of emitting particles on X axis.
  18716. */
  18717. maxScaleX: number;
  18718. /**
  18719. * Minimum scale of emitting particles on Y axis.
  18720. */
  18721. minScaleY: number;
  18722. /**
  18723. * Maximum scale of emitting particles on Y axis.
  18724. */
  18725. maxScaleY: number;
  18726. /**
  18727. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18728. */
  18729. color1: Color4;
  18730. /**
  18731. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18732. */
  18733. color2: Color4;
  18734. /**
  18735. * Color the particle will have at the end of its lifetime.
  18736. */
  18737. colorDead: Color4;
  18738. /**
  18739. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18740. */
  18741. emitRate: number;
  18742. /**
  18743. * You can use gravity if you want to give an orientation to your particles.
  18744. */
  18745. gravity: Vector3;
  18746. /**
  18747. * Minimum power of emitting particles.
  18748. */
  18749. minEmitPower: number;
  18750. /**
  18751. * Maximum power of emitting particles.
  18752. */
  18753. maxEmitPower: number;
  18754. /**
  18755. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18756. */
  18757. minAngularSpeed: number;
  18758. /**
  18759. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18760. */
  18761. maxAngularSpeed: number;
  18762. /**
  18763. * Gets or sets the minimal initial rotation in radians.
  18764. */
  18765. minInitialRotation: number;
  18766. /**
  18767. * Gets or sets the maximal initial rotation in radians.
  18768. */
  18769. maxInitialRotation: number;
  18770. /**
  18771. * The particle emitter type defines the emitter used by the particle system.
  18772. * It can be for example box, sphere, or cone...
  18773. */
  18774. particleEmitterType: Nullable<IParticleEmitterType>;
  18775. /**
  18776. * Defines the delay in milliseconds before starting the system (0 by default)
  18777. */
  18778. startDelay: number;
  18779. /**
  18780. * 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
  18781. */
  18782. preWarmCycles: number;
  18783. /**
  18784. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18785. */
  18786. preWarmStepOffset: number;
  18787. /**
  18788. * 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)
  18789. */
  18790. spriteCellChangeSpeed: number;
  18791. /**
  18792. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18793. */
  18794. startSpriteCellID: number;
  18795. /**
  18796. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18797. */
  18798. endSpriteCellID: number;
  18799. /**
  18800. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18801. */
  18802. spriteCellWidth: number;
  18803. /**
  18804. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18805. */
  18806. spriteCellHeight: number;
  18807. /**
  18808. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18809. */
  18810. spriteRandomStartCell: boolean;
  18811. /**
  18812. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18813. */
  18814. isAnimationSheetEnabled: boolean;
  18815. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18816. translationPivot: Vector2;
  18817. /**
  18818. * Gets or sets a texture used to add random noise to particle positions
  18819. */
  18820. noiseTexture: Nullable<BaseTexture>;
  18821. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18822. noiseStrength: Vector3;
  18823. /**
  18824. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18825. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18826. */
  18827. billboardMode: number;
  18828. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18829. limitVelocityDamping: number;
  18830. /**
  18831. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18832. */
  18833. beginAnimationOnStart: boolean;
  18834. /**
  18835. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18836. */
  18837. beginAnimationFrom: number;
  18838. /**
  18839. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18840. */
  18841. beginAnimationTo: number;
  18842. /**
  18843. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18844. */
  18845. beginAnimationLoop: boolean;
  18846. /**
  18847. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18848. */
  18849. disposeOnStop: boolean;
  18850. /**
  18851. * Gets the maximum number of particles active at the same time.
  18852. * @returns The max number of active particles.
  18853. */
  18854. getCapacity(): number;
  18855. /**
  18856. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18857. * @returns True if it has been started, otherwise false.
  18858. */
  18859. isStarted(): boolean;
  18860. /**
  18861. * Animates the particle system for this frame.
  18862. */
  18863. animate(): void;
  18864. /**
  18865. * Renders the particle system in its current state.
  18866. * @returns the current number of particles
  18867. */
  18868. render(): number;
  18869. /**
  18870. * Dispose the particle system and frees its associated resources.
  18871. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18872. */
  18873. dispose(disposeTexture?: boolean): void;
  18874. /**
  18875. * Clones the particle system.
  18876. * @param name The name of the cloned object
  18877. * @param newEmitter The new emitter to use
  18878. * @returns the cloned particle system
  18879. */
  18880. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18881. /**
  18882. * Serializes the particle system to a JSON object.
  18883. * @returns the JSON object
  18884. */
  18885. serialize(): any;
  18886. /**
  18887. * Rebuild the particle system
  18888. */
  18889. rebuild(): void;
  18890. /**
  18891. * Starts the particle system and begins to emit
  18892. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18893. */
  18894. start(delay?: number): void;
  18895. /**
  18896. * Stops the particle system.
  18897. */
  18898. stop(): void;
  18899. /**
  18900. * Remove all active particles
  18901. */
  18902. reset(): void;
  18903. /**
  18904. * Is this system ready to be used/rendered
  18905. * @return true if the system is ready
  18906. */
  18907. isReady(): boolean;
  18908. /**
  18909. * Adds a new color gradient
  18910. * @param gradient defines the gradient to use (between 0 and 1)
  18911. * @param color1 defines the color to affect to the specified gradient
  18912. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18913. * @returns the current particle system
  18914. */
  18915. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18916. /**
  18917. * Remove a specific color gradient
  18918. * @param gradient defines the gradient to remove
  18919. * @returns the current particle system
  18920. */
  18921. removeColorGradient(gradient: number): IParticleSystem;
  18922. /**
  18923. * Adds a new size gradient
  18924. * @param gradient defines the gradient to use (between 0 and 1)
  18925. * @param factor defines the size factor to affect to the specified gradient
  18926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18927. * @returns the current particle system
  18928. */
  18929. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18930. /**
  18931. * Remove a specific size gradient
  18932. * @param gradient defines the gradient to remove
  18933. * @returns the current particle system
  18934. */
  18935. removeSizeGradient(gradient: number): IParticleSystem;
  18936. /**
  18937. * Gets the current list of color gradients.
  18938. * You must use addColorGradient and removeColorGradient to udpate this list
  18939. * @returns the list of color gradients
  18940. */
  18941. getColorGradients(): Nullable<Array<ColorGradient>>;
  18942. /**
  18943. * Gets the current list of size gradients.
  18944. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18945. * @returns the list of size gradients
  18946. */
  18947. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18948. /**
  18949. * Gets the current list of angular speed gradients.
  18950. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18951. * @returns the list of angular speed gradients
  18952. */
  18953. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18954. /**
  18955. * Adds a new angular speed gradient
  18956. * @param gradient defines the gradient to use (between 0 and 1)
  18957. * @param factor defines the angular speed to affect to the specified gradient
  18958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18959. * @returns the current particle system
  18960. */
  18961. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18962. /**
  18963. * Remove a specific angular speed gradient
  18964. * @param gradient defines the gradient to remove
  18965. * @returns the current particle system
  18966. */
  18967. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18968. /**
  18969. * Gets the current list of velocity gradients.
  18970. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18971. * @returns the list of velocity gradients
  18972. */
  18973. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18974. /**
  18975. * Adds a new velocity gradient
  18976. * @param gradient defines the gradient to use (between 0 and 1)
  18977. * @param factor defines the velocity to affect to the specified gradient
  18978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18979. * @returns the current particle system
  18980. */
  18981. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18982. /**
  18983. * Remove a specific velocity gradient
  18984. * @param gradient defines the gradient to remove
  18985. * @returns the current particle system
  18986. */
  18987. removeVelocityGradient(gradient: number): IParticleSystem;
  18988. /**
  18989. * Gets the current list of limit velocity gradients.
  18990. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18991. * @returns the list of limit velocity gradients
  18992. */
  18993. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18994. /**
  18995. * Adds a new limit velocity gradient
  18996. * @param gradient defines the gradient to use (between 0 and 1)
  18997. * @param factor defines the limit velocity to affect to the specified gradient
  18998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18999. * @returns the current particle system
  19000. */
  19001. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19002. /**
  19003. * Remove a specific limit velocity gradient
  19004. * @param gradient defines the gradient to remove
  19005. * @returns the current particle system
  19006. */
  19007. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19008. /**
  19009. * Adds a new drag gradient
  19010. * @param gradient defines the gradient to use (between 0 and 1)
  19011. * @param factor defines the drag to affect to the specified gradient
  19012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19013. * @returns the current particle system
  19014. */
  19015. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19016. /**
  19017. * Remove a specific drag gradient
  19018. * @param gradient defines the gradient to remove
  19019. * @returns the current particle system
  19020. */
  19021. removeDragGradient(gradient: number): IParticleSystem;
  19022. /**
  19023. * Gets the current list of drag gradients.
  19024. * You must use addDragGradient and removeDragGradient to udpate this list
  19025. * @returns the list of drag gradients
  19026. */
  19027. getDragGradients(): Nullable<Array<FactorGradient>>;
  19028. /**
  19029. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19030. * @param gradient defines the gradient to use (between 0 and 1)
  19031. * @param factor defines the emit rate to affect to the specified gradient
  19032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19033. * @returns the current particle system
  19034. */
  19035. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19036. /**
  19037. * Remove a specific emit rate gradient
  19038. * @param gradient defines the gradient to remove
  19039. * @returns the current particle system
  19040. */
  19041. removeEmitRateGradient(gradient: number): IParticleSystem;
  19042. /**
  19043. * Gets the current list of emit rate gradients.
  19044. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19045. * @returns the list of emit rate gradients
  19046. */
  19047. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19048. /**
  19049. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19050. * @param gradient defines the gradient to use (between 0 and 1)
  19051. * @param factor defines the start size to affect to the specified gradient
  19052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19053. * @returns the current particle system
  19054. */
  19055. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19056. /**
  19057. * Remove a specific start size gradient
  19058. * @param gradient defines the gradient to remove
  19059. * @returns the current particle system
  19060. */
  19061. removeStartSizeGradient(gradient: number): IParticleSystem;
  19062. /**
  19063. * Gets the current list of start size gradients.
  19064. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19065. * @returns the list of start size gradients
  19066. */
  19067. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19068. /**
  19069. * Adds a new life time gradient
  19070. * @param gradient defines the gradient to use (between 0 and 1)
  19071. * @param factor defines the life time factor to affect to the specified gradient
  19072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19073. * @returns the current particle system
  19074. */
  19075. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19076. /**
  19077. * Remove a specific life time gradient
  19078. * @param gradient defines the gradient to remove
  19079. * @returns the current particle system
  19080. */
  19081. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19082. /**
  19083. * Gets the current list of life time gradients.
  19084. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19085. * @returns the list of life time gradients
  19086. */
  19087. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19088. /**
  19089. * Gets the current list of color gradients.
  19090. * You must use addColorGradient and removeColorGradient to udpate this list
  19091. * @returns the list of color gradients
  19092. */
  19093. getColorGradients(): Nullable<Array<ColorGradient>>;
  19094. /**
  19095. * Adds a new ramp gradient used to remap particle colors
  19096. * @param gradient defines the gradient to use (between 0 and 1)
  19097. * @param color defines the color to affect to the specified gradient
  19098. * @returns the current particle system
  19099. */
  19100. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19101. /**
  19102. * Gets the current list of ramp gradients.
  19103. * You must use addRampGradient and removeRampGradient to udpate this list
  19104. * @returns the list of ramp gradients
  19105. */
  19106. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19107. /** Gets or sets a boolean indicating that ramp gradients must be used
  19108. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19109. */
  19110. useRampGradients: boolean;
  19111. /**
  19112. * Adds a new color remap gradient
  19113. * @param gradient defines the gradient to use (between 0 and 1)
  19114. * @param min defines the color remap minimal range
  19115. * @param max defines the color remap maximal range
  19116. * @returns the current particle system
  19117. */
  19118. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19119. /**
  19120. * Gets the current list of color remap gradients.
  19121. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19122. * @returns the list of color remap gradients
  19123. */
  19124. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19125. /**
  19126. * Adds a new alpha remap gradient
  19127. * @param gradient defines the gradient to use (between 0 and 1)
  19128. * @param min defines the alpha remap minimal range
  19129. * @param max defines the alpha remap maximal range
  19130. * @returns the current particle system
  19131. */
  19132. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19133. /**
  19134. * Gets the current list of alpha remap gradients.
  19135. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19136. * @returns the list of alpha remap gradients
  19137. */
  19138. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19139. /**
  19140. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19143. * @returns the emitter
  19144. */
  19145. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19146. /**
  19147. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19148. * @param radius The radius of the hemisphere to emit from
  19149. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19150. * @returns the emitter
  19151. */
  19152. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19153. /**
  19154. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19155. * @param radius The radius of the sphere to emit from
  19156. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19157. * @returns the emitter
  19158. */
  19159. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19160. /**
  19161. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19162. * @param radius The radius of the sphere to emit from
  19163. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19164. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19165. * @returns the emitter
  19166. */
  19167. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19168. /**
  19169. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19170. * @param radius The radius of the emission cylinder
  19171. * @param height The height of the emission cylinder
  19172. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19173. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19174. * @returns the emitter
  19175. */
  19176. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19177. /**
  19178. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19179. * @param radius The radius of the cylinder to emit from
  19180. * @param height The height of the emission cylinder
  19181. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19184. * @returns the emitter
  19185. */
  19186. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19187. /**
  19188. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19189. * @param radius The radius of the cone to emit from
  19190. * @param angle The base angle of the cone
  19191. * @returns the emitter
  19192. */
  19193. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19194. /**
  19195. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19196. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19197. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19198. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19199. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19200. * @returns the emitter
  19201. */
  19202. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19203. /**
  19204. * Get hosting scene
  19205. * @returns the scene
  19206. */
  19207. getScene(): Scene;
  19208. }
  19209. }
  19210. declare module "babylonjs/Meshes/instancedMesh" {
  19211. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19212. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19213. import { Camera } from "babylonjs/Cameras/camera";
  19214. import { Node } from "babylonjs/node";
  19215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19216. import { Mesh } from "babylonjs/Meshes/mesh";
  19217. import { Material } from "babylonjs/Materials/material";
  19218. import { Skeleton } from "babylonjs/Bones/skeleton";
  19219. import { Light } from "babylonjs/Lights/light";
  19220. /**
  19221. * Creates an instance based on a source mesh.
  19222. */
  19223. export class InstancedMesh extends AbstractMesh {
  19224. private _sourceMesh;
  19225. private _currentLOD;
  19226. /** @hidden */
  19227. _indexInSourceMeshInstanceArray: number;
  19228. constructor(name: string, source: Mesh);
  19229. /**
  19230. * Returns the string "InstancedMesh".
  19231. */
  19232. getClassName(): string;
  19233. /** Gets the list of lights affecting that mesh */
  19234. readonly lightSources: Light[];
  19235. _resyncLightSources(): void;
  19236. _resyncLighSource(light: Light): void;
  19237. _removeLightSource(light: Light, dispose: boolean): void;
  19238. /**
  19239. * If the source mesh receives shadows
  19240. */
  19241. readonly receiveShadows: boolean;
  19242. /**
  19243. * The material of the source mesh
  19244. */
  19245. readonly material: Nullable<Material>;
  19246. /**
  19247. * Visibility of the source mesh
  19248. */
  19249. readonly visibility: number;
  19250. /**
  19251. * Skeleton of the source mesh
  19252. */
  19253. readonly skeleton: Nullable<Skeleton>;
  19254. /**
  19255. * Rendering ground id of the source mesh
  19256. */
  19257. renderingGroupId: number;
  19258. /**
  19259. * Returns the total number of vertices (integer).
  19260. */
  19261. getTotalVertices(): number;
  19262. /**
  19263. * Returns a positive integer : the total number of indices in this mesh geometry.
  19264. * @returns the numner of indices or zero if the mesh has no geometry.
  19265. */
  19266. getTotalIndices(): number;
  19267. /**
  19268. * The source mesh of the instance
  19269. */
  19270. readonly sourceMesh: Mesh;
  19271. /**
  19272. * Is this node ready to be used/rendered
  19273. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19274. * @return {boolean} is it ready
  19275. */
  19276. isReady(completeCheck?: boolean): boolean;
  19277. /**
  19278. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19279. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19280. * @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.
  19281. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19282. */
  19283. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19284. /**
  19285. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19286. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19287. * The `data` are either a numeric array either a Float32Array.
  19288. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19289. * 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).
  19290. * Note that a new underlying VertexBuffer object is created each call.
  19291. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19292. *
  19293. * Possible `kind` values :
  19294. * - VertexBuffer.PositionKind
  19295. * - VertexBuffer.UVKind
  19296. * - VertexBuffer.UV2Kind
  19297. * - VertexBuffer.UV3Kind
  19298. * - VertexBuffer.UV4Kind
  19299. * - VertexBuffer.UV5Kind
  19300. * - VertexBuffer.UV6Kind
  19301. * - VertexBuffer.ColorKind
  19302. * - VertexBuffer.MatricesIndicesKind
  19303. * - VertexBuffer.MatricesIndicesExtraKind
  19304. * - VertexBuffer.MatricesWeightsKind
  19305. * - VertexBuffer.MatricesWeightsExtraKind
  19306. *
  19307. * Returns the Mesh.
  19308. */
  19309. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19310. /**
  19311. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19312. * If the mesh has no geometry, it is simply returned as it is.
  19313. * The `data` are either a numeric array either a Float32Array.
  19314. * No new underlying VertexBuffer object is created.
  19315. * 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.
  19316. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19317. *
  19318. * Possible `kind` values :
  19319. * - VertexBuffer.PositionKind
  19320. * - VertexBuffer.UVKind
  19321. * - VertexBuffer.UV2Kind
  19322. * - VertexBuffer.UV3Kind
  19323. * - VertexBuffer.UV4Kind
  19324. * - VertexBuffer.UV5Kind
  19325. * - VertexBuffer.UV6Kind
  19326. * - VertexBuffer.ColorKind
  19327. * - VertexBuffer.MatricesIndicesKind
  19328. * - VertexBuffer.MatricesIndicesExtraKind
  19329. * - VertexBuffer.MatricesWeightsKind
  19330. * - VertexBuffer.MatricesWeightsExtraKind
  19331. *
  19332. * Returns the Mesh.
  19333. */
  19334. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19335. /**
  19336. * Sets the mesh indices.
  19337. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19338. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19339. * This method creates a new index buffer each call.
  19340. * Returns the Mesh.
  19341. */
  19342. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19343. /**
  19344. * Boolean : True if the mesh owns the requested kind of data.
  19345. */
  19346. isVerticesDataPresent(kind: string): boolean;
  19347. /**
  19348. * Returns an array of indices (IndicesArray).
  19349. */
  19350. getIndices(): Nullable<IndicesArray>;
  19351. readonly _positions: Nullable<Vector3[]>;
  19352. /**
  19353. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19354. * This means the mesh underlying bounding box and sphere are recomputed.
  19355. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19356. * @returns the current mesh
  19357. */
  19358. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19359. /** @hidden */
  19360. _preActivate(): InstancedMesh;
  19361. /** @hidden */
  19362. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19363. /** @hidden */
  19364. _postActivate(): void;
  19365. getWorldMatrix(): Matrix;
  19366. readonly isAnInstance: boolean;
  19367. /**
  19368. * Returns the current associated LOD AbstractMesh.
  19369. */
  19370. getLOD(camera: Camera): AbstractMesh;
  19371. /** @hidden */
  19372. _syncSubMeshes(): InstancedMesh;
  19373. /** @hidden */
  19374. _generatePointsArray(): boolean;
  19375. /**
  19376. * Creates a new InstancedMesh from the current mesh.
  19377. * - name (string) : the cloned mesh name
  19378. * - newParent (optional Node) : the optional Node to parent the clone to.
  19379. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19380. *
  19381. * Returns the clone.
  19382. */
  19383. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19384. /**
  19385. * Disposes the InstancedMesh.
  19386. * Returns nothing.
  19387. */
  19388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19389. }
  19390. }
  19391. declare module "babylonjs/Materials/shaderMaterial" {
  19392. import { Scene } from "babylonjs/scene";
  19393. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19395. import { Mesh } from "babylonjs/Meshes/mesh";
  19396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19398. import { Texture } from "babylonjs/Materials/Textures/texture";
  19399. import { Material } from "babylonjs/Materials/material";
  19400. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19401. /**
  19402. * Defines the options associated with the creation of a shader material.
  19403. */
  19404. export interface IShaderMaterialOptions {
  19405. /**
  19406. * Does the material work in alpha blend mode
  19407. */
  19408. needAlphaBlending: boolean;
  19409. /**
  19410. * Does the material work in alpha test mode
  19411. */
  19412. needAlphaTesting: boolean;
  19413. /**
  19414. * The list of attribute names used in the shader
  19415. */
  19416. attributes: string[];
  19417. /**
  19418. * The list of unifrom names used in the shader
  19419. */
  19420. uniforms: string[];
  19421. /**
  19422. * The list of UBO names used in the shader
  19423. */
  19424. uniformBuffers: string[];
  19425. /**
  19426. * The list of sampler names used in the shader
  19427. */
  19428. samplers: string[];
  19429. /**
  19430. * The list of defines used in the shader
  19431. */
  19432. defines: string[];
  19433. }
  19434. /**
  19435. * 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.
  19436. *
  19437. * This returned material effects how the mesh will look based on the code in the shaders.
  19438. *
  19439. * @see http://doc.babylonjs.com/how_to/shader_material
  19440. */
  19441. export class ShaderMaterial extends Material {
  19442. private _shaderPath;
  19443. private _options;
  19444. private _textures;
  19445. private _textureArrays;
  19446. private _floats;
  19447. private _ints;
  19448. private _floatsArrays;
  19449. private _colors3;
  19450. private _colors3Arrays;
  19451. private _colors4;
  19452. private _colors4Arrays;
  19453. private _vectors2;
  19454. private _vectors3;
  19455. private _vectors4;
  19456. private _matrices;
  19457. private _matrices3x3;
  19458. private _matrices2x2;
  19459. private _vectors2Arrays;
  19460. private _vectors3Arrays;
  19461. private _vectors4Arrays;
  19462. private _cachedWorldViewMatrix;
  19463. private _cachedWorldViewProjectionMatrix;
  19464. private _renderId;
  19465. /**
  19466. * Instantiate a new shader material.
  19467. * 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.
  19468. * This returned material effects how the mesh will look based on the code in the shaders.
  19469. * @see http://doc.babylonjs.com/how_to/shader_material
  19470. * @param name Define the name of the material in the scene
  19471. * @param scene Define the scene the material belongs to
  19472. * @param shaderPath Defines the route to the shader code in one of three ways:
  19473. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19474. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19475. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19476. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19477. * @param options Define the options used to create the shader
  19478. */
  19479. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19480. /**
  19481. * Gets the options used to compile the shader.
  19482. * They can be modified to trigger a new compilation
  19483. */
  19484. readonly options: IShaderMaterialOptions;
  19485. /**
  19486. * Gets the current class name of the material e.g. "ShaderMaterial"
  19487. * Mainly use in serialization.
  19488. * @returns the class name
  19489. */
  19490. getClassName(): string;
  19491. /**
  19492. * Specifies if the material will require alpha blending
  19493. * @returns a boolean specifying if alpha blending is needed
  19494. */
  19495. needAlphaBlending(): boolean;
  19496. /**
  19497. * Specifies if this material should be rendered in alpha test mode
  19498. * @returns a boolean specifying if an alpha test is needed.
  19499. */
  19500. needAlphaTesting(): boolean;
  19501. private _checkUniform;
  19502. /**
  19503. * Set a texture in the shader.
  19504. * @param name Define the name of the uniform samplers as defined in the shader
  19505. * @param texture Define the texture to bind to this sampler
  19506. * @return the material itself allowing "fluent" like uniform updates
  19507. */
  19508. setTexture(name: string, texture: Texture): ShaderMaterial;
  19509. /**
  19510. * Set a texture array in the shader.
  19511. * @param name Define the name of the uniform sampler array as defined in the shader
  19512. * @param textures Define the list of textures to bind to this sampler
  19513. * @return the material itself allowing "fluent" like uniform updates
  19514. */
  19515. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19516. /**
  19517. * Set a float in the shader.
  19518. * @param name Define the name of the uniform as defined in the shader
  19519. * @param value Define the value to give to the uniform
  19520. * @return the material itself allowing "fluent" like uniform updates
  19521. */
  19522. setFloat(name: string, value: number): ShaderMaterial;
  19523. /**
  19524. * Set a int in the shader.
  19525. * @param name Define the name of the uniform as defined in the shader
  19526. * @param value Define the value to give to the uniform
  19527. * @return the material itself allowing "fluent" like uniform updates
  19528. */
  19529. setInt(name: string, value: number): ShaderMaterial;
  19530. /**
  19531. * Set an array of floats in the shader.
  19532. * @param name Define the name of the uniform as defined in the shader
  19533. * @param value Define the value to give to the uniform
  19534. * @return the material itself allowing "fluent" like uniform updates
  19535. */
  19536. setFloats(name: string, value: number[]): ShaderMaterial;
  19537. /**
  19538. * Set a vec3 in the shader from a Color3.
  19539. * @param name Define the name of the uniform as defined in the shader
  19540. * @param value Define the value to give to the uniform
  19541. * @return the material itself allowing "fluent" like uniform updates
  19542. */
  19543. setColor3(name: string, value: Color3): ShaderMaterial;
  19544. /**
  19545. * Set a vec3 array in the shader from a Color3 array.
  19546. * @param name Define the name of the uniform as defined in the shader
  19547. * @param value Define the value to give to the uniform
  19548. * @return the material itself allowing "fluent" like uniform updates
  19549. */
  19550. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19551. /**
  19552. * Set a vec4 in the shader from a Color4.
  19553. * @param name Define the name of the uniform as defined in the shader
  19554. * @param value Define the value to give to the uniform
  19555. * @return the material itself allowing "fluent" like uniform updates
  19556. */
  19557. setColor4(name: string, value: Color4): ShaderMaterial;
  19558. /**
  19559. * Set a vec4 array in the shader from a Color4 array.
  19560. * @param name Define the name of the uniform as defined in the shader
  19561. * @param value Define the value to give to the uniform
  19562. * @return the material itself allowing "fluent" like uniform updates
  19563. */
  19564. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19565. /**
  19566. * Set a vec2 in the shader from a Vector2.
  19567. * @param name Define the name of the uniform as defined in the shader
  19568. * @param value Define the value to give to the uniform
  19569. * @return the material itself allowing "fluent" like uniform updates
  19570. */
  19571. setVector2(name: string, value: Vector2): ShaderMaterial;
  19572. /**
  19573. * Set a vec3 in the shader from a Vector3.
  19574. * @param name Define the name of the uniform as defined in the shader
  19575. * @param value Define the value to give to the uniform
  19576. * @return the material itself allowing "fluent" like uniform updates
  19577. */
  19578. setVector3(name: string, value: Vector3): ShaderMaterial;
  19579. /**
  19580. * Set a vec4 in the shader from a Vector4.
  19581. * @param name Define the name of the uniform as defined in the shader
  19582. * @param value Define the value to give to the uniform
  19583. * @return the material itself allowing "fluent" like uniform updates
  19584. */
  19585. setVector4(name: string, value: Vector4): ShaderMaterial;
  19586. /**
  19587. * Set a mat4 in the shader from a Matrix.
  19588. * @param name Define the name of the uniform as defined in the shader
  19589. * @param value Define the value to give to the uniform
  19590. * @return the material itself allowing "fluent" like uniform updates
  19591. */
  19592. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19593. /**
  19594. * Set a mat3 in the shader from a Float32Array.
  19595. * @param name Define the name of the uniform as defined in the shader
  19596. * @param value Define the value to give to the uniform
  19597. * @return the material itself allowing "fluent" like uniform updates
  19598. */
  19599. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19600. /**
  19601. * Set a mat2 in the shader from a Float32Array.
  19602. * @param name Define the name of the uniform as defined in the shader
  19603. * @param value Define the value to give to the uniform
  19604. * @return the material itself allowing "fluent" like uniform updates
  19605. */
  19606. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19607. /**
  19608. * Set a vec2 array in the shader from a number array.
  19609. * @param name Define the name of the uniform as defined in the shader
  19610. * @param value Define the value to give to the uniform
  19611. * @return the material itself allowing "fluent" like uniform updates
  19612. */
  19613. setArray2(name: string, value: number[]): ShaderMaterial;
  19614. /**
  19615. * Set a vec3 array in the shader from a number array.
  19616. * @param name Define the name of the uniform as defined in the shader
  19617. * @param value Define the value to give to the uniform
  19618. * @return the material itself allowing "fluent" like uniform updates
  19619. */
  19620. setArray3(name: string, value: number[]): ShaderMaterial;
  19621. /**
  19622. * Set a vec4 array in the shader from a number array.
  19623. * @param name Define the name of the uniform as defined in the shader
  19624. * @param value Define the value to give to the uniform
  19625. * @return the material itself allowing "fluent" like uniform updates
  19626. */
  19627. setArray4(name: string, value: number[]): ShaderMaterial;
  19628. private _checkCache;
  19629. /**
  19630. * Specifies that the submesh is ready to be used
  19631. * @param mesh defines the mesh to check
  19632. * @param subMesh defines which submesh to check
  19633. * @param useInstances specifies that instances should be used
  19634. * @returns a boolean indicating that the submesh is ready or not
  19635. */
  19636. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19637. /**
  19638. * Checks if the material is ready to render the requested mesh
  19639. * @param mesh Define the mesh to render
  19640. * @param useInstances Define whether or not the material is used with instances
  19641. * @returns true if ready, otherwise false
  19642. */
  19643. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19644. /**
  19645. * Binds the world matrix to the material
  19646. * @param world defines the world transformation matrix
  19647. */
  19648. bindOnlyWorldMatrix(world: Matrix): void;
  19649. /**
  19650. * Binds the material to the mesh
  19651. * @param world defines the world transformation matrix
  19652. * @param mesh defines the mesh to bind the material to
  19653. */
  19654. bind(world: Matrix, mesh?: Mesh): void;
  19655. /**
  19656. * Gets the active textures from the material
  19657. * @returns an array of textures
  19658. */
  19659. getActiveTextures(): BaseTexture[];
  19660. /**
  19661. * Specifies if the material uses a texture
  19662. * @param texture defines the texture to check against the material
  19663. * @returns a boolean specifying if the material uses the texture
  19664. */
  19665. hasTexture(texture: BaseTexture): boolean;
  19666. /**
  19667. * Makes a duplicate of the material, and gives it a new name
  19668. * @param name defines the new name for the duplicated material
  19669. * @returns the cloned material
  19670. */
  19671. clone(name: string): ShaderMaterial;
  19672. /**
  19673. * Disposes the material
  19674. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19675. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19676. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19677. */
  19678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19679. /**
  19680. * Serializes this material in a JSON representation
  19681. * @returns the serialized material object
  19682. */
  19683. serialize(): any;
  19684. /**
  19685. * Creates a shader material from parsed shader material data
  19686. * @param source defines the JSON represnetation of the material
  19687. * @param scene defines the hosting scene
  19688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19689. * @returns a new material
  19690. */
  19691. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19692. }
  19693. }
  19694. declare module "babylonjs/Shaders/color.fragment" {
  19695. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19696. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19697. /** @hidden */
  19698. export var colorPixelShader: {
  19699. name: string;
  19700. shader: string;
  19701. };
  19702. }
  19703. declare module "babylonjs/Shaders/color.vertex" {
  19704. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19705. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19706. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19707. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19708. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19709. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19710. /** @hidden */
  19711. export var colorVertexShader: {
  19712. name: string;
  19713. shader: string;
  19714. };
  19715. }
  19716. declare module "babylonjs/Meshes/linesMesh" {
  19717. import { Nullable } from "babylonjs/types";
  19718. import { Scene } from "babylonjs/scene";
  19719. import { Color3 } from "babylonjs/Maths/math.color";
  19720. import { Node } from "babylonjs/node";
  19721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19722. import { Mesh } from "babylonjs/Meshes/mesh";
  19723. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19724. import { Effect } from "babylonjs/Materials/effect";
  19725. import { Material } from "babylonjs/Materials/material";
  19726. import "babylonjs/Shaders/color.fragment";
  19727. import "babylonjs/Shaders/color.vertex";
  19728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19729. /**
  19730. * Line mesh
  19731. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19732. */
  19733. export class LinesMesh extends Mesh {
  19734. /**
  19735. * If vertex color should be applied to the mesh
  19736. */
  19737. readonly useVertexColor?: boolean | undefined;
  19738. /**
  19739. * If vertex alpha should be applied to the mesh
  19740. */
  19741. readonly useVertexAlpha?: boolean | undefined;
  19742. /**
  19743. * Color of the line (Default: White)
  19744. */
  19745. color: Color3;
  19746. /**
  19747. * Alpha of the line (Default: 1)
  19748. */
  19749. alpha: number;
  19750. /**
  19751. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19752. * This margin is expressed in world space coordinates, so its value may vary.
  19753. * Default value is 0.1
  19754. */
  19755. intersectionThreshold: number;
  19756. private _colorShader;
  19757. private color4;
  19758. /**
  19759. * Creates a new LinesMesh
  19760. * @param name defines the name
  19761. * @param scene defines the hosting scene
  19762. * @param parent defines the parent mesh if any
  19763. * @param source defines the optional source LinesMesh used to clone data from
  19764. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19765. * When false, achieved by calling a clone(), also passing False.
  19766. * This will make creation of children, recursive.
  19767. * @param useVertexColor defines if this LinesMesh supports vertex color
  19768. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19769. */
  19770. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19771. /**
  19772. * If vertex color should be applied to the mesh
  19773. */
  19774. useVertexColor?: boolean | undefined,
  19775. /**
  19776. * If vertex alpha should be applied to the mesh
  19777. */
  19778. useVertexAlpha?: boolean | undefined);
  19779. private _addClipPlaneDefine;
  19780. private _removeClipPlaneDefine;
  19781. isReady(): boolean;
  19782. /**
  19783. * Returns the string "LineMesh"
  19784. */
  19785. getClassName(): string;
  19786. /**
  19787. * @hidden
  19788. */
  19789. /**
  19790. * @hidden
  19791. */
  19792. material: Material;
  19793. /**
  19794. * @hidden
  19795. */
  19796. readonly checkCollisions: boolean;
  19797. /** @hidden */
  19798. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19799. /** @hidden */
  19800. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19801. /**
  19802. * Disposes of the line mesh
  19803. * @param doNotRecurse If children should be disposed
  19804. */
  19805. dispose(doNotRecurse?: boolean): void;
  19806. /**
  19807. * Returns a new LineMesh object cloned from the current one.
  19808. */
  19809. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19810. /**
  19811. * Creates a new InstancedLinesMesh object from the mesh model.
  19812. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19813. * @param name defines the name of the new instance
  19814. * @returns a new InstancedLinesMesh
  19815. */
  19816. createInstance(name: string): InstancedLinesMesh;
  19817. }
  19818. /**
  19819. * Creates an instance based on a source LinesMesh
  19820. */
  19821. export class InstancedLinesMesh extends InstancedMesh {
  19822. /**
  19823. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19824. * This margin is expressed in world space coordinates, so its value may vary.
  19825. * Initilized with the intersectionThreshold value of the source LinesMesh
  19826. */
  19827. intersectionThreshold: number;
  19828. constructor(name: string, source: LinesMesh);
  19829. /**
  19830. * Returns the string "InstancedLinesMesh".
  19831. */
  19832. getClassName(): string;
  19833. }
  19834. }
  19835. declare module "babylonjs/Shaders/line.fragment" {
  19836. /** @hidden */
  19837. export var linePixelShader: {
  19838. name: string;
  19839. shader: string;
  19840. };
  19841. }
  19842. declare module "babylonjs/Shaders/line.vertex" {
  19843. /** @hidden */
  19844. export var lineVertexShader: {
  19845. name: string;
  19846. shader: string;
  19847. };
  19848. }
  19849. declare module "babylonjs/Rendering/edgesRenderer" {
  19850. import { Nullable } from "babylonjs/types";
  19851. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19853. import { Vector3 } from "babylonjs/Maths/math.vector";
  19854. import { IDisposable } from "babylonjs/scene";
  19855. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19856. import "babylonjs/Shaders/line.fragment";
  19857. import "babylonjs/Shaders/line.vertex";
  19858. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19859. module "babylonjs/Meshes/abstractMesh" {
  19860. interface AbstractMesh {
  19861. /**
  19862. * Gets the edgesRenderer associated with the mesh
  19863. */
  19864. edgesRenderer: Nullable<EdgesRenderer>;
  19865. }
  19866. }
  19867. module "babylonjs/Meshes/linesMesh" {
  19868. interface LinesMesh {
  19869. /**
  19870. * Enables the edge rendering mode on the mesh.
  19871. * This mode makes the mesh edges visible
  19872. * @param epsilon defines the maximal distance between two angles to detect a face
  19873. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19874. * @returns the currentAbstractMesh
  19875. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19876. */
  19877. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19878. }
  19879. }
  19880. module "babylonjs/Meshes/linesMesh" {
  19881. interface InstancedLinesMesh {
  19882. /**
  19883. * Enables the edge rendering mode on the mesh.
  19884. * This mode makes the mesh edges visible
  19885. * @param epsilon defines the maximal distance between two angles to detect a face
  19886. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19887. * @returns the current InstancedLinesMesh
  19888. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19889. */
  19890. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19891. }
  19892. }
  19893. /**
  19894. * Defines the minimum contract an Edges renderer should follow.
  19895. */
  19896. export interface IEdgesRenderer extends IDisposable {
  19897. /**
  19898. * Gets or sets a boolean indicating if the edgesRenderer is active
  19899. */
  19900. isEnabled: boolean;
  19901. /**
  19902. * Renders the edges of the attached mesh,
  19903. */
  19904. render(): void;
  19905. /**
  19906. * Checks wether or not the edges renderer is ready to render.
  19907. * @return true if ready, otherwise false.
  19908. */
  19909. isReady(): boolean;
  19910. }
  19911. /**
  19912. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19913. */
  19914. export class EdgesRenderer implements IEdgesRenderer {
  19915. /**
  19916. * Define the size of the edges with an orthographic camera
  19917. */
  19918. edgesWidthScalerForOrthographic: number;
  19919. /**
  19920. * Define the size of the edges with a perspective camera
  19921. */
  19922. edgesWidthScalerForPerspective: number;
  19923. protected _source: AbstractMesh;
  19924. protected _linesPositions: number[];
  19925. protected _linesNormals: number[];
  19926. protected _linesIndices: number[];
  19927. protected _epsilon: number;
  19928. protected _indicesCount: number;
  19929. protected _lineShader: ShaderMaterial;
  19930. protected _ib: DataBuffer;
  19931. protected _buffers: {
  19932. [key: string]: Nullable<VertexBuffer>;
  19933. };
  19934. protected _checkVerticesInsteadOfIndices: boolean;
  19935. private _meshRebuildObserver;
  19936. private _meshDisposeObserver;
  19937. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19938. isEnabled: boolean;
  19939. /**
  19940. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19941. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19942. * @param source Mesh used to create edges
  19943. * @param epsilon sum of angles in adjacency to check for edge
  19944. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19945. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19946. */
  19947. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19948. protected _prepareRessources(): void;
  19949. /** @hidden */
  19950. _rebuild(): void;
  19951. /**
  19952. * Releases the required resources for the edges renderer
  19953. */
  19954. dispose(): void;
  19955. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19956. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19957. /**
  19958. * Checks if the pair of p0 and p1 is en edge
  19959. * @param faceIndex
  19960. * @param edge
  19961. * @param faceNormals
  19962. * @param p0
  19963. * @param p1
  19964. * @private
  19965. */
  19966. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19967. /**
  19968. * push line into the position, normal and index buffer
  19969. * @protected
  19970. */
  19971. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19972. /**
  19973. * Generates lines edges from adjacencjes
  19974. * @private
  19975. */
  19976. _generateEdgesLines(): void;
  19977. /**
  19978. * Checks wether or not the edges renderer is ready to render.
  19979. * @return true if ready, otherwise false.
  19980. */
  19981. isReady(): boolean;
  19982. /**
  19983. * Renders the edges of the attached mesh,
  19984. */
  19985. render(): void;
  19986. }
  19987. /**
  19988. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19989. */
  19990. export class LineEdgesRenderer extends EdgesRenderer {
  19991. /**
  19992. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19993. * @param source LineMesh used to generate edges
  19994. * @param epsilon not important (specified angle for edge detection)
  19995. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19996. */
  19997. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19998. /**
  19999. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20000. */
  20001. _generateEdgesLines(): void;
  20002. }
  20003. }
  20004. declare module "babylonjs/Rendering/renderingGroup" {
  20005. import { SmartArray } from "babylonjs/Misc/smartArray";
  20006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20008. import { Nullable } from "babylonjs/types";
  20009. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20010. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20011. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20012. import { Material } from "babylonjs/Materials/material";
  20013. import { Scene } from "babylonjs/scene";
  20014. /**
  20015. * This represents the object necessary to create a rendering group.
  20016. * This is exclusively used and created by the rendering manager.
  20017. * To modify the behavior, you use the available helpers in your scene or meshes.
  20018. * @hidden
  20019. */
  20020. export class RenderingGroup {
  20021. index: number;
  20022. private static _zeroVector;
  20023. private _scene;
  20024. private _opaqueSubMeshes;
  20025. private _transparentSubMeshes;
  20026. private _alphaTestSubMeshes;
  20027. private _depthOnlySubMeshes;
  20028. private _particleSystems;
  20029. private _spriteManagers;
  20030. private _opaqueSortCompareFn;
  20031. private _alphaTestSortCompareFn;
  20032. private _transparentSortCompareFn;
  20033. private _renderOpaque;
  20034. private _renderAlphaTest;
  20035. private _renderTransparent;
  20036. /** @hidden */
  20037. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20038. onBeforeTransparentRendering: () => void;
  20039. /**
  20040. * Set the opaque sort comparison function.
  20041. * If null the sub meshes will be render in the order they were created
  20042. */
  20043. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20044. /**
  20045. * Set the alpha test sort comparison function.
  20046. * If null the sub meshes will be render in the order they were created
  20047. */
  20048. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20049. /**
  20050. * Set the transparent sort comparison function.
  20051. * If null the sub meshes will be render in the order they were created
  20052. */
  20053. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20054. /**
  20055. * Creates a new rendering group.
  20056. * @param index The rendering group index
  20057. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20058. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20059. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20060. */
  20061. 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>);
  20062. /**
  20063. * Render all the sub meshes contained in the group.
  20064. * @param customRenderFunction Used to override the default render behaviour of the group.
  20065. * @returns true if rendered some submeshes.
  20066. */
  20067. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20068. /**
  20069. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20070. * @param subMeshes The submeshes to render
  20071. */
  20072. private renderOpaqueSorted;
  20073. /**
  20074. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20075. * @param subMeshes The submeshes to render
  20076. */
  20077. private renderAlphaTestSorted;
  20078. /**
  20079. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20080. * @param subMeshes The submeshes to render
  20081. */
  20082. private renderTransparentSorted;
  20083. /**
  20084. * Renders the submeshes in a specified order.
  20085. * @param subMeshes The submeshes to sort before render
  20086. * @param sortCompareFn The comparison function use to sort
  20087. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20088. * @param transparent Specifies to activate blending if true
  20089. */
  20090. private static renderSorted;
  20091. /**
  20092. * Renders the submeshes in the order they were dispatched (no sort applied).
  20093. * @param subMeshes The submeshes to render
  20094. */
  20095. private static renderUnsorted;
  20096. /**
  20097. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20098. * are rendered back to front if in the same alpha index.
  20099. *
  20100. * @param a The first submesh
  20101. * @param b The second submesh
  20102. * @returns The result of the comparison
  20103. */
  20104. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20105. /**
  20106. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20107. * are rendered back to front.
  20108. *
  20109. * @param a The first submesh
  20110. * @param b The second submesh
  20111. * @returns The result of the comparison
  20112. */
  20113. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20114. /**
  20115. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20116. * are rendered front to back (prevent overdraw).
  20117. *
  20118. * @param a The first submesh
  20119. * @param b The second submesh
  20120. * @returns The result of the comparison
  20121. */
  20122. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20123. /**
  20124. * Resets the different lists of submeshes to prepare a new frame.
  20125. */
  20126. prepare(): void;
  20127. dispose(): void;
  20128. /**
  20129. * Inserts the submesh in its correct queue depending on its material.
  20130. * @param subMesh The submesh to dispatch
  20131. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20132. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20133. */
  20134. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20135. dispatchSprites(spriteManager: ISpriteManager): void;
  20136. dispatchParticles(particleSystem: IParticleSystem): void;
  20137. private _renderParticles;
  20138. private _renderSprites;
  20139. }
  20140. }
  20141. declare module "babylonjs/Rendering/renderingManager" {
  20142. import { Nullable } from "babylonjs/types";
  20143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20145. import { SmartArray } from "babylonjs/Misc/smartArray";
  20146. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20147. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20148. import { Material } from "babylonjs/Materials/material";
  20149. import { Scene } from "babylonjs/scene";
  20150. import { Camera } from "babylonjs/Cameras/camera";
  20151. /**
  20152. * Interface describing the different options available in the rendering manager
  20153. * regarding Auto Clear between groups.
  20154. */
  20155. export interface IRenderingManagerAutoClearSetup {
  20156. /**
  20157. * Defines whether or not autoclear is enable.
  20158. */
  20159. autoClear: boolean;
  20160. /**
  20161. * Defines whether or not to autoclear the depth buffer.
  20162. */
  20163. depth: boolean;
  20164. /**
  20165. * Defines whether or not to autoclear the stencil buffer.
  20166. */
  20167. stencil: boolean;
  20168. }
  20169. /**
  20170. * This class is used by the onRenderingGroupObservable
  20171. */
  20172. export class RenderingGroupInfo {
  20173. /**
  20174. * The Scene that being rendered
  20175. */
  20176. scene: Scene;
  20177. /**
  20178. * The camera currently used for the rendering pass
  20179. */
  20180. camera: Nullable<Camera>;
  20181. /**
  20182. * The ID of the renderingGroup being processed
  20183. */
  20184. renderingGroupId: number;
  20185. }
  20186. /**
  20187. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20188. * It is enable to manage the different groups as well as the different necessary sort functions.
  20189. * This should not be used directly aside of the few static configurations
  20190. */
  20191. export class RenderingManager {
  20192. /**
  20193. * The max id used for rendering groups (not included)
  20194. */
  20195. static MAX_RENDERINGGROUPS: number;
  20196. /**
  20197. * The min id used for rendering groups (included)
  20198. */
  20199. static MIN_RENDERINGGROUPS: number;
  20200. /**
  20201. * Used to globally prevent autoclearing scenes.
  20202. */
  20203. static AUTOCLEAR: boolean;
  20204. /**
  20205. * @hidden
  20206. */
  20207. _useSceneAutoClearSetup: boolean;
  20208. private _scene;
  20209. private _renderingGroups;
  20210. private _depthStencilBufferAlreadyCleaned;
  20211. private _autoClearDepthStencil;
  20212. private _customOpaqueSortCompareFn;
  20213. private _customAlphaTestSortCompareFn;
  20214. private _customTransparentSortCompareFn;
  20215. private _renderingGroupInfo;
  20216. /**
  20217. * Instantiates a new rendering group for a particular scene
  20218. * @param scene Defines the scene the groups belongs to
  20219. */
  20220. constructor(scene: Scene);
  20221. private _clearDepthStencilBuffer;
  20222. /**
  20223. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20224. * @hidden
  20225. */
  20226. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20227. /**
  20228. * Resets the different information of the group to prepare a new frame
  20229. * @hidden
  20230. */
  20231. reset(): void;
  20232. /**
  20233. * Dispose and release the group and its associated resources.
  20234. * @hidden
  20235. */
  20236. dispose(): void;
  20237. /**
  20238. * Clear the info related to rendering groups preventing retention points during dispose.
  20239. */
  20240. freeRenderingGroups(): void;
  20241. private _prepareRenderingGroup;
  20242. /**
  20243. * Add a sprite manager to the rendering manager in order to render it this frame.
  20244. * @param spriteManager Define the sprite manager to render
  20245. */
  20246. dispatchSprites(spriteManager: ISpriteManager): void;
  20247. /**
  20248. * Add a particle system to the rendering manager in order to render it this frame.
  20249. * @param particleSystem Define the particle system to render
  20250. */
  20251. dispatchParticles(particleSystem: IParticleSystem): void;
  20252. /**
  20253. * Add a submesh to the manager in order to render it this frame
  20254. * @param subMesh The submesh to dispatch
  20255. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20256. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20257. */
  20258. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20259. /**
  20260. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20261. * This allowed control for front to back rendering or reversly depending of the special needs.
  20262. *
  20263. * @param renderingGroupId The rendering group id corresponding to its index
  20264. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20265. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20266. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20267. */
  20268. 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;
  20269. /**
  20270. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20271. *
  20272. * @param renderingGroupId The rendering group id corresponding to its index
  20273. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20274. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20275. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20276. */
  20277. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20278. /**
  20279. * Gets the current auto clear configuration for one rendering group of the rendering
  20280. * manager.
  20281. * @param index the rendering group index to get the information for
  20282. * @returns The auto clear setup for the requested rendering group
  20283. */
  20284. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20285. }
  20286. }
  20287. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20288. import { Observable } from "babylonjs/Misc/observable";
  20289. import { SmartArray } from "babylonjs/Misc/smartArray";
  20290. import { Nullable } from "babylonjs/types";
  20291. import { Camera } from "babylonjs/Cameras/camera";
  20292. import { Scene } from "babylonjs/scene";
  20293. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20294. import { Color4 } from "babylonjs/Maths/math.color";
  20295. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20299. import { Texture } from "babylonjs/Materials/Textures/texture";
  20300. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20301. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20302. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20303. import { Engine } from "babylonjs/Engines/engine";
  20304. /**
  20305. * This Helps creating a texture that will be created from a camera in your scene.
  20306. * It is basically a dynamic texture that could be used to create special effects for instance.
  20307. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20308. */
  20309. export class RenderTargetTexture extends Texture {
  20310. isCube: boolean;
  20311. /**
  20312. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20313. */
  20314. static readonly REFRESHRATE_RENDER_ONCE: number;
  20315. /**
  20316. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20317. */
  20318. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20319. /**
  20320. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20321. * the central point of your effect and can save a lot of performances.
  20322. */
  20323. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20324. /**
  20325. * Use this predicate to dynamically define the list of mesh you want to render.
  20326. * If set, the renderList property will be overwritten.
  20327. */
  20328. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20329. private _renderList;
  20330. /**
  20331. * Use this list to define the list of mesh you want to render.
  20332. */
  20333. renderList: Nullable<Array<AbstractMesh>>;
  20334. private _hookArray;
  20335. /**
  20336. * Define if particles should be rendered in your texture.
  20337. */
  20338. renderParticles: boolean;
  20339. /**
  20340. * Define if sprites should be rendered in your texture.
  20341. */
  20342. renderSprites: boolean;
  20343. /**
  20344. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20345. */
  20346. coordinatesMode: number;
  20347. /**
  20348. * Define the camera used to render the texture.
  20349. */
  20350. activeCamera: Nullable<Camera>;
  20351. /**
  20352. * Override the render function of the texture with your own one.
  20353. */
  20354. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20355. /**
  20356. * Define if camera post processes should be use while rendering the texture.
  20357. */
  20358. useCameraPostProcesses: boolean;
  20359. /**
  20360. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20361. */
  20362. ignoreCameraViewport: boolean;
  20363. private _postProcessManager;
  20364. private _postProcesses;
  20365. private _resizeObserver;
  20366. /**
  20367. * An event triggered when the texture is unbind.
  20368. */
  20369. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20370. /**
  20371. * An event triggered when the texture is unbind.
  20372. */
  20373. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20374. private _onAfterUnbindObserver;
  20375. /**
  20376. * Set a after unbind callback in the texture.
  20377. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20378. */
  20379. onAfterUnbind: () => void;
  20380. /**
  20381. * An event triggered before rendering the texture
  20382. */
  20383. onBeforeRenderObservable: Observable<number>;
  20384. private _onBeforeRenderObserver;
  20385. /**
  20386. * Set a before render callback in the texture.
  20387. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20388. */
  20389. onBeforeRender: (faceIndex: number) => void;
  20390. /**
  20391. * An event triggered after rendering the texture
  20392. */
  20393. onAfterRenderObservable: Observable<number>;
  20394. private _onAfterRenderObserver;
  20395. /**
  20396. * Set a after render callback in the texture.
  20397. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20398. */
  20399. onAfterRender: (faceIndex: number) => void;
  20400. /**
  20401. * An event triggered after the texture clear
  20402. */
  20403. onClearObservable: Observable<Engine>;
  20404. private _onClearObserver;
  20405. /**
  20406. * Set a clear callback in the texture.
  20407. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20408. */
  20409. onClear: (Engine: Engine) => void;
  20410. /**
  20411. * An event triggered when the texture is resized.
  20412. */
  20413. onResizeObservable: Observable<RenderTargetTexture>;
  20414. /**
  20415. * Define the clear color of the Render Target if it should be different from the scene.
  20416. */
  20417. clearColor: Color4;
  20418. protected _size: number | {
  20419. width: number;
  20420. height: number;
  20421. };
  20422. protected _initialSizeParameter: number | {
  20423. width: number;
  20424. height: number;
  20425. } | {
  20426. ratio: number;
  20427. };
  20428. protected _sizeRatio: Nullable<number>;
  20429. /** @hidden */
  20430. _generateMipMaps: boolean;
  20431. protected _renderingManager: RenderingManager;
  20432. /** @hidden */
  20433. _waitingRenderList: string[];
  20434. protected _doNotChangeAspectRatio: boolean;
  20435. protected _currentRefreshId: number;
  20436. protected _refreshRate: number;
  20437. protected _textureMatrix: Matrix;
  20438. protected _samples: number;
  20439. protected _renderTargetOptions: RenderTargetCreationOptions;
  20440. /**
  20441. * Gets render target creation options that were used.
  20442. */
  20443. readonly renderTargetOptions: RenderTargetCreationOptions;
  20444. protected _engine: Engine;
  20445. protected _onRatioRescale(): void;
  20446. /**
  20447. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20448. * It must define where the camera used to render the texture is set
  20449. */
  20450. boundingBoxPosition: Vector3;
  20451. private _boundingBoxSize;
  20452. /**
  20453. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20454. * When defined, the cubemap will switch to local mode
  20455. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20456. * @example https://www.babylonjs-playground.com/#RNASML
  20457. */
  20458. boundingBoxSize: Vector3;
  20459. /**
  20460. * In case the RTT has been created with a depth texture, get the associated
  20461. * depth texture.
  20462. * Otherwise, return null.
  20463. */
  20464. depthStencilTexture: Nullable<InternalTexture>;
  20465. /**
  20466. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20467. * or used a shadow, depth texture...
  20468. * @param name The friendly name of the texture
  20469. * @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)
  20470. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20471. * @param generateMipMaps True if mip maps need to be generated after render.
  20472. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20473. * @param type The type of the buffer in the RTT (int, half float, float...)
  20474. * @param isCube True if a cube texture needs to be created
  20475. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20476. * @param generateDepthBuffer True to generate a depth buffer
  20477. * @param generateStencilBuffer True to generate a stencil buffer
  20478. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20479. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20480. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20481. */
  20482. constructor(name: string, size: number | {
  20483. width: number;
  20484. height: number;
  20485. } | {
  20486. ratio: number;
  20487. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20488. /**
  20489. * Creates a depth stencil texture.
  20490. * This is only available in WebGL 2 or with the depth texture extension available.
  20491. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20492. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20493. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20494. */
  20495. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20496. private _processSizeParameter;
  20497. /**
  20498. * Define the number of samples to use in case of MSAA.
  20499. * It defaults to one meaning no MSAA has been enabled.
  20500. */
  20501. samples: number;
  20502. /**
  20503. * Resets the refresh counter of the texture and start bak from scratch.
  20504. * Could be useful to regenerate the texture if it is setup to render only once.
  20505. */
  20506. resetRefreshCounter(): void;
  20507. /**
  20508. * Define the refresh rate of the texture or the rendering frequency.
  20509. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20510. */
  20511. refreshRate: number;
  20512. /**
  20513. * Adds a post process to the render target rendering passes.
  20514. * @param postProcess define the post process to add
  20515. */
  20516. addPostProcess(postProcess: PostProcess): void;
  20517. /**
  20518. * Clear all the post processes attached to the render target
  20519. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20520. */
  20521. clearPostProcesses(dispose?: boolean): void;
  20522. /**
  20523. * Remove one of the post process from the list of attached post processes to the texture
  20524. * @param postProcess define the post process to remove from the list
  20525. */
  20526. removePostProcess(postProcess: PostProcess): void;
  20527. /** @hidden */
  20528. _shouldRender(): boolean;
  20529. /**
  20530. * Gets the actual render size of the texture.
  20531. * @returns the width of the render size
  20532. */
  20533. getRenderSize(): number;
  20534. /**
  20535. * Gets the actual render width of the texture.
  20536. * @returns the width of the render size
  20537. */
  20538. getRenderWidth(): number;
  20539. /**
  20540. * Gets the actual render height of the texture.
  20541. * @returns the height of the render size
  20542. */
  20543. getRenderHeight(): number;
  20544. /**
  20545. * Get if the texture can be rescaled or not.
  20546. */
  20547. readonly canRescale: boolean;
  20548. /**
  20549. * Resize the texture using a ratio.
  20550. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20551. */
  20552. scale(ratio: number): void;
  20553. /**
  20554. * Get the texture reflection matrix used to rotate/transform the reflection.
  20555. * @returns the reflection matrix
  20556. */
  20557. getReflectionTextureMatrix(): Matrix;
  20558. /**
  20559. * Resize the texture to a new desired size.
  20560. * Be carrefull as it will recreate all the data in the new texture.
  20561. * @param size Define the new size. It can be:
  20562. * - a number for squared texture,
  20563. * - an object containing { width: number, height: number }
  20564. * - or an object containing a ratio { ratio: number }
  20565. */
  20566. resize(size: number | {
  20567. width: number;
  20568. height: number;
  20569. } | {
  20570. ratio: number;
  20571. }): void;
  20572. /**
  20573. * Renders all the objects from the render list into the texture.
  20574. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20575. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20576. */
  20577. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20578. private _bestReflectionRenderTargetDimension;
  20579. /**
  20580. * @hidden
  20581. * @param faceIndex face index to bind to if this is a cubetexture
  20582. */
  20583. _bindFrameBuffer(faceIndex?: number): void;
  20584. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20585. private renderToTarget;
  20586. /**
  20587. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20588. * This allowed control for front to back rendering or reversly depending of the special needs.
  20589. *
  20590. * @param renderingGroupId The rendering group id corresponding to its index
  20591. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20592. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20593. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20594. */
  20595. 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;
  20596. /**
  20597. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20598. *
  20599. * @param renderingGroupId The rendering group id corresponding to its index
  20600. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20601. */
  20602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20603. /**
  20604. * Clones the texture.
  20605. * @returns the cloned texture
  20606. */
  20607. clone(): RenderTargetTexture;
  20608. /**
  20609. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20610. * @returns The JSON representation of the texture
  20611. */
  20612. serialize(): any;
  20613. /**
  20614. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20615. */
  20616. disposeFramebufferObjects(): void;
  20617. /**
  20618. * Dispose the texture and release its associated resources.
  20619. */
  20620. dispose(): void;
  20621. /** @hidden */
  20622. _rebuild(): void;
  20623. /**
  20624. * Clear the info related to rendering groups preventing retention point in material dispose.
  20625. */
  20626. freeRenderingGroups(): void;
  20627. /**
  20628. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20629. * @returns the view count
  20630. */
  20631. getViewCount(): number;
  20632. }
  20633. }
  20634. declare module "babylonjs/Materials/material" {
  20635. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20636. import { SmartArray } from "babylonjs/Misc/smartArray";
  20637. import { Observable } from "babylonjs/Misc/observable";
  20638. import { Nullable } from "babylonjs/types";
  20639. import { Scene } from "babylonjs/scene";
  20640. import { Matrix } from "babylonjs/Maths/math.vector";
  20641. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20643. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20644. import { Effect } from "babylonjs/Materials/effect";
  20645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20647. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20648. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20649. import { Mesh } from "babylonjs/Meshes/mesh";
  20650. import { Animation } from "babylonjs/Animations/animation";
  20651. /**
  20652. * Base class for the main features of a material in Babylon.js
  20653. */
  20654. export class Material implements IAnimatable {
  20655. /**
  20656. * Returns the triangle fill mode
  20657. */
  20658. static readonly TriangleFillMode: number;
  20659. /**
  20660. * Returns the wireframe mode
  20661. */
  20662. static readonly WireFrameFillMode: number;
  20663. /**
  20664. * Returns the point fill mode
  20665. */
  20666. static readonly PointFillMode: number;
  20667. /**
  20668. * Returns the point list draw mode
  20669. */
  20670. static readonly PointListDrawMode: number;
  20671. /**
  20672. * Returns the line list draw mode
  20673. */
  20674. static readonly LineListDrawMode: number;
  20675. /**
  20676. * Returns the line loop draw mode
  20677. */
  20678. static readonly LineLoopDrawMode: number;
  20679. /**
  20680. * Returns the line strip draw mode
  20681. */
  20682. static readonly LineStripDrawMode: number;
  20683. /**
  20684. * Returns the triangle strip draw mode
  20685. */
  20686. static readonly TriangleStripDrawMode: number;
  20687. /**
  20688. * Returns the triangle fan draw mode
  20689. */
  20690. static readonly TriangleFanDrawMode: number;
  20691. /**
  20692. * Stores the clock-wise side orientation
  20693. */
  20694. static readonly ClockWiseSideOrientation: number;
  20695. /**
  20696. * Stores the counter clock-wise side orientation
  20697. */
  20698. static readonly CounterClockWiseSideOrientation: number;
  20699. /**
  20700. * The dirty texture flag value
  20701. */
  20702. static readonly TextureDirtyFlag: number;
  20703. /**
  20704. * The dirty light flag value
  20705. */
  20706. static readonly LightDirtyFlag: number;
  20707. /**
  20708. * The dirty fresnel flag value
  20709. */
  20710. static readonly FresnelDirtyFlag: number;
  20711. /**
  20712. * The dirty attribute flag value
  20713. */
  20714. static readonly AttributesDirtyFlag: number;
  20715. /**
  20716. * The dirty misc flag value
  20717. */
  20718. static readonly MiscDirtyFlag: number;
  20719. /**
  20720. * The all dirty flag value
  20721. */
  20722. static readonly AllDirtyFlag: number;
  20723. /**
  20724. * The ID of the material
  20725. */
  20726. id: string;
  20727. /**
  20728. * Gets or sets the unique id of the material
  20729. */
  20730. uniqueId: number;
  20731. /**
  20732. * The name of the material
  20733. */
  20734. name: string;
  20735. /**
  20736. * Gets or sets user defined metadata
  20737. */
  20738. metadata: any;
  20739. /**
  20740. * For internal use only. Please do not use.
  20741. */
  20742. reservedDataStore: any;
  20743. /**
  20744. * Specifies if the ready state should be checked on each call
  20745. */
  20746. checkReadyOnEveryCall: boolean;
  20747. /**
  20748. * Specifies if the ready state should be checked once
  20749. */
  20750. checkReadyOnlyOnce: boolean;
  20751. /**
  20752. * The state of the material
  20753. */
  20754. state: string;
  20755. /**
  20756. * The alpha value of the material
  20757. */
  20758. protected _alpha: number;
  20759. /**
  20760. * List of inspectable custom properties (used by the Inspector)
  20761. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20762. */
  20763. inspectableCustomProperties: IInspectable[];
  20764. /**
  20765. * Sets the alpha value of the material
  20766. */
  20767. /**
  20768. * Gets the alpha value of the material
  20769. */
  20770. alpha: number;
  20771. /**
  20772. * Specifies if back face culling is enabled
  20773. */
  20774. protected _backFaceCulling: boolean;
  20775. /**
  20776. * Sets the back-face culling state
  20777. */
  20778. /**
  20779. * Gets the back-face culling state
  20780. */
  20781. backFaceCulling: boolean;
  20782. /**
  20783. * Stores the value for side orientation
  20784. */
  20785. sideOrientation: number;
  20786. /**
  20787. * Callback triggered when the material is compiled
  20788. */
  20789. onCompiled: Nullable<(effect: Effect) => void>;
  20790. /**
  20791. * Callback triggered when an error occurs
  20792. */
  20793. onError: Nullable<(effect: Effect, errors: string) => void>;
  20794. /**
  20795. * Callback triggered to get the render target textures
  20796. */
  20797. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20798. /**
  20799. * Gets a boolean indicating that current material needs to register RTT
  20800. */
  20801. readonly hasRenderTargetTextures: boolean;
  20802. /**
  20803. * Specifies if the material should be serialized
  20804. */
  20805. doNotSerialize: boolean;
  20806. /**
  20807. * @hidden
  20808. */
  20809. _storeEffectOnSubMeshes: boolean;
  20810. /**
  20811. * Stores the animations for the material
  20812. */
  20813. animations: Nullable<Array<Animation>>;
  20814. /**
  20815. * An event triggered when the material is disposed
  20816. */
  20817. onDisposeObservable: Observable<Material>;
  20818. /**
  20819. * An observer which watches for dispose events
  20820. */
  20821. private _onDisposeObserver;
  20822. private _onUnBindObservable;
  20823. /**
  20824. * Called during a dispose event
  20825. */
  20826. onDispose: () => void;
  20827. private _onBindObservable;
  20828. /**
  20829. * An event triggered when the material is bound
  20830. */
  20831. readonly onBindObservable: Observable<AbstractMesh>;
  20832. /**
  20833. * An observer which watches for bind events
  20834. */
  20835. private _onBindObserver;
  20836. /**
  20837. * Called during a bind event
  20838. */
  20839. onBind: (Mesh: AbstractMesh) => void;
  20840. /**
  20841. * An event triggered when the material is unbound
  20842. */
  20843. readonly onUnBindObservable: Observable<Material>;
  20844. /**
  20845. * Stores the value of the alpha mode
  20846. */
  20847. private _alphaMode;
  20848. /**
  20849. * Sets the value of the alpha mode.
  20850. *
  20851. * | Value | Type | Description |
  20852. * | --- | --- | --- |
  20853. * | 0 | ALPHA_DISABLE | |
  20854. * | 1 | ALPHA_ADD | |
  20855. * | 2 | ALPHA_COMBINE | |
  20856. * | 3 | ALPHA_SUBTRACT | |
  20857. * | 4 | ALPHA_MULTIPLY | |
  20858. * | 5 | ALPHA_MAXIMIZED | |
  20859. * | 6 | ALPHA_ONEONE | |
  20860. * | 7 | ALPHA_PREMULTIPLIED | |
  20861. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20862. * | 9 | ALPHA_INTERPOLATE | |
  20863. * | 10 | ALPHA_SCREENMODE | |
  20864. *
  20865. */
  20866. /**
  20867. * Gets the value of the alpha mode
  20868. */
  20869. alphaMode: number;
  20870. /**
  20871. * Stores the state of the need depth pre-pass value
  20872. */
  20873. private _needDepthPrePass;
  20874. /**
  20875. * Sets the need depth pre-pass value
  20876. */
  20877. /**
  20878. * Gets the depth pre-pass value
  20879. */
  20880. needDepthPrePass: boolean;
  20881. /**
  20882. * Specifies if depth writing should be disabled
  20883. */
  20884. disableDepthWrite: boolean;
  20885. /**
  20886. * Specifies if depth writing should be forced
  20887. */
  20888. forceDepthWrite: boolean;
  20889. /**
  20890. * Specifies if there should be a separate pass for culling
  20891. */
  20892. separateCullingPass: boolean;
  20893. /**
  20894. * Stores the state specifing if fog should be enabled
  20895. */
  20896. private _fogEnabled;
  20897. /**
  20898. * Sets the state for enabling fog
  20899. */
  20900. /**
  20901. * Gets the value of the fog enabled state
  20902. */
  20903. fogEnabled: boolean;
  20904. /**
  20905. * Stores the size of points
  20906. */
  20907. pointSize: number;
  20908. /**
  20909. * Stores the z offset value
  20910. */
  20911. zOffset: number;
  20912. /**
  20913. * Gets a value specifying if wireframe mode is enabled
  20914. */
  20915. /**
  20916. * Sets the state of wireframe mode
  20917. */
  20918. wireframe: boolean;
  20919. /**
  20920. * Gets the value specifying if point clouds are enabled
  20921. */
  20922. /**
  20923. * Sets the state of point cloud mode
  20924. */
  20925. pointsCloud: boolean;
  20926. /**
  20927. * Gets the material fill mode
  20928. */
  20929. /**
  20930. * Sets the material fill mode
  20931. */
  20932. fillMode: number;
  20933. /**
  20934. * @hidden
  20935. * Stores the effects for the material
  20936. */
  20937. _effect: Nullable<Effect>;
  20938. /**
  20939. * @hidden
  20940. * Specifies if the material was previously ready
  20941. */
  20942. _wasPreviouslyReady: boolean;
  20943. /**
  20944. * Specifies if uniform buffers should be used
  20945. */
  20946. private _useUBO;
  20947. /**
  20948. * Stores a reference to the scene
  20949. */
  20950. private _scene;
  20951. /**
  20952. * Stores the fill mode state
  20953. */
  20954. private _fillMode;
  20955. /**
  20956. * Specifies if the depth write state should be cached
  20957. */
  20958. private _cachedDepthWriteState;
  20959. /**
  20960. * Stores the uniform buffer
  20961. */
  20962. protected _uniformBuffer: UniformBuffer;
  20963. /** @hidden */
  20964. _indexInSceneMaterialArray: number;
  20965. /** @hidden */
  20966. meshMap: Nullable<{
  20967. [id: string]: AbstractMesh | undefined;
  20968. }>;
  20969. /**
  20970. * Creates a material instance
  20971. * @param name defines the name of the material
  20972. * @param scene defines the scene to reference
  20973. * @param doNotAdd specifies if the material should be added to the scene
  20974. */
  20975. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20976. /**
  20977. * Returns a string representation of the current material
  20978. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20979. * @returns a string with material information
  20980. */
  20981. toString(fullDetails?: boolean): string;
  20982. /**
  20983. * Gets the class name of the material
  20984. * @returns a string with the class name of the material
  20985. */
  20986. getClassName(): string;
  20987. /**
  20988. * Specifies if updates for the material been locked
  20989. */
  20990. readonly isFrozen: boolean;
  20991. /**
  20992. * Locks updates for the material
  20993. */
  20994. freeze(): void;
  20995. /**
  20996. * Unlocks updates for the material
  20997. */
  20998. unfreeze(): void;
  20999. /**
  21000. * Specifies if the material is ready to be used
  21001. * @param mesh defines the mesh to check
  21002. * @param useInstances specifies if instances should be used
  21003. * @returns a boolean indicating if the material is ready to be used
  21004. */
  21005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21006. /**
  21007. * Specifies that the submesh is ready to be used
  21008. * @param mesh defines the mesh to check
  21009. * @param subMesh defines which submesh to check
  21010. * @param useInstances specifies that instances should be used
  21011. * @returns a boolean indicating that the submesh is ready or not
  21012. */
  21013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21014. /**
  21015. * Returns the material effect
  21016. * @returns the effect associated with the material
  21017. */
  21018. getEffect(): Nullable<Effect>;
  21019. /**
  21020. * Returns the current scene
  21021. * @returns a Scene
  21022. */
  21023. getScene(): Scene;
  21024. /**
  21025. * Specifies if the material will require alpha blending
  21026. * @returns a boolean specifying if alpha blending is needed
  21027. */
  21028. needAlphaBlending(): boolean;
  21029. /**
  21030. * Specifies if the mesh will require alpha blending
  21031. * @param mesh defines the mesh to check
  21032. * @returns a boolean specifying if alpha blending is needed for the mesh
  21033. */
  21034. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21035. /**
  21036. * Specifies if this material should be rendered in alpha test mode
  21037. * @returns a boolean specifying if an alpha test is needed.
  21038. */
  21039. needAlphaTesting(): boolean;
  21040. /**
  21041. * Gets the texture used for the alpha test
  21042. * @returns the texture to use for alpha testing
  21043. */
  21044. getAlphaTestTexture(): Nullable<BaseTexture>;
  21045. /**
  21046. * Marks the material to indicate that it needs to be re-calculated
  21047. */
  21048. markDirty(): void;
  21049. /** @hidden */
  21050. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21051. /**
  21052. * Binds the material to the mesh
  21053. * @param world defines the world transformation matrix
  21054. * @param mesh defines the mesh to bind the material to
  21055. */
  21056. bind(world: Matrix, mesh?: Mesh): void;
  21057. /**
  21058. * Binds the submesh to the material
  21059. * @param world defines the world transformation matrix
  21060. * @param mesh defines the mesh containing the submesh
  21061. * @param subMesh defines the submesh to bind the material to
  21062. */
  21063. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21064. /**
  21065. * Binds the world matrix to the material
  21066. * @param world defines the world transformation matrix
  21067. */
  21068. bindOnlyWorldMatrix(world: Matrix): void;
  21069. /**
  21070. * Binds the scene's uniform buffer to the effect.
  21071. * @param effect defines the effect to bind to the scene uniform buffer
  21072. * @param sceneUbo defines the uniform buffer storing scene data
  21073. */
  21074. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21075. /**
  21076. * Binds the view matrix to the effect
  21077. * @param effect defines the effect to bind the view matrix to
  21078. */
  21079. bindView(effect: Effect): void;
  21080. /**
  21081. * Binds the view projection matrix to the effect
  21082. * @param effect defines the effect to bind the view projection matrix to
  21083. */
  21084. bindViewProjection(effect: Effect): void;
  21085. /**
  21086. * Specifies if material alpha testing should be turned on for the mesh
  21087. * @param mesh defines the mesh to check
  21088. */
  21089. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21090. /**
  21091. * Processes to execute after binding the material to a mesh
  21092. * @param mesh defines the rendered mesh
  21093. */
  21094. protected _afterBind(mesh?: Mesh): void;
  21095. /**
  21096. * Unbinds the material from the mesh
  21097. */
  21098. unbind(): void;
  21099. /**
  21100. * Gets the active textures from the material
  21101. * @returns an array of textures
  21102. */
  21103. getActiveTextures(): BaseTexture[];
  21104. /**
  21105. * Specifies if the material uses a texture
  21106. * @param texture defines the texture to check against the material
  21107. * @returns a boolean specifying if the material uses the texture
  21108. */
  21109. hasTexture(texture: BaseTexture): boolean;
  21110. /**
  21111. * Makes a duplicate of the material, and gives it a new name
  21112. * @param name defines the new name for the duplicated material
  21113. * @returns the cloned material
  21114. */
  21115. clone(name: string): Nullable<Material>;
  21116. /**
  21117. * Gets the meshes bound to the material
  21118. * @returns an array of meshes bound to the material
  21119. */
  21120. getBindedMeshes(): AbstractMesh[];
  21121. /**
  21122. * Force shader compilation
  21123. * @param mesh defines the mesh associated with this material
  21124. * @param onCompiled defines a function to execute once the material is compiled
  21125. * @param options defines the options to configure the compilation
  21126. */
  21127. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21128. clipPlane: boolean;
  21129. }>): void;
  21130. /**
  21131. * Force shader compilation
  21132. * @param mesh defines the mesh that will use this material
  21133. * @param options defines additional options for compiling the shaders
  21134. * @returns a promise that resolves when the compilation completes
  21135. */
  21136. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21137. clipPlane: boolean;
  21138. }>): Promise<void>;
  21139. private static readonly _AllDirtyCallBack;
  21140. private static readonly _ImageProcessingDirtyCallBack;
  21141. private static readonly _TextureDirtyCallBack;
  21142. private static readonly _FresnelDirtyCallBack;
  21143. private static readonly _MiscDirtyCallBack;
  21144. private static readonly _LightsDirtyCallBack;
  21145. private static readonly _AttributeDirtyCallBack;
  21146. private static _FresnelAndMiscDirtyCallBack;
  21147. private static _TextureAndMiscDirtyCallBack;
  21148. private static readonly _DirtyCallbackArray;
  21149. private static readonly _RunDirtyCallBacks;
  21150. /**
  21151. * Marks a define in the material to indicate that it needs to be re-computed
  21152. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21153. */
  21154. markAsDirty(flag: number): void;
  21155. /**
  21156. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21157. * @param func defines a function which checks material defines against the submeshes
  21158. */
  21159. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21160. /**
  21161. * Indicates that we need to re-calculated for all submeshes
  21162. */
  21163. protected _markAllSubMeshesAsAllDirty(): void;
  21164. /**
  21165. * Indicates that image processing needs to be re-calculated for all submeshes
  21166. */
  21167. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21168. /**
  21169. * Indicates that textures need to be re-calculated for all submeshes
  21170. */
  21171. protected _markAllSubMeshesAsTexturesDirty(): void;
  21172. /**
  21173. * Indicates that fresnel needs to be re-calculated for all submeshes
  21174. */
  21175. protected _markAllSubMeshesAsFresnelDirty(): void;
  21176. /**
  21177. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21178. */
  21179. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21180. /**
  21181. * Indicates that lights need to be re-calculated for all submeshes
  21182. */
  21183. protected _markAllSubMeshesAsLightsDirty(): void;
  21184. /**
  21185. * Indicates that attributes need to be re-calculated for all submeshes
  21186. */
  21187. protected _markAllSubMeshesAsAttributesDirty(): void;
  21188. /**
  21189. * Indicates that misc needs to be re-calculated for all submeshes
  21190. */
  21191. protected _markAllSubMeshesAsMiscDirty(): void;
  21192. /**
  21193. * Indicates that textures and misc need to be re-calculated for all submeshes
  21194. */
  21195. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21196. /**
  21197. * Disposes the material
  21198. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21199. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21200. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21201. */
  21202. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21203. /** @hidden */
  21204. private releaseVertexArrayObject;
  21205. /**
  21206. * Serializes this material
  21207. * @returns the serialized material object
  21208. */
  21209. serialize(): any;
  21210. /**
  21211. * Creates a material from parsed material data
  21212. * @param parsedMaterial defines parsed material data
  21213. * @param scene defines the hosting scene
  21214. * @param rootUrl defines the root URL to use to load textures
  21215. * @returns a new material
  21216. */
  21217. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21218. }
  21219. }
  21220. declare module "babylonjs/Materials/multiMaterial" {
  21221. import { Nullable } from "babylonjs/types";
  21222. import { Scene } from "babylonjs/scene";
  21223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21224. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21226. import { Material } from "babylonjs/Materials/material";
  21227. /**
  21228. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21229. * separate meshes. This can be use to improve performances.
  21230. * @see http://doc.babylonjs.com/how_to/multi_materials
  21231. */
  21232. export class MultiMaterial extends Material {
  21233. private _subMaterials;
  21234. /**
  21235. * Gets or Sets the list of Materials used within the multi material.
  21236. * They need to be ordered according to the submeshes order in the associated mesh
  21237. */
  21238. subMaterials: Nullable<Material>[];
  21239. /**
  21240. * Function used to align with Node.getChildren()
  21241. * @returns the list of Materials used within the multi material
  21242. */
  21243. getChildren(): Nullable<Material>[];
  21244. /**
  21245. * Instantiates a new Multi Material
  21246. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21247. * separate meshes. This can be use to improve performances.
  21248. * @see http://doc.babylonjs.com/how_to/multi_materials
  21249. * @param name Define the name in the scene
  21250. * @param scene Define the scene the material belongs to
  21251. */
  21252. constructor(name: string, scene: Scene);
  21253. private _hookArray;
  21254. /**
  21255. * Get one of the submaterial by its index in the submaterials array
  21256. * @param index The index to look the sub material at
  21257. * @returns The Material if the index has been defined
  21258. */
  21259. getSubMaterial(index: number): Nullable<Material>;
  21260. /**
  21261. * Get the list of active textures for the whole sub materials list.
  21262. * @returns All the textures that will be used during the rendering
  21263. */
  21264. getActiveTextures(): BaseTexture[];
  21265. /**
  21266. * Gets the current class name of the material e.g. "MultiMaterial"
  21267. * Mainly use in serialization.
  21268. * @returns the class name
  21269. */
  21270. getClassName(): string;
  21271. /**
  21272. * Checks if the material is ready to render the requested sub mesh
  21273. * @param mesh Define the mesh the submesh belongs to
  21274. * @param subMesh Define the sub mesh to look readyness for
  21275. * @param useInstances Define whether or not the material is used with instances
  21276. * @returns true if ready, otherwise false
  21277. */
  21278. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21279. /**
  21280. * Clones the current material and its related sub materials
  21281. * @param name Define the name of the newly cloned material
  21282. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21283. * @returns the cloned material
  21284. */
  21285. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21286. /**
  21287. * Serializes the materials into a JSON representation.
  21288. * @returns the JSON representation
  21289. */
  21290. serialize(): any;
  21291. /**
  21292. * Dispose the material and release its associated resources
  21293. * @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)
  21294. * @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)
  21295. * @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)
  21296. */
  21297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21298. /**
  21299. * Creates a MultiMaterial from parsed MultiMaterial data.
  21300. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21301. * @param scene defines the hosting scene
  21302. * @returns a new MultiMaterial
  21303. */
  21304. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21305. }
  21306. }
  21307. declare module "babylonjs/Meshes/subMesh" {
  21308. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21309. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21310. import { Engine } from "babylonjs/Engines/engine";
  21311. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21312. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21313. import { Effect } from "babylonjs/Materials/effect";
  21314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21315. import { Plane } from "babylonjs/Maths/math.plane";
  21316. import { Collider } from "babylonjs/Collisions/collider";
  21317. import { Material } from "babylonjs/Materials/material";
  21318. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21320. import { Mesh } from "babylonjs/Meshes/mesh";
  21321. import { Ray } from "babylonjs/Culling/ray";
  21322. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21323. /**
  21324. * Base class for submeshes
  21325. */
  21326. export class BaseSubMesh {
  21327. /** @hidden */
  21328. _materialDefines: Nullable<MaterialDefines>;
  21329. /** @hidden */
  21330. _materialEffect: Nullable<Effect>;
  21331. /**
  21332. * Gets associated effect
  21333. */
  21334. readonly effect: Nullable<Effect>;
  21335. /**
  21336. * Sets associated effect (effect used to render this submesh)
  21337. * @param effect defines the effect to associate with
  21338. * @param defines defines the set of defines used to compile this effect
  21339. */
  21340. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21341. }
  21342. /**
  21343. * Defines a subdivision inside a mesh
  21344. */
  21345. export class SubMesh extends BaseSubMesh implements ICullable {
  21346. /** the material index to use */
  21347. materialIndex: number;
  21348. /** vertex index start */
  21349. verticesStart: number;
  21350. /** vertices count */
  21351. verticesCount: number;
  21352. /** index start */
  21353. indexStart: number;
  21354. /** indices count */
  21355. indexCount: number;
  21356. /** @hidden */
  21357. _linesIndexCount: number;
  21358. private _mesh;
  21359. private _renderingMesh;
  21360. private _boundingInfo;
  21361. private _linesIndexBuffer;
  21362. /** @hidden */
  21363. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21364. /** @hidden */
  21365. _trianglePlanes: Plane[];
  21366. /** @hidden */
  21367. _lastColliderTransformMatrix: Nullable<Matrix>;
  21368. /** @hidden */
  21369. _renderId: number;
  21370. /** @hidden */
  21371. _alphaIndex: number;
  21372. /** @hidden */
  21373. _distanceToCamera: number;
  21374. /** @hidden */
  21375. _id: number;
  21376. private _currentMaterial;
  21377. /**
  21378. * Add a new submesh to a mesh
  21379. * @param materialIndex defines the material index to use
  21380. * @param verticesStart defines vertex index start
  21381. * @param verticesCount defines vertices count
  21382. * @param indexStart defines index start
  21383. * @param indexCount defines indices count
  21384. * @param mesh defines the parent mesh
  21385. * @param renderingMesh defines an optional rendering mesh
  21386. * @param createBoundingBox defines if bounding box should be created for this submesh
  21387. * @returns the new submesh
  21388. */
  21389. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21390. /**
  21391. * Creates a new submesh
  21392. * @param materialIndex defines the material index to use
  21393. * @param verticesStart defines vertex index start
  21394. * @param verticesCount defines vertices count
  21395. * @param indexStart defines index start
  21396. * @param indexCount defines indices count
  21397. * @param mesh defines the parent mesh
  21398. * @param renderingMesh defines an optional rendering mesh
  21399. * @param createBoundingBox defines if bounding box should be created for this submesh
  21400. */
  21401. constructor(
  21402. /** the material index to use */
  21403. materialIndex: number,
  21404. /** vertex index start */
  21405. verticesStart: number,
  21406. /** vertices count */
  21407. verticesCount: number,
  21408. /** index start */
  21409. indexStart: number,
  21410. /** indices count */
  21411. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21412. /**
  21413. * Returns true if this submesh covers the entire parent mesh
  21414. * @ignorenaming
  21415. */
  21416. readonly IsGlobal: boolean;
  21417. /**
  21418. * Returns the submesh BoudingInfo object
  21419. * @returns current bounding info (or mesh's one if the submesh is global)
  21420. */
  21421. getBoundingInfo(): BoundingInfo;
  21422. /**
  21423. * Sets the submesh BoundingInfo
  21424. * @param boundingInfo defines the new bounding info to use
  21425. * @returns the SubMesh
  21426. */
  21427. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21428. /**
  21429. * Returns the mesh of the current submesh
  21430. * @return the parent mesh
  21431. */
  21432. getMesh(): AbstractMesh;
  21433. /**
  21434. * Returns the rendering mesh of the submesh
  21435. * @returns the rendering mesh (could be different from parent mesh)
  21436. */
  21437. getRenderingMesh(): Mesh;
  21438. /**
  21439. * Returns the submesh material
  21440. * @returns null or the current material
  21441. */
  21442. getMaterial(): Nullable<Material>;
  21443. /**
  21444. * Sets a new updated BoundingInfo object to the submesh
  21445. * @param data defines an optional position array to use to determine the bounding info
  21446. * @returns the SubMesh
  21447. */
  21448. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21449. /** @hidden */
  21450. _checkCollision(collider: Collider): boolean;
  21451. /**
  21452. * Updates the submesh BoundingInfo
  21453. * @param world defines the world matrix to use to update the bounding info
  21454. * @returns the submesh
  21455. */
  21456. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21457. /**
  21458. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21459. * @param frustumPlanes defines the frustum planes
  21460. * @returns true if the submesh is intersecting with the frustum
  21461. */
  21462. isInFrustum(frustumPlanes: Plane[]): boolean;
  21463. /**
  21464. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21465. * @param frustumPlanes defines the frustum planes
  21466. * @returns true if the submesh is inside the frustum
  21467. */
  21468. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21469. /**
  21470. * Renders the submesh
  21471. * @param enableAlphaMode defines if alpha needs to be used
  21472. * @returns the submesh
  21473. */
  21474. render(enableAlphaMode: boolean): SubMesh;
  21475. /**
  21476. * @hidden
  21477. */
  21478. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21479. /**
  21480. * Checks if the submesh intersects with a ray
  21481. * @param ray defines the ray to test
  21482. * @returns true is the passed ray intersects the submesh bounding box
  21483. */
  21484. canIntersects(ray: Ray): boolean;
  21485. /**
  21486. * Intersects current submesh with a ray
  21487. * @param ray defines the ray to test
  21488. * @param positions defines mesh's positions array
  21489. * @param indices defines mesh's indices array
  21490. * @param fastCheck defines if only bounding info should be used
  21491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21492. * @returns intersection info or null if no intersection
  21493. */
  21494. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21495. /** @hidden */
  21496. private _intersectLines;
  21497. /** @hidden */
  21498. private _intersectUnIndexedLines;
  21499. /** @hidden */
  21500. private _intersectTriangles;
  21501. /** @hidden */
  21502. private _intersectUnIndexedTriangles;
  21503. /** @hidden */
  21504. _rebuild(): void;
  21505. /**
  21506. * Creates a new submesh from the passed mesh
  21507. * @param newMesh defines the new hosting mesh
  21508. * @param newRenderingMesh defines an optional rendering mesh
  21509. * @returns the new submesh
  21510. */
  21511. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21512. /**
  21513. * Release associated resources
  21514. */
  21515. dispose(): void;
  21516. /**
  21517. * Gets the class name
  21518. * @returns the string "SubMesh".
  21519. */
  21520. getClassName(): string;
  21521. /**
  21522. * Creates a new submesh from indices data
  21523. * @param materialIndex the index of the main mesh material
  21524. * @param startIndex the index where to start the copy in the mesh indices array
  21525. * @param indexCount the number of indices to copy then from the startIndex
  21526. * @param mesh the main mesh to create the submesh from
  21527. * @param renderingMesh the optional rendering mesh
  21528. * @returns a new submesh
  21529. */
  21530. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21531. }
  21532. }
  21533. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21534. /**
  21535. * Class used to represent data loading progression
  21536. */
  21537. export class SceneLoaderFlags {
  21538. private static _ForceFullSceneLoadingForIncremental;
  21539. private static _ShowLoadingScreen;
  21540. private static _CleanBoneMatrixWeights;
  21541. private static _loggingLevel;
  21542. /**
  21543. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21544. */
  21545. static ForceFullSceneLoadingForIncremental: boolean;
  21546. /**
  21547. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21548. */
  21549. static ShowLoadingScreen: boolean;
  21550. /**
  21551. * Defines the current logging level (while loading the scene)
  21552. * @ignorenaming
  21553. */
  21554. static loggingLevel: number;
  21555. /**
  21556. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21557. */
  21558. static CleanBoneMatrixWeights: boolean;
  21559. }
  21560. }
  21561. declare module "babylonjs/Meshes/geometry" {
  21562. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21563. import { Scene } from "babylonjs/scene";
  21564. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21565. import { Engine } from "babylonjs/Engines/engine";
  21566. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21567. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21568. import { Effect } from "babylonjs/Materials/effect";
  21569. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21570. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21571. import { Mesh } from "babylonjs/Meshes/mesh";
  21572. /**
  21573. * Class used to store geometry data (vertex buffers + index buffer)
  21574. */
  21575. export class Geometry implements IGetSetVerticesData {
  21576. /**
  21577. * Gets or sets the ID of the geometry
  21578. */
  21579. id: string;
  21580. /**
  21581. * Gets or sets the unique ID of the geometry
  21582. */
  21583. uniqueId: number;
  21584. /**
  21585. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21586. */
  21587. delayLoadState: number;
  21588. /**
  21589. * Gets the file containing the data to load when running in delay load state
  21590. */
  21591. delayLoadingFile: Nullable<string>;
  21592. /**
  21593. * Callback called when the geometry is updated
  21594. */
  21595. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21596. private _scene;
  21597. private _engine;
  21598. private _meshes;
  21599. private _totalVertices;
  21600. /** @hidden */
  21601. _indices: IndicesArray;
  21602. /** @hidden */
  21603. _vertexBuffers: {
  21604. [key: string]: VertexBuffer;
  21605. };
  21606. private _isDisposed;
  21607. private _extend;
  21608. private _boundingBias;
  21609. /** @hidden */
  21610. _delayInfo: Array<string>;
  21611. private _indexBuffer;
  21612. private _indexBufferIsUpdatable;
  21613. /** @hidden */
  21614. _boundingInfo: Nullable<BoundingInfo>;
  21615. /** @hidden */
  21616. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21617. /** @hidden */
  21618. _softwareSkinningFrameId: number;
  21619. private _vertexArrayObjects;
  21620. private _updatable;
  21621. /** @hidden */
  21622. _positions: Nullable<Vector3[]>;
  21623. /**
  21624. * 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
  21625. */
  21626. /**
  21627. * 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
  21628. */
  21629. boundingBias: Vector2;
  21630. /**
  21631. * Static function used to attach a new empty geometry to a mesh
  21632. * @param mesh defines the mesh to attach the geometry to
  21633. * @returns the new Geometry
  21634. */
  21635. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21636. /**
  21637. * Creates a new geometry
  21638. * @param id defines the unique ID
  21639. * @param scene defines the hosting scene
  21640. * @param vertexData defines the VertexData used to get geometry data
  21641. * @param updatable defines if geometry must be updatable (false by default)
  21642. * @param mesh defines the mesh that will be associated with the geometry
  21643. */
  21644. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21645. /**
  21646. * Gets the current extend of the geometry
  21647. */
  21648. readonly extend: {
  21649. minimum: Vector3;
  21650. maximum: Vector3;
  21651. };
  21652. /**
  21653. * Gets the hosting scene
  21654. * @returns the hosting Scene
  21655. */
  21656. getScene(): Scene;
  21657. /**
  21658. * Gets the hosting engine
  21659. * @returns the hosting Engine
  21660. */
  21661. getEngine(): Engine;
  21662. /**
  21663. * Defines if the geometry is ready to use
  21664. * @returns true if the geometry is ready to be used
  21665. */
  21666. isReady(): boolean;
  21667. /**
  21668. * Gets a value indicating that the geometry should not be serialized
  21669. */
  21670. readonly doNotSerialize: boolean;
  21671. /** @hidden */
  21672. _rebuild(): void;
  21673. /**
  21674. * Affects all geometry data in one call
  21675. * @param vertexData defines the geometry data
  21676. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21677. */
  21678. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21679. /**
  21680. * Set specific vertex data
  21681. * @param kind defines the data kind (Position, normal, etc...)
  21682. * @param data defines the vertex data to use
  21683. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21684. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21685. */
  21686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21687. /**
  21688. * Removes a specific vertex data
  21689. * @param kind defines the data kind (Position, normal, etc...)
  21690. */
  21691. removeVerticesData(kind: string): void;
  21692. /**
  21693. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21694. * @param buffer defines the vertex buffer to use
  21695. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21696. */
  21697. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21698. /**
  21699. * Update a specific vertex buffer
  21700. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21701. * It will do nothing if the buffer is not updatable
  21702. * @param kind defines the data kind (Position, normal, etc...)
  21703. * @param data defines the data to use
  21704. * @param offset defines the offset in the target buffer where to store the data
  21705. * @param useBytes set to true if the offset is in bytes
  21706. */
  21707. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21708. /**
  21709. * Update a specific vertex buffer
  21710. * This function will create a new buffer if the current one is not updatable
  21711. * @param kind defines the data kind (Position, normal, etc...)
  21712. * @param data defines the data to use
  21713. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21714. */
  21715. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21716. private _updateBoundingInfo;
  21717. /** @hidden */
  21718. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21719. /**
  21720. * Gets total number of vertices
  21721. * @returns the total number of vertices
  21722. */
  21723. getTotalVertices(): number;
  21724. /**
  21725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21726. * @param kind defines the data kind (Position, normal, etc...)
  21727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21729. * @returns a float array containing vertex data
  21730. */
  21731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21732. /**
  21733. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21734. * @param kind defines the data kind (Position, normal, etc...)
  21735. * @returns true if the vertex buffer with the specified kind is updatable
  21736. */
  21737. isVertexBufferUpdatable(kind: string): boolean;
  21738. /**
  21739. * Gets a specific vertex buffer
  21740. * @param kind defines the data kind (Position, normal, etc...)
  21741. * @returns a VertexBuffer
  21742. */
  21743. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21744. /**
  21745. * Returns all vertex buffers
  21746. * @return an object holding all vertex buffers indexed by kind
  21747. */
  21748. getVertexBuffers(): Nullable<{
  21749. [key: string]: VertexBuffer;
  21750. }>;
  21751. /**
  21752. * Gets a boolean indicating if specific vertex buffer is present
  21753. * @param kind defines the data kind (Position, normal, etc...)
  21754. * @returns true if data is present
  21755. */
  21756. isVerticesDataPresent(kind: string): boolean;
  21757. /**
  21758. * Gets a list of all attached data kinds (Position, normal, etc...)
  21759. * @returns a list of string containing all kinds
  21760. */
  21761. getVerticesDataKinds(): string[];
  21762. /**
  21763. * Update index buffer
  21764. * @param indices defines the indices to store in the index buffer
  21765. * @param offset defines the offset in the target buffer where to store the data
  21766. * @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)
  21767. */
  21768. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21769. /**
  21770. * Creates a new index buffer
  21771. * @param indices defines the indices to store in the index buffer
  21772. * @param totalVertices defines the total number of vertices (could be null)
  21773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21774. */
  21775. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21776. /**
  21777. * Return the total number of indices
  21778. * @returns the total number of indices
  21779. */
  21780. getTotalIndices(): number;
  21781. /**
  21782. * Gets the index buffer array
  21783. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21784. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21785. * @returns the index buffer array
  21786. */
  21787. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21788. /**
  21789. * Gets the index buffer
  21790. * @return the index buffer
  21791. */
  21792. getIndexBuffer(): Nullable<DataBuffer>;
  21793. /** @hidden */
  21794. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21795. /**
  21796. * Release the associated resources for a specific mesh
  21797. * @param mesh defines the source mesh
  21798. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21799. */
  21800. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21801. /**
  21802. * Apply current geometry to a given mesh
  21803. * @param mesh defines the mesh to apply geometry to
  21804. */
  21805. applyToMesh(mesh: Mesh): void;
  21806. private _updateExtend;
  21807. private _applyToMesh;
  21808. private notifyUpdate;
  21809. /**
  21810. * Load the geometry if it was flagged as delay loaded
  21811. * @param scene defines the hosting scene
  21812. * @param onLoaded defines a callback called when the geometry is loaded
  21813. */
  21814. load(scene: Scene, onLoaded?: () => void): void;
  21815. private _queueLoad;
  21816. /**
  21817. * Invert the geometry to move from a right handed system to a left handed one.
  21818. */
  21819. toLeftHanded(): void;
  21820. /** @hidden */
  21821. _resetPointsArrayCache(): void;
  21822. /** @hidden */
  21823. _generatePointsArray(): boolean;
  21824. /**
  21825. * Gets a value indicating if the geometry is disposed
  21826. * @returns true if the geometry was disposed
  21827. */
  21828. isDisposed(): boolean;
  21829. private _disposeVertexArrayObjects;
  21830. /**
  21831. * Free all associated resources
  21832. */
  21833. dispose(): void;
  21834. /**
  21835. * Clone the current geometry into a new geometry
  21836. * @param id defines the unique ID of the new geometry
  21837. * @returns a new geometry object
  21838. */
  21839. copy(id: string): Geometry;
  21840. /**
  21841. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21842. * @return a JSON representation of the current geometry data (without the vertices data)
  21843. */
  21844. serialize(): any;
  21845. private toNumberArray;
  21846. /**
  21847. * Serialize all vertices data into a JSON oject
  21848. * @returns a JSON representation of the current geometry data
  21849. */
  21850. serializeVerticeData(): any;
  21851. /**
  21852. * Extracts a clone of a mesh geometry
  21853. * @param mesh defines the source mesh
  21854. * @param id defines the unique ID of the new geometry object
  21855. * @returns the new geometry object
  21856. */
  21857. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21858. /**
  21859. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21861. * Be aware Math.random() could cause collisions, but:
  21862. * "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"
  21863. * @returns a string containing a new GUID
  21864. */
  21865. static RandomId(): string;
  21866. /** @hidden */
  21867. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21868. private static _CleanMatricesWeights;
  21869. /**
  21870. * Create a new geometry from persisted data (Using .babylon file format)
  21871. * @param parsedVertexData defines the persisted data
  21872. * @param scene defines the hosting scene
  21873. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21874. * @returns the new geometry object
  21875. */
  21876. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21877. }
  21878. }
  21879. declare module "babylonjs/Meshes/mesh.vertexData" {
  21880. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21881. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21882. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21883. import { Geometry } from "babylonjs/Meshes/geometry";
  21884. import { Mesh } from "babylonjs/Meshes/mesh";
  21885. /**
  21886. * Define an interface for all classes that will get and set the data on vertices
  21887. */
  21888. export interface IGetSetVerticesData {
  21889. /**
  21890. * Gets a boolean indicating if specific vertex data is present
  21891. * @param kind defines the vertex data kind to use
  21892. * @returns true is data kind is present
  21893. */
  21894. isVerticesDataPresent(kind: string): boolean;
  21895. /**
  21896. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21897. * @param kind defines the data kind (Position, normal, etc...)
  21898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21899. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21900. * @returns a float array containing vertex data
  21901. */
  21902. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21903. /**
  21904. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21905. * @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.
  21906. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21907. * @returns the indices array or an empty array if the mesh has no geometry
  21908. */
  21909. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21910. /**
  21911. * Set specific vertex data
  21912. * @param kind defines the data kind (Position, normal, etc...)
  21913. * @param data defines the vertex data to use
  21914. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21915. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21916. */
  21917. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21918. /**
  21919. * Update a specific associated vertex buffer
  21920. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21921. * - VertexBuffer.PositionKind
  21922. * - VertexBuffer.UVKind
  21923. * - VertexBuffer.UV2Kind
  21924. * - VertexBuffer.UV3Kind
  21925. * - VertexBuffer.UV4Kind
  21926. * - VertexBuffer.UV5Kind
  21927. * - VertexBuffer.UV6Kind
  21928. * - VertexBuffer.ColorKind
  21929. * - VertexBuffer.MatricesIndicesKind
  21930. * - VertexBuffer.MatricesIndicesExtraKind
  21931. * - VertexBuffer.MatricesWeightsKind
  21932. * - VertexBuffer.MatricesWeightsExtraKind
  21933. * @param data defines the data source
  21934. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21935. * @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)
  21936. */
  21937. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21938. /**
  21939. * Creates a new index buffer
  21940. * @param indices defines the indices to store in the index buffer
  21941. * @param totalVertices defines the total number of vertices (could be null)
  21942. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21943. */
  21944. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21945. }
  21946. /**
  21947. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21948. */
  21949. export class VertexData {
  21950. /**
  21951. * Mesh side orientation : usually the external or front surface
  21952. */
  21953. static readonly FRONTSIDE: number;
  21954. /**
  21955. * Mesh side orientation : usually the internal or back surface
  21956. */
  21957. static readonly BACKSIDE: number;
  21958. /**
  21959. * Mesh side orientation : both internal and external or front and back surfaces
  21960. */
  21961. static readonly DOUBLESIDE: number;
  21962. /**
  21963. * Mesh side orientation : by default, `FRONTSIDE`
  21964. */
  21965. static readonly DEFAULTSIDE: number;
  21966. /**
  21967. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21968. */
  21969. positions: Nullable<FloatArray>;
  21970. /**
  21971. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21972. */
  21973. normals: Nullable<FloatArray>;
  21974. /**
  21975. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21976. */
  21977. tangents: Nullable<FloatArray>;
  21978. /**
  21979. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21980. */
  21981. uvs: Nullable<FloatArray>;
  21982. /**
  21983. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21984. */
  21985. uvs2: Nullable<FloatArray>;
  21986. /**
  21987. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21988. */
  21989. uvs3: Nullable<FloatArray>;
  21990. /**
  21991. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21992. */
  21993. uvs4: Nullable<FloatArray>;
  21994. /**
  21995. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21996. */
  21997. uvs5: Nullable<FloatArray>;
  21998. /**
  21999. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22000. */
  22001. uvs6: Nullable<FloatArray>;
  22002. /**
  22003. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22004. */
  22005. colors: Nullable<FloatArray>;
  22006. /**
  22007. * 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).
  22008. */
  22009. matricesIndices: Nullable<FloatArray>;
  22010. /**
  22011. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22012. */
  22013. matricesWeights: Nullable<FloatArray>;
  22014. /**
  22015. * An array extending the number of possible indices
  22016. */
  22017. matricesIndicesExtra: Nullable<FloatArray>;
  22018. /**
  22019. * An array extending the number of possible weights when the number of indices is extended
  22020. */
  22021. matricesWeightsExtra: Nullable<FloatArray>;
  22022. /**
  22023. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22024. */
  22025. indices: Nullable<IndicesArray>;
  22026. /**
  22027. * Uses the passed data array to set the set the values for the specified kind of data
  22028. * @param data a linear array of floating numbers
  22029. * @param kind the type of data that is being set, eg positions, colors etc
  22030. */
  22031. set(data: FloatArray, kind: string): void;
  22032. /**
  22033. * Associates the vertexData to the passed Mesh.
  22034. * Sets it as updatable or not (default `false`)
  22035. * @param mesh the mesh the vertexData is applied to
  22036. * @param updatable when used and having the value true allows new data to update the vertexData
  22037. * @returns the VertexData
  22038. */
  22039. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22040. /**
  22041. * Associates the vertexData to the passed Geometry.
  22042. * Sets it as updatable or not (default `false`)
  22043. * @param geometry the geometry the vertexData is applied to
  22044. * @param updatable when used and having the value true allows new data to update the vertexData
  22045. * @returns VertexData
  22046. */
  22047. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22048. /**
  22049. * Updates the associated mesh
  22050. * @param mesh the mesh to be updated
  22051. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22052. * @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
  22053. * @returns VertexData
  22054. */
  22055. updateMesh(mesh: Mesh): VertexData;
  22056. /**
  22057. * Updates the associated geometry
  22058. * @param geometry the geometry to be updated
  22059. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22060. * @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
  22061. * @returns VertexData.
  22062. */
  22063. updateGeometry(geometry: Geometry): VertexData;
  22064. private _applyTo;
  22065. private _update;
  22066. /**
  22067. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22068. * @param matrix the transforming matrix
  22069. * @returns the VertexData
  22070. */
  22071. transform(matrix: Matrix): VertexData;
  22072. /**
  22073. * Merges the passed VertexData into the current one
  22074. * @param other the VertexData to be merged into the current one
  22075. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22076. * @returns the modified VertexData
  22077. */
  22078. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22079. private _mergeElement;
  22080. private _validate;
  22081. /**
  22082. * Serializes the VertexData
  22083. * @returns a serialized object
  22084. */
  22085. serialize(): any;
  22086. /**
  22087. * Extracts the vertexData from a mesh
  22088. * @param mesh the mesh from which to extract the VertexData
  22089. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22090. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22091. * @returns the object VertexData associated to the passed mesh
  22092. */
  22093. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22094. /**
  22095. * Extracts the vertexData from the geometry
  22096. * @param geometry the geometry from which to extract the VertexData
  22097. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22098. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22099. * @returns the object VertexData associated to the passed mesh
  22100. */
  22101. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22102. private static _ExtractFrom;
  22103. /**
  22104. * Creates the VertexData for a Ribbon
  22105. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22106. * * pathArray array of paths, each of which an array of successive Vector3
  22107. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22108. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22109. * * 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
  22110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22111. * * 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)
  22112. * * 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)
  22113. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22114. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22115. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22116. * @returns the VertexData of the ribbon
  22117. */
  22118. static CreateRibbon(options: {
  22119. pathArray: Vector3[][];
  22120. closeArray?: boolean;
  22121. closePath?: boolean;
  22122. offset?: number;
  22123. sideOrientation?: number;
  22124. frontUVs?: Vector4;
  22125. backUVs?: Vector4;
  22126. invertUV?: boolean;
  22127. uvs?: Vector2[];
  22128. colors?: Color4[];
  22129. }): VertexData;
  22130. /**
  22131. * Creates the VertexData for a box
  22132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22133. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22134. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22135. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22136. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22137. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22138. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22140. * * 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)
  22141. * * 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)
  22142. * @returns the VertexData of the box
  22143. */
  22144. static CreateBox(options: {
  22145. size?: number;
  22146. width?: number;
  22147. height?: number;
  22148. depth?: number;
  22149. faceUV?: Vector4[];
  22150. faceColors?: Color4[];
  22151. sideOrientation?: number;
  22152. frontUVs?: Vector4;
  22153. backUVs?: Vector4;
  22154. }): VertexData;
  22155. /**
  22156. * Creates the VertexData for a tiled box
  22157. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22158. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22159. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22160. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22162. * @returns the VertexData of the box
  22163. */
  22164. static CreateTiledBox(options: {
  22165. pattern?: number;
  22166. width?: number;
  22167. height?: number;
  22168. depth?: number;
  22169. tileSize?: number;
  22170. tileWidth?: number;
  22171. tileHeight?: number;
  22172. alignHorizontal?: number;
  22173. alignVertical?: number;
  22174. faceUV?: Vector4[];
  22175. faceColors?: Color4[];
  22176. sideOrientation?: number;
  22177. }): VertexData;
  22178. /**
  22179. * Creates the VertexData for a tiled plane
  22180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22181. * * pattern a limited pattern arrangement depending on the number
  22182. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22183. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22184. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22186. * * 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)
  22187. * * 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)
  22188. * @returns the VertexData of the tiled plane
  22189. */
  22190. static CreateTiledPlane(options: {
  22191. pattern?: number;
  22192. tileSize?: number;
  22193. tileWidth?: number;
  22194. tileHeight?: number;
  22195. size?: number;
  22196. width?: number;
  22197. height?: number;
  22198. alignHorizontal?: number;
  22199. alignVertical?: number;
  22200. sideOrientation?: number;
  22201. frontUVs?: Vector4;
  22202. backUVs?: Vector4;
  22203. }): VertexData;
  22204. /**
  22205. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22207. * * segments sets the number of horizontal strips optional, default 32
  22208. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22209. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22210. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22211. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22212. * * 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
  22213. * * 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
  22214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * * 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)
  22216. * * 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)
  22217. * @returns the VertexData of the ellipsoid
  22218. */
  22219. static CreateSphere(options: {
  22220. segments?: number;
  22221. diameter?: number;
  22222. diameterX?: number;
  22223. diameterY?: number;
  22224. diameterZ?: number;
  22225. arc?: number;
  22226. slice?: number;
  22227. sideOrientation?: number;
  22228. frontUVs?: Vector4;
  22229. backUVs?: Vector4;
  22230. }): VertexData;
  22231. /**
  22232. * Creates the VertexData for a cylinder, cone or prism
  22233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22234. * * height sets the height (y direction) of the cylinder, optional, default 2
  22235. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22236. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22237. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22238. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22239. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22240. * * 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
  22241. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22242. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22243. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22244. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22246. * * 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)
  22247. * * 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)
  22248. * @returns the VertexData of the cylinder, cone or prism
  22249. */
  22250. static CreateCylinder(options: {
  22251. height?: number;
  22252. diameterTop?: number;
  22253. diameterBottom?: number;
  22254. diameter?: number;
  22255. tessellation?: number;
  22256. subdivisions?: number;
  22257. arc?: number;
  22258. faceColors?: Color4[];
  22259. faceUV?: Vector4[];
  22260. hasRings?: boolean;
  22261. enclose?: boolean;
  22262. sideOrientation?: number;
  22263. frontUVs?: Vector4;
  22264. backUVs?: Vector4;
  22265. }): VertexData;
  22266. /**
  22267. * Creates the VertexData for a torus
  22268. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22269. * * diameter the diameter of the torus, optional default 1
  22270. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22271. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22273. * * 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)
  22274. * * 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)
  22275. * @returns the VertexData of the torus
  22276. */
  22277. static CreateTorus(options: {
  22278. diameter?: number;
  22279. thickness?: number;
  22280. tessellation?: number;
  22281. sideOrientation?: number;
  22282. frontUVs?: Vector4;
  22283. backUVs?: Vector4;
  22284. }): VertexData;
  22285. /**
  22286. * Creates the VertexData of the LineSystem
  22287. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22288. * - lines an array of lines, each line being an array of successive Vector3
  22289. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22290. * @returns the VertexData of the LineSystem
  22291. */
  22292. static CreateLineSystem(options: {
  22293. lines: Vector3[][];
  22294. colors?: Nullable<Color4[][]>;
  22295. }): VertexData;
  22296. /**
  22297. * Create the VertexData for a DashedLines
  22298. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22299. * - points an array successive Vector3
  22300. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22301. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22302. * - dashNb the intended total number of dashes, optional, default 200
  22303. * @returns the VertexData for the DashedLines
  22304. */
  22305. static CreateDashedLines(options: {
  22306. points: Vector3[];
  22307. dashSize?: number;
  22308. gapSize?: number;
  22309. dashNb?: number;
  22310. }): VertexData;
  22311. /**
  22312. * Creates the VertexData for a Ground
  22313. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22314. * - width the width (x direction) of the ground, optional, default 1
  22315. * - height the height (z direction) of the ground, optional, default 1
  22316. * - subdivisions the number of subdivisions per side, optional, default 1
  22317. * @returns the VertexData of the Ground
  22318. */
  22319. static CreateGround(options: {
  22320. width?: number;
  22321. height?: number;
  22322. subdivisions?: number;
  22323. subdivisionsX?: number;
  22324. subdivisionsY?: number;
  22325. }): VertexData;
  22326. /**
  22327. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22328. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22329. * * xmin the ground minimum X coordinate, optional, default -1
  22330. * * zmin the ground minimum Z coordinate, optional, default -1
  22331. * * xmax the ground maximum X coordinate, optional, default 1
  22332. * * zmax the ground maximum Z coordinate, optional, default 1
  22333. * * 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}
  22334. * * 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}
  22335. * @returns the VertexData of the TiledGround
  22336. */
  22337. static CreateTiledGround(options: {
  22338. xmin: number;
  22339. zmin: number;
  22340. xmax: number;
  22341. zmax: number;
  22342. subdivisions?: {
  22343. w: number;
  22344. h: number;
  22345. };
  22346. precision?: {
  22347. w: number;
  22348. h: number;
  22349. };
  22350. }): VertexData;
  22351. /**
  22352. * Creates the VertexData of the Ground designed from a heightmap
  22353. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22354. * * width the width (x direction) of the ground
  22355. * * height the height (z direction) of the ground
  22356. * * subdivisions the number of subdivisions per side
  22357. * * minHeight the minimum altitude on the ground, optional, default 0
  22358. * * maxHeight the maximum altitude on the ground, optional default 1
  22359. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22360. * * buffer the array holding the image color data
  22361. * * bufferWidth the width of image
  22362. * * bufferHeight the height of image
  22363. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22364. * @returns the VertexData of the Ground designed from a heightmap
  22365. */
  22366. static CreateGroundFromHeightMap(options: {
  22367. width: number;
  22368. height: number;
  22369. subdivisions: number;
  22370. minHeight: number;
  22371. maxHeight: number;
  22372. colorFilter: Color3;
  22373. buffer: Uint8Array;
  22374. bufferWidth: number;
  22375. bufferHeight: number;
  22376. alphaFilter: number;
  22377. }): VertexData;
  22378. /**
  22379. * Creates the VertexData for a Plane
  22380. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22381. * * size sets the width and height of the plane to the value of size, optional default 1
  22382. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22383. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22385. * * 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)
  22386. * * 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)
  22387. * @returns the VertexData of the box
  22388. */
  22389. static CreatePlane(options: {
  22390. size?: number;
  22391. width?: number;
  22392. height?: number;
  22393. sideOrientation?: number;
  22394. frontUVs?: Vector4;
  22395. backUVs?: Vector4;
  22396. }): VertexData;
  22397. /**
  22398. * Creates the VertexData of the Disc or regular Polygon
  22399. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22400. * * radius the radius of the disc, optional default 0.5
  22401. * * tessellation the number of polygon sides, optional, default 64
  22402. * * 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
  22403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22404. * * 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)
  22405. * * 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)
  22406. * @returns the VertexData of the box
  22407. */
  22408. static CreateDisc(options: {
  22409. radius?: number;
  22410. tessellation?: number;
  22411. arc?: number;
  22412. sideOrientation?: number;
  22413. frontUVs?: Vector4;
  22414. backUVs?: Vector4;
  22415. }): VertexData;
  22416. /**
  22417. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22418. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22419. * @param polygon a mesh built from polygonTriangulation.build()
  22420. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22422. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22423. * @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)
  22424. * @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)
  22425. * @returns the VertexData of the Polygon
  22426. */
  22427. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22428. /**
  22429. * Creates the VertexData of the IcoSphere
  22430. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22431. * * radius the radius of the IcoSphere, optional default 1
  22432. * * radiusX allows stretching in the x direction, optional, default radius
  22433. * * radiusY allows stretching in the y direction, optional, default radius
  22434. * * radiusZ allows stretching in the z direction, optional, default radius
  22435. * * flat when true creates a flat shaded mesh, optional, default true
  22436. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22438. * * 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)
  22439. * * 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)
  22440. * @returns the VertexData of the IcoSphere
  22441. */
  22442. static CreateIcoSphere(options: {
  22443. radius?: number;
  22444. radiusX?: number;
  22445. radiusY?: number;
  22446. radiusZ?: number;
  22447. flat?: boolean;
  22448. subdivisions?: number;
  22449. sideOrientation?: number;
  22450. frontUVs?: Vector4;
  22451. backUVs?: Vector4;
  22452. }): VertexData;
  22453. /**
  22454. * Creates the VertexData for a Polyhedron
  22455. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22456. * * type provided types are:
  22457. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22458. * * 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)
  22459. * * size the size of the IcoSphere, optional default 1
  22460. * * sizeX allows stretching in the x direction, optional, default size
  22461. * * sizeY allows stretching in the y direction, optional, default size
  22462. * * sizeZ allows stretching in the z direction, optional, default size
  22463. * * 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
  22464. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22465. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22466. * * flat when true creates a flat shaded mesh, optional, default true
  22467. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22469. * * 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)
  22470. * * 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)
  22471. * @returns the VertexData of the Polyhedron
  22472. */
  22473. static CreatePolyhedron(options: {
  22474. type?: number;
  22475. size?: number;
  22476. sizeX?: number;
  22477. sizeY?: number;
  22478. sizeZ?: number;
  22479. custom?: any;
  22480. faceUV?: Vector4[];
  22481. faceColors?: Color4[];
  22482. flat?: boolean;
  22483. sideOrientation?: number;
  22484. frontUVs?: Vector4;
  22485. backUVs?: Vector4;
  22486. }): VertexData;
  22487. /**
  22488. * Creates the VertexData for a TorusKnot
  22489. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22490. * * radius the radius of the torus knot, optional, default 2
  22491. * * tube the thickness of the tube, optional, default 0.5
  22492. * * radialSegments the number of sides on each tube segments, optional, default 32
  22493. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22494. * * p the number of windings around the z axis, optional, default 2
  22495. * * q the number of windings around the x axis, optional, default 3
  22496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22497. * * 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)
  22498. * * 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)
  22499. * @returns the VertexData of the Torus Knot
  22500. */
  22501. static CreateTorusKnot(options: {
  22502. radius?: number;
  22503. tube?: number;
  22504. radialSegments?: number;
  22505. tubularSegments?: number;
  22506. p?: number;
  22507. q?: number;
  22508. sideOrientation?: number;
  22509. frontUVs?: Vector4;
  22510. backUVs?: Vector4;
  22511. }): VertexData;
  22512. /**
  22513. * Compute normals for given positions and indices
  22514. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22515. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22516. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22517. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22518. * * facetNormals : optional array of facet normals (vector3)
  22519. * * facetPositions : optional array of facet positions (vector3)
  22520. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22521. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22522. * * bInfo : optional bounding info, required for facetPartitioning computation
  22523. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22524. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22525. * * useRightHandedSystem: optional boolean to for right handed system computation
  22526. * * depthSort : optional boolean to enable the facet depth sort computation
  22527. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22528. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22529. */
  22530. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22531. facetNormals?: any;
  22532. facetPositions?: any;
  22533. facetPartitioning?: any;
  22534. ratio?: number;
  22535. bInfo?: any;
  22536. bbSize?: Vector3;
  22537. subDiv?: any;
  22538. useRightHandedSystem?: boolean;
  22539. depthSort?: boolean;
  22540. distanceTo?: Vector3;
  22541. depthSortedFacets?: any;
  22542. }): void;
  22543. /** @hidden */
  22544. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22545. /**
  22546. * Applies VertexData created from the imported parameters to the geometry
  22547. * @param parsedVertexData the parsed data from an imported file
  22548. * @param geometry the geometry to apply the VertexData to
  22549. */
  22550. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22551. }
  22552. }
  22553. declare module "babylonjs/Morph/morphTarget" {
  22554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22555. import { Observable } from "babylonjs/Misc/observable";
  22556. import { Nullable, FloatArray } from "babylonjs/types";
  22557. import { Scene } from "babylonjs/scene";
  22558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22559. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22560. /**
  22561. * Defines a target to use with MorphTargetManager
  22562. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22563. */
  22564. export class MorphTarget implements IAnimatable {
  22565. /** defines the name of the target */
  22566. name: string;
  22567. /**
  22568. * Gets or sets the list of animations
  22569. */
  22570. animations: import("babylonjs/Animations/animation").Animation[];
  22571. private _scene;
  22572. private _positions;
  22573. private _normals;
  22574. private _tangents;
  22575. private _uvs;
  22576. private _influence;
  22577. /**
  22578. * Observable raised when the influence changes
  22579. */
  22580. onInfluenceChanged: Observable<boolean>;
  22581. /** @hidden */
  22582. _onDataLayoutChanged: Observable<void>;
  22583. /**
  22584. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22585. */
  22586. influence: number;
  22587. /**
  22588. * Gets or sets the id of the morph Target
  22589. */
  22590. id: string;
  22591. private _animationPropertiesOverride;
  22592. /**
  22593. * Gets or sets the animation properties override
  22594. */
  22595. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22596. /**
  22597. * Creates a new MorphTarget
  22598. * @param name defines the name of the target
  22599. * @param influence defines the influence to use
  22600. * @param scene defines the scene the morphtarget belongs to
  22601. */
  22602. constructor(
  22603. /** defines the name of the target */
  22604. name: string, influence?: number, scene?: Nullable<Scene>);
  22605. /**
  22606. * Gets a boolean defining if the target contains position data
  22607. */
  22608. readonly hasPositions: boolean;
  22609. /**
  22610. * Gets a boolean defining if the target contains normal data
  22611. */
  22612. readonly hasNormals: boolean;
  22613. /**
  22614. * Gets a boolean defining if the target contains tangent data
  22615. */
  22616. readonly hasTangents: boolean;
  22617. /**
  22618. * Gets a boolean defining if the target contains texture coordinates data
  22619. */
  22620. readonly hasUVs: boolean;
  22621. /**
  22622. * Affects position data to this target
  22623. * @param data defines the position data to use
  22624. */
  22625. setPositions(data: Nullable<FloatArray>): void;
  22626. /**
  22627. * Gets the position data stored in this target
  22628. * @returns a FloatArray containing the position data (or null if not present)
  22629. */
  22630. getPositions(): Nullable<FloatArray>;
  22631. /**
  22632. * Affects normal data to this target
  22633. * @param data defines the normal data to use
  22634. */
  22635. setNormals(data: Nullable<FloatArray>): void;
  22636. /**
  22637. * Gets the normal data stored in this target
  22638. * @returns a FloatArray containing the normal data (or null if not present)
  22639. */
  22640. getNormals(): Nullable<FloatArray>;
  22641. /**
  22642. * Affects tangent data to this target
  22643. * @param data defines the tangent data to use
  22644. */
  22645. setTangents(data: Nullable<FloatArray>): void;
  22646. /**
  22647. * Gets the tangent data stored in this target
  22648. * @returns a FloatArray containing the tangent data (or null if not present)
  22649. */
  22650. getTangents(): Nullable<FloatArray>;
  22651. /**
  22652. * Affects texture coordinates data to this target
  22653. * @param data defines the texture coordinates data to use
  22654. */
  22655. setUVs(data: Nullable<FloatArray>): void;
  22656. /**
  22657. * Gets the texture coordinates data stored in this target
  22658. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22659. */
  22660. getUVs(): Nullable<FloatArray>;
  22661. /**
  22662. * Serializes the current target into a Serialization object
  22663. * @returns the serialized object
  22664. */
  22665. serialize(): any;
  22666. /**
  22667. * Returns the string "MorphTarget"
  22668. * @returns "MorphTarget"
  22669. */
  22670. getClassName(): string;
  22671. /**
  22672. * Creates a new target from serialized data
  22673. * @param serializationObject defines the serialized data to use
  22674. * @returns a new MorphTarget
  22675. */
  22676. static Parse(serializationObject: any): MorphTarget;
  22677. /**
  22678. * Creates a MorphTarget from mesh data
  22679. * @param mesh defines the source mesh
  22680. * @param name defines the name to use for the new target
  22681. * @param influence defines the influence to attach to the target
  22682. * @returns a new MorphTarget
  22683. */
  22684. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22685. }
  22686. }
  22687. declare module "babylonjs/Morph/morphTargetManager" {
  22688. import { Nullable } from "babylonjs/types";
  22689. import { Scene } from "babylonjs/scene";
  22690. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22691. /**
  22692. * This class is used to deform meshes using morphing between different targets
  22693. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22694. */
  22695. export class MorphTargetManager {
  22696. private _targets;
  22697. private _targetInfluenceChangedObservers;
  22698. private _targetDataLayoutChangedObservers;
  22699. private _activeTargets;
  22700. private _scene;
  22701. private _influences;
  22702. private _supportsNormals;
  22703. private _supportsTangents;
  22704. private _supportsUVs;
  22705. private _vertexCount;
  22706. private _uniqueId;
  22707. private _tempInfluences;
  22708. /**
  22709. * Gets or sets a boolean indicating if normals must be morphed
  22710. */
  22711. enableNormalMorphing: boolean;
  22712. /**
  22713. * Gets or sets a boolean indicating if tangents must be morphed
  22714. */
  22715. enableTangentMorphing: boolean;
  22716. /**
  22717. * Gets or sets a boolean indicating if UV must be morphed
  22718. */
  22719. enableUVMorphing: boolean;
  22720. /**
  22721. * Creates a new MorphTargetManager
  22722. * @param scene defines the current scene
  22723. */
  22724. constructor(scene?: Nullable<Scene>);
  22725. /**
  22726. * Gets the unique ID of this manager
  22727. */
  22728. readonly uniqueId: number;
  22729. /**
  22730. * Gets the number of vertices handled by this manager
  22731. */
  22732. readonly vertexCount: number;
  22733. /**
  22734. * Gets a boolean indicating if this manager supports morphing of normals
  22735. */
  22736. readonly supportsNormals: boolean;
  22737. /**
  22738. * Gets a boolean indicating if this manager supports morphing of tangents
  22739. */
  22740. readonly supportsTangents: boolean;
  22741. /**
  22742. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22743. */
  22744. readonly supportsUVs: boolean;
  22745. /**
  22746. * Gets the number of targets stored in this manager
  22747. */
  22748. readonly numTargets: number;
  22749. /**
  22750. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22751. */
  22752. readonly numInfluencers: number;
  22753. /**
  22754. * Gets the list of influences (one per target)
  22755. */
  22756. readonly influences: Float32Array;
  22757. /**
  22758. * Gets the active target at specified index. An active target is a target with an influence > 0
  22759. * @param index defines the index to check
  22760. * @returns the requested target
  22761. */
  22762. getActiveTarget(index: number): MorphTarget;
  22763. /**
  22764. * Gets the target at specified index
  22765. * @param index defines the index to check
  22766. * @returns the requested target
  22767. */
  22768. getTarget(index: number): MorphTarget;
  22769. /**
  22770. * Add a new target to this manager
  22771. * @param target defines the target to add
  22772. */
  22773. addTarget(target: MorphTarget): void;
  22774. /**
  22775. * Removes a target from the manager
  22776. * @param target defines the target to remove
  22777. */
  22778. removeTarget(target: MorphTarget): void;
  22779. /**
  22780. * Serializes the current manager into a Serialization object
  22781. * @returns the serialized object
  22782. */
  22783. serialize(): any;
  22784. private _syncActiveTargets;
  22785. /**
  22786. * Syncrhonize the targets with all the meshes using this morph target manager
  22787. */
  22788. synchronize(): void;
  22789. /**
  22790. * Creates a new MorphTargetManager from serialized data
  22791. * @param serializationObject defines the serialized data
  22792. * @param scene defines the hosting scene
  22793. * @returns the new MorphTargetManager
  22794. */
  22795. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22796. }
  22797. }
  22798. declare module "babylonjs/Meshes/meshLODLevel" {
  22799. import { Mesh } from "babylonjs/Meshes/mesh";
  22800. import { Nullable } from "babylonjs/types";
  22801. /**
  22802. * Class used to represent a specific level of detail of a mesh
  22803. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22804. */
  22805. export class MeshLODLevel {
  22806. /** Defines the distance where this level should start being displayed */
  22807. distance: number;
  22808. /** Defines the mesh to use to render this level */
  22809. mesh: Nullable<Mesh>;
  22810. /**
  22811. * Creates a new LOD level
  22812. * @param distance defines the distance where this level should star being displayed
  22813. * @param mesh defines the mesh to use to render this level
  22814. */
  22815. constructor(
  22816. /** Defines the distance where this level should start being displayed */
  22817. distance: number,
  22818. /** Defines the mesh to use to render this level */
  22819. mesh: Nullable<Mesh>);
  22820. }
  22821. }
  22822. declare module "babylonjs/Meshes/groundMesh" {
  22823. import { Scene } from "babylonjs/scene";
  22824. import { Vector3 } from "babylonjs/Maths/math.vector";
  22825. import { Mesh } from "babylonjs/Meshes/mesh";
  22826. /**
  22827. * Mesh representing the gorund
  22828. */
  22829. export class GroundMesh extends Mesh {
  22830. /** If octree should be generated */
  22831. generateOctree: boolean;
  22832. private _heightQuads;
  22833. /** @hidden */
  22834. _subdivisionsX: number;
  22835. /** @hidden */
  22836. _subdivisionsY: number;
  22837. /** @hidden */
  22838. _width: number;
  22839. /** @hidden */
  22840. _height: number;
  22841. /** @hidden */
  22842. _minX: number;
  22843. /** @hidden */
  22844. _maxX: number;
  22845. /** @hidden */
  22846. _minZ: number;
  22847. /** @hidden */
  22848. _maxZ: number;
  22849. constructor(name: string, scene: Scene);
  22850. /**
  22851. * "GroundMesh"
  22852. * @returns "GroundMesh"
  22853. */
  22854. getClassName(): string;
  22855. /**
  22856. * The minimum of x and y subdivisions
  22857. */
  22858. readonly subdivisions: number;
  22859. /**
  22860. * X subdivisions
  22861. */
  22862. readonly subdivisionsX: number;
  22863. /**
  22864. * Y subdivisions
  22865. */
  22866. readonly subdivisionsY: number;
  22867. /**
  22868. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22869. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22870. * @param chunksCount the number of subdivisions for x and y
  22871. * @param octreeBlocksSize (Default: 32)
  22872. */
  22873. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22874. /**
  22875. * Returns a height (y) value in the Worl system :
  22876. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22877. * @param x x coordinate
  22878. * @param z z coordinate
  22879. * @returns the ground y position if (x, z) are outside the ground surface.
  22880. */
  22881. getHeightAtCoordinates(x: number, z: number): number;
  22882. /**
  22883. * Returns a normalized vector (Vector3) orthogonal to the ground
  22884. * at the ground coordinates (x, z) expressed in the World system.
  22885. * @param x x coordinate
  22886. * @param z z coordinate
  22887. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22888. */
  22889. getNormalAtCoordinates(x: number, z: number): Vector3;
  22890. /**
  22891. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22892. * at the ground coordinates (x, z) expressed in the World system.
  22893. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22894. * @param x x coordinate
  22895. * @param z z coordinate
  22896. * @param ref vector to store the result
  22897. * @returns the GroundMesh.
  22898. */
  22899. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22900. /**
  22901. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22902. * if the ground has been updated.
  22903. * This can be used in the render loop.
  22904. * @returns the GroundMesh.
  22905. */
  22906. updateCoordinateHeights(): GroundMesh;
  22907. private _getFacetAt;
  22908. private _initHeightQuads;
  22909. private _computeHeightQuads;
  22910. /**
  22911. * Serializes this ground mesh
  22912. * @param serializationObject object to write serialization to
  22913. */
  22914. serialize(serializationObject: any): void;
  22915. /**
  22916. * Parses a serialized ground mesh
  22917. * @param parsedMesh the serialized mesh
  22918. * @param scene the scene to create the ground mesh in
  22919. * @returns the created ground mesh
  22920. */
  22921. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22922. }
  22923. }
  22924. declare module "babylonjs/Physics/physicsJoint" {
  22925. import { Vector3 } from "babylonjs/Maths/math.vector";
  22926. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22927. /**
  22928. * Interface for Physics-Joint data
  22929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22930. */
  22931. export interface PhysicsJointData {
  22932. /**
  22933. * The main pivot of the joint
  22934. */
  22935. mainPivot?: Vector3;
  22936. /**
  22937. * The connected pivot of the joint
  22938. */
  22939. connectedPivot?: Vector3;
  22940. /**
  22941. * The main axis of the joint
  22942. */
  22943. mainAxis?: Vector3;
  22944. /**
  22945. * The connected axis of the joint
  22946. */
  22947. connectedAxis?: Vector3;
  22948. /**
  22949. * The collision of the joint
  22950. */
  22951. collision?: boolean;
  22952. /**
  22953. * Native Oimo/Cannon/Energy data
  22954. */
  22955. nativeParams?: any;
  22956. }
  22957. /**
  22958. * This is a holder class for the physics joint created by the physics plugin
  22959. * It holds a set of functions to control the underlying joint
  22960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22961. */
  22962. export class PhysicsJoint {
  22963. /**
  22964. * The type of the physics joint
  22965. */
  22966. type: number;
  22967. /**
  22968. * The data for the physics joint
  22969. */
  22970. jointData: PhysicsJointData;
  22971. private _physicsJoint;
  22972. protected _physicsPlugin: IPhysicsEnginePlugin;
  22973. /**
  22974. * Initializes the physics joint
  22975. * @param type The type of the physics joint
  22976. * @param jointData The data for the physics joint
  22977. */
  22978. constructor(
  22979. /**
  22980. * The type of the physics joint
  22981. */
  22982. type: number,
  22983. /**
  22984. * The data for the physics joint
  22985. */
  22986. jointData: PhysicsJointData);
  22987. /**
  22988. * Gets the physics joint
  22989. */
  22990. /**
  22991. * Sets the physics joint
  22992. */
  22993. physicsJoint: any;
  22994. /**
  22995. * Sets the physics plugin
  22996. */
  22997. physicsPlugin: IPhysicsEnginePlugin;
  22998. /**
  22999. * Execute a function that is physics-plugin specific.
  23000. * @param {Function} func the function that will be executed.
  23001. * It accepts two parameters: the physics world and the physics joint
  23002. */
  23003. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23004. /**
  23005. * Distance-Joint type
  23006. */
  23007. static DistanceJoint: number;
  23008. /**
  23009. * Hinge-Joint type
  23010. */
  23011. static HingeJoint: number;
  23012. /**
  23013. * Ball-and-Socket joint type
  23014. */
  23015. static BallAndSocketJoint: number;
  23016. /**
  23017. * Wheel-Joint type
  23018. */
  23019. static WheelJoint: number;
  23020. /**
  23021. * Slider-Joint type
  23022. */
  23023. static SliderJoint: number;
  23024. /**
  23025. * Prismatic-Joint type
  23026. */
  23027. static PrismaticJoint: number;
  23028. /**
  23029. * Universal-Joint type
  23030. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23031. */
  23032. static UniversalJoint: number;
  23033. /**
  23034. * Hinge-Joint 2 type
  23035. */
  23036. static Hinge2Joint: number;
  23037. /**
  23038. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23039. */
  23040. static PointToPointJoint: number;
  23041. /**
  23042. * Spring-Joint type
  23043. */
  23044. static SpringJoint: number;
  23045. /**
  23046. * Lock-Joint type
  23047. */
  23048. static LockJoint: number;
  23049. }
  23050. /**
  23051. * A class representing a physics distance joint
  23052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23053. */
  23054. export class DistanceJoint extends PhysicsJoint {
  23055. /**
  23056. *
  23057. * @param jointData The data for the Distance-Joint
  23058. */
  23059. constructor(jointData: DistanceJointData);
  23060. /**
  23061. * Update the predefined distance.
  23062. * @param maxDistance The maximum preferred distance
  23063. * @param minDistance The minimum preferred distance
  23064. */
  23065. updateDistance(maxDistance: number, minDistance?: number): void;
  23066. }
  23067. /**
  23068. * Represents a Motor-Enabled Joint
  23069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23070. */
  23071. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23072. /**
  23073. * Initializes the Motor-Enabled Joint
  23074. * @param type The type of the joint
  23075. * @param jointData The physica joint data for the joint
  23076. */
  23077. constructor(type: number, jointData: PhysicsJointData);
  23078. /**
  23079. * Set the motor values.
  23080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23081. * @param force the force to apply
  23082. * @param maxForce max force for this motor.
  23083. */
  23084. setMotor(force?: number, maxForce?: number): void;
  23085. /**
  23086. * Set the motor's limits.
  23087. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23088. * @param upperLimit The upper limit of the motor
  23089. * @param lowerLimit The lower limit of the motor
  23090. */
  23091. setLimit(upperLimit: number, lowerLimit?: number): void;
  23092. }
  23093. /**
  23094. * This class represents a single physics Hinge-Joint
  23095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23096. */
  23097. export class HingeJoint extends MotorEnabledJoint {
  23098. /**
  23099. * Initializes the Hinge-Joint
  23100. * @param jointData The joint data for the Hinge-Joint
  23101. */
  23102. constructor(jointData: PhysicsJointData);
  23103. /**
  23104. * Set the motor values.
  23105. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23106. * @param {number} force the force to apply
  23107. * @param {number} maxForce max force for this motor.
  23108. */
  23109. setMotor(force?: number, maxForce?: number): void;
  23110. /**
  23111. * Set the motor's limits.
  23112. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23113. * @param upperLimit The upper limit of the motor
  23114. * @param lowerLimit The lower limit of the motor
  23115. */
  23116. setLimit(upperLimit: number, lowerLimit?: number): void;
  23117. }
  23118. /**
  23119. * This class represents a dual hinge physics joint (same as wheel joint)
  23120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23121. */
  23122. export class Hinge2Joint extends MotorEnabledJoint {
  23123. /**
  23124. * Initializes the Hinge2-Joint
  23125. * @param jointData The joint data for the Hinge2-Joint
  23126. */
  23127. constructor(jointData: PhysicsJointData);
  23128. /**
  23129. * Set the motor values.
  23130. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23131. * @param {number} targetSpeed the speed the motor is to reach
  23132. * @param {number} maxForce max force for this motor.
  23133. * @param {motorIndex} the motor's index, 0 or 1.
  23134. */
  23135. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23136. /**
  23137. * Set the motor limits.
  23138. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23139. * @param {number} upperLimit the upper limit
  23140. * @param {number} lowerLimit lower limit
  23141. * @param {motorIndex} the motor's index, 0 or 1.
  23142. */
  23143. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23144. }
  23145. /**
  23146. * Interface for a motor enabled joint
  23147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23148. */
  23149. export interface IMotorEnabledJoint {
  23150. /**
  23151. * Physics joint
  23152. */
  23153. physicsJoint: any;
  23154. /**
  23155. * Sets the motor of the motor-enabled joint
  23156. * @param force The force of the motor
  23157. * @param maxForce The maximum force of the motor
  23158. * @param motorIndex The index of the motor
  23159. */
  23160. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23161. /**
  23162. * Sets the limit of the motor
  23163. * @param upperLimit The upper limit of the motor
  23164. * @param lowerLimit The lower limit of the motor
  23165. * @param motorIndex The index of the motor
  23166. */
  23167. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23168. }
  23169. /**
  23170. * Joint data for a Distance-Joint
  23171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23172. */
  23173. export interface DistanceJointData extends PhysicsJointData {
  23174. /**
  23175. * Max distance the 2 joint objects can be apart
  23176. */
  23177. maxDistance: number;
  23178. }
  23179. /**
  23180. * Joint data from a spring joint
  23181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23182. */
  23183. export interface SpringJointData extends PhysicsJointData {
  23184. /**
  23185. * Length of the spring
  23186. */
  23187. length: number;
  23188. /**
  23189. * Stiffness of the spring
  23190. */
  23191. stiffness: number;
  23192. /**
  23193. * Damping of the spring
  23194. */
  23195. damping: number;
  23196. /** this callback will be called when applying the force to the impostors. */
  23197. forceApplicationCallback: () => void;
  23198. }
  23199. }
  23200. declare module "babylonjs/Physics/physicsRaycastResult" {
  23201. import { Vector3 } from "babylonjs/Maths/math.vector";
  23202. /**
  23203. * Holds the data for the raycast result
  23204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23205. */
  23206. export class PhysicsRaycastResult {
  23207. private _hasHit;
  23208. private _hitDistance;
  23209. private _hitNormalWorld;
  23210. private _hitPointWorld;
  23211. private _rayFromWorld;
  23212. private _rayToWorld;
  23213. /**
  23214. * Gets if there was a hit
  23215. */
  23216. readonly hasHit: boolean;
  23217. /**
  23218. * Gets the distance from the hit
  23219. */
  23220. readonly hitDistance: number;
  23221. /**
  23222. * Gets the hit normal/direction in the world
  23223. */
  23224. readonly hitNormalWorld: Vector3;
  23225. /**
  23226. * Gets the hit point in the world
  23227. */
  23228. readonly hitPointWorld: Vector3;
  23229. /**
  23230. * Gets the ray "start point" of the ray in the world
  23231. */
  23232. readonly rayFromWorld: Vector3;
  23233. /**
  23234. * Gets the ray "end point" of the ray in the world
  23235. */
  23236. readonly rayToWorld: Vector3;
  23237. /**
  23238. * Sets the hit data (normal & point in world space)
  23239. * @param hitNormalWorld defines the normal in world space
  23240. * @param hitPointWorld defines the point in world space
  23241. */
  23242. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23243. /**
  23244. * Sets the distance from the start point to the hit point
  23245. * @param distance
  23246. */
  23247. setHitDistance(distance: number): void;
  23248. /**
  23249. * Calculates the distance manually
  23250. */
  23251. calculateHitDistance(): void;
  23252. /**
  23253. * Resets all the values to default
  23254. * @param from The from point on world space
  23255. * @param to The to point on world space
  23256. */
  23257. reset(from?: Vector3, to?: Vector3): void;
  23258. }
  23259. /**
  23260. * Interface for the size containing width and height
  23261. */
  23262. interface IXYZ {
  23263. /**
  23264. * X
  23265. */
  23266. x: number;
  23267. /**
  23268. * Y
  23269. */
  23270. y: number;
  23271. /**
  23272. * Z
  23273. */
  23274. z: number;
  23275. }
  23276. }
  23277. declare module "babylonjs/Physics/IPhysicsEngine" {
  23278. import { Nullable } from "babylonjs/types";
  23279. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23281. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23282. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23283. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23284. /**
  23285. * Interface used to describe a physics joint
  23286. */
  23287. export interface PhysicsImpostorJoint {
  23288. /** Defines the main impostor to which the joint is linked */
  23289. mainImpostor: PhysicsImpostor;
  23290. /** Defines the impostor that is connected to the main impostor using this joint */
  23291. connectedImpostor: PhysicsImpostor;
  23292. /** Defines the joint itself */
  23293. joint: PhysicsJoint;
  23294. }
  23295. /** @hidden */
  23296. export interface IPhysicsEnginePlugin {
  23297. world: any;
  23298. name: string;
  23299. setGravity(gravity: Vector3): void;
  23300. setTimeStep(timeStep: number): void;
  23301. getTimeStep(): number;
  23302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23303. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23304. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23306. removePhysicsBody(impostor: PhysicsImpostor): void;
  23307. generateJoint(joint: PhysicsImpostorJoint): void;
  23308. removeJoint(joint: PhysicsImpostorJoint): void;
  23309. isSupported(): boolean;
  23310. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23311. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23312. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23313. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23314. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23315. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23316. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23317. getBodyMass(impostor: PhysicsImpostor): number;
  23318. getBodyFriction(impostor: PhysicsImpostor): number;
  23319. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23320. getBodyRestitution(impostor: PhysicsImpostor): number;
  23321. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23322. getBodyPressure?(impostor: PhysicsImpostor): number;
  23323. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23324. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23325. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23326. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23327. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23328. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23329. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23330. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23331. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23332. sleepBody(impostor: PhysicsImpostor): void;
  23333. wakeUpBody(impostor: PhysicsImpostor): void;
  23334. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23335. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23336. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23337. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23338. getRadius(impostor: PhysicsImpostor): number;
  23339. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23340. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23341. dispose(): void;
  23342. }
  23343. /**
  23344. * Interface used to define a physics engine
  23345. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23346. */
  23347. export interface IPhysicsEngine {
  23348. /**
  23349. * Gets the gravity vector used by the simulation
  23350. */
  23351. gravity: Vector3;
  23352. /**
  23353. * Sets the gravity vector used by the simulation
  23354. * @param gravity defines the gravity vector to use
  23355. */
  23356. setGravity(gravity: Vector3): void;
  23357. /**
  23358. * Set the time step of the physics engine.
  23359. * Default is 1/60.
  23360. * To slow it down, enter 1/600 for example.
  23361. * To speed it up, 1/30
  23362. * @param newTimeStep the new timestep to apply to this world.
  23363. */
  23364. setTimeStep(newTimeStep: number): void;
  23365. /**
  23366. * Get the time step of the physics engine.
  23367. * @returns the current time step
  23368. */
  23369. getTimeStep(): number;
  23370. /**
  23371. * Release all resources
  23372. */
  23373. dispose(): void;
  23374. /**
  23375. * Gets the name of the current physics plugin
  23376. * @returns the name of the plugin
  23377. */
  23378. getPhysicsPluginName(): string;
  23379. /**
  23380. * Adding a new impostor for the impostor tracking.
  23381. * This will be done by the impostor itself.
  23382. * @param impostor the impostor to add
  23383. */
  23384. addImpostor(impostor: PhysicsImpostor): void;
  23385. /**
  23386. * Remove an impostor from the engine.
  23387. * This impostor and its mesh will not longer be updated by the physics engine.
  23388. * @param impostor the impostor to remove
  23389. */
  23390. removeImpostor(impostor: PhysicsImpostor): void;
  23391. /**
  23392. * Add a joint to the physics engine
  23393. * @param mainImpostor defines the main impostor to which the joint is added.
  23394. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23395. * @param joint defines the joint that will connect both impostors.
  23396. */
  23397. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23398. /**
  23399. * Removes a joint from the simulation
  23400. * @param mainImpostor defines the impostor used with the joint
  23401. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23402. * @param joint defines the joint to remove
  23403. */
  23404. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23405. /**
  23406. * Gets the current plugin used to run the simulation
  23407. * @returns current plugin
  23408. */
  23409. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23410. /**
  23411. * Gets the list of physic impostors
  23412. * @returns an array of PhysicsImpostor
  23413. */
  23414. getImpostors(): Array<PhysicsImpostor>;
  23415. /**
  23416. * Gets the impostor for a physics enabled object
  23417. * @param object defines the object impersonated by the impostor
  23418. * @returns the PhysicsImpostor or null if not found
  23419. */
  23420. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23421. /**
  23422. * Gets the impostor for a physics body object
  23423. * @param body defines physics body used by the impostor
  23424. * @returns the PhysicsImpostor or null if not found
  23425. */
  23426. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23427. /**
  23428. * Does a raycast in the physics world
  23429. * @param from when should the ray start?
  23430. * @param to when should the ray end?
  23431. * @returns PhysicsRaycastResult
  23432. */
  23433. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23434. /**
  23435. * Called by the scene. No need to call it.
  23436. * @param delta defines the timespam between frames
  23437. */
  23438. _step(delta: number): void;
  23439. }
  23440. }
  23441. declare module "babylonjs/Physics/physicsImpostor" {
  23442. import { Nullable, IndicesArray } from "babylonjs/types";
  23443. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23446. import { Scene } from "babylonjs/scene";
  23447. import { Bone } from "babylonjs/Bones/bone";
  23448. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23449. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23450. import { Space } from "babylonjs/Maths/math.axis";
  23451. /**
  23452. * The interface for the physics imposter parameters
  23453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23454. */
  23455. export interface PhysicsImpostorParameters {
  23456. /**
  23457. * The mass of the physics imposter
  23458. */
  23459. mass: number;
  23460. /**
  23461. * The friction of the physics imposter
  23462. */
  23463. friction?: number;
  23464. /**
  23465. * The coefficient of restitution of the physics imposter
  23466. */
  23467. restitution?: number;
  23468. /**
  23469. * The native options of the physics imposter
  23470. */
  23471. nativeOptions?: any;
  23472. /**
  23473. * Specifies if the parent should be ignored
  23474. */
  23475. ignoreParent?: boolean;
  23476. /**
  23477. * Specifies if bi-directional transformations should be disabled
  23478. */
  23479. disableBidirectionalTransformation?: boolean;
  23480. /**
  23481. * The pressure inside the physics imposter, soft object only
  23482. */
  23483. pressure?: number;
  23484. /**
  23485. * The stiffness the physics imposter, soft object only
  23486. */
  23487. stiffness?: number;
  23488. /**
  23489. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23490. */
  23491. velocityIterations?: number;
  23492. /**
  23493. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23494. */
  23495. positionIterations?: number;
  23496. /**
  23497. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23498. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23499. * Add to fix multiple points
  23500. */
  23501. fixedPoints?: number;
  23502. /**
  23503. * The collision margin around a soft object
  23504. */
  23505. margin?: number;
  23506. /**
  23507. * The collision margin around a soft object
  23508. */
  23509. damping?: number;
  23510. /**
  23511. * The path for a rope based on an extrusion
  23512. */
  23513. path?: any;
  23514. /**
  23515. * The shape of an extrusion used for a rope based on an extrusion
  23516. */
  23517. shape?: any;
  23518. }
  23519. /**
  23520. * Interface for a physics-enabled object
  23521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23522. */
  23523. export interface IPhysicsEnabledObject {
  23524. /**
  23525. * The position of the physics-enabled object
  23526. */
  23527. position: Vector3;
  23528. /**
  23529. * The rotation of the physics-enabled object
  23530. */
  23531. rotationQuaternion: Nullable<Quaternion>;
  23532. /**
  23533. * The scale of the physics-enabled object
  23534. */
  23535. scaling: Vector3;
  23536. /**
  23537. * The rotation of the physics-enabled object
  23538. */
  23539. rotation?: Vector3;
  23540. /**
  23541. * The parent of the physics-enabled object
  23542. */
  23543. parent?: any;
  23544. /**
  23545. * The bounding info of the physics-enabled object
  23546. * @returns The bounding info of the physics-enabled object
  23547. */
  23548. getBoundingInfo(): BoundingInfo;
  23549. /**
  23550. * Computes the world matrix
  23551. * @param force Specifies if the world matrix should be computed by force
  23552. * @returns A world matrix
  23553. */
  23554. computeWorldMatrix(force: boolean): Matrix;
  23555. /**
  23556. * Gets the world matrix
  23557. * @returns A world matrix
  23558. */
  23559. getWorldMatrix?(): Matrix;
  23560. /**
  23561. * Gets the child meshes
  23562. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23563. * @returns An array of abstract meshes
  23564. */
  23565. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23566. /**
  23567. * Gets the vertex data
  23568. * @param kind The type of vertex data
  23569. * @returns A nullable array of numbers, or a float32 array
  23570. */
  23571. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23572. /**
  23573. * Gets the indices from the mesh
  23574. * @returns A nullable array of index arrays
  23575. */
  23576. getIndices?(): Nullable<IndicesArray>;
  23577. /**
  23578. * Gets the scene from the mesh
  23579. * @returns the indices array or null
  23580. */
  23581. getScene?(): Scene;
  23582. /**
  23583. * Gets the absolute position from the mesh
  23584. * @returns the absolute position
  23585. */
  23586. getAbsolutePosition(): Vector3;
  23587. /**
  23588. * Gets the absolute pivot point from the mesh
  23589. * @returns the absolute pivot point
  23590. */
  23591. getAbsolutePivotPoint(): Vector3;
  23592. /**
  23593. * Rotates the mesh
  23594. * @param axis The axis of rotation
  23595. * @param amount The amount of rotation
  23596. * @param space The space of the rotation
  23597. * @returns The rotation transform node
  23598. */
  23599. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23600. /**
  23601. * Translates the mesh
  23602. * @param axis The axis of translation
  23603. * @param distance The distance of translation
  23604. * @param space The space of the translation
  23605. * @returns The transform node
  23606. */
  23607. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23608. /**
  23609. * Sets the absolute position of the mesh
  23610. * @param absolutePosition The absolute position of the mesh
  23611. * @returns The transform node
  23612. */
  23613. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23614. /**
  23615. * Gets the class name of the mesh
  23616. * @returns The class name
  23617. */
  23618. getClassName(): string;
  23619. }
  23620. /**
  23621. * Represents a physics imposter
  23622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23623. */
  23624. export class PhysicsImpostor {
  23625. /**
  23626. * The physics-enabled object used as the physics imposter
  23627. */
  23628. object: IPhysicsEnabledObject;
  23629. /**
  23630. * The type of the physics imposter
  23631. */
  23632. type: number;
  23633. private _options;
  23634. private _scene?;
  23635. /**
  23636. * The default object size of the imposter
  23637. */
  23638. static DEFAULT_OBJECT_SIZE: Vector3;
  23639. /**
  23640. * The identity quaternion of the imposter
  23641. */
  23642. static IDENTITY_QUATERNION: Quaternion;
  23643. /** @hidden */
  23644. _pluginData: any;
  23645. private _physicsEngine;
  23646. private _physicsBody;
  23647. private _bodyUpdateRequired;
  23648. private _onBeforePhysicsStepCallbacks;
  23649. private _onAfterPhysicsStepCallbacks;
  23650. /** @hidden */
  23651. _onPhysicsCollideCallbacks: Array<{
  23652. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23653. otherImpostors: Array<PhysicsImpostor>;
  23654. }>;
  23655. private _deltaPosition;
  23656. private _deltaRotation;
  23657. private _deltaRotationConjugated;
  23658. /** @hidden */
  23659. _isFromLine: boolean;
  23660. private _parent;
  23661. private _isDisposed;
  23662. private static _tmpVecs;
  23663. private static _tmpQuat;
  23664. /**
  23665. * Specifies if the physics imposter is disposed
  23666. */
  23667. readonly isDisposed: boolean;
  23668. /**
  23669. * Gets the mass of the physics imposter
  23670. */
  23671. mass: number;
  23672. /**
  23673. * Gets the coefficient of friction
  23674. */
  23675. /**
  23676. * Sets the coefficient of friction
  23677. */
  23678. friction: number;
  23679. /**
  23680. * Gets the coefficient of restitution
  23681. */
  23682. /**
  23683. * Sets the coefficient of restitution
  23684. */
  23685. restitution: number;
  23686. /**
  23687. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23688. */
  23689. /**
  23690. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23691. */
  23692. pressure: number;
  23693. /**
  23694. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23695. */
  23696. /**
  23697. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23698. */
  23699. stiffness: number;
  23700. /**
  23701. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23702. */
  23703. /**
  23704. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23705. */
  23706. velocityIterations: number;
  23707. /**
  23708. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23709. */
  23710. /**
  23711. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23712. */
  23713. positionIterations: number;
  23714. /**
  23715. * The unique id of the physics imposter
  23716. * set by the physics engine when adding this impostor to the array
  23717. */
  23718. uniqueId: number;
  23719. /**
  23720. * @hidden
  23721. */
  23722. soft: boolean;
  23723. /**
  23724. * @hidden
  23725. */
  23726. segments: number;
  23727. private _joints;
  23728. /**
  23729. * Initializes the physics imposter
  23730. * @param object The physics-enabled object used as the physics imposter
  23731. * @param type The type of the physics imposter
  23732. * @param _options The options for the physics imposter
  23733. * @param _scene The Babylon scene
  23734. */
  23735. constructor(
  23736. /**
  23737. * The physics-enabled object used as the physics imposter
  23738. */
  23739. object: IPhysicsEnabledObject,
  23740. /**
  23741. * The type of the physics imposter
  23742. */
  23743. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23744. /**
  23745. * This function will completly initialize this impostor.
  23746. * It will create a new body - but only if this mesh has no parent.
  23747. * If it has, this impostor will not be used other than to define the impostor
  23748. * of the child mesh.
  23749. * @hidden
  23750. */
  23751. _init(): void;
  23752. private _getPhysicsParent;
  23753. /**
  23754. * Should a new body be generated.
  23755. * @returns boolean specifying if body initialization is required
  23756. */
  23757. isBodyInitRequired(): boolean;
  23758. /**
  23759. * Sets the updated scaling
  23760. * @param updated Specifies if the scaling is updated
  23761. */
  23762. setScalingUpdated(): void;
  23763. /**
  23764. * Force a regeneration of this or the parent's impostor's body.
  23765. * Use under cautious - This will remove all joints already implemented.
  23766. */
  23767. forceUpdate(): void;
  23768. /**
  23769. * Gets the body that holds this impostor. Either its own, or its parent.
  23770. */
  23771. /**
  23772. * Set the physics body. Used mainly by the physics engine/plugin
  23773. */
  23774. physicsBody: any;
  23775. /**
  23776. * Get the parent of the physics imposter
  23777. * @returns Physics imposter or null
  23778. */
  23779. /**
  23780. * Sets the parent of the physics imposter
  23781. */
  23782. parent: Nullable<PhysicsImpostor>;
  23783. /**
  23784. * Resets the update flags
  23785. */
  23786. resetUpdateFlags(): void;
  23787. /**
  23788. * Gets the object extend size
  23789. * @returns the object extend size
  23790. */
  23791. getObjectExtendSize(): Vector3;
  23792. /**
  23793. * Gets the object center
  23794. * @returns The object center
  23795. */
  23796. getObjectCenter(): Vector3;
  23797. /**
  23798. * Get a specific parametes from the options parameter
  23799. * @param paramName The object parameter name
  23800. * @returns The object parameter
  23801. */
  23802. getParam(paramName: string): any;
  23803. /**
  23804. * Sets a specific parameter in the options given to the physics plugin
  23805. * @param paramName The parameter name
  23806. * @param value The value of the parameter
  23807. */
  23808. setParam(paramName: string, value: number): void;
  23809. /**
  23810. * Specifically change the body's mass option. Won't recreate the physics body object
  23811. * @param mass The mass of the physics imposter
  23812. */
  23813. setMass(mass: number): void;
  23814. /**
  23815. * Gets the linear velocity
  23816. * @returns linear velocity or null
  23817. */
  23818. getLinearVelocity(): Nullable<Vector3>;
  23819. /**
  23820. * Sets the linear velocity
  23821. * @param velocity linear velocity or null
  23822. */
  23823. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23824. /**
  23825. * Gets the angular velocity
  23826. * @returns angular velocity or null
  23827. */
  23828. getAngularVelocity(): Nullable<Vector3>;
  23829. /**
  23830. * Sets the angular velocity
  23831. * @param velocity The velocity or null
  23832. */
  23833. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23834. /**
  23835. * Execute a function with the physics plugin native code
  23836. * Provide a function the will have two variables - the world object and the physics body object
  23837. * @param func The function to execute with the physics plugin native code
  23838. */
  23839. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23840. /**
  23841. * Register a function that will be executed before the physics world is stepping forward
  23842. * @param func The function to execute before the physics world is stepped forward
  23843. */
  23844. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23845. /**
  23846. * Unregister a function that will be executed before the physics world is stepping forward
  23847. * @param func The function to execute before the physics world is stepped forward
  23848. */
  23849. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23850. /**
  23851. * Register a function that will be executed after the physics step
  23852. * @param func The function to execute after physics step
  23853. */
  23854. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23855. /**
  23856. * Unregisters a function that will be executed after the physics step
  23857. * @param func The function to execute after physics step
  23858. */
  23859. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23860. /**
  23861. * register a function that will be executed when this impostor collides against a different body
  23862. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23863. * @param func Callback that is executed on collision
  23864. */
  23865. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23866. /**
  23867. * Unregisters the physics imposter on contact
  23868. * @param collideAgainst The physics object to collide against
  23869. * @param func Callback to execute on collision
  23870. */
  23871. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23872. private _tmpQuat;
  23873. private _tmpQuat2;
  23874. /**
  23875. * Get the parent rotation
  23876. * @returns The parent rotation
  23877. */
  23878. getParentsRotation(): Quaternion;
  23879. /**
  23880. * this function is executed by the physics engine.
  23881. */
  23882. beforeStep: () => void;
  23883. /**
  23884. * this function is executed by the physics engine
  23885. */
  23886. afterStep: () => void;
  23887. /**
  23888. * Legacy collision detection event support
  23889. */
  23890. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23891. /**
  23892. * event and body object due to cannon's event-based architecture.
  23893. */
  23894. onCollide: (e: {
  23895. body: any;
  23896. }) => void;
  23897. /**
  23898. * Apply a force
  23899. * @param force The force to apply
  23900. * @param contactPoint The contact point for the force
  23901. * @returns The physics imposter
  23902. */
  23903. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23904. /**
  23905. * Apply an impulse
  23906. * @param force The impulse force
  23907. * @param contactPoint The contact point for the impulse force
  23908. * @returns The physics imposter
  23909. */
  23910. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23911. /**
  23912. * A help function to create a joint
  23913. * @param otherImpostor A physics imposter used to create a joint
  23914. * @param jointType The type of joint
  23915. * @param jointData The data for the joint
  23916. * @returns The physics imposter
  23917. */
  23918. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23919. /**
  23920. * Add a joint to this impostor with a different impostor
  23921. * @param otherImpostor A physics imposter used to add a joint
  23922. * @param joint The joint to add
  23923. * @returns The physics imposter
  23924. */
  23925. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23926. /**
  23927. * Add an anchor to a cloth impostor
  23928. * @param otherImpostor rigid impostor to anchor to
  23929. * @param width ratio across width from 0 to 1
  23930. * @param height ratio up height from 0 to 1
  23931. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23932. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23933. * @returns impostor the soft imposter
  23934. */
  23935. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23936. /**
  23937. * Add a hook to a rope impostor
  23938. * @param otherImpostor rigid impostor to anchor to
  23939. * @param length ratio across rope from 0 to 1
  23940. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23941. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23942. * @returns impostor the rope imposter
  23943. */
  23944. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23945. /**
  23946. * Will keep this body still, in a sleep mode.
  23947. * @returns the physics imposter
  23948. */
  23949. sleep(): PhysicsImpostor;
  23950. /**
  23951. * Wake the body up.
  23952. * @returns The physics imposter
  23953. */
  23954. wakeUp(): PhysicsImpostor;
  23955. /**
  23956. * Clones the physics imposter
  23957. * @param newObject The physics imposter clones to this physics-enabled object
  23958. * @returns A nullable physics imposter
  23959. */
  23960. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23961. /**
  23962. * Disposes the physics imposter
  23963. */
  23964. dispose(): void;
  23965. /**
  23966. * Sets the delta position
  23967. * @param position The delta position amount
  23968. */
  23969. setDeltaPosition(position: Vector3): void;
  23970. /**
  23971. * Sets the delta rotation
  23972. * @param rotation The delta rotation amount
  23973. */
  23974. setDeltaRotation(rotation: Quaternion): void;
  23975. /**
  23976. * Gets the box size of the physics imposter and stores the result in the input parameter
  23977. * @param result Stores the box size
  23978. * @returns The physics imposter
  23979. */
  23980. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23981. /**
  23982. * Gets the radius of the physics imposter
  23983. * @returns Radius of the physics imposter
  23984. */
  23985. getRadius(): number;
  23986. /**
  23987. * Sync a bone with this impostor
  23988. * @param bone The bone to sync to the impostor.
  23989. * @param boneMesh The mesh that the bone is influencing.
  23990. * @param jointPivot The pivot of the joint / bone in local space.
  23991. * @param distToJoint Optional distance from the impostor to the joint.
  23992. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23993. */
  23994. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23995. /**
  23996. * Sync impostor to a bone
  23997. * @param bone The bone that the impostor will be synced to.
  23998. * @param boneMesh The mesh that the bone is influencing.
  23999. * @param jointPivot The pivot of the joint / bone in local space.
  24000. * @param distToJoint Optional distance from the impostor to the joint.
  24001. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24002. * @param boneAxis Optional vector3 axis the bone is aligned with
  24003. */
  24004. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24005. /**
  24006. * No-Imposter type
  24007. */
  24008. static NoImpostor: number;
  24009. /**
  24010. * Sphere-Imposter type
  24011. */
  24012. static SphereImpostor: number;
  24013. /**
  24014. * Box-Imposter type
  24015. */
  24016. static BoxImpostor: number;
  24017. /**
  24018. * Plane-Imposter type
  24019. */
  24020. static PlaneImpostor: number;
  24021. /**
  24022. * Mesh-imposter type
  24023. */
  24024. static MeshImpostor: number;
  24025. /**
  24026. * Capsule-Impostor type (Ammo.js plugin only)
  24027. */
  24028. static CapsuleImpostor: number;
  24029. /**
  24030. * Cylinder-Imposter type
  24031. */
  24032. static CylinderImpostor: number;
  24033. /**
  24034. * Particle-Imposter type
  24035. */
  24036. static ParticleImpostor: number;
  24037. /**
  24038. * Heightmap-Imposter type
  24039. */
  24040. static HeightmapImpostor: number;
  24041. /**
  24042. * ConvexHull-Impostor type (Ammo.js plugin only)
  24043. */
  24044. static ConvexHullImpostor: number;
  24045. /**
  24046. * Rope-Imposter type
  24047. */
  24048. static RopeImpostor: number;
  24049. /**
  24050. * Cloth-Imposter type
  24051. */
  24052. static ClothImpostor: number;
  24053. /**
  24054. * Softbody-Imposter type
  24055. */
  24056. static SoftbodyImpostor: number;
  24057. }
  24058. }
  24059. declare module "babylonjs/Meshes/mesh" {
  24060. import { Observable } from "babylonjs/Misc/observable";
  24061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24062. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24063. import { Camera } from "babylonjs/Cameras/camera";
  24064. import { Scene } from "babylonjs/scene";
  24065. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24066. import { Color4 } from "babylonjs/Maths/math.color";
  24067. import { Engine } from "babylonjs/Engines/engine";
  24068. import { Node } from "babylonjs/node";
  24069. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24070. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24071. import { Buffer } from "babylonjs/Meshes/buffer";
  24072. import { Geometry } from "babylonjs/Meshes/geometry";
  24073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24075. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24076. import { Effect } from "babylonjs/Materials/effect";
  24077. import { Material } from "babylonjs/Materials/material";
  24078. import { Skeleton } from "babylonjs/Bones/skeleton";
  24079. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24080. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24081. import { Path3D } from "babylonjs/Maths/math.path";
  24082. import { Plane } from "babylonjs/Maths/math.plane";
  24083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24084. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24086. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24087. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24088. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24089. /**
  24090. * @hidden
  24091. **/
  24092. export class _CreationDataStorage {
  24093. closePath?: boolean;
  24094. closeArray?: boolean;
  24095. idx: number[];
  24096. dashSize: number;
  24097. gapSize: number;
  24098. path3D: Path3D;
  24099. pathArray: Vector3[][];
  24100. arc: number;
  24101. radius: number;
  24102. cap: number;
  24103. tessellation: number;
  24104. }
  24105. /**
  24106. * @hidden
  24107. **/
  24108. class _InstanceDataStorage {
  24109. visibleInstances: any;
  24110. batchCache: _InstancesBatch;
  24111. instancesBufferSize: number;
  24112. instancesBuffer: Nullable<Buffer>;
  24113. instancesData: Float32Array;
  24114. overridenInstanceCount: number;
  24115. isFrozen: boolean;
  24116. previousBatch: Nullable<_InstancesBatch>;
  24117. hardwareInstancedRendering: boolean;
  24118. sideOrientation: number;
  24119. }
  24120. /**
  24121. * @hidden
  24122. **/
  24123. export class _InstancesBatch {
  24124. mustReturn: boolean;
  24125. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24126. renderSelf: boolean[];
  24127. hardwareInstancedRendering: boolean[];
  24128. }
  24129. /**
  24130. * Class used to represent renderable models
  24131. */
  24132. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24133. /**
  24134. * Mesh side orientation : usually the external or front surface
  24135. */
  24136. static readonly FRONTSIDE: number;
  24137. /**
  24138. * Mesh side orientation : usually the internal or back surface
  24139. */
  24140. static readonly BACKSIDE: number;
  24141. /**
  24142. * Mesh side orientation : both internal and external or front and back surfaces
  24143. */
  24144. static readonly DOUBLESIDE: number;
  24145. /**
  24146. * Mesh side orientation : by default, `FRONTSIDE`
  24147. */
  24148. static readonly DEFAULTSIDE: number;
  24149. /**
  24150. * Mesh cap setting : no cap
  24151. */
  24152. static readonly NO_CAP: number;
  24153. /**
  24154. * Mesh cap setting : one cap at the beginning of the mesh
  24155. */
  24156. static readonly CAP_START: number;
  24157. /**
  24158. * Mesh cap setting : one cap at the end of the mesh
  24159. */
  24160. static readonly CAP_END: number;
  24161. /**
  24162. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24163. */
  24164. static readonly CAP_ALL: number;
  24165. /**
  24166. * Mesh pattern setting : no flip or rotate
  24167. */
  24168. static readonly NO_FLIP: number;
  24169. /**
  24170. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24171. */
  24172. static readonly FLIP_TILE: number;
  24173. /**
  24174. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24175. */
  24176. static readonly ROTATE_TILE: number;
  24177. /**
  24178. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24179. */
  24180. static readonly FLIP_ROW: number;
  24181. /**
  24182. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24183. */
  24184. static readonly ROTATE_ROW: number;
  24185. /**
  24186. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24187. */
  24188. static readonly FLIP_N_ROTATE_TILE: number;
  24189. /**
  24190. * Mesh pattern setting : rotate pattern and rotate
  24191. */
  24192. static readonly FLIP_N_ROTATE_ROW: number;
  24193. /**
  24194. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24195. */
  24196. static readonly CENTER: number;
  24197. /**
  24198. * Mesh tile positioning : part tiles on left
  24199. */
  24200. static readonly LEFT: number;
  24201. /**
  24202. * Mesh tile positioning : part tiles on right
  24203. */
  24204. static readonly RIGHT: number;
  24205. /**
  24206. * Mesh tile positioning : part tiles on top
  24207. */
  24208. static readonly TOP: number;
  24209. /**
  24210. * Mesh tile positioning : part tiles on bottom
  24211. */
  24212. static readonly BOTTOM: number;
  24213. /**
  24214. * Gets the default side orientation.
  24215. * @param orientation the orientation to value to attempt to get
  24216. * @returns the default orientation
  24217. * @hidden
  24218. */
  24219. static _GetDefaultSideOrientation(orientation?: number): number;
  24220. private _internalMeshDataInfo;
  24221. /**
  24222. * An event triggered before rendering the mesh
  24223. */
  24224. readonly onBeforeRenderObservable: Observable<Mesh>;
  24225. /**
  24226. * An event triggered before binding the mesh
  24227. */
  24228. readonly onBeforeBindObservable: Observable<Mesh>;
  24229. /**
  24230. * An event triggered after rendering the mesh
  24231. */
  24232. readonly onAfterRenderObservable: Observable<Mesh>;
  24233. /**
  24234. * An event triggered before drawing the mesh
  24235. */
  24236. readonly onBeforeDrawObservable: Observable<Mesh>;
  24237. private _onBeforeDrawObserver;
  24238. /**
  24239. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24240. */
  24241. onBeforeDraw: () => void;
  24242. readonly hasInstances: boolean;
  24243. /**
  24244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24246. */
  24247. delayLoadState: number;
  24248. /**
  24249. * Gets the list of instances created from this mesh
  24250. * it is not supposed to be modified manually.
  24251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24253. */
  24254. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24255. /**
  24256. * Gets the file containing delay loading data for this mesh
  24257. */
  24258. delayLoadingFile: string;
  24259. /** @hidden */
  24260. _binaryInfo: any;
  24261. /**
  24262. * User defined function used to change how LOD level selection is done
  24263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24264. */
  24265. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24266. /**
  24267. * Gets or sets the morph target manager
  24268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24269. */
  24270. morphTargetManager: Nullable<MorphTargetManager>;
  24271. /** @hidden */
  24272. _creationDataStorage: Nullable<_CreationDataStorage>;
  24273. /** @hidden */
  24274. _geometry: Nullable<Geometry>;
  24275. /** @hidden */
  24276. _delayInfo: Array<string>;
  24277. /** @hidden */
  24278. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24279. /** @hidden */
  24280. _instanceDataStorage: _InstanceDataStorage;
  24281. private _effectiveMaterial;
  24282. /** @hidden */
  24283. _shouldGenerateFlatShading: boolean;
  24284. /** @hidden */
  24285. _originalBuilderSideOrientation: number;
  24286. /**
  24287. * Use this property to change the original side orientation defined at construction time
  24288. */
  24289. overrideMaterialSideOrientation: Nullable<number>;
  24290. /**
  24291. * Gets the source mesh (the one used to clone this one from)
  24292. */
  24293. readonly source: Nullable<Mesh>;
  24294. /**
  24295. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24296. */
  24297. isUnIndexed: boolean;
  24298. /**
  24299. * @constructor
  24300. * @param name The value used by scene.getMeshByName() to do a lookup.
  24301. * @param scene The scene to add this mesh to.
  24302. * @param parent The parent of this mesh, if it has one
  24303. * @param source An optional Mesh from which geometry is shared, cloned.
  24304. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24305. * When false, achieved by calling a clone(), also passing False.
  24306. * This will make creation of children, recursive.
  24307. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24308. */
  24309. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24310. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24311. /**
  24312. * Gets the class name
  24313. * @returns the string "Mesh".
  24314. */
  24315. getClassName(): string;
  24316. /** @hidden */
  24317. readonly _isMesh: boolean;
  24318. /**
  24319. * Returns a description of this mesh
  24320. * @param fullDetails define if full details about this mesh must be used
  24321. * @returns a descriptive string representing this mesh
  24322. */
  24323. toString(fullDetails?: boolean): string;
  24324. /** @hidden */
  24325. _unBindEffect(): void;
  24326. /**
  24327. * Gets a boolean indicating if this mesh has LOD
  24328. */
  24329. readonly hasLODLevels: boolean;
  24330. /**
  24331. * Gets the list of MeshLODLevel associated with the current mesh
  24332. * @returns an array of MeshLODLevel
  24333. */
  24334. getLODLevels(): MeshLODLevel[];
  24335. private _sortLODLevels;
  24336. /**
  24337. * Add a mesh as LOD level triggered at the given distance.
  24338. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24339. * @param distance The distance from the center of the object to show this level
  24340. * @param mesh The mesh to be added as LOD level (can be null)
  24341. * @return This mesh (for chaining)
  24342. */
  24343. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24344. /**
  24345. * Returns the LOD level mesh at the passed distance or null if not found.
  24346. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24347. * @param distance The distance from the center of the object to show this level
  24348. * @returns a Mesh or `null`
  24349. */
  24350. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24351. /**
  24352. * Remove a mesh from the LOD array
  24353. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24354. * @param mesh defines the mesh to be removed
  24355. * @return This mesh (for chaining)
  24356. */
  24357. removeLODLevel(mesh: Mesh): Mesh;
  24358. /**
  24359. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24360. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24361. * @param camera defines the camera to use to compute distance
  24362. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24363. * @return This mesh (for chaining)
  24364. */
  24365. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24366. /**
  24367. * Gets the mesh internal Geometry object
  24368. */
  24369. readonly geometry: Nullable<Geometry>;
  24370. /**
  24371. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24372. * @returns the total number of vertices
  24373. */
  24374. getTotalVertices(): number;
  24375. /**
  24376. * Returns the content of an associated vertex buffer
  24377. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.UVKind
  24380. * - VertexBuffer.UV2Kind
  24381. * - VertexBuffer.UV3Kind
  24382. * - VertexBuffer.UV4Kind
  24383. * - VertexBuffer.UV5Kind
  24384. * - VertexBuffer.UV6Kind
  24385. * - VertexBuffer.ColorKind
  24386. * - VertexBuffer.MatricesIndicesKind
  24387. * - VertexBuffer.MatricesIndicesExtraKind
  24388. * - VertexBuffer.MatricesWeightsKind
  24389. * - VertexBuffer.MatricesWeightsExtraKind
  24390. * @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
  24391. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24392. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24393. */
  24394. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24395. /**
  24396. * Returns the mesh VertexBuffer object from the requested `kind`
  24397. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24398. * - VertexBuffer.PositionKind
  24399. * - VertexBuffer.NormalKind
  24400. * - VertexBuffer.UVKind
  24401. * - VertexBuffer.UV2Kind
  24402. * - VertexBuffer.UV3Kind
  24403. * - VertexBuffer.UV4Kind
  24404. * - VertexBuffer.UV5Kind
  24405. * - VertexBuffer.UV6Kind
  24406. * - VertexBuffer.ColorKind
  24407. * - VertexBuffer.MatricesIndicesKind
  24408. * - VertexBuffer.MatricesIndicesExtraKind
  24409. * - VertexBuffer.MatricesWeightsKind
  24410. * - VertexBuffer.MatricesWeightsExtraKind
  24411. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24412. */
  24413. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24414. /**
  24415. * Tests if a specific vertex buffer is associated with this mesh
  24416. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24417. * - VertexBuffer.PositionKind
  24418. * - VertexBuffer.NormalKind
  24419. * - VertexBuffer.UVKind
  24420. * - VertexBuffer.UV2Kind
  24421. * - VertexBuffer.UV3Kind
  24422. * - VertexBuffer.UV4Kind
  24423. * - VertexBuffer.UV5Kind
  24424. * - VertexBuffer.UV6Kind
  24425. * - VertexBuffer.ColorKind
  24426. * - VertexBuffer.MatricesIndicesKind
  24427. * - VertexBuffer.MatricesIndicesExtraKind
  24428. * - VertexBuffer.MatricesWeightsKind
  24429. * - VertexBuffer.MatricesWeightsExtraKind
  24430. * @returns a boolean
  24431. */
  24432. isVerticesDataPresent(kind: string): boolean;
  24433. /**
  24434. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24435. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24436. * - VertexBuffer.PositionKind
  24437. * - VertexBuffer.UVKind
  24438. * - VertexBuffer.UV2Kind
  24439. * - VertexBuffer.UV3Kind
  24440. * - VertexBuffer.UV4Kind
  24441. * - VertexBuffer.UV5Kind
  24442. * - VertexBuffer.UV6Kind
  24443. * - VertexBuffer.ColorKind
  24444. * - VertexBuffer.MatricesIndicesKind
  24445. * - VertexBuffer.MatricesIndicesExtraKind
  24446. * - VertexBuffer.MatricesWeightsKind
  24447. * - VertexBuffer.MatricesWeightsExtraKind
  24448. * @returns a boolean
  24449. */
  24450. isVertexBufferUpdatable(kind: string): boolean;
  24451. /**
  24452. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24453. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24454. * - VertexBuffer.PositionKind
  24455. * - VertexBuffer.NormalKind
  24456. * - VertexBuffer.UVKind
  24457. * - VertexBuffer.UV2Kind
  24458. * - VertexBuffer.UV3Kind
  24459. * - VertexBuffer.UV4Kind
  24460. * - VertexBuffer.UV5Kind
  24461. * - VertexBuffer.UV6Kind
  24462. * - VertexBuffer.ColorKind
  24463. * - VertexBuffer.MatricesIndicesKind
  24464. * - VertexBuffer.MatricesIndicesExtraKind
  24465. * - VertexBuffer.MatricesWeightsKind
  24466. * - VertexBuffer.MatricesWeightsExtraKind
  24467. * @returns an array of strings
  24468. */
  24469. getVerticesDataKinds(): string[];
  24470. /**
  24471. * Returns a positive integer : the total number of indices in this mesh geometry.
  24472. * @returns the numner of indices or zero if the mesh has no geometry.
  24473. */
  24474. getTotalIndices(): number;
  24475. /**
  24476. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24477. * @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.
  24478. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24479. * @returns the indices array or an empty array if the mesh has no geometry
  24480. */
  24481. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24482. readonly isBlocked: boolean;
  24483. /**
  24484. * Determine if the current mesh is ready to be rendered
  24485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24486. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24487. * @returns true if all associated assets are ready (material, textures, shaders)
  24488. */
  24489. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24490. /**
  24491. * 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.
  24492. */
  24493. readonly areNormalsFrozen: boolean;
  24494. /**
  24495. * 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.
  24496. * @returns the current mesh
  24497. */
  24498. freezeNormals(): Mesh;
  24499. /**
  24500. * 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
  24501. * @returns the current mesh
  24502. */
  24503. unfreezeNormals(): Mesh;
  24504. /**
  24505. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24506. */
  24507. overridenInstanceCount: number;
  24508. /** @hidden */
  24509. _preActivate(): Mesh;
  24510. /** @hidden */
  24511. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24512. /** @hidden */
  24513. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24514. /**
  24515. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24516. * This means the mesh underlying bounding box and sphere are recomputed.
  24517. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24518. * @returns the current mesh
  24519. */
  24520. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24521. /** @hidden */
  24522. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24523. /**
  24524. * This function will subdivide the mesh into multiple submeshes
  24525. * @param count defines the expected number of submeshes
  24526. */
  24527. subdivide(count: number): void;
  24528. /**
  24529. * Copy a FloatArray into a specific associated vertex buffer
  24530. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24531. * - VertexBuffer.PositionKind
  24532. * - VertexBuffer.UVKind
  24533. * - VertexBuffer.UV2Kind
  24534. * - VertexBuffer.UV3Kind
  24535. * - VertexBuffer.UV4Kind
  24536. * - VertexBuffer.UV5Kind
  24537. * - VertexBuffer.UV6Kind
  24538. * - VertexBuffer.ColorKind
  24539. * - VertexBuffer.MatricesIndicesKind
  24540. * - VertexBuffer.MatricesIndicesExtraKind
  24541. * - VertexBuffer.MatricesWeightsKind
  24542. * - VertexBuffer.MatricesWeightsExtraKind
  24543. * @param data defines the data source
  24544. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24545. * @param stride defines the data stride size (can be null)
  24546. * @returns the current mesh
  24547. */
  24548. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24549. /**
  24550. * Flags an associated vertex buffer as updatable
  24551. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24552. * - VertexBuffer.PositionKind
  24553. * - VertexBuffer.UVKind
  24554. * - VertexBuffer.UV2Kind
  24555. * - VertexBuffer.UV3Kind
  24556. * - VertexBuffer.UV4Kind
  24557. * - VertexBuffer.UV5Kind
  24558. * - VertexBuffer.UV6Kind
  24559. * - VertexBuffer.ColorKind
  24560. * - VertexBuffer.MatricesIndicesKind
  24561. * - VertexBuffer.MatricesIndicesExtraKind
  24562. * - VertexBuffer.MatricesWeightsKind
  24563. * - VertexBuffer.MatricesWeightsExtraKind
  24564. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24565. */
  24566. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24567. /**
  24568. * Sets the mesh global Vertex Buffer
  24569. * @param buffer defines the buffer to use
  24570. * @returns the current mesh
  24571. */
  24572. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24573. /**
  24574. * Update a specific associated vertex buffer
  24575. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24576. * - VertexBuffer.PositionKind
  24577. * - VertexBuffer.UVKind
  24578. * - VertexBuffer.UV2Kind
  24579. * - VertexBuffer.UV3Kind
  24580. * - VertexBuffer.UV4Kind
  24581. * - VertexBuffer.UV5Kind
  24582. * - VertexBuffer.UV6Kind
  24583. * - VertexBuffer.ColorKind
  24584. * - VertexBuffer.MatricesIndicesKind
  24585. * - VertexBuffer.MatricesIndicesExtraKind
  24586. * - VertexBuffer.MatricesWeightsKind
  24587. * - VertexBuffer.MatricesWeightsExtraKind
  24588. * @param data defines the data source
  24589. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24590. * @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)
  24591. * @returns the current mesh
  24592. */
  24593. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24594. /**
  24595. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24596. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24597. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24598. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24599. * @returns the current mesh
  24600. */
  24601. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24602. /**
  24603. * Creates a un-shared specific occurence of the geometry for the mesh.
  24604. * @returns the current mesh
  24605. */
  24606. makeGeometryUnique(): Mesh;
  24607. /**
  24608. * Set the index buffer of this mesh
  24609. * @param indices defines the source data
  24610. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24611. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24612. * @returns the current mesh
  24613. */
  24614. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24615. /**
  24616. * Update the current index buffer
  24617. * @param indices defines the source data
  24618. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24619. * @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)
  24620. * @returns the current mesh
  24621. */
  24622. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24623. /**
  24624. * Invert the geometry to move from a right handed system to a left handed one.
  24625. * @returns the current mesh
  24626. */
  24627. toLeftHanded(): Mesh;
  24628. /** @hidden */
  24629. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24630. /** @hidden */
  24631. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24632. /**
  24633. * Registers for this mesh a javascript function called just before the rendering process
  24634. * @param func defines the function to call before rendering this mesh
  24635. * @returns the current mesh
  24636. */
  24637. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24638. /**
  24639. * Disposes a previously registered javascript function called before the rendering
  24640. * @param func defines the function to remove
  24641. * @returns the current mesh
  24642. */
  24643. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24644. /**
  24645. * Registers for this mesh a javascript function called just after the rendering is complete
  24646. * @param func defines the function to call after rendering this mesh
  24647. * @returns the current mesh
  24648. */
  24649. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24650. /**
  24651. * Disposes a previously registered javascript function called after the rendering.
  24652. * @param func defines the function to remove
  24653. * @returns the current mesh
  24654. */
  24655. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24656. /** @hidden */
  24657. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24658. /** @hidden */
  24659. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24660. /** @hidden */
  24661. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24662. /** @hidden */
  24663. _rebuild(): void;
  24664. /** @hidden */
  24665. _freeze(): void;
  24666. /** @hidden */
  24667. _unFreeze(): void;
  24668. /**
  24669. * 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
  24670. * @param subMesh defines the subMesh to render
  24671. * @param enableAlphaMode defines if alpha mode can be changed
  24672. * @returns the current mesh
  24673. */
  24674. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24675. private _onBeforeDraw;
  24676. /**
  24677. * Renormalize the mesh and patch it up if there are no weights
  24678. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24679. * However in the case of zero weights then we set just a single influence to 1.
  24680. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24681. */
  24682. cleanMatrixWeights(): void;
  24683. private normalizeSkinFourWeights;
  24684. private normalizeSkinWeightsAndExtra;
  24685. /**
  24686. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24687. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24688. * the user know there was an issue with importing the mesh
  24689. * @returns a validation object with skinned, valid and report string
  24690. */
  24691. validateSkinning(): {
  24692. skinned: boolean;
  24693. valid: boolean;
  24694. report: string;
  24695. };
  24696. /** @hidden */
  24697. _checkDelayState(): Mesh;
  24698. private _queueLoad;
  24699. /**
  24700. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24701. * A mesh is in the frustum if its bounding box intersects the frustum
  24702. * @param frustumPlanes defines the frustum to test
  24703. * @returns true if the mesh is in the frustum planes
  24704. */
  24705. isInFrustum(frustumPlanes: Plane[]): boolean;
  24706. /**
  24707. * Sets the mesh material by the material or multiMaterial `id` property
  24708. * @param id is a string identifying the material or the multiMaterial
  24709. * @returns the current mesh
  24710. */
  24711. setMaterialByID(id: string): Mesh;
  24712. /**
  24713. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24714. * @returns an array of IAnimatable
  24715. */
  24716. getAnimatables(): IAnimatable[];
  24717. /**
  24718. * Modifies the mesh geometry according to the passed transformation matrix.
  24719. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24720. * The mesh normals are modified using the same transformation.
  24721. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24722. * @param transform defines the transform matrix to use
  24723. * @see http://doc.babylonjs.com/resources/baking_transformations
  24724. * @returns the current mesh
  24725. */
  24726. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24727. /**
  24728. * Modifies the mesh geometry according to its own current World Matrix.
  24729. * The mesh World Matrix is then reset.
  24730. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24731. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24732. * @see http://doc.babylonjs.com/resources/baking_transformations
  24733. * @returns the current mesh
  24734. */
  24735. bakeCurrentTransformIntoVertices(): Mesh;
  24736. /** @hidden */
  24737. readonly _positions: Nullable<Vector3[]>;
  24738. /** @hidden */
  24739. _resetPointsArrayCache(): Mesh;
  24740. /** @hidden */
  24741. _generatePointsArray(): boolean;
  24742. /**
  24743. * Returns a new Mesh object generated from the current mesh properties.
  24744. * This method must not get confused with createInstance()
  24745. * @param name is a string, the name given to the new mesh
  24746. * @param newParent can be any Node object (default `null`)
  24747. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24748. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24749. * @returns a new mesh
  24750. */
  24751. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24752. /**
  24753. * Releases resources associated with this mesh.
  24754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24756. */
  24757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24758. /**
  24759. * Modifies the mesh geometry according to a displacement map.
  24760. * 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.
  24761. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24762. * @param url is a string, the URL from the image file is to be downloaded.
  24763. * @param minHeight is the lower limit of the displacement.
  24764. * @param maxHeight is the upper limit of the displacement.
  24765. * @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.
  24766. * @param uvOffset is an optional vector2 used to offset UV.
  24767. * @param uvScale is an optional vector2 used to scale UV.
  24768. * @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.
  24769. * @returns the Mesh.
  24770. */
  24771. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24772. /**
  24773. * Modifies the mesh geometry according to a displacementMap buffer.
  24774. * 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.
  24775. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24776. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24777. * @param heightMapWidth is the width of the buffer image.
  24778. * @param heightMapHeight is the height of the buffer image.
  24779. * @param minHeight is the lower limit of the displacement.
  24780. * @param maxHeight is the upper limit of the displacement.
  24781. * @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.
  24782. * @param uvOffset is an optional vector2 used to offset UV.
  24783. * @param uvScale is an optional vector2 used to scale UV.
  24784. * @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.
  24785. * @returns the Mesh.
  24786. */
  24787. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24788. /**
  24789. * Modify the mesh to get a flat shading rendering.
  24790. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24791. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24792. * @returns current mesh
  24793. */
  24794. convertToFlatShadedMesh(): Mesh;
  24795. /**
  24796. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24797. * In other words, more vertices, no more indices and a single bigger VBO.
  24798. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24799. * @returns current mesh
  24800. */
  24801. convertToUnIndexedMesh(): Mesh;
  24802. /**
  24803. * Inverses facet orientations.
  24804. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24805. * @param flipNormals will also inverts the normals
  24806. * @returns current mesh
  24807. */
  24808. flipFaces(flipNormals?: boolean): Mesh;
  24809. /**
  24810. * Increase the number of facets and hence vertices in a mesh
  24811. * Vertex normals are interpolated from existing vertex normals
  24812. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24813. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24814. */
  24815. increaseVertices(numberPerEdge: number): void;
  24816. /**
  24817. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24818. * This will undo any application of covertToFlatShadedMesh
  24819. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24820. */
  24821. forceSharedVertices(): void;
  24822. /** @hidden */
  24823. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24824. /** @hidden */
  24825. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24826. /**
  24827. * Creates a new InstancedMesh object from the mesh model.
  24828. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24829. * @param name defines the name of the new instance
  24830. * @returns a new InstancedMesh
  24831. */
  24832. createInstance(name: string): InstancedMesh;
  24833. /**
  24834. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24835. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24836. * @returns the current mesh
  24837. */
  24838. synchronizeInstances(): Mesh;
  24839. /**
  24840. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24841. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24842. * This should be used together with the simplification to avoid disappearing triangles.
  24843. * @param successCallback an optional success callback to be called after the optimization finished.
  24844. * @returns the current mesh
  24845. */
  24846. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24847. /**
  24848. * Serialize current mesh
  24849. * @param serializationObject defines the object which will receive the serialization data
  24850. */
  24851. serialize(serializationObject: any): void;
  24852. /** @hidden */
  24853. _syncGeometryWithMorphTargetManager(): void;
  24854. /** @hidden */
  24855. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24856. /**
  24857. * Returns a new Mesh object parsed from the source provided.
  24858. * @param parsedMesh is the source
  24859. * @param scene defines the hosting scene
  24860. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24861. * @returns a new Mesh
  24862. */
  24863. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24864. /**
  24865. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24866. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24867. * @param name defines the name of the mesh to create
  24868. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24869. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24870. * @param closePath creates a seam between the first and the last points of each path of the path array
  24871. * @param offset is taken in account only if the `pathArray` is containing a single path
  24872. * @param scene defines the hosting scene
  24873. * @param updatable defines if the mesh must be flagged as updatable
  24874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24875. * @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)
  24876. * @returns a new Mesh
  24877. */
  24878. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24879. /**
  24880. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24881. * @param name defines the name of the mesh to create
  24882. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24883. * @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
  24884. * @param scene defines the hosting scene
  24885. * @param updatable defines if the mesh must be flagged as updatable
  24886. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24887. * @returns a new Mesh
  24888. */
  24889. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24890. /**
  24891. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24892. * @param name defines the name of the mesh to create
  24893. * @param size sets the size (float) of each box side (default 1)
  24894. * @param scene defines the hosting scene
  24895. * @param updatable defines if the mesh must be flagged as updatable
  24896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24897. * @returns a new Mesh
  24898. */
  24899. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24900. /**
  24901. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24902. * @param name defines the name of the mesh to create
  24903. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24904. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24905. * @param scene defines the hosting scene
  24906. * @param updatable defines if the mesh must be flagged as updatable
  24907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24908. * @returns a new Mesh
  24909. */
  24910. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24911. /**
  24912. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24913. * @param name defines the name of the mesh to create
  24914. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24915. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24916. * @param scene defines the hosting scene
  24917. * @returns a new Mesh
  24918. */
  24919. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24920. /**
  24921. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24922. * @param name defines the name of the mesh to create
  24923. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24924. * @param diameterTop set the top cap diameter (floats, default 1)
  24925. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24926. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24927. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24928. * @param scene defines the hosting scene
  24929. * @param updatable defines if the mesh must be flagged as updatable
  24930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24931. * @returns a new Mesh
  24932. */
  24933. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24934. /**
  24935. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24936. * @param name defines the name of the mesh to create
  24937. * @param diameter sets the diameter size (float) of the torus (default 1)
  24938. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24939. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24940. * @param scene defines the hosting scene
  24941. * @param updatable defines if the mesh must be flagged as updatable
  24942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24943. * @returns a new Mesh
  24944. */
  24945. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24946. /**
  24947. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24948. * @param name defines the name of the mesh to create
  24949. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24950. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24951. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24952. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24953. * @param p the number of windings on X axis (positive integers, default 2)
  24954. * @param q the number of windings on Y axis (positive integers, default 3)
  24955. * @param scene defines the hosting scene
  24956. * @param updatable defines if the mesh must be flagged as updatable
  24957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24958. * @returns a new Mesh
  24959. */
  24960. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24961. /**
  24962. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24963. * @param name defines the name of the mesh to create
  24964. * @param points is an array successive Vector3
  24965. * @param scene defines the hosting scene
  24966. * @param updatable defines if the mesh must be flagged as updatable
  24967. * @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).
  24968. * @returns a new Mesh
  24969. */
  24970. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24971. /**
  24972. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24973. * @param name defines the name of the mesh to create
  24974. * @param points is an array successive Vector3
  24975. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24976. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24977. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24978. * @param scene defines the hosting scene
  24979. * @param updatable defines if the mesh must be flagged as updatable
  24980. * @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)
  24981. * @returns a new Mesh
  24982. */
  24983. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24984. /**
  24985. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24986. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24987. * 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.
  24988. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24989. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24990. * Remember you can only change the shape positions, not their number when updating a polygon.
  24991. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24992. * @param name defines the name of the mesh to create
  24993. * @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
  24994. * @param scene defines the hosting scene
  24995. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24996. * @param updatable defines if the mesh must be flagged as updatable
  24997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24998. * @param earcutInjection can be used to inject your own earcut reference
  24999. * @returns a new Mesh
  25000. */
  25001. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25002. /**
  25003. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25004. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25005. * @param name defines the name of the mesh to create
  25006. * @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
  25007. * @param depth defines the height of extrusion
  25008. * @param scene defines the hosting scene
  25009. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @param earcutInjection can be used to inject your own earcut reference
  25013. * @returns a new Mesh
  25014. */
  25015. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25016. /**
  25017. * Creates an extruded shape mesh.
  25018. * 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
  25019. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25020. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25021. * @param name defines the name of the mesh to create
  25022. * @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
  25023. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25024. * @param scale is the value to scale the shape
  25025. * @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
  25026. * @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
  25027. * @param scene defines the hosting scene
  25028. * @param updatable defines if the mesh must be flagged as updatable
  25029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25030. * @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)
  25031. * @returns a new Mesh
  25032. */
  25033. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25034. /**
  25035. * Creates an custom extruded shape mesh.
  25036. * The custom extrusion is a parametric shape.
  25037. * It has no predefined shape. Its final shape will depend on the input parameters.
  25038. * Please consider using the same method from the MeshBuilder class instead
  25039. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25040. * @param name defines the name of the mesh to create
  25041. * @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
  25042. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25043. * @param scaleFunction is a custom Javascript function called on each path point
  25044. * @param rotationFunction is a custom Javascript function called on each path point
  25045. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25046. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25047. * @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
  25048. * @param scene defines the hosting scene
  25049. * @param updatable defines if the mesh must be flagged as updatable
  25050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25051. * @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)
  25052. * @returns a new Mesh
  25053. */
  25054. 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;
  25055. /**
  25056. * Creates lathe mesh.
  25057. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25058. * Please consider using the same method from the MeshBuilder class instead
  25059. * @param name defines the name of the mesh to create
  25060. * @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
  25061. * @param radius is the radius value of the lathe
  25062. * @param tessellation is the side number of the lathe.
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25069. /**
  25070. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25073. * @param scene defines the hosting scene
  25074. * @param updatable defines if the mesh must be flagged as updatable
  25075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25076. * @returns a new Mesh
  25077. */
  25078. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25079. /**
  25080. * Creates a ground mesh.
  25081. * Please consider using the same method from the MeshBuilder class instead
  25082. * @param name defines the name of the mesh to create
  25083. * @param width set the width of the ground
  25084. * @param height set the height of the ground
  25085. * @param subdivisions sets the number of subdivisions per side
  25086. * @param scene defines the hosting scene
  25087. * @param updatable defines if the mesh must be flagged as updatable
  25088. * @returns a new Mesh
  25089. */
  25090. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25091. /**
  25092. * Creates a tiled ground mesh.
  25093. * Please consider using the same method from the MeshBuilder class instead
  25094. * @param name defines the name of the mesh to create
  25095. * @param xmin set the ground minimum X coordinate
  25096. * @param zmin set the ground minimum Y coordinate
  25097. * @param xmax set the ground maximum X coordinate
  25098. * @param zmax set the ground maximum Z coordinate
  25099. * @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
  25100. * @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
  25101. * @param scene defines the hosting scene
  25102. * @param updatable defines if the mesh must be flagged as updatable
  25103. * @returns a new Mesh
  25104. */
  25105. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25106. w: number;
  25107. h: number;
  25108. }, precision: {
  25109. w: number;
  25110. h: number;
  25111. }, scene: Scene, updatable?: boolean): Mesh;
  25112. /**
  25113. * Creates a ground mesh from a height map.
  25114. * Please consider using the same method from the MeshBuilder class instead
  25115. * @see http://doc.babylonjs.com/babylon101/height_map
  25116. * @param name defines the name of the mesh to create
  25117. * @param url sets the URL of the height map image resource
  25118. * @param width set the ground width size
  25119. * @param height set the ground height size
  25120. * @param subdivisions sets the number of subdivision per side
  25121. * @param minHeight is the minimum altitude on the ground
  25122. * @param maxHeight is the maximum altitude on the ground
  25123. * @param scene defines the hosting scene
  25124. * @param updatable defines if the mesh must be flagged as updatable
  25125. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25126. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25127. * @returns a new Mesh
  25128. */
  25129. 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;
  25130. /**
  25131. * Creates a tube mesh.
  25132. * The tube is a parametric shape.
  25133. * It has no predefined shape. Its final shape will depend on the input parameters.
  25134. * Please consider using the same method from the MeshBuilder class instead
  25135. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25136. * @param name defines the name of the mesh to create
  25137. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25138. * @param radius sets the tube radius size
  25139. * @param tessellation is the number of sides on the tubular surface
  25140. * @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
  25141. * @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
  25142. * @param scene defines the hosting scene
  25143. * @param updatable defines if the mesh must be flagged as updatable
  25144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25145. * @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)
  25146. * @returns a new Mesh
  25147. */
  25148. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25149. (i: number, distance: number): number;
  25150. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25151. /**
  25152. * Creates a polyhedron mesh.
  25153. * Please consider using the same method from the MeshBuilder class instead.
  25154. * * 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
  25155. * * The parameter `size` (positive float, default 1) sets the polygon size
  25156. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25157. * * 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`
  25158. * * 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
  25159. * * 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)`)
  25160. * * 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
  25161. * * 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
  25162. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25163. * * If you create a double-sided mesh, you can choose what parts of 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
  25164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25165. * @param name defines the name of the mesh to create
  25166. * @param options defines the options used to create the mesh
  25167. * @param scene defines the hosting scene
  25168. * @returns a new Mesh
  25169. */
  25170. static CreatePolyhedron(name: string, options: {
  25171. type?: number;
  25172. size?: number;
  25173. sizeX?: number;
  25174. sizeY?: number;
  25175. sizeZ?: number;
  25176. custom?: any;
  25177. faceUV?: Vector4[];
  25178. faceColors?: Color4[];
  25179. updatable?: boolean;
  25180. sideOrientation?: number;
  25181. }, scene: Scene): Mesh;
  25182. /**
  25183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25184. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25185. * * 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`)
  25186. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25187. * * 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
  25188. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25189. * * If you create a double-sided mesh, you can choose what parts of 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
  25190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25191. * @param name defines the name of the mesh
  25192. * @param options defines the options used to create the mesh
  25193. * @param scene defines the hosting scene
  25194. * @returns a new Mesh
  25195. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25196. */
  25197. static CreateIcoSphere(name: string, options: {
  25198. radius?: number;
  25199. flat?: boolean;
  25200. subdivisions?: number;
  25201. sideOrientation?: number;
  25202. updatable?: boolean;
  25203. }, scene: Scene): Mesh;
  25204. /**
  25205. * Creates a decal mesh.
  25206. * Please consider using the same method from the MeshBuilder class instead.
  25207. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25208. * @param name defines the name of the mesh
  25209. * @param sourceMesh defines the mesh receiving the decal
  25210. * @param position sets the position of the decal in world coordinates
  25211. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25212. * @param size sets the decal scaling
  25213. * @param angle sets the angle to rotate the decal
  25214. * @returns a new Mesh
  25215. */
  25216. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25217. /**
  25218. * Prepare internal position array for software CPU skinning
  25219. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25220. */
  25221. setPositionsForCPUSkinning(): Float32Array;
  25222. /**
  25223. * Prepare internal normal array for software CPU skinning
  25224. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25225. */
  25226. setNormalsForCPUSkinning(): Float32Array;
  25227. /**
  25228. * Updates the vertex buffer by applying transformation from the bones
  25229. * @param skeleton defines the skeleton to apply to current mesh
  25230. * @returns the current mesh
  25231. */
  25232. applySkeleton(skeleton: Skeleton): Mesh;
  25233. /**
  25234. * 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
  25235. * @param meshes defines the list of meshes to scan
  25236. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25237. */
  25238. static MinMax(meshes: AbstractMesh[]): {
  25239. min: Vector3;
  25240. max: Vector3;
  25241. };
  25242. /**
  25243. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25244. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25245. * @returns a vector3
  25246. */
  25247. static Center(meshesOrMinMaxVector: {
  25248. min: Vector3;
  25249. max: Vector3;
  25250. } | AbstractMesh[]): Vector3;
  25251. /**
  25252. * Merge the array of meshes into a single mesh for performance reasons.
  25253. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25254. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25255. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25256. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25257. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25258. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25259. * @returns a new mesh
  25260. */
  25261. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25262. /** @hidden */
  25263. addInstance(instance: InstancedMesh): void;
  25264. /** @hidden */
  25265. removeInstance(instance: InstancedMesh): void;
  25266. }
  25267. }
  25268. declare module "babylonjs/Cameras/camera" {
  25269. import { SmartArray } from "babylonjs/Misc/smartArray";
  25270. import { Observable } from "babylonjs/Misc/observable";
  25271. import { Nullable } from "babylonjs/types";
  25272. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25273. import { Scene } from "babylonjs/scene";
  25274. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25275. import { Node } from "babylonjs/node";
  25276. import { Mesh } from "babylonjs/Meshes/mesh";
  25277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25278. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25279. import { Viewport } from "babylonjs/Maths/math.viewport";
  25280. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25281. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25283. import { Ray } from "babylonjs/Culling/ray";
  25284. /**
  25285. * This is the base class of all the camera used in the application.
  25286. * @see http://doc.babylonjs.com/features/cameras
  25287. */
  25288. export class Camera extends Node {
  25289. /** @hidden */
  25290. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25291. /**
  25292. * This is the default projection mode used by the cameras.
  25293. * It helps recreating a feeling of perspective and better appreciate depth.
  25294. * This is the best way to simulate real life cameras.
  25295. */
  25296. static readonly PERSPECTIVE_CAMERA: number;
  25297. /**
  25298. * This helps creating camera with an orthographic mode.
  25299. * 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.
  25300. */
  25301. static readonly ORTHOGRAPHIC_CAMERA: number;
  25302. /**
  25303. * This is the default FOV mode for perspective cameras.
  25304. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25305. */
  25306. static readonly FOVMODE_VERTICAL_FIXED: number;
  25307. /**
  25308. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25309. */
  25310. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25311. /**
  25312. * This specifies ther is no need for a camera rig.
  25313. * Basically only one eye is rendered corresponding to the camera.
  25314. */
  25315. static readonly RIG_MODE_NONE: number;
  25316. /**
  25317. * Simulates a camera Rig with one blue eye and one red eye.
  25318. * This can be use with 3d blue and red glasses.
  25319. */
  25320. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25321. /**
  25322. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25323. */
  25324. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25325. /**
  25326. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25327. */
  25328. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25329. /**
  25330. * Defines that both eyes of the camera will be rendered over under each other.
  25331. */
  25332. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25333. /**
  25334. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25335. */
  25336. static readonly RIG_MODE_VR: number;
  25337. /**
  25338. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25339. */
  25340. static readonly RIG_MODE_WEBVR: number;
  25341. /**
  25342. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25343. */
  25344. static readonly RIG_MODE_CUSTOM: number;
  25345. /**
  25346. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25347. */
  25348. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25349. /**
  25350. * Define the input manager associated with the camera.
  25351. */
  25352. inputs: CameraInputsManager<Camera>;
  25353. /** @hidden */
  25354. _position: Vector3;
  25355. /**
  25356. * Define the current local position of the camera in the scene
  25357. */
  25358. position: Vector3;
  25359. /**
  25360. * The vector the camera should consider as up.
  25361. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25362. */
  25363. upVector: Vector3;
  25364. /**
  25365. * Define the current limit on the left side for an orthographic camera
  25366. * In scene unit
  25367. */
  25368. orthoLeft: Nullable<number>;
  25369. /**
  25370. * Define the current limit on the right side for an orthographic camera
  25371. * In scene unit
  25372. */
  25373. orthoRight: Nullable<number>;
  25374. /**
  25375. * Define the current limit on the bottom side for an orthographic camera
  25376. * In scene unit
  25377. */
  25378. orthoBottom: Nullable<number>;
  25379. /**
  25380. * Define the current limit on the top side for an orthographic camera
  25381. * In scene unit
  25382. */
  25383. orthoTop: Nullable<number>;
  25384. /**
  25385. * Field Of View is set in Radians. (default is 0.8)
  25386. */
  25387. fov: number;
  25388. /**
  25389. * Define the minimum distance the camera can see from.
  25390. * This is important to note that the depth buffer are not infinite and the closer it starts
  25391. * the more your scene might encounter depth fighting issue.
  25392. */
  25393. minZ: number;
  25394. /**
  25395. * Define the maximum distance the camera can see to.
  25396. * This is important to note that the depth buffer are not infinite and the further it end
  25397. * the more your scene might encounter depth fighting issue.
  25398. */
  25399. maxZ: number;
  25400. /**
  25401. * Define the default inertia of the camera.
  25402. * This helps giving a smooth feeling to the camera movement.
  25403. */
  25404. inertia: number;
  25405. /**
  25406. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25407. */
  25408. mode: number;
  25409. /**
  25410. * Define wether the camera is intermediate.
  25411. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25412. */
  25413. isIntermediate: boolean;
  25414. /**
  25415. * Define the viewport of the camera.
  25416. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25417. */
  25418. viewport: Viewport;
  25419. /**
  25420. * Restricts the camera to viewing objects with the same layerMask.
  25421. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25422. */
  25423. layerMask: number;
  25424. /**
  25425. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25426. */
  25427. fovMode: number;
  25428. /**
  25429. * Rig mode of the camera.
  25430. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25431. * This is normally controlled byt the camera themselves as internal use.
  25432. */
  25433. cameraRigMode: number;
  25434. /**
  25435. * Defines the distance between both "eyes" in case of a RIG
  25436. */
  25437. interaxialDistance: number;
  25438. /**
  25439. * Defines if stereoscopic rendering is done side by side or over under.
  25440. */
  25441. isStereoscopicSideBySide: boolean;
  25442. /**
  25443. * 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
  25444. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25445. * else in the scene. (Eg. security camera)
  25446. *
  25447. * 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)
  25448. */
  25449. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25450. /**
  25451. * When set, the camera will render to this render target instead of the default canvas
  25452. *
  25453. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25454. */
  25455. outputRenderTarget: Nullable<RenderTargetTexture>;
  25456. /**
  25457. * Observable triggered when the camera view matrix has changed.
  25458. */
  25459. onViewMatrixChangedObservable: Observable<Camera>;
  25460. /**
  25461. * Observable triggered when the camera Projection matrix has changed.
  25462. */
  25463. onProjectionMatrixChangedObservable: Observable<Camera>;
  25464. /**
  25465. * Observable triggered when the inputs have been processed.
  25466. */
  25467. onAfterCheckInputsObservable: Observable<Camera>;
  25468. /**
  25469. * Observable triggered when reset has been called and applied to the camera.
  25470. */
  25471. onRestoreStateObservable: Observable<Camera>;
  25472. /** @hidden */
  25473. _cameraRigParams: any;
  25474. /** @hidden */
  25475. _rigCameras: Camera[];
  25476. /** @hidden */
  25477. _rigPostProcess: Nullable<PostProcess>;
  25478. protected _webvrViewMatrix: Matrix;
  25479. /** @hidden */
  25480. _skipRendering: boolean;
  25481. /** @hidden */
  25482. _projectionMatrix: Matrix;
  25483. /** @hidden */
  25484. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25485. /** @hidden */
  25486. _activeMeshes: SmartArray<AbstractMesh>;
  25487. protected _globalPosition: Vector3;
  25488. /** @hidden */
  25489. _computedViewMatrix: Matrix;
  25490. private _doNotComputeProjectionMatrix;
  25491. private _transformMatrix;
  25492. private _frustumPlanes;
  25493. private _refreshFrustumPlanes;
  25494. private _storedFov;
  25495. private _stateStored;
  25496. /**
  25497. * Instantiates a new camera object.
  25498. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25499. * @see http://doc.babylonjs.com/features/cameras
  25500. * @param name Defines the name of the camera in the scene
  25501. * @param position Defines the position of the camera
  25502. * @param scene Defines the scene the camera belongs too
  25503. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25504. */
  25505. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25506. /**
  25507. * Store current camera state (fov, position, etc..)
  25508. * @returns the camera
  25509. */
  25510. storeState(): Camera;
  25511. /**
  25512. * Restores the camera state values if it has been stored. You must call storeState() first
  25513. */
  25514. protected _restoreStateValues(): boolean;
  25515. /**
  25516. * Restored camera state. You must call storeState() first.
  25517. * @returns true if restored and false otherwise
  25518. */
  25519. restoreState(): boolean;
  25520. /**
  25521. * Gets the class name of the camera.
  25522. * @returns the class name
  25523. */
  25524. getClassName(): string;
  25525. /** @hidden */
  25526. readonly _isCamera: boolean;
  25527. /**
  25528. * Gets a string representation of the camera useful for debug purpose.
  25529. * @param fullDetails Defines that a more verboe level of logging is required
  25530. * @returns the string representation
  25531. */
  25532. toString(fullDetails?: boolean): string;
  25533. /**
  25534. * Gets the current world space position of the camera.
  25535. */
  25536. readonly globalPosition: Vector3;
  25537. /**
  25538. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25539. * @returns the active meshe list
  25540. */
  25541. getActiveMeshes(): SmartArray<AbstractMesh>;
  25542. /**
  25543. * Check wether a mesh is part of the current active mesh list of the camera
  25544. * @param mesh Defines the mesh to check
  25545. * @returns true if active, false otherwise
  25546. */
  25547. isActiveMesh(mesh: Mesh): boolean;
  25548. /**
  25549. * Is this camera ready to be used/rendered
  25550. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25551. * @return true if the camera is ready
  25552. */
  25553. isReady(completeCheck?: boolean): boolean;
  25554. /** @hidden */
  25555. _initCache(): void;
  25556. /** @hidden */
  25557. _updateCache(ignoreParentClass?: boolean): void;
  25558. /** @hidden */
  25559. _isSynchronized(): boolean;
  25560. /** @hidden */
  25561. _isSynchronizedViewMatrix(): boolean;
  25562. /** @hidden */
  25563. _isSynchronizedProjectionMatrix(): boolean;
  25564. /**
  25565. * Attach the input controls to a specific dom element to get the input from.
  25566. * @param element Defines the element the controls should be listened from
  25567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25568. */
  25569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25570. /**
  25571. * Detach the current controls from the specified dom element.
  25572. * @param element Defines the element to stop listening the inputs from
  25573. */
  25574. detachControl(element: HTMLElement): void;
  25575. /**
  25576. * Update the camera state according to the different inputs gathered during the frame.
  25577. */
  25578. update(): void;
  25579. /** @hidden */
  25580. _checkInputs(): void;
  25581. /** @hidden */
  25582. readonly rigCameras: Camera[];
  25583. /**
  25584. * Gets the post process used by the rig cameras
  25585. */
  25586. readonly rigPostProcess: Nullable<PostProcess>;
  25587. /**
  25588. * Internal, gets the first post proces.
  25589. * @returns the first post process to be run on this camera.
  25590. */
  25591. _getFirstPostProcess(): Nullable<PostProcess>;
  25592. private _cascadePostProcessesToRigCams;
  25593. /**
  25594. * Attach a post process to the camera.
  25595. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25596. * @param postProcess The post process to attach to the camera
  25597. * @param insertAt The position of the post process in case several of them are in use in the scene
  25598. * @returns the position the post process has been inserted at
  25599. */
  25600. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25601. /**
  25602. * Detach a post process to the camera.
  25603. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25604. * @param postProcess The post process to detach from the camera
  25605. */
  25606. detachPostProcess(postProcess: PostProcess): void;
  25607. /**
  25608. * Gets the current world matrix of the camera
  25609. */
  25610. getWorldMatrix(): Matrix;
  25611. /** @hidden */
  25612. _getViewMatrix(): Matrix;
  25613. /**
  25614. * Gets the current view matrix of the camera.
  25615. * @param force forces the camera to recompute the matrix without looking at the cached state
  25616. * @returns the view matrix
  25617. */
  25618. getViewMatrix(force?: boolean): Matrix;
  25619. /**
  25620. * Freeze the projection matrix.
  25621. * It will prevent the cache check of the camera projection compute and can speed up perf
  25622. * if no parameter of the camera are meant to change
  25623. * @param projection Defines manually a projection if necessary
  25624. */
  25625. freezeProjectionMatrix(projection?: Matrix): void;
  25626. /**
  25627. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25628. */
  25629. unfreezeProjectionMatrix(): void;
  25630. /**
  25631. * Gets the current projection matrix of the camera.
  25632. * @param force forces the camera to recompute the matrix without looking at the cached state
  25633. * @returns the projection matrix
  25634. */
  25635. getProjectionMatrix(force?: boolean): Matrix;
  25636. /**
  25637. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25638. * @returns a Matrix
  25639. */
  25640. getTransformationMatrix(): Matrix;
  25641. private _updateFrustumPlanes;
  25642. /**
  25643. * Checks if a cullable object (mesh...) is in the camera frustum
  25644. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25645. * @param target The object to check
  25646. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25647. * @returns true if the object is in frustum otherwise false
  25648. */
  25649. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25650. /**
  25651. * Checks if a cullable object (mesh...) is in the camera frustum
  25652. * Unlike isInFrustum this cheks the full bounding box
  25653. * @param target The object to check
  25654. * @returns true if the object is in frustum otherwise false
  25655. */
  25656. isCompletelyInFrustum(target: ICullable): boolean;
  25657. /**
  25658. * Gets a ray in the forward direction from the camera.
  25659. * @param length Defines the length of the ray to create
  25660. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25661. * @param origin Defines the start point of the ray which defaults to the camera position
  25662. * @returns the forward ray
  25663. */
  25664. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25665. /**
  25666. * Releases resources associated with this node.
  25667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25669. */
  25670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25671. /** @hidden */
  25672. _isLeftCamera: boolean;
  25673. /**
  25674. * Gets the left camera of a rig setup in case of Rigged Camera
  25675. */
  25676. readonly isLeftCamera: boolean;
  25677. /** @hidden */
  25678. _isRightCamera: boolean;
  25679. /**
  25680. * Gets the right camera of a rig setup in case of Rigged Camera
  25681. */
  25682. readonly isRightCamera: boolean;
  25683. /**
  25684. * Gets the left camera of a rig setup in case of Rigged Camera
  25685. */
  25686. readonly leftCamera: Nullable<FreeCamera>;
  25687. /**
  25688. * Gets the right camera of a rig setup in case of Rigged Camera
  25689. */
  25690. readonly rightCamera: Nullable<FreeCamera>;
  25691. /**
  25692. * Gets the left camera target of a rig setup in case of Rigged Camera
  25693. * @returns the target position
  25694. */
  25695. getLeftTarget(): Nullable<Vector3>;
  25696. /**
  25697. * Gets the right camera target of a rig setup in case of Rigged Camera
  25698. * @returns the target position
  25699. */
  25700. getRightTarget(): Nullable<Vector3>;
  25701. /**
  25702. * @hidden
  25703. */
  25704. setCameraRigMode(mode: number, rigParams: any): void;
  25705. /** @hidden */
  25706. static _setStereoscopicRigMode(camera: Camera): void;
  25707. /** @hidden */
  25708. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25709. /** @hidden */
  25710. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25711. /** @hidden */
  25712. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25713. /** @hidden */
  25714. _getVRProjectionMatrix(): Matrix;
  25715. protected _updateCameraRotationMatrix(): void;
  25716. protected _updateWebVRCameraRotationMatrix(): void;
  25717. /**
  25718. * This function MUST be overwritten by the different WebVR cameras available.
  25719. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25720. * @hidden
  25721. */
  25722. _getWebVRProjectionMatrix(): Matrix;
  25723. /**
  25724. * This function MUST be overwritten by the different WebVR cameras available.
  25725. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25726. * @hidden
  25727. */
  25728. _getWebVRViewMatrix(): Matrix;
  25729. /** @hidden */
  25730. setCameraRigParameter(name: string, value: any): void;
  25731. /**
  25732. * needs to be overridden by children so sub has required properties to be copied
  25733. * @hidden
  25734. */
  25735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25736. /**
  25737. * May need to be overridden by children
  25738. * @hidden
  25739. */
  25740. _updateRigCameras(): void;
  25741. /** @hidden */
  25742. _setupInputs(): void;
  25743. /**
  25744. * Serialiaze the camera setup to a json represention
  25745. * @returns the JSON representation
  25746. */
  25747. serialize(): any;
  25748. /**
  25749. * Clones the current camera.
  25750. * @param name The cloned camera name
  25751. * @returns the cloned camera
  25752. */
  25753. clone(name: string): Camera;
  25754. /**
  25755. * Gets the direction of the camera relative to a given local axis.
  25756. * @param localAxis Defines the reference axis to provide a relative direction.
  25757. * @return the direction
  25758. */
  25759. getDirection(localAxis: Vector3): Vector3;
  25760. /**
  25761. * Returns the current camera absolute rotation
  25762. */
  25763. readonly absoluteRotation: Quaternion;
  25764. /**
  25765. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25766. * @param localAxis Defines the reference axis to provide a relative direction.
  25767. * @param result Defines the vector to store the result in
  25768. */
  25769. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25770. /**
  25771. * Gets a camera constructor for a given camera type
  25772. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25773. * @param name The name of the camera the result will be able to instantiate
  25774. * @param scene The scene the result will construct the camera in
  25775. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25776. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25777. * @returns a factory method to construc the camera
  25778. */
  25779. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25780. /**
  25781. * Compute the world matrix of the camera.
  25782. * @returns the camera workd matrix
  25783. */
  25784. computeWorldMatrix(): Matrix;
  25785. /**
  25786. * Parse a JSON and creates the camera from the parsed information
  25787. * @param parsedCamera The JSON to parse
  25788. * @param scene The scene to instantiate the camera in
  25789. * @returns the newly constructed camera
  25790. */
  25791. static Parse(parsedCamera: any, scene: Scene): Camera;
  25792. }
  25793. }
  25794. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25795. import { Nullable } from "babylonjs/types";
  25796. import { Scene } from "babylonjs/scene";
  25797. import { Vector4 } from "babylonjs/Maths/math.vector";
  25798. import { Mesh } from "babylonjs/Meshes/mesh";
  25799. /**
  25800. * Class containing static functions to help procedurally build meshes
  25801. */
  25802. export class DiscBuilder {
  25803. /**
  25804. * Creates a plane polygonal mesh. By default, this is a disc
  25805. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25806. * * 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
  25807. * * 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
  25808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25811. * @param name defines the name of the mesh
  25812. * @param options defines the options used to create the mesh
  25813. * @param scene defines the hosting scene
  25814. * @returns the plane polygonal mesh
  25815. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25816. */
  25817. static CreateDisc(name: string, options: {
  25818. radius?: number;
  25819. tessellation?: number;
  25820. arc?: number;
  25821. updatable?: boolean;
  25822. sideOrientation?: number;
  25823. frontUVs?: Vector4;
  25824. backUVs?: Vector4;
  25825. }, scene?: Nullable<Scene>): Mesh;
  25826. }
  25827. }
  25828. declare module "babylonjs/Particles/solidParticleSystem" {
  25829. import { Vector3 } from "babylonjs/Maths/math.vector";
  25830. import { Mesh } from "babylonjs/Meshes/mesh";
  25831. import { Scene, IDisposable } from "babylonjs/scene";
  25832. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25833. /**
  25834. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25835. *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.
  25836. * The SPS is also a particle system. It provides some methods to manage the particles.
  25837. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25838. *
  25839. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25840. */
  25841. export class SolidParticleSystem implements IDisposable {
  25842. /**
  25843. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25844. * Example : var p = SPS.particles[i];
  25845. */
  25846. particles: SolidParticle[];
  25847. /**
  25848. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25849. */
  25850. nbParticles: number;
  25851. /**
  25852. * If the particles must ever face the camera (default false). Useful for planar particles.
  25853. */
  25854. billboard: boolean;
  25855. /**
  25856. * Recompute normals when adding a shape
  25857. */
  25858. recomputeNormals: boolean;
  25859. /**
  25860. * This a counter ofr your own usage. It's not set by any SPS functions.
  25861. */
  25862. counter: number;
  25863. /**
  25864. * The SPS name. This name is also given to the underlying mesh.
  25865. */
  25866. name: string;
  25867. /**
  25868. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25869. */
  25870. mesh: Mesh;
  25871. /**
  25872. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25873. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25874. */
  25875. vars: any;
  25876. /**
  25877. * This array is populated when the SPS is set as 'pickable'.
  25878. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25879. * Each element of this array is an object `{idx: int, faceId: int}`.
  25880. * `idx` is the picked particle index in the `SPS.particles` array
  25881. * `faceId` is the picked face index counted within this particle.
  25882. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25883. */
  25884. pickedParticles: {
  25885. idx: number;
  25886. faceId: number;
  25887. }[];
  25888. /**
  25889. * This array is populated when `enableDepthSort` is set to true.
  25890. * Each element of this array is an instance of the class DepthSortedParticle.
  25891. */
  25892. depthSortedParticles: DepthSortedParticle[];
  25893. /**
  25894. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25895. * @hidden
  25896. */
  25897. _bSphereOnly: boolean;
  25898. /**
  25899. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25900. * @hidden
  25901. */
  25902. _bSphereRadiusFactor: number;
  25903. private _scene;
  25904. private _positions;
  25905. private _indices;
  25906. private _normals;
  25907. private _colors;
  25908. private _uvs;
  25909. private _indices32;
  25910. private _positions32;
  25911. private _normals32;
  25912. private _fixedNormal32;
  25913. private _colors32;
  25914. private _uvs32;
  25915. private _index;
  25916. private _updatable;
  25917. private _pickable;
  25918. private _isVisibilityBoxLocked;
  25919. private _alwaysVisible;
  25920. private _depthSort;
  25921. private _shapeCounter;
  25922. private _copy;
  25923. private _color;
  25924. private _computeParticleColor;
  25925. private _computeParticleTexture;
  25926. private _computeParticleRotation;
  25927. private _computeParticleVertex;
  25928. private _computeBoundingBox;
  25929. private _depthSortParticles;
  25930. private _camera;
  25931. private _mustUnrotateFixedNormals;
  25932. private _particlesIntersect;
  25933. private _needs32Bits;
  25934. /**
  25935. * Creates a SPS (Solid Particle System) object.
  25936. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25937. * @param scene (Scene) is the scene in which the SPS is added.
  25938. * @param options defines the options of the sps e.g.
  25939. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25940. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25941. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25942. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25943. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25944. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25945. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25946. */
  25947. constructor(name: string, scene: Scene, options?: {
  25948. updatable?: boolean;
  25949. isPickable?: boolean;
  25950. enableDepthSort?: boolean;
  25951. particleIntersection?: boolean;
  25952. boundingSphereOnly?: boolean;
  25953. bSphereRadiusFactor?: number;
  25954. });
  25955. /**
  25956. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25957. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25958. * @returns the created mesh
  25959. */
  25960. buildMesh(): Mesh;
  25961. /**
  25962. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25963. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25964. * Thus the particles generated from `digest()` have their property `position` set yet.
  25965. * @param mesh ( Mesh ) is the mesh to be digested
  25966. * @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
  25967. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25968. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25969. * @returns the current SPS
  25970. */
  25971. digest(mesh: Mesh, options?: {
  25972. facetNb?: number;
  25973. number?: number;
  25974. delta?: number;
  25975. }): SolidParticleSystem;
  25976. private _unrotateFixedNormals;
  25977. private _resetCopy;
  25978. private _meshBuilder;
  25979. private _posToShape;
  25980. private _uvsToShapeUV;
  25981. private _addParticle;
  25982. /**
  25983. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25984. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25985. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25986. * @param nb (positive integer) the number of particles to be created from this model
  25987. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25988. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25989. * @returns the number of shapes in the system
  25990. */
  25991. addShape(mesh: Mesh, nb: number, options?: {
  25992. positionFunction?: any;
  25993. vertexFunction?: any;
  25994. }): number;
  25995. private _rebuildParticle;
  25996. /**
  25997. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25998. * @returns the SPS.
  25999. */
  26000. rebuildMesh(): SolidParticleSystem;
  26001. /**
  26002. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26003. * This method calls `updateParticle()` for each particle of the SPS.
  26004. * For an animated SPS, it is usually called within the render loop.
  26005. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26006. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26007. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26008. * @returns the SPS.
  26009. */
  26010. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26011. /**
  26012. * Disposes the SPS.
  26013. */
  26014. dispose(): void;
  26015. /**
  26016. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26018. * @returns the SPS.
  26019. */
  26020. refreshVisibleSize(): SolidParticleSystem;
  26021. /**
  26022. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26023. * @param size the size (float) of the visibility box
  26024. * note : this doesn't lock the SPS mesh bounding box.
  26025. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26026. */
  26027. setVisibilityBox(size: number): void;
  26028. /**
  26029. * Gets whether the SPS as always visible or not
  26030. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26031. */
  26032. /**
  26033. * Sets the SPS as always visible or not
  26034. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26035. */
  26036. isAlwaysVisible: boolean;
  26037. /**
  26038. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26039. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26040. */
  26041. /**
  26042. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26043. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26044. */
  26045. isVisibilityBoxLocked: boolean;
  26046. /**
  26047. * Tells to `setParticles()` to compute the particle rotations or not.
  26048. * Default value : true. The SPS is faster when it's set to false.
  26049. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26050. */
  26051. /**
  26052. * Gets if `setParticles()` computes the particle rotations or not.
  26053. * Default value : true. The SPS is faster when it's set to false.
  26054. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26055. */
  26056. computeParticleRotation: boolean;
  26057. /**
  26058. * Tells to `setParticles()` to compute the particle colors or not.
  26059. * Default value : true. The SPS is faster when it's set to false.
  26060. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26061. */
  26062. /**
  26063. * Gets if `setParticles()` computes the particle colors or not.
  26064. * Default value : true. The SPS is faster when it's set to false.
  26065. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26066. */
  26067. computeParticleColor: boolean;
  26068. /**
  26069. * Gets if `setParticles()` computes the particle textures or not.
  26070. * Default value : true. The SPS is faster when it's set to false.
  26071. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26072. */
  26073. computeParticleTexture: boolean;
  26074. /**
  26075. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26076. * Default value : false. The SPS is faster when it's set to false.
  26077. * Note : the particle custom vertex positions aren't stored values.
  26078. */
  26079. /**
  26080. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26081. * Default value : false. The SPS is faster when it's set to false.
  26082. * Note : the particle custom vertex positions aren't stored values.
  26083. */
  26084. computeParticleVertex: boolean;
  26085. /**
  26086. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26087. */
  26088. /**
  26089. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26090. */
  26091. computeBoundingBox: boolean;
  26092. /**
  26093. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26094. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26095. * Default : `true`
  26096. */
  26097. /**
  26098. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26099. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26100. * Default : `true`
  26101. */
  26102. depthSortParticles: boolean;
  26103. /**
  26104. * This function does nothing. It may be overwritten to set all the particle first values.
  26105. * The SPS doesn't call this function, you may have to call it by your own.
  26106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26107. */
  26108. initParticles(): void;
  26109. /**
  26110. * This function does nothing. It may be overwritten to recycle a particle.
  26111. * The SPS doesn't call this function, you may have to call it by your own.
  26112. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26113. * @param particle The particle to recycle
  26114. * @returns the recycled particle
  26115. */
  26116. recycleParticle(particle: SolidParticle): SolidParticle;
  26117. /**
  26118. * Updates a particle : this function should be overwritten by the user.
  26119. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26120. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26121. * @example : just set a particle position or velocity and recycle conditions
  26122. * @param particle The particle to update
  26123. * @returns the updated particle
  26124. */
  26125. updateParticle(particle: SolidParticle): SolidParticle;
  26126. /**
  26127. * Updates a vertex of a particle : it can be overwritten by the user.
  26128. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26129. * @param particle the current particle
  26130. * @param vertex the current index of the current particle
  26131. * @param pt the index of the current vertex in the particle shape
  26132. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26133. * @example : just set a vertex particle position
  26134. * @returns the updated vertex
  26135. */
  26136. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26137. /**
  26138. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26139. * This does nothing and may be overwritten by the user.
  26140. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26141. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26142. * @param update the boolean update value actually passed to setParticles()
  26143. */
  26144. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26145. /**
  26146. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26147. * This will be passed three parameters.
  26148. * This does nothing and may be overwritten by the user.
  26149. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26150. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26151. * @param update the boolean update value actually passed to setParticles()
  26152. */
  26153. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26154. }
  26155. }
  26156. declare module "babylonjs/Particles/solidParticle" {
  26157. import { Nullable } from "babylonjs/types";
  26158. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26159. import { Color4 } from "babylonjs/Maths/math.color";
  26160. import { Mesh } from "babylonjs/Meshes/mesh";
  26161. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26162. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26163. import { Plane } from "babylonjs/Maths/math.plane";
  26164. /**
  26165. * Represents one particle of a solid particle system.
  26166. */
  26167. export class SolidParticle {
  26168. /**
  26169. * particle global index
  26170. */
  26171. idx: number;
  26172. /**
  26173. * The color of the particle
  26174. */
  26175. color: Nullable<Color4>;
  26176. /**
  26177. * The world space position of the particle.
  26178. */
  26179. position: Vector3;
  26180. /**
  26181. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26182. */
  26183. rotation: Vector3;
  26184. /**
  26185. * The world space rotation quaternion of the particle.
  26186. */
  26187. rotationQuaternion: Nullable<Quaternion>;
  26188. /**
  26189. * The scaling of the particle.
  26190. */
  26191. scaling: Vector3;
  26192. /**
  26193. * The uvs of the particle.
  26194. */
  26195. uvs: Vector4;
  26196. /**
  26197. * The current speed of the particle.
  26198. */
  26199. velocity: Vector3;
  26200. /**
  26201. * The pivot point in the particle local space.
  26202. */
  26203. pivot: Vector3;
  26204. /**
  26205. * Must the particle be translated from its pivot point in its local space ?
  26206. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26207. * Default : false
  26208. */
  26209. translateFromPivot: boolean;
  26210. /**
  26211. * Is the particle active or not ?
  26212. */
  26213. alive: boolean;
  26214. /**
  26215. * Is the particle visible or not ?
  26216. */
  26217. isVisible: boolean;
  26218. /**
  26219. * Index of this particle in the global "positions" array (Internal use)
  26220. * @hidden
  26221. */
  26222. _pos: number;
  26223. /**
  26224. * @hidden Index of this particle in the global "indices" array (Internal use)
  26225. */
  26226. _ind: number;
  26227. /**
  26228. * @hidden ModelShape of this particle (Internal use)
  26229. */
  26230. _model: ModelShape;
  26231. /**
  26232. * ModelShape id of this particle
  26233. */
  26234. shapeId: number;
  26235. /**
  26236. * Index of the particle in its shape id
  26237. */
  26238. idxInShape: number;
  26239. /**
  26240. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26241. */
  26242. _modelBoundingInfo: BoundingInfo;
  26243. /**
  26244. * @hidden Particle BoundingInfo object (Internal use)
  26245. */
  26246. _boundingInfo: BoundingInfo;
  26247. /**
  26248. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26249. */
  26250. _sps: SolidParticleSystem;
  26251. /**
  26252. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26253. */
  26254. _stillInvisible: boolean;
  26255. /**
  26256. * @hidden Last computed particle rotation matrix
  26257. */
  26258. _rotationMatrix: number[];
  26259. /**
  26260. * Parent particle Id, if any.
  26261. * Default null.
  26262. */
  26263. parentId: Nullable<number>;
  26264. /**
  26265. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26266. * The possible values are :
  26267. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26268. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26269. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26270. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26271. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26272. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26273. * */
  26274. cullingStrategy: number;
  26275. /**
  26276. * @hidden Internal global position in the SPS.
  26277. */
  26278. _globalPosition: Vector3;
  26279. /**
  26280. * Creates a Solid Particle object.
  26281. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26282. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26283. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26284. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26285. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26286. * @param shapeId (integer) is the model shape identifier in the SPS.
  26287. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26288. * @param sps defines the sps it is associated to
  26289. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26290. */
  26291. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26292. /**
  26293. * Legacy support, changed scale to scaling
  26294. */
  26295. /**
  26296. * Legacy support, changed scale to scaling
  26297. */
  26298. scale: Vector3;
  26299. /**
  26300. * Legacy support, changed quaternion to rotationQuaternion
  26301. */
  26302. /**
  26303. * Legacy support, changed quaternion to rotationQuaternion
  26304. */
  26305. quaternion: Nullable<Quaternion>;
  26306. /**
  26307. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26308. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26309. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26310. * @returns true if it intersects
  26311. */
  26312. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26313. /**
  26314. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26315. * A particle is in the frustum if its bounding box intersects the frustum
  26316. * @param frustumPlanes defines the frustum to test
  26317. * @returns true if the particle is in the frustum planes
  26318. */
  26319. isInFrustum(frustumPlanes: Plane[]): boolean;
  26320. /**
  26321. * get the rotation matrix of the particle
  26322. * @hidden
  26323. */
  26324. getRotationMatrix(m: Matrix): void;
  26325. }
  26326. /**
  26327. * Represents the shape of the model used by one particle of a solid particle system.
  26328. * SPS internal tool, don't use it manually.
  26329. */
  26330. export class ModelShape {
  26331. /**
  26332. * The shape id
  26333. * @hidden
  26334. */
  26335. shapeID: number;
  26336. /**
  26337. * flat array of model positions (internal use)
  26338. * @hidden
  26339. */
  26340. _shape: Vector3[];
  26341. /**
  26342. * flat array of model UVs (internal use)
  26343. * @hidden
  26344. */
  26345. _shapeUV: number[];
  26346. /**
  26347. * length of the shape in the model indices array (internal use)
  26348. * @hidden
  26349. */
  26350. _indicesLength: number;
  26351. /**
  26352. * Custom position function (internal use)
  26353. * @hidden
  26354. */
  26355. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26356. /**
  26357. * Custom vertex function (internal use)
  26358. * @hidden
  26359. */
  26360. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26361. /**
  26362. * 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.
  26363. * SPS internal tool, don't use it manually.
  26364. * @hidden
  26365. */
  26366. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26367. }
  26368. /**
  26369. * Represents a Depth Sorted Particle in the solid particle system.
  26370. */
  26371. export class DepthSortedParticle {
  26372. /**
  26373. * Index of the particle in the "indices" array
  26374. */
  26375. ind: number;
  26376. /**
  26377. * Length of the particle shape in the "indices" array
  26378. */
  26379. indicesLength: number;
  26380. /**
  26381. * Squared distance from the particle to the camera
  26382. */
  26383. sqDistance: number;
  26384. }
  26385. }
  26386. declare module "babylonjs/Collisions/meshCollisionData" {
  26387. import { Collider } from "babylonjs/Collisions/collider";
  26388. import { Vector3 } from "babylonjs/Maths/math.vector";
  26389. import { Nullable } from "babylonjs/types";
  26390. import { Observer } from "babylonjs/Misc/observable";
  26391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26392. /**
  26393. * @hidden
  26394. */
  26395. export class _MeshCollisionData {
  26396. _checkCollisions: boolean;
  26397. _collisionMask: number;
  26398. _collisionGroup: number;
  26399. _collider: Nullable<Collider>;
  26400. _oldPositionForCollisions: Vector3;
  26401. _diffPositionForCollisions: Vector3;
  26402. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26403. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26404. }
  26405. }
  26406. declare module "babylonjs/Meshes/abstractMesh" {
  26407. import { Observable } from "babylonjs/Misc/observable";
  26408. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26409. import { Camera } from "babylonjs/Cameras/camera";
  26410. import { Scene, IDisposable } from "babylonjs/scene";
  26411. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26412. import { Node } from "babylonjs/node";
  26413. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26416. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26417. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26418. import { Material } from "babylonjs/Materials/material";
  26419. import { Light } from "babylonjs/Lights/light";
  26420. import { Skeleton } from "babylonjs/Bones/skeleton";
  26421. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26422. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26423. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26424. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26425. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26426. import { Plane } from "babylonjs/Maths/math.plane";
  26427. import { Ray } from "babylonjs/Culling/ray";
  26428. import { Collider } from "babylonjs/Collisions/collider";
  26429. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26430. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26431. /** @hidden */
  26432. class _FacetDataStorage {
  26433. facetPositions: Vector3[];
  26434. facetNormals: Vector3[];
  26435. facetPartitioning: number[][];
  26436. facetNb: number;
  26437. partitioningSubdivisions: number;
  26438. partitioningBBoxRatio: number;
  26439. facetDataEnabled: boolean;
  26440. facetParameters: any;
  26441. bbSize: Vector3;
  26442. subDiv: {
  26443. max: number;
  26444. X: number;
  26445. Y: number;
  26446. Z: number;
  26447. };
  26448. facetDepthSort: boolean;
  26449. facetDepthSortEnabled: boolean;
  26450. depthSortedIndices: IndicesArray;
  26451. depthSortedFacets: {
  26452. ind: number;
  26453. sqDistance: number;
  26454. }[];
  26455. facetDepthSortFunction: (f1: {
  26456. ind: number;
  26457. sqDistance: number;
  26458. }, f2: {
  26459. ind: number;
  26460. sqDistance: number;
  26461. }) => number;
  26462. facetDepthSortFrom: Vector3;
  26463. facetDepthSortOrigin: Vector3;
  26464. invertedMatrix: Matrix;
  26465. }
  26466. /**
  26467. * @hidden
  26468. **/
  26469. class _InternalAbstractMeshDataInfo {
  26470. _hasVertexAlpha: boolean;
  26471. _useVertexColors: boolean;
  26472. _numBoneInfluencers: number;
  26473. _applyFog: boolean;
  26474. _receiveShadows: boolean;
  26475. _facetData: _FacetDataStorage;
  26476. _visibility: number;
  26477. _skeleton: Nullable<Skeleton>;
  26478. _layerMask: number;
  26479. _computeBonesUsingShaders: boolean;
  26480. _isActive: boolean;
  26481. _onlyForInstances: boolean;
  26482. _isActiveIntermediate: boolean;
  26483. _onlyForInstancesIntermediate: boolean;
  26484. }
  26485. /**
  26486. * Class used to store all common mesh properties
  26487. */
  26488. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26489. /** No occlusion */
  26490. static OCCLUSION_TYPE_NONE: number;
  26491. /** Occlusion set to optimisitic */
  26492. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26493. /** Occlusion set to strict */
  26494. static OCCLUSION_TYPE_STRICT: number;
  26495. /** Use an accurante occlusion algorithm */
  26496. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26497. /** Use a conservative occlusion algorithm */
  26498. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26499. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26500. * Test order :
  26501. * Is the bounding sphere outside the frustum ?
  26502. * If not, are the bounding box vertices outside the frustum ?
  26503. * It not, then the cullable object is in the frustum.
  26504. */
  26505. static readonly CULLINGSTRATEGY_STANDARD: number;
  26506. /** Culling strategy : Bounding Sphere Only.
  26507. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26508. * It's also less accurate than the standard because some not visible objects can still be selected.
  26509. * Test : is the bounding sphere outside the frustum ?
  26510. * If not, then the cullable object is in the frustum.
  26511. */
  26512. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26513. /** Culling strategy : Optimistic Inclusion.
  26514. * This in an inclusion test first, then the standard exclusion test.
  26515. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26516. * 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.
  26517. * Anyway, it's as accurate as the standard strategy.
  26518. * Test :
  26519. * Is the cullable object bounding sphere center in the frustum ?
  26520. * If not, apply the default culling strategy.
  26521. */
  26522. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26523. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26524. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26525. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26526. * 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.
  26527. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26528. * Test :
  26529. * Is the cullable object bounding sphere center in the frustum ?
  26530. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26531. */
  26532. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26533. /**
  26534. * No billboard
  26535. */
  26536. static readonly BILLBOARDMODE_NONE: number;
  26537. /** Billboard on X axis */
  26538. static readonly BILLBOARDMODE_X: number;
  26539. /** Billboard on Y axis */
  26540. static readonly BILLBOARDMODE_Y: number;
  26541. /** Billboard on Z axis */
  26542. static readonly BILLBOARDMODE_Z: number;
  26543. /** Billboard on all axes */
  26544. static readonly BILLBOARDMODE_ALL: number;
  26545. /** Billboard on using position instead of orientation */
  26546. static readonly BILLBOARDMODE_USE_POSITION: number;
  26547. /** @hidden */
  26548. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26549. /**
  26550. * The culling strategy to use to check whether the mesh must be rendered or not.
  26551. * This value can be changed at any time and will be used on the next render mesh selection.
  26552. * The possible values are :
  26553. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26554. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26555. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26557. * Please read each static variable documentation to get details about the culling process.
  26558. * */
  26559. cullingStrategy: number;
  26560. /**
  26561. * Gets the number of facets in the mesh
  26562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26563. */
  26564. readonly facetNb: number;
  26565. /**
  26566. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26568. */
  26569. partitioningSubdivisions: number;
  26570. /**
  26571. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26572. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26574. */
  26575. partitioningBBoxRatio: number;
  26576. /**
  26577. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26578. * Works only for updatable meshes.
  26579. * Doesn't work with multi-materials
  26580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26581. */
  26582. mustDepthSortFacets: boolean;
  26583. /**
  26584. * The location (Vector3) where the facet depth sort must be computed from.
  26585. * By default, the active camera position.
  26586. * Used only when facet depth sort is enabled
  26587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26588. */
  26589. facetDepthSortFrom: Vector3;
  26590. /**
  26591. * gets a boolean indicating if facetData is enabled
  26592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26593. */
  26594. readonly isFacetDataEnabled: boolean;
  26595. /** @hidden */
  26596. _updateNonUniformScalingState(value: boolean): boolean;
  26597. /**
  26598. * An event triggered when this mesh collides with another one
  26599. */
  26600. onCollideObservable: Observable<AbstractMesh>;
  26601. /** Set a function to call when this mesh collides with another one */
  26602. onCollide: () => void;
  26603. /**
  26604. * An event triggered when the collision's position changes
  26605. */
  26606. onCollisionPositionChangeObservable: Observable<Vector3>;
  26607. /** Set a function to call when the collision's position changes */
  26608. onCollisionPositionChange: () => void;
  26609. /**
  26610. * An event triggered when material is changed
  26611. */
  26612. onMaterialChangedObservable: Observable<AbstractMesh>;
  26613. /**
  26614. * Gets or sets the orientation for POV movement & rotation
  26615. */
  26616. definedFacingForward: boolean;
  26617. /** @hidden */
  26618. _occlusionQuery: Nullable<WebGLQuery>;
  26619. /** @hidden */
  26620. _renderingGroup: Nullable<RenderingGroup>;
  26621. /**
  26622. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26623. */
  26624. /**
  26625. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26626. */
  26627. visibility: number;
  26628. /** Gets or sets the alpha index used to sort transparent meshes
  26629. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26630. */
  26631. alphaIndex: number;
  26632. /**
  26633. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26634. */
  26635. isVisible: boolean;
  26636. /**
  26637. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26638. */
  26639. isPickable: boolean;
  26640. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26641. showSubMeshesBoundingBox: boolean;
  26642. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26643. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26644. */
  26645. isBlocker: boolean;
  26646. /**
  26647. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26648. */
  26649. enablePointerMoveEvents: boolean;
  26650. /**
  26651. * Specifies the rendering group id for this mesh (0 by default)
  26652. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26653. */
  26654. renderingGroupId: number;
  26655. private _material;
  26656. /** Gets or sets current material */
  26657. material: Nullable<Material>;
  26658. /**
  26659. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26660. * @see http://doc.babylonjs.com/babylon101/shadows
  26661. */
  26662. receiveShadows: boolean;
  26663. /** Defines color to use when rendering outline */
  26664. outlineColor: Color3;
  26665. /** Define width to use when rendering outline */
  26666. outlineWidth: number;
  26667. /** Defines color to use when rendering overlay */
  26668. overlayColor: Color3;
  26669. /** Defines alpha to use when rendering overlay */
  26670. overlayAlpha: number;
  26671. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26672. hasVertexAlpha: boolean;
  26673. /** 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) */
  26674. useVertexColors: boolean;
  26675. /**
  26676. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26677. */
  26678. computeBonesUsingShaders: boolean;
  26679. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26680. numBoneInfluencers: number;
  26681. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26682. applyFog: boolean;
  26683. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26684. useOctreeForRenderingSelection: boolean;
  26685. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26686. useOctreeForPicking: boolean;
  26687. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26688. useOctreeForCollisions: boolean;
  26689. /**
  26690. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26691. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26692. */
  26693. layerMask: number;
  26694. /**
  26695. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26696. */
  26697. alwaysSelectAsActiveMesh: boolean;
  26698. /**
  26699. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26700. */
  26701. doNotSyncBoundingInfo: boolean;
  26702. /**
  26703. * Gets or sets the current action manager
  26704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26705. */
  26706. actionManager: Nullable<AbstractActionManager>;
  26707. private _meshCollisionData;
  26708. /**
  26709. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26711. */
  26712. ellipsoid: Vector3;
  26713. /**
  26714. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26716. */
  26717. ellipsoidOffset: Vector3;
  26718. /**
  26719. * Gets or sets a collision mask used to mask collisions (default is -1).
  26720. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26721. */
  26722. collisionMask: number;
  26723. /**
  26724. * Gets or sets the current collision group mask (-1 by default).
  26725. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26726. */
  26727. collisionGroup: number;
  26728. /**
  26729. * Defines edge width used when edgesRenderer is enabled
  26730. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26731. */
  26732. edgesWidth: number;
  26733. /**
  26734. * Defines edge color used when edgesRenderer is enabled
  26735. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26736. */
  26737. edgesColor: Color4;
  26738. /** @hidden */
  26739. _edgesRenderer: Nullable<IEdgesRenderer>;
  26740. /** @hidden */
  26741. _masterMesh: Nullable<AbstractMesh>;
  26742. /** @hidden */
  26743. _boundingInfo: Nullable<BoundingInfo>;
  26744. /** @hidden */
  26745. _renderId: number;
  26746. /**
  26747. * Gets or sets the list of subMeshes
  26748. * @see http://doc.babylonjs.com/how_to/multi_materials
  26749. */
  26750. subMeshes: SubMesh[];
  26751. /** @hidden */
  26752. _intersectionsInProgress: AbstractMesh[];
  26753. /** @hidden */
  26754. _unIndexed: boolean;
  26755. /** @hidden */
  26756. _lightSources: Light[];
  26757. /** Gets the list of lights affecting that mesh */
  26758. readonly lightSources: Light[];
  26759. /** @hidden */
  26760. readonly _positions: Nullable<Vector3[]>;
  26761. /** @hidden */
  26762. _waitingData: {
  26763. lods: Nullable<any>;
  26764. actions: Nullable<any>;
  26765. freezeWorldMatrix: Nullable<boolean>;
  26766. };
  26767. /** @hidden */
  26768. _bonesTransformMatrices: Nullable<Float32Array>;
  26769. /** @hidden */
  26770. _transformMatrixTexture: Nullable<RawTexture>;
  26771. /**
  26772. * Gets or sets a skeleton to apply skining transformations
  26773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26774. */
  26775. skeleton: Nullable<Skeleton>;
  26776. /**
  26777. * An event triggered when the mesh is rebuilt.
  26778. */
  26779. onRebuildObservable: Observable<AbstractMesh>;
  26780. /**
  26781. * Creates a new AbstractMesh
  26782. * @param name defines the name of the mesh
  26783. * @param scene defines the hosting scene
  26784. */
  26785. constructor(name: string, scene?: Nullable<Scene>);
  26786. /**
  26787. * Returns the string "AbstractMesh"
  26788. * @returns "AbstractMesh"
  26789. */
  26790. getClassName(): string;
  26791. /**
  26792. * Gets a string representation of the current mesh
  26793. * @param fullDetails defines a boolean indicating if full details must be included
  26794. * @returns a string representation of the current mesh
  26795. */
  26796. toString(fullDetails?: boolean): string;
  26797. /**
  26798. * @hidden
  26799. */
  26800. protected _getEffectiveParent(): Nullable<Node>;
  26801. /** @hidden */
  26802. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26803. /** @hidden */
  26804. _rebuild(): void;
  26805. /** @hidden */
  26806. _resyncLightSources(): void;
  26807. /** @hidden */
  26808. _resyncLighSource(light: Light): void;
  26809. /** @hidden */
  26810. _unBindEffect(): void;
  26811. /** @hidden */
  26812. _removeLightSource(light: Light, dispose: boolean): void;
  26813. private _markSubMeshesAsDirty;
  26814. /** @hidden */
  26815. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26816. /** @hidden */
  26817. _markSubMeshesAsAttributesDirty(): void;
  26818. /** @hidden */
  26819. _markSubMeshesAsMiscDirty(): void;
  26820. /**
  26821. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26822. */
  26823. scaling: Vector3;
  26824. /**
  26825. * Returns true if the mesh is blocked. Implemented by child classes
  26826. */
  26827. readonly isBlocked: boolean;
  26828. /**
  26829. * Returns the mesh itself by default. Implemented by child classes
  26830. * @param camera defines the camera to use to pick the right LOD level
  26831. * @returns the currentAbstractMesh
  26832. */
  26833. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26834. /**
  26835. * Returns 0 by default. Implemented by child classes
  26836. * @returns an integer
  26837. */
  26838. getTotalVertices(): number;
  26839. /**
  26840. * Returns a positive integer : the total number of indices in this mesh geometry.
  26841. * @returns the numner of indices or zero if the mesh has no geometry.
  26842. */
  26843. getTotalIndices(): number;
  26844. /**
  26845. * Returns null by default. Implemented by child classes
  26846. * @returns null
  26847. */
  26848. getIndices(): Nullable<IndicesArray>;
  26849. /**
  26850. * Returns the array of the requested vertex data kind. Implemented by child classes
  26851. * @param kind defines the vertex data kind to use
  26852. * @returns null
  26853. */
  26854. getVerticesData(kind: string): Nullable<FloatArray>;
  26855. /**
  26856. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26857. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26858. * Note that a new underlying VertexBuffer object is created each call.
  26859. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26860. * @param kind defines vertex data kind:
  26861. * * VertexBuffer.PositionKind
  26862. * * VertexBuffer.UVKind
  26863. * * VertexBuffer.UV2Kind
  26864. * * VertexBuffer.UV3Kind
  26865. * * VertexBuffer.UV4Kind
  26866. * * VertexBuffer.UV5Kind
  26867. * * VertexBuffer.UV6Kind
  26868. * * VertexBuffer.ColorKind
  26869. * * VertexBuffer.MatricesIndicesKind
  26870. * * VertexBuffer.MatricesIndicesExtraKind
  26871. * * VertexBuffer.MatricesWeightsKind
  26872. * * VertexBuffer.MatricesWeightsExtraKind
  26873. * @param data defines the data source
  26874. * @param updatable defines if the data must be flagged as updatable (or static)
  26875. * @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
  26876. * @returns the current mesh
  26877. */
  26878. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26879. /**
  26880. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26881. * If the mesh has no geometry, it is simply returned as it is.
  26882. * @param kind defines vertex data kind:
  26883. * * VertexBuffer.PositionKind
  26884. * * VertexBuffer.UVKind
  26885. * * VertexBuffer.UV2Kind
  26886. * * VertexBuffer.UV3Kind
  26887. * * VertexBuffer.UV4Kind
  26888. * * VertexBuffer.UV5Kind
  26889. * * VertexBuffer.UV6Kind
  26890. * * VertexBuffer.ColorKind
  26891. * * VertexBuffer.MatricesIndicesKind
  26892. * * VertexBuffer.MatricesIndicesExtraKind
  26893. * * VertexBuffer.MatricesWeightsKind
  26894. * * VertexBuffer.MatricesWeightsExtraKind
  26895. * @param data defines the data source
  26896. * @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
  26897. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26898. * @returns the current mesh
  26899. */
  26900. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26901. /**
  26902. * Sets the mesh indices,
  26903. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26904. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26905. * @param totalVertices Defines the total number of vertices
  26906. * @returns the current mesh
  26907. */
  26908. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26909. /**
  26910. * Gets a boolean indicating if specific vertex data is present
  26911. * @param kind defines the vertex data kind to use
  26912. * @returns true is data kind is present
  26913. */
  26914. isVerticesDataPresent(kind: string): boolean;
  26915. /**
  26916. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26917. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26918. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26919. * @returns a BoundingInfo
  26920. */
  26921. getBoundingInfo(): BoundingInfo;
  26922. /**
  26923. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26924. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26925. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26926. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26927. * @returns the current mesh
  26928. */
  26929. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26930. /**
  26931. * Overwrite the current bounding info
  26932. * @param boundingInfo defines the new bounding info
  26933. * @returns the current mesh
  26934. */
  26935. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26936. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26937. readonly useBones: boolean;
  26938. /** @hidden */
  26939. _preActivate(): void;
  26940. /** @hidden */
  26941. _preActivateForIntermediateRendering(renderId: number): void;
  26942. /** @hidden */
  26943. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26944. /** @hidden */
  26945. _postActivate(): void;
  26946. /** @hidden */
  26947. _freeze(): void;
  26948. /** @hidden */
  26949. _unFreeze(): void;
  26950. /**
  26951. * Gets the current world matrix
  26952. * @returns a Matrix
  26953. */
  26954. getWorldMatrix(): Matrix;
  26955. /** @hidden */
  26956. _getWorldMatrixDeterminant(): number;
  26957. /**
  26958. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26959. */
  26960. readonly isAnInstance: boolean;
  26961. /**
  26962. * Gets a boolean indicating if this mesh has instances
  26963. */
  26964. readonly hasInstances: boolean;
  26965. /**
  26966. * Perform relative position change from the point of view of behind the front of the mesh.
  26967. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26968. * Supports definition of mesh facing forward or backward
  26969. * @param amountRight defines the distance on the right axis
  26970. * @param amountUp defines the distance on the up axis
  26971. * @param amountForward defines the distance on the forward axis
  26972. * @returns the current mesh
  26973. */
  26974. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26975. /**
  26976. * Calculate relative position change from the point of view of behind the front of the mesh.
  26977. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26978. * Supports definition of mesh facing forward or backward
  26979. * @param amountRight defines the distance on the right axis
  26980. * @param amountUp defines the distance on the up axis
  26981. * @param amountForward defines the distance on the forward axis
  26982. * @returns the new displacement vector
  26983. */
  26984. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26985. /**
  26986. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26987. * Supports definition of mesh facing forward or backward
  26988. * @param flipBack defines the flip
  26989. * @param twirlClockwise defines the twirl
  26990. * @param tiltRight defines the tilt
  26991. * @returns the current mesh
  26992. */
  26993. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26994. /**
  26995. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26996. * Supports definition of mesh facing forward or backward.
  26997. * @param flipBack defines the flip
  26998. * @param twirlClockwise defines the twirl
  26999. * @param tiltRight defines the tilt
  27000. * @returns the new rotation vector
  27001. */
  27002. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27003. /**
  27004. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27005. * This means the mesh underlying bounding box and sphere are recomputed.
  27006. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27007. * @returns the current mesh
  27008. */
  27009. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27010. /** @hidden */
  27011. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27012. /** @hidden */
  27013. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27014. /** @hidden */
  27015. _updateBoundingInfo(): AbstractMesh;
  27016. /** @hidden */
  27017. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27018. /** @hidden */
  27019. protected _afterComputeWorldMatrix(): void;
  27020. /** @hidden */
  27021. readonly _effectiveMesh: AbstractMesh;
  27022. /**
  27023. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27024. * A mesh is in the frustum if its bounding box intersects the frustum
  27025. * @param frustumPlanes defines the frustum to test
  27026. * @returns true if the mesh is in the frustum planes
  27027. */
  27028. isInFrustum(frustumPlanes: Plane[]): boolean;
  27029. /**
  27030. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27031. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27032. * @param frustumPlanes defines the frustum to test
  27033. * @returns true if the mesh is completely in the frustum planes
  27034. */
  27035. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27036. /**
  27037. * True if the mesh intersects another mesh or a SolidParticle object
  27038. * @param mesh defines a target mesh or SolidParticle to test
  27039. * @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)
  27040. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27041. * @returns true if there is an intersection
  27042. */
  27043. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27044. /**
  27045. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27046. * @param point defines the point to test
  27047. * @returns true if there is an intersection
  27048. */
  27049. intersectsPoint(point: Vector3): boolean;
  27050. /**
  27051. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27052. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27053. */
  27054. checkCollisions: boolean;
  27055. /**
  27056. * Gets Collider object used to compute collisions (not physics)
  27057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27058. */
  27059. readonly collider: Nullable<Collider>;
  27060. /**
  27061. * Move the mesh using collision engine
  27062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27063. * @param displacement defines the requested displacement vector
  27064. * @returns the current mesh
  27065. */
  27066. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27067. private _onCollisionPositionChange;
  27068. /** @hidden */
  27069. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27070. /** @hidden */
  27071. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27072. /** @hidden */
  27073. _checkCollision(collider: Collider): AbstractMesh;
  27074. /** @hidden */
  27075. _generatePointsArray(): boolean;
  27076. /**
  27077. * Checks if the passed Ray intersects with the mesh
  27078. * @param ray defines the ray to use
  27079. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27081. * @returns the picking info
  27082. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27083. */
  27084. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27085. /**
  27086. * Clones the current mesh
  27087. * @param name defines the mesh name
  27088. * @param newParent defines the new mesh parent
  27089. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27090. * @returns the new mesh
  27091. */
  27092. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27093. /**
  27094. * Disposes all the submeshes of the current meshnp
  27095. * @returns the current mesh
  27096. */
  27097. releaseSubMeshes(): AbstractMesh;
  27098. /**
  27099. * Releases resources associated with this abstract mesh.
  27100. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27101. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27102. */
  27103. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27104. /**
  27105. * Adds the passed mesh as a child to the current mesh
  27106. * @param mesh defines the child mesh
  27107. * @returns the current mesh
  27108. */
  27109. addChild(mesh: AbstractMesh): AbstractMesh;
  27110. /**
  27111. * Removes the passed mesh from the current mesh children list
  27112. * @param mesh defines the child mesh
  27113. * @returns the current mesh
  27114. */
  27115. removeChild(mesh: AbstractMesh): AbstractMesh;
  27116. /** @hidden */
  27117. private _initFacetData;
  27118. /**
  27119. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27120. * This method can be called within the render loop.
  27121. * 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
  27122. * @returns the current mesh
  27123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27124. */
  27125. updateFacetData(): AbstractMesh;
  27126. /**
  27127. * Returns the facetLocalNormals array.
  27128. * The normals are expressed in the mesh local spac
  27129. * @returns an array of Vector3
  27130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27131. */
  27132. getFacetLocalNormals(): Vector3[];
  27133. /**
  27134. * Returns the facetLocalPositions array.
  27135. * The facet positions are expressed in the mesh local space
  27136. * @returns an array of Vector3
  27137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27138. */
  27139. getFacetLocalPositions(): Vector3[];
  27140. /**
  27141. * Returns the facetLocalPartioning array
  27142. * @returns an array of array of numbers
  27143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27144. */
  27145. getFacetLocalPartitioning(): number[][];
  27146. /**
  27147. * Returns the i-th facet position in the world system.
  27148. * This method allocates a new Vector3 per call
  27149. * @param i defines the facet index
  27150. * @returns a new Vector3
  27151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27152. */
  27153. getFacetPosition(i: number): Vector3;
  27154. /**
  27155. * Sets the reference Vector3 with the i-th facet position in the world system
  27156. * @param i defines the facet index
  27157. * @param ref defines the target vector
  27158. * @returns the current mesh
  27159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27160. */
  27161. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27162. /**
  27163. * Returns the i-th facet normal in the world system.
  27164. * This method allocates a new Vector3 per call
  27165. * @param i defines the facet index
  27166. * @returns a new Vector3
  27167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27168. */
  27169. getFacetNormal(i: number): Vector3;
  27170. /**
  27171. * Sets the reference Vector3 with the i-th facet normal in the world system
  27172. * @param i defines the facet index
  27173. * @param ref defines the target vector
  27174. * @returns the current mesh
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27176. */
  27177. getFacetNormalToRef(i: number, ref: Vector3): this;
  27178. /**
  27179. * 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)
  27180. * @param x defines x coordinate
  27181. * @param y defines y coordinate
  27182. * @param z defines z coordinate
  27183. * @returns the array of facet indexes
  27184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27185. */
  27186. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27187. /**
  27188. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27189. * @param projected sets as the (x,y,z) world projection on the facet
  27190. * @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
  27191. * @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
  27192. * @param x defines x coordinate
  27193. * @param y defines y coordinate
  27194. * @param z defines z coordinate
  27195. * @returns the face index if found (or null instead)
  27196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27197. */
  27198. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27199. /**
  27200. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27201. * @param projected sets as the (x,y,z) local projection on the facet
  27202. * @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
  27203. * @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
  27204. * @param x defines x coordinate
  27205. * @param y defines y coordinate
  27206. * @param z defines z coordinate
  27207. * @returns the face index if found (or null instead)
  27208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27209. */
  27210. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27211. /**
  27212. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27213. * @returns the parameters
  27214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27215. */
  27216. getFacetDataParameters(): any;
  27217. /**
  27218. * Disables the feature FacetData and frees the related memory
  27219. * @returns the current mesh
  27220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27221. */
  27222. disableFacetData(): AbstractMesh;
  27223. /**
  27224. * Updates the AbstractMesh indices array
  27225. * @param indices defines the data source
  27226. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27227. * @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)
  27228. * @returns the current mesh
  27229. */
  27230. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27231. /**
  27232. * Creates new normals data for the mesh
  27233. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27234. * @returns the current mesh
  27235. */
  27236. createNormals(updatable: boolean): AbstractMesh;
  27237. /**
  27238. * Align the mesh with a normal
  27239. * @param normal defines the normal to use
  27240. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27241. * @returns the current mesh
  27242. */
  27243. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27244. /** @hidden */
  27245. _checkOcclusionQuery(): boolean;
  27246. /**
  27247. * Disables the mesh edge rendering mode
  27248. * @returns the currentAbstractMesh
  27249. */
  27250. disableEdgesRendering(): AbstractMesh;
  27251. /**
  27252. * Enables the edge rendering mode on the mesh.
  27253. * This mode makes the mesh edges visible
  27254. * @param epsilon defines the maximal distance between two angles to detect a face
  27255. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27256. * @returns the currentAbstractMesh
  27257. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27258. */
  27259. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27260. }
  27261. }
  27262. declare module "babylonjs/Actions/actionEvent" {
  27263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27264. import { Nullable } from "babylonjs/types";
  27265. import { Sprite } from "babylonjs/Sprites/sprite";
  27266. import { Scene } from "babylonjs/scene";
  27267. import { Vector2 } from "babylonjs/Maths/math.vector";
  27268. /**
  27269. * Interface used to define ActionEvent
  27270. */
  27271. export interface IActionEvent {
  27272. /** The mesh or sprite that triggered the action */
  27273. source: any;
  27274. /** The X mouse cursor position at the time of the event */
  27275. pointerX: number;
  27276. /** The Y mouse cursor position at the time of the event */
  27277. pointerY: number;
  27278. /** The mesh that is currently pointed at (can be null) */
  27279. meshUnderPointer: Nullable<AbstractMesh>;
  27280. /** the original (browser) event that triggered the ActionEvent */
  27281. sourceEvent?: any;
  27282. /** additional data for the event */
  27283. additionalData?: any;
  27284. }
  27285. /**
  27286. * ActionEvent is the event being sent when an action is triggered.
  27287. */
  27288. export class ActionEvent implements IActionEvent {
  27289. /** The mesh or sprite that triggered the action */
  27290. source: any;
  27291. /** The X mouse cursor position at the time of the event */
  27292. pointerX: number;
  27293. /** The Y mouse cursor position at the time of the event */
  27294. pointerY: number;
  27295. /** The mesh that is currently pointed at (can be null) */
  27296. meshUnderPointer: Nullable<AbstractMesh>;
  27297. /** the original (browser) event that triggered the ActionEvent */
  27298. sourceEvent?: any;
  27299. /** additional data for the event */
  27300. additionalData?: any;
  27301. /**
  27302. * Creates a new ActionEvent
  27303. * @param source The mesh or sprite that triggered the action
  27304. * @param pointerX The X mouse cursor position at the time of the event
  27305. * @param pointerY The Y mouse cursor position at the time of the event
  27306. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27307. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27308. * @param additionalData additional data for the event
  27309. */
  27310. constructor(
  27311. /** The mesh or sprite that triggered the action */
  27312. source: any,
  27313. /** The X mouse cursor position at the time of the event */
  27314. pointerX: number,
  27315. /** The Y mouse cursor position at the time of the event */
  27316. pointerY: number,
  27317. /** The mesh that is currently pointed at (can be null) */
  27318. meshUnderPointer: Nullable<AbstractMesh>,
  27319. /** the original (browser) event that triggered the ActionEvent */
  27320. sourceEvent?: any,
  27321. /** additional data for the event */
  27322. additionalData?: any);
  27323. /**
  27324. * Helper function to auto-create an ActionEvent from a source mesh.
  27325. * @param source The source mesh that triggered the event
  27326. * @param evt The original (browser) event
  27327. * @param additionalData additional data for the event
  27328. * @returns the new ActionEvent
  27329. */
  27330. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27331. /**
  27332. * Helper function to auto-create an ActionEvent from a source sprite
  27333. * @param source The source sprite that triggered the event
  27334. * @param scene Scene associated with the sprite
  27335. * @param evt The original (browser) event
  27336. * @param additionalData additional data for the event
  27337. * @returns the new ActionEvent
  27338. */
  27339. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27340. /**
  27341. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27342. * @param scene the scene where the event occurred
  27343. * @param evt The original (browser) event
  27344. * @returns the new ActionEvent
  27345. */
  27346. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27347. /**
  27348. * Helper function to auto-create an ActionEvent from a primitive
  27349. * @param prim defines the target primitive
  27350. * @param pointerPos defines the pointer position
  27351. * @param evt The original (browser) event
  27352. * @param additionalData additional data for the event
  27353. * @returns the new ActionEvent
  27354. */
  27355. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27356. }
  27357. }
  27358. declare module "babylonjs/Actions/abstractActionManager" {
  27359. import { IDisposable } from "babylonjs/scene";
  27360. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27361. import { IAction } from "babylonjs/Actions/action";
  27362. import { Nullable } from "babylonjs/types";
  27363. /**
  27364. * Abstract class used to decouple action Manager from scene and meshes.
  27365. * Do not instantiate.
  27366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27367. */
  27368. export abstract class AbstractActionManager implements IDisposable {
  27369. /** Gets the list of active triggers */
  27370. static Triggers: {
  27371. [key: string]: number;
  27372. };
  27373. /** Gets the cursor to use when hovering items */
  27374. hoverCursor: string;
  27375. /** Gets the list of actions */
  27376. actions: IAction[];
  27377. /**
  27378. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27379. */
  27380. isRecursive: boolean;
  27381. /**
  27382. * Releases all associated resources
  27383. */
  27384. abstract dispose(): void;
  27385. /**
  27386. * Does this action manager has pointer triggers
  27387. */
  27388. abstract readonly hasPointerTriggers: boolean;
  27389. /**
  27390. * Does this action manager has pick triggers
  27391. */
  27392. abstract readonly hasPickTriggers: boolean;
  27393. /**
  27394. * Process a specific trigger
  27395. * @param trigger defines the trigger to process
  27396. * @param evt defines the event details to be processed
  27397. */
  27398. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27399. /**
  27400. * Does this action manager handles actions of any of the given triggers
  27401. * @param triggers defines the triggers to be tested
  27402. * @return a boolean indicating whether one (or more) of the triggers is handled
  27403. */
  27404. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27405. /**
  27406. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27407. * speed.
  27408. * @param triggerA defines the trigger to be tested
  27409. * @param triggerB defines the trigger to be tested
  27410. * @return a boolean indicating whether one (or more) of the triggers is handled
  27411. */
  27412. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27413. /**
  27414. * Does this action manager handles actions of a given trigger
  27415. * @param trigger defines the trigger to be tested
  27416. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27417. * @return whether the trigger is handled
  27418. */
  27419. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27420. /**
  27421. * Serialize this manager to a JSON object
  27422. * @param name defines the property name to store this manager
  27423. * @returns a JSON representation of this manager
  27424. */
  27425. abstract serialize(name: string): any;
  27426. /**
  27427. * Registers an action to this action manager
  27428. * @param action defines the action to be registered
  27429. * @return the action amended (prepared) after registration
  27430. */
  27431. abstract registerAction(action: IAction): Nullable<IAction>;
  27432. /**
  27433. * Unregisters an action to this action manager
  27434. * @param action defines the action to be unregistered
  27435. * @return a boolean indicating whether the action has been unregistered
  27436. */
  27437. abstract unregisterAction(action: IAction): Boolean;
  27438. /**
  27439. * Does exist one action manager with at least one trigger
  27440. **/
  27441. static readonly HasTriggers: boolean;
  27442. /**
  27443. * Does exist one action manager with at least one pick trigger
  27444. **/
  27445. static readonly HasPickTriggers: boolean;
  27446. /**
  27447. * Does exist one action manager that handles actions of a given trigger
  27448. * @param trigger defines the trigger to be tested
  27449. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27450. **/
  27451. static HasSpecificTrigger(trigger: number): boolean;
  27452. }
  27453. }
  27454. declare module "babylonjs/node" {
  27455. import { Scene } from "babylonjs/scene";
  27456. import { Nullable } from "babylonjs/types";
  27457. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27458. import { Engine } from "babylonjs/Engines/engine";
  27459. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27460. import { Observable } from "babylonjs/Misc/observable";
  27461. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27462. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27463. import { Animatable } from "babylonjs/Animations/animatable";
  27464. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27465. import { Animation } from "babylonjs/Animations/animation";
  27466. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27468. /**
  27469. * Defines how a node can be built from a string name.
  27470. */
  27471. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27472. /**
  27473. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27474. */
  27475. export class Node implements IBehaviorAware<Node> {
  27476. /** @hidden */
  27477. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27478. private static _NodeConstructors;
  27479. /**
  27480. * Add a new node constructor
  27481. * @param type defines the type name of the node to construct
  27482. * @param constructorFunc defines the constructor function
  27483. */
  27484. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27485. /**
  27486. * Returns a node constructor based on type name
  27487. * @param type defines the type name
  27488. * @param name defines the new node name
  27489. * @param scene defines the hosting scene
  27490. * @param options defines optional options to transmit to constructors
  27491. * @returns the new constructor or null
  27492. */
  27493. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27494. /**
  27495. * Gets or sets the name of the node
  27496. */
  27497. name: string;
  27498. /**
  27499. * Gets or sets the id of the node
  27500. */
  27501. id: string;
  27502. /**
  27503. * Gets or sets the unique id of the node
  27504. */
  27505. uniqueId: number;
  27506. /**
  27507. * Gets or sets a string used to store user defined state for the node
  27508. */
  27509. state: string;
  27510. /**
  27511. * Gets or sets an object used to store user defined information for the node
  27512. */
  27513. metadata: any;
  27514. /**
  27515. * For internal use only. Please do not use.
  27516. */
  27517. reservedDataStore: any;
  27518. /**
  27519. * List of inspectable custom properties (used by the Inspector)
  27520. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27521. */
  27522. inspectableCustomProperties: IInspectable[];
  27523. /**
  27524. * Gets or sets a boolean used to define if the node must be serialized
  27525. */
  27526. doNotSerialize: boolean;
  27527. /** @hidden */
  27528. _isDisposed: boolean;
  27529. /**
  27530. * Gets a list of Animations associated with the node
  27531. */
  27532. animations: import("babylonjs/Animations/animation").Animation[];
  27533. protected _ranges: {
  27534. [name: string]: Nullable<AnimationRange>;
  27535. };
  27536. /**
  27537. * Callback raised when the node is ready to be used
  27538. */
  27539. onReady: Nullable<(node: Node) => void>;
  27540. private _isEnabled;
  27541. private _isParentEnabled;
  27542. private _isReady;
  27543. /** @hidden */
  27544. _currentRenderId: number;
  27545. private _parentUpdateId;
  27546. /** @hidden */
  27547. _childUpdateId: number;
  27548. /** @hidden */
  27549. _waitingParentId: Nullable<string>;
  27550. /** @hidden */
  27551. _scene: Scene;
  27552. /** @hidden */
  27553. _cache: any;
  27554. private _parentNode;
  27555. private _children;
  27556. /** @hidden */
  27557. _worldMatrix: Matrix;
  27558. /** @hidden */
  27559. _worldMatrixDeterminant: number;
  27560. /** @hidden */
  27561. _worldMatrixDeterminantIsDirty: boolean;
  27562. /** @hidden */
  27563. private _sceneRootNodesIndex;
  27564. /**
  27565. * Gets a boolean indicating if the node has been disposed
  27566. * @returns true if the node was disposed
  27567. */
  27568. isDisposed(): boolean;
  27569. /**
  27570. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27571. * @see https://doc.babylonjs.com/how_to/parenting
  27572. */
  27573. parent: Nullable<Node>;
  27574. private addToSceneRootNodes;
  27575. private removeFromSceneRootNodes;
  27576. private _animationPropertiesOverride;
  27577. /**
  27578. * Gets or sets the animation properties override
  27579. */
  27580. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27581. /**
  27582. * Gets a string idenfifying the name of the class
  27583. * @returns "Node" string
  27584. */
  27585. getClassName(): string;
  27586. /** @hidden */
  27587. readonly _isNode: boolean;
  27588. /**
  27589. * An event triggered when the mesh is disposed
  27590. */
  27591. onDisposeObservable: Observable<Node>;
  27592. private _onDisposeObserver;
  27593. /**
  27594. * Sets a callback that will be raised when the node will be disposed
  27595. */
  27596. onDispose: () => void;
  27597. /**
  27598. * Creates a new Node
  27599. * @param name the name and id to be given to this node
  27600. * @param scene the scene this node will be added to
  27601. * @param addToRootNodes the node will be added to scene.rootNodes
  27602. */
  27603. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27604. /**
  27605. * Gets the scene of the node
  27606. * @returns a scene
  27607. */
  27608. getScene(): Scene;
  27609. /**
  27610. * Gets the engine of the node
  27611. * @returns a Engine
  27612. */
  27613. getEngine(): Engine;
  27614. private _behaviors;
  27615. /**
  27616. * Attach a behavior to the node
  27617. * @see http://doc.babylonjs.com/features/behaviour
  27618. * @param behavior defines the behavior to attach
  27619. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27620. * @returns the current Node
  27621. */
  27622. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27623. /**
  27624. * Remove an attached behavior
  27625. * @see http://doc.babylonjs.com/features/behaviour
  27626. * @param behavior defines the behavior to attach
  27627. * @returns the current Node
  27628. */
  27629. removeBehavior(behavior: Behavior<Node>): Node;
  27630. /**
  27631. * Gets the list of attached behaviors
  27632. * @see http://doc.babylonjs.com/features/behaviour
  27633. */
  27634. readonly behaviors: Behavior<Node>[];
  27635. /**
  27636. * Gets an attached behavior by name
  27637. * @param name defines the name of the behavior to look for
  27638. * @see http://doc.babylonjs.com/features/behaviour
  27639. * @returns null if behavior was not found else the requested behavior
  27640. */
  27641. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27642. /**
  27643. * Returns the latest update of the World matrix
  27644. * @returns a Matrix
  27645. */
  27646. getWorldMatrix(): Matrix;
  27647. /** @hidden */
  27648. _getWorldMatrixDeterminant(): number;
  27649. /**
  27650. * Returns directly the latest state of the mesh World matrix.
  27651. * A Matrix is returned.
  27652. */
  27653. readonly worldMatrixFromCache: Matrix;
  27654. /** @hidden */
  27655. _initCache(): void;
  27656. /** @hidden */
  27657. updateCache(force?: boolean): void;
  27658. /** @hidden */
  27659. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27660. /** @hidden */
  27661. _updateCache(ignoreParentClass?: boolean): void;
  27662. /** @hidden */
  27663. _isSynchronized(): boolean;
  27664. /** @hidden */
  27665. _markSyncedWithParent(): void;
  27666. /** @hidden */
  27667. isSynchronizedWithParent(): boolean;
  27668. /** @hidden */
  27669. isSynchronized(): boolean;
  27670. /**
  27671. * Is this node ready to be used/rendered
  27672. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27673. * @return true if the node is ready
  27674. */
  27675. isReady(completeCheck?: boolean): boolean;
  27676. /**
  27677. * Is this node enabled?
  27678. * 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
  27679. * @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
  27680. * @return whether this node (and its parent) is enabled
  27681. */
  27682. isEnabled(checkAncestors?: boolean): boolean;
  27683. /** @hidden */
  27684. protected _syncParentEnabledState(): void;
  27685. /**
  27686. * Set the enabled state of this node
  27687. * @param value defines the new enabled state
  27688. */
  27689. setEnabled(value: boolean): void;
  27690. /**
  27691. * Is this node a descendant of the given node?
  27692. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27693. * @param ancestor defines the parent node to inspect
  27694. * @returns a boolean indicating if this node is a descendant of the given node
  27695. */
  27696. isDescendantOf(ancestor: Node): boolean;
  27697. /** @hidden */
  27698. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27699. /**
  27700. * Will return all nodes that have this node as ascendant
  27701. * @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
  27702. * @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
  27703. * @return all children nodes of all types
  27704. */
  27705. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27706. /**
  27707. * Get all child-meshes of this node
  27708. * @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)
  27709. * @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
  27710. * @returns an array of AbstractMesh
  27711. */
  27712. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27713. /**
  27714. * Get all direct children of this node
  27715. * @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
  27716. * @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)
  27717. * @returns an array of Node
  27718. */
  27719. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27720. /** @hidden */
  27721. _setReady(state: boolean): void;
  27722. /**
  27723. * Get an animation by name
  27724. * @param name defines the name of the animation to look for
  27725. * @returns null if not found else the requested animation
  27726. */
  27727. getAnimationByName(name: string): Nullable<Animation>;
  27728. /**
  27729. * Creates an animation range for this node
  27730. * @param name defines the name of the range
  27731. * @param from defines the starting key
  27732. * @param to defines the end key
  27733. */
  27734. createAnimationRange(name: string, from: number, to: number): void;
  27735. /**
  27736. * Delete a specific animation range
  27737. * @param name defines the name of the range to delete
  27738. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27739. */
  27740. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27741. /**
  27742. * Get an animation range by name
  27743. * @param name defines the name of the animation range to look for
  27744. * @returns null if not found else the requested animation range
  27745. */
  27746. getAnimationRange(name: string): Nullable<AnimationRange>;
  27747. /**
  27748. * Gets the list of all animation ranges defined on this node
  27749. * @returns an array
  27750. */
  27751. getAnimationRanges(): Nullable<AnimationRange>[];
  27752. /**
  27753. * Will start the animation sequence
  27754. * @param name defines the range frames for animation sequence
  27755. * @param loop defines if the animation should loop (false by default)
  27756. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27757. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27758. * @returns the object created for this animation. If range does not exist, it will return null
  27759. */
  27760. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27761. /**
  27762. * Serialize animation ranges into a JSON compatible object
  27763. * @returns serialization object
  27764. */
  27765. serializeAnimationRanges(): any;
  27766. /**
  27767. * Computes the world matrix of the node
  27768. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27769. * @returns the world matrix
  27770. */
  27771. computeWorldMatrix(force?: boolean): Matrix;
  27772. /**
  27773. * Releases resources associated with this node.
  27774. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27775. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27776. */
  27777. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27778. /**
  27779. * Parse animation range data from a serialization object and store them into a given node
  27780. * @param node defines where to store the animation ranges
  27781. * @param parsedNode defines the serialization object to read data from
  27782. * @param scene defines the hosting scene
  27783. */
  27784. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27785. /**
  27786. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27787. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27788. * @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
  27789. * @returns the new bounding vectors
  27790. */
  27791. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27792. min: Vector3;
  27793. max: Vector3;
  27794. };
  27795. }
  27796. }
  27797. declare module "babylonjs/Animations/animation" {
  27798. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27799. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27800. import { Color3 } from "babylonjs/Maths/math.color";
  27801. import { Nullable } from "babylonjs/types";
  27802. import { Scene } from "babylonjs/scene";
  27803. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27804. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27805. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27806. import { Node } from "babylonjs/node";
  27807. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27808. import { Size } from "babylonjs/Maths/math.size";
  27809. import { Animatable } from "babylonjs/Animations/animatable";
  27810. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27811. /**
  27812. * @hidden
  27813. */
  27814. export class _IAnimationState {
  27815. key: number;
  27816. repeatCount: number;
  27817. workValue?: any;
  27818. loopMode?: number;
  27819. offsetValue?: any;
  27820. highLimitValue?: any;
  27821. }
  27822. /**
  27823. * Class used to store any kind of animation
  27824. */
  27825. export class Animation {
  27826. /**Name of the animation */
  27827. name: string;
  27828. /**Property to animate */
  27829. targetProperty: string;
  27830. /**The frames per second of the animation */
  27831. framePerSecond: number;
  27832. /**The data type of the animation */
  27833. dataType: number;
  27834. /**The loop mode of the animation */
  27835. loopMode?: number | undefined;
  27836. /**Specifies if blending should be enabled */
  27837. enableBlending?: boolean | undefined;
  27838. /**
  27839. * Use matrix interpolation instead of using direct key value when animating matrices
  27840. */
  27841. static AllowMatricesInterpolation: boolean;
  27842. /**
  27843. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27844. */
  27845. static AllowMatrixDecomposeForInterpolation: boolean;
  27846. /**
  27847. * Stores the key frames of the animation
  27848. */
  27849. private _keys;
  27850. /**
  27851. * Stores the easing function of the animation
  27852. */
  27853. private _easingFunction;
  27854. /**
  27855. * @hidden Internal use only
  27856. */
  27857. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27858. /**
  27859. * The set of event that will be linked to this animation
  27860. */
  27861. private _events;
  27862. /**
  27863. * Stores an array of target property paths
  27864. */
  27865. targetPropertyPath: string[];
  27866. /**
  27867. * Stores the blending speed of the animation
  27868. */
  27869. blendingSpeed: number;
  27870. /**
  27871. * Stores the animation ranges for the animation
  27872. */
  27873. private _ranges;
  27874. /**
  27875. * @hidden Internal use
  27876. */
  27877. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27878. /**
  27879. * Sets up an animation
  27880. * @param property The property to animate
  27881. * @param animationType The animation type to apply
  27882. * @param framePerSecond The frames per second of the animation
  27883. * @param easingFunction The easing function used in the animation
  27884. * @returns The created animation
  27885. */
  27886. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27887. /**
  27888. * Create and start an animation on a node
  27889. * @param name defines the name of the global animation that will be run on all nodes
  27890. * @param node defines the root node where the animation will take place
  27891. * @param targetProperty defines property to animate
  27892. * @param framePerSecond defines the number of frame per second yo use
  27893. * @param totalFrame defines the number of frames in total
  27894. * @param from defines the initial value
  27895. * @param to defines the final value
  27896. * @param loopMode defines which loop mode you want to use (off by default)
  27897. * @param easingFunction defines the easing function to use (linear by default)
  27898. * @param onAnimationEnd defines the callback to call when animation end
  27899. * @returns the animatable created for this animation
  27900. */
  27901. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27902. /**
  27903. * Create and start an animation on a node and its descendants
  27904. * @param name defines the name of the global animation that will be run on all nodes
  27905. * @param node defines the root node where the animation will take place
  27906. * @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
  27907. * @param targetProperty defines property to animate
  27908. * @param framePerSecond defines the number of frame per second to use
  27909. * @param totalFrame defines the number of frames in total
  27910. * @param from defines the initial value
  27911. * @param to defines the final value
  27912. * @param loopMode defines which loop mode you want to use (off by default)
  27913. * @param easingFunction defines the easing function to use (linear by default)
  27914. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27915. * @returns the list of animatables created for all nodes
  27916. * @example https://www.babylonjs-playground.com/#MH0VLI
  27917. */
  27918. 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[]>;
  27919. /**
  27920. * Creates a new animation, merges it with the existing animations and starts it
  27921. * @param name Name of the animation
  27922. * @param node Node which contains the scene that begins the animations
  27923. * @param targetProperty Specifies which property to animate
  27924. * @param framePerSecond The frames per second of the animation
  27925. * @param totalFrame The total number of frames
  27926. * @param from The frame at the beginning of the animation
  27927. * @param to The frame at the end of the animation
  27928. * @param loopMode Specifies the loop mode of the animation
  27929. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27930. * @param onAnimationEnd Callback to run once the animation is complete
  27931. * @returns Nullable animation
  27932. */
  27933. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27934. /**
  27935. * Transition property of an host to the target Value
  27936. * @param property The property to transition
  27937. * @param targetValue The target Value of the property
  27938. * @param host The object where the property to animate belongs
  27939. * @param scene Scene used to run the animation
  27940. * @param frameRate Framerate (in frame/s) to use
  27941. * @param transition The transition type we want to use
  27942. * @param duration The duration of the animation, in milliseconds
  27943. * @param onAnimationEnd Callback trigger at the end of the animation
  27944. * @returns Nullable animation
  27945. */
  27946. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27947. /**
  27948. * Return the array of runtime animations currently using this animation
  27949. */
  27950. readonly runtimeAnimations: RuntimeAnimation[];
  27951. /**
  27952. * Specifies if any of the runtime animations are currently running
  27953. */
  27954. readonly hasRunningRuntimeAnimations: boolean;
  27955. /**
  27956. * Initializes the animation
  27957. * @param name Name of the animation
  27958. * @param targetProperty Property to animate
  27959. * @param framePerSecond The frames per second of the animation
  27960. * @param dataType The data type of the animation
  27961. * @param loopMode The loop mode of the animation
  27962. * @param enableBlending Specifies if blending should be enabled
  27963. */
  27964. constructor(
  27965. /**Name of the animation */
  27966. name: string,
  27967. /**Property to animate */
  27968. targetProperty: string,
  27969. /**The frames per second of the animation */
  27970. framePerSecond: number,
  27971. /**The data type of the animation */
  27972. dataType: number,
  27973. /**The loop mode of the animation */
  27974. loopMode?: number | undefined,
  27975. /**Specifies if blending should be enabled */
  27976. enableBlending?: boolean | undefined);
  27977. /**
  27978. * Converts the animation to a string
  27979. * @param fullDetails support for multiple levels of logging within scene loading
  27980. * @returns String form of the animation
  27981. */
  27982. toString(fullDetails?: boolean): string;
  27983. /**
  27984. * Add an event to this animation
  27985. * @param event Event to add
  27986. */
  27987. addEvent(event: AnimationEvent): void;
  27988. /**
  27989. * Remove all events found at the given frame
  27990. * @param frame The frame to remove events from
  27991. */
  27992. removeEvents(frame: number): void;
  27993. /**
  27994. * Retrieves all the events from the animation
  27995. * @returns Events from the animation
  27996. */
  27997. getEvents(): AnimationEvent[];
  27998. /**
  27999. * Creates an animation range
  28000. * @param name Name of the animation range
  28001. * @param from Starting frame of the animation range
  28002. * @param to Ending frame of the animation
  28003. */
  28004. createRange(name: string, from: number, to: number): void;
  28005. /**
  28006. * Deletes an animation range by name
  28007. * @param name Name of the animation range to delete
  28008. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28009. */
  28010. deleteRange(name: string, deleteFrames?: boolean): void;
  28011. /**
  28012. * Gets the animation range by name, or null if not defined
  28013. * @param name Name of the animation range
  28014. * @returns Nullable animation range
  28015. */
  28016. getRange(name: string): Nullable<AnimationRange>;
  28017. /**
  28018. * Gets the key frames from the animation
  28019. * @returns The key frames of the animation
  28020. */
  28021. getKeys(): Array<IAnimationKey>;
  28022. /**
  28023. * Gets the highest frame rate of the animation
  28024. * @returns Highest frame rate of the animation
  28025. */
  28026. getHighestFrame(): number;
  28027. /**
  28028. * Gets the easing function of the animation
  28029. * @returns Easing function of the animation
  28030. */
  28031. getEasingFunction(): IEasingFunction;
  28032. /**
  28033. * Sets the easing function of the animation
  28034. * @param easingFunction A custom mathematical formula for animation
  28035. */
  28036. setEasingFunction(easingFunction: EasingFunction): void;
  28037. /**
  28038. * Interpolates a scalar linearly
  28039. * @param startValue Start value of the animation curve
  28040. * @param endValue End value of the animation curve
  28041. * @param gradient Scalar amount to interpolate
  28042. * @returns Interpolated scalar value
  28043. */
  28044. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28045. /**
  28046. * Interpolates a scalar cubically
  28047. * @param startValue Start value of the animation curve
  28048. * @param outTangent End tangent of the animation
  28049. * @param endValue End value of the animation curve
  28050. * @param inTangent Start tangent of the animation curve
  28051. * @param gradient Scalar amount to interpolate
  28052. * @returns Interpolated scalar value
  28053. */
  28054. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28055. /**
  28056. * Interpolates a quaternion using a spherical linear interpolation
  28057. * @param startValue Start value of the animation curve
  28058. * @param endValue End value of the animation curve
  28059. * @param gradient Scalar amount to interpolate
  28060. * @returns Interpolated quaternion value
  28061. */
  28062. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28063. /**
  28064. * Interpolates a quaternion cubically
  28065. * @param startValue Start value of the animation curve
  28066. * @param outTangent End tangent of the animation curve
  28067. * @param endValue End value of the animation curve
  28068. * @param inTangent Start tangent of the animation curve
  28069. * @param gradient Scalar amount to interpolate
  28070. * @returns Interpolated quaternion value
  28071. */
  28072. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28073. /**
  28074. * Interpolates a Vector3 linearl
  28075. * @param startValue Start value of the animation curve
  28076. * @param endValue End value of the animation curve
  28077. * @param gradient Scalar amount to interpolate
  28078. * @returns Interpolated scalar value
  28079. */
  28080. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28081. /**
  28082. * Interpolates a Vector3 cubically
  28083. * @param startValue Start value of the animation curve
  28084. * @param outTangent End tangent of the animation
  28085. * @param endValue End value of the animation curve
  28086. * @param inTangent Start tangent of the animation curve
  28087. * @param gradient Scalar amount to interpolate
  28088. * @returns InterpolatedVector3 value
  28089. */
  28090. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28091. /**
  28092. * Interpolates a Vector2 linearly
  28093. * @param startValue Start value of the animation curve
  28094. * @param endValue End value of the animation curve
  28095. * @param gradient Scalar amount to interpolate
  28096. * @returns Interpolated Vector2 value
  28097. */
  28098. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28099. /**
  28100. * Interpolates a Vector2 cubically
  28101. * @param startValue Start value of the animation curve
  28102. * @param outTangent End tangent of the animation
  28103. * @param endValue End value of the animation curve
  28104. * @param inTangent Start tangent of the animation curve
  28105. * @param gradient Scalar amount to interpolate
  28106. * @returns Interpolated Vector2 value
  28107. */
  28108. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28109. /**
  28110. * Interpolates a size linearly
  28111. * @param startValue Start value of the animation curve
  28112. * @param endValue End value of the animation curve
  28113. * @param gradient Scalar amount to interpolate
  28114. * @returns Interpolated Size value
  28115. */
  28116. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28117. /**
  28118. * Interpolates a Color3 linearly
  28119. * @param startValue Start value of the animation curve
  28120. * @param endValue End value of the animation curve
  28121. * @param gradient Scalar amount to interpolate
  28122. * @returns Interpolated Color3 value
  28123. */
  28124. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28125. /**
  28126. * @hidden Internal use only
  28127. */
  28128. _getKeyValue(value: any): any;
  28129. /**
  28130. * @hidden Internal use only
  28131. */
  28132. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28133. /**
  28134. * Defines the function to use to interpolate matrices
  28135. * @param startValue defines the start matrix
  28136. * @param endValue defines the end matrix
  28137. * @param gradient defines the gradient between both matrices
  28138. * @param result defines an optional target matrix where to store the interpolation
  28139. * @returns the interpolated matrix
  28140. */
  28141. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28142. /**
  28143. * Makes a copy of the animation
  28144. * @returns Cloned animation
  28145. */
  28146. clone(): Animation;
  28147. /**
  28148. * Sets the key frames of the animation
  28149. * @param values The animation key frames to set
  28150. */
  28151. setKeys(values: Array<IAnimationKey>): void;
  28152. /**
  28153. * Serializes the animation to an object
  28154. * @returns Serialized object
  28155. */
  28156. serialize(): any;
  28157. /**
  28158. * Float animation type
  28159. */
  28160. private static _ANIMATIONTYPE_FLOAT;
  28161. /**
  28162. * Vector3 animation type
  28163. */
  28164. private static _ANIMATIONTYPE_VECTOR3;
  28165. /**
  28166. * Quaternion animation type
  28167. */
  28168. private static _ANIMATIONTYPE_QUATERNION;
  28169. /**
  28170. * Matrix animation type
  28171. */
  28172. private static _ANIMATIONTYPE_MATRIX;
  28173. /**
  28174. * Color3 animation type
  28175. */
  28176. private static _ANIMATIONTYPE_COLOR3;
  28177. /**
  28178. * Vector2 animation type
  28179. */
  28180. private static _ANIMATIONTYPE_VECTOR2;
  28181. /**
  28182. * Size animation type
  28183. */
  28184. private static _ANIMATIONTYPE_SIZE;
  28185. /**
  28186. * Relative Loop Mode
  28187. */
  28188. private static _ANIMATIONLOOPMODE_RELATIVE;
  28189. /**
  28190. * Cycle Loop Mode
  28191. */
  28192. private static _ANIMATIONLOOPMODE_CYCLE;
  28193. /**
  28194. * Constant Loop Mode
  28195. */
  28196. private static _ANIMATIONLOOPMODE_CONSTANT;
  28197. /**
  28198. * Get the float animation type
  28199. */
  28200. static readonly ANIMATIONTYPE_FLOAT: number;
  28201. /**
  28202. * Get the Vector3 animation type
  28203. */
  28204. static readonly ANIMATIONTYPE_VECTOR3: number;
  28205. /**
  28206. * Get the Vector2 animation type
  28207. */
  28208. static readonly ANIMATIONTYPE_VECTOR2: number;
  28209. /**
  28210. * Get the Size animation type
  28211. */
  28212. static readonly ANIMATIONTYPE_SIZE: number;
  28213. /**
  28214. * Get the Quaternion animation type
  28215. */
  28216. static readonly ANIMATIONTYPE_QUATERNION: number;
  28217. /**
  28218. * Get the Matrix animation type
  28219. */
  28220. static readonly ANIMATIONTYPE_MATRIX: number;
  28221. /**
  28222. * Get the Color3 animation type
  28223. */
  28224. static readonly ANIMATIONTYPE_COLOR3: number;
  28225. /**
  28226. * Get the Relative Loop Mode
  28227. */
  28228. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28229. /**
  28230. * Get the Cycle Loop Mode
  28231. */
  28232. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28233. /**
  28234. * Get the Constant Loop Mode
  28235. */
  28236. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28237. /** @hidden */
  28238. static _UniversalLerp(left: any, right: any, amount: number): any;
  28239. /**
  28240. * Parses an animation object and creates an animation
  28241. * @param parsedAnimation Parsed animation object
  28242. * @returns Animation object
  28243. */
  28244. static Parse(parsedAnimation: any): Animation;
  28245. /**
  28246. * Appends the serialized animations from the source animations
  28247. * @param source Source containing the animations
  28248. * @param destination Target to store the animations
  28249. */
  28250. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28251. }
  28252. }
  28253. declare module "babylonjs/Animations/animatable.interface" {
  28254. import { Nullable } from "babylonjs/types";
  28255. import { Animation } from "babylonjs/Animations/animation";
  28256. /**
  28257. * Interface containing an array of animations
  28258. */
  28259. export interface IAnimatable {
  28260. /**
  28261. * Array of animations
  28262. */
  28263. animations: Nullable<Array<Animation>>;
  28264. }
  28265. }
  28266. declare module "babylonjs/Materials/fresnelParameters" {
  28267. import { Color3 } from "babylonjs/Maths/math.color";
  28268. /**
  28269. * This represents all the required information to add a fresnel effect on a material:
  28270. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28271. */
  28272. export class FresnelParameters {
  28273. private _isEnabled;
  28274. /**
  28275. * Define if the fresnel effect is enable or not.
  28276. */
  28277. isEnabled: boolean;
  28278. /**
  28279. * Define the color used on edges (grazing angle)
  28280. */
  28281. leftColor: Color3;
  28282. /**
  28283. * Define the color used on center
  28284. */
  28285. rightColor: Color3;
  28286. /**
  28287. * Define bias applied to computed fresnel term
  28288. */
  28289. bias: number;
  28290. /**
  28291. * Defined the power exponent applied to fresnel term
  28292. */
  28293. power: number;
  28294. /**
  28295. * Clones the current fresnel and its valuues
  28296. * @returns a clone fresnel configuration
  28297. */
  28298. clone(): FresnelParameters;
  28299. /**
  28300. * Serializes the current fresnel parameters to a JSON representation.
  28301. * @return the JSON serialization
  28302. */
  28303. serialize(): any;
  28304. /**
  28305. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28306. * @param parsedFresnelParameters Define the JSON representation
  28307. * @returns the parsed parameters
  28308. */
  28309. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28310. }
  28311. }
  28312. declare module "babylonjs/Misc/decorators" {
  28313. import { Nullable } from "babylonjs/types";
  28314. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28315. import { Scene } from "babylonjs/scene";
  28316. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28317. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28318. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28319. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28320. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28321. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28322. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28323. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28324. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28325. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28326. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28327. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28328. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28329. /**
  28330. * Decorator used to define property that can be serialized as reference to a camera
  28331. * @param sourceName defines the name of the property to decorate
  28332. */
  28333. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28334. /**
  28335. * Class used to help serialization objects
  28336. */
  28337. export class SerializationHelper {
  28338. /** @hidden */
  28339. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28340. /** @hidden */
  28341. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28342. /** @hidden */
  28343. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28344. /** @hidden */
  28345. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28346. /**
  28347. * Appends the serialized animations from the source animations
  28348. * @param source Source containing the animations
  28349. * @param destination Target to store the animations
  28350. */
  28351. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28352. /**
  28353. * Static function used to serialized a specific entity
  28354. * @param entity defines the entity to serialize
  28355. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28356. * @returns a JSON compatible object representing the serialization of the entity
  28357. */
  28358. static Serialize<T>(entity: T, serializationObject?: any): any;
  28359. /**
  28360. * Creates a new entity from a serialization data object
  28361. * @param creationFunction defines a function used to instanciated the new entity
  28362. * @param source defines the source serialization data
  28363. * @param scene defines the hosting scene
  28364. * @param rootUrl defines the root url for resources
  28365. * @returns a new entity
  28366. */
  28367. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28368. /**
  28369. * Clones an object
  28370. * @param creationFunction defines the function used to instanciate the new object
  28371. * @param source defines the source object
  28372. * @returns the cloned object
  28373. */
  28374. static Clone<T>(creationFunction: () => T, source: T): T;
  28375. /**
  28376. * Instanciates a new object based on a source one (some data will be shared between both object)
  28377. * @param creationFunction defines the function used to instanciate the new object
  28378. * @param source defines the source object
  28379. * @returns the new object
  28380. */
  28381. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28382. }
  28383. }
  28384. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28385. import { Nullable } from "babylonjs/types";
  28386. /**
  28387. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28388. */
  28389. export interface CubeMapInfo {
  28390. /**
  28391. * The pixel array for the front face.
  28392. * This is stored in format, left to right, up to down format.
  28393. */
  28394. front: Nullable<ArrayBufferView>;
  28395. /**
  28396. * The pixel array for the back face.
  28397. * This is stored in format, left to right, up to down format.
  28398. */
  28399. back: Nullable<ArrayBufferView>;
  28400. /**
  28401. * The pixel array for the left face.
  28402. * This is stored in format, left to right, up to down format.
  28403. */
  28404. left: Nullable<ArrayBufferView>;
  28405. /**
  28406. * The pixel array for the right face.
  28407. * This is stored in format, left to right, up to down format.
  28408. */
  28409. right: Nullable<ArrayBufferView>;
  28410. /**
  28411. * The pixel array for the up face.
  28412. * This is stored in format, left to right, up to down format.
  28413. */
  28414. up: Nullable<ArrayBufferView>;
  28415. /**
  28416. * The pixel array for the down face.
  28417. * This is stored in format, left to right, up to down format.
  28418. */
  28419. down: Nullable<ArrayBufferView>;
  28420. /**
  28421. * The size of the cubemap stored.
  28422. *
  28423. * Each faces will be size * size pixels.
  28424. */
  28425. size: number;
  28426. /**
  28427. * The format of the texture.
  28428. *
  28429. * RGBA, RGB.
  28430. */
  28431. format: number;
  28432. /**
  28433. * The type of the texture data.
  28434. *
  28435. * UNSIGNED_INT, FLOAT.
  28436. */
  28437. type: number;
  28438. /**
  28439. * Specifies whether the texture is in gamma space.
  28440. */
  28441. gammaSpace: boolean;
  28442. }
  28443. /**
  28444. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28445. */
  28446. export class PanoramaToCubeMapTools {
  28447. private static FACE_FRONT;
  28448. private static FACE_BACK;
  28449. private static FACE_RIGHT;
  28450. private static FACE_LEFT;
  28451. private static FACE_DOWN;
  28452. private static FACE_UP;
  28453. /**
  28454. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28455. *
  28456. * @param float32Array The source data.
  28457. * @param inputWidth The width of the input panorama.
  28458. * @param inputHeight The height of the input panorama.
  28459. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28460. * @return The cubemap data
  28461. */
  28462. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28463. private static CreateCubemapTexture;
  28464. private static CalcProjectionSpherical;
  28465. }
  28466. }
  28467. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28468. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28470. import { Nullable } from "babylonjs/types";
  28471. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28472. /**
  28473. * Helper class dealing with the extraction of spherical polynomial dataArray
  28474. * from a cube map.
  28475. */
  28476. export class CubeMapToSphericalPolynomialTools {
  28477. private static FileFaces;
  28478. /**
  28479. * Converts a texture to the according Spherical Polynomial data.
  28480. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28481. *
  28482. * @param texture The texture to extract the information from.
  28483. * @return The Spherical Polynomial data.
  28484. */
  28485. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28486. /**
  28487. * Converts a cubemap to the according Spherical Polynomial data.
  28488. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28489. *
  28490. * @param cubeInfo The Cube map to extract the information from.
  28491. * @return The Spherical Polynomial data.
  28492. */
  28493. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28494. }
  28495. }
  28496. declare module "babylonjs/Misc/guid" {
  28497. /**
  28498. * Class used to manipulate GUIDs
  28499. */
  28500. export class GUID {
  28501. /**
  28502. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28503. * Be aware Math.random() could cause collisions, but:
  28504. * "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"
  28505. * @returns a pseudo random id
  28506. */
  28507. static RandomId(): string;
  28508. }
  28509. }
  28510. declare module "babylonjs/Materials/Textures/baseTexture" {
  28511. import { Observable } from "babylonjs/Misc/observable";
  28512. import { Nullable } from "babylonjs/types";
  28513. import { Scene } from "babylonjs/scene";
  28514. import { Matrix } from "babylonjs/Maths/math.vector";
  28515. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28516. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28517. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28518. import { ISize } from "babylonjs/Maths/math.size";
  28519. /**
  28520. * Base class of all the textures in babylon.
  28521. * It groups all the common properties the materials, post process, lights... might need
  28522. * in order to make a correct use of the texture.
  28523. */
  28524. export class BaseTexture implements IAnimatable {
  28525. /**
  28526. * Default anisotropic filtering level for the application.
  28527. * It is set to 4 as a good tradeoff between perf and quality.
  28528. */
  28529. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28530. /**
  28531. * Gets or sets the unique id of the texture
  28532. */
  28533. uniqueId: number;
  28534. /**
  28535. * Define the name of the texture.
  28536. */
  28537. name: string;
  28538. /**
  28539. * Gets or sets an object used to store user defined information.
  28540. */
  28541. metadata: any;
  28542. /**
  28543. * For internal use only. Please do not use.
  28544. */
  28545. reservedDataStore: any;
  28546. private _hasAlpha;
  28547. /**
  28548. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28549. */
  28550. hasAlpha: boolean;
  28551. /**
  28552. * Defines if the alpha value should be determined via the rgb values.
  28553. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28554. */
  28555. getAlphaFromRGB: boolean;
  28556. /**
  28557. * Intensity or strength of the texture.
  28558. * It is commonly used by materials to fine tune the intensity of the texture
  28559. */
  28560. level: number;
  28561. /**
  28562. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28563. * This is part of the texture as textures usually maps to one uv set.
  28564. */
  28565. coordinatesIndex: number;
  28566. private _coordinatesMode;
  28567. /**
  28568. * How a texture is mapped.
  28569. *
  28570. * | Value | Type | Description |
  28571. * | ----- | ----------------------------------- | ----------- |
  28572. * | 0 | EXPLICIT_MODE | |
  28573. * | 1 | SPHERICAL_MODE | |
  28574. * | 2 | PLANAR_MODE | |
  28575. * | 3 | CUBIC_MODE | |
  28576. * | 4 | PROJECTION_MODE | |
  28577. * | 5 | SKYBOX_MODE | |
  28578. * | 6 | INVCUBIC_MODE | |
  28579. * | 7 | EQUIRECTANGULAR_MODE | |
  28580. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28581. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28582. */
  28583. coordinatesMode: number;
  28584. /**
  28585. * | Value | Type | Description |
  28586. * | ----- | ------------------ | ----------- |
  28587. * | 0 | CLAMP_ADDRESSMODE | |
  28588. * | 1 | WRAP_ADDRESSMODE | |
  28589. * | 2 | MIRROR_ADDRESSMODE | |
  28590. */
  28591. wrapU: number;
  28592. /**
  28593. * | Value | Type | Description |
  28594. * | ----- | ------------------ | ----------- |
  28595. * | 0 | CLAMP_ADDRESSMODE | |
  28596. * | 1 | WRAP_ADDRESSMODE | |
  28597. * | 2 | MIRROR_ADDRESSMODE | |
  28598. */
  28599. wrapV: number;
  28600. /**
  28601. * | Value | Type | Description |
  28602. * | ----- | ------------------ | ----------- |
  28603. * | 0 | CLAMP_ADDRESSMODE | |
  28604. * | 1 | WRAP_ADDRESSMODE | |
  28605. * | 2 | MIRROR_ADDRESSMODE | |
  28606. */
  28607. wrapR: number;
  28608. /**
  28609. * With compliant hardware and browser (supporting anisotropic filtering)
  28610. * this defines the level of anisotropic filtering in the texture.
  28611. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28612. */
  28613. anisotropicFilteringLevel: number;
  28614. /**
  28615. * Define if the texture is a cube texture or if false a 2d texture.
  28616. */
  28617. isCube: boolean;
  28618. /**
  28619. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28620. */
  28621. is3D: boolean;
  28622. /**
  28623. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28624. * HDR texture are usually stored in linear space.
  28625. * This only impacts the PBR and Background materials
  28626. */
  28627. gammaSpace: boolean;
  28628. /**
  28629. * Gets or sets whether or not the texture contains RGBD data.
  28630. */
  28631. isRGBD: boolean;
  28632. /**
  28633. * Is Z inverted in the texture (useful in a cube texture).
  28634. */
  28635. invertZ: boolean;
  28636. /**
  28637. * Are mip maps generated for this texture or not.
  28638. */
  28639. readonly noMipmap: boolean;
  28640. /**
  28641. * @hidden
  28642. */
  28643. lodLevelInAlpha: boolean;
  28644. /**
  28645. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28646. */
  28647. lodGenerationOffset: number;
  28648. /**
  28649. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28650. */
  28651. lodGenerationScale: number;
  28652. /**
  28653. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28654. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28655. * average roughness values.
  28656. */
  28657. linearSpecularLOD: boolean;
  28658. /**
  28659. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28660. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28661. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28662. */
  28663. irradianceTexture: Nullable<BaseTexture>;
  28664. /**
  28665. * Define if the texture is a render target.
  28666. */
  28667. isRenderTarget: boolean;
  28668. /**
  28669. * Define the unique id of the texture in the scene.
  28670. */
  28671. readonly uid: string;
  28672. /**
  28673. * Return a string representation of the texture.
  28674. * @returns the texture as a string
  28675. */
  28676. toString(): string;
  28677. /**
  28678. * Get the class name of the texture.
  28679. * @returns "BaseTexture"
  28680. */
  28681. getClassName(): string;
  28682. /**
  28683. * Define the list of animation attached to the texture.
  28684. */
  28685. animations: import("babylonjs/Animations/animation").Animation[];
  28686. /**
  28687. * An event triggered when the texture is disposed.
  28688. */
  28689. onDisposeObservable: Observable<BaseTexture>;
  28690. private _onDisposeObserver;
  28691. /**
  28692. * Callback triggered when the texture has been disposed.
  28693. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28694. */
  28695. onDispose: () => void;
  28696. /**
  28697. * Define the current state of the loading sequence when in delayed load mode.
  28698. */
  28699. delayLoadState: number;
  28700. private _scene;
  28701. /** @hidden */
  28702. _texture: Nullable<InternalTexture>;
  28703. private _uid;
  28704. /**
  28705. * Define if the texture is preventinga material to render or not.
  28706. * If not and the texture is not ready, the engine will use a default black texture instead.
  28707. */
  28708. readonly isBlocking: boolean;
  28709. /**
  28710. * Instantiates a new BaseTexture.
  28711. * Base class of all the textures in babylon.
  28712. * It groups all the common properties the materials, post process, lights... might need
  28713. * in order to make a correct use of the texture.
  28714. * @param scene Define the scene the texture blongs to
  28715. */
  28716. constructor(scene: Nullable<Scene>);
  28717. /**
  28718. * Get the scene the texture belongs to.
  28719. * @returns the scene or null if undefined
  28720. */
  28721. getScene(): Nullable<Scene>;
  28722. /**
  28723. * Get the texture transform matrix used to offset tile the texture for istance.
  28724. * @returns the transformation matrix
  28725. */
  28726. getTextureMatrix(): Matrix;
  28727. /**
  28728. * Get the texture reflection matrix used to rotate/transform the reflection.
  28729. * @returns the reflection matrix
  28730. */
  28731. getReflectionTextureMatrix(): Matrix;
  28732. /**
  28733. * Get the underlying lower level texture from Babylon.
  28734. * @returns the insternal texture
  28735. */
  28736. getInternalTexture(): Nullable<InternalTexture>;
  28737. /**
  28738. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28739. * @returns true if ready or not blocking
  28740. */
  28741. isReadyOrNotBlocking(): boolean;
  28742. /**
  28743. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28744. * @returns true if fully ready
  28745. */
  28746. isReady(): boolean;
  28747. private _cachedSize;
  28748. /**
  28749. * Get the size of the texture.
  28750. * @returns the texture size.
  28751. */
  28752. getSize(): ISize;
  28753. /**
  28754. * Get the base size of the texture.
  28755. * It can be different from the size if the texture has been resized for POT for instance
  28756. * @returns the base size
  28757. */
  28758. getBaseSize(): ISize;
  28759. /**
  28760. * Update the sampling mode of the texture.
  28761. * Default is Trilinear mode.
  28762. *
  28763. * | Value | Type | Description |
  28764. * | ----- | ------------------ | ----------- |
  28765. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28766. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28767. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28768. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28769. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28770. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28771. * | 7 | NEAREST_LINEAR | |
  28772. * | 8 | NEAREST_NEAREST | |
  28773. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28774. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28775. * | 11 | LINEAR_LINEAR | |
  28776. * | 12 | LINEAR_NEAREST | |
  28777. *
  28778. * > _mag_: magnification filter (close to the viewer)
  28779. * > _min_: minification filter (far from the viewer)
  28780. * > _mip_: filter used between mip map levels
  28781. *@param samplingMode Define the new sampling mode of the texture
  28782. */
  28783. updateSamplingMode(samplingMode: number): void;
  28784. /**
  28785. * Scales the texture if is `canRescale()`
  28786. * @param ratio the resize factor we want to use to rescale
  28787. */
  28788. scale(ratio: number): void;
  28789. /**
  28790. * Get if the texture can rescale.
  28791. */
  28792. readonly canRescale: boolean;
  28793. /** @hidden */
  28794. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28795. /** @hidden */
  28796. _rebuild(): void;
  28797. /**
  28798. * Triggers the load sequence in delayed load mode.
  28799. */
  28800. delayLoad(): void;
  28801. /**
  28802. * Clones the texture.
  28803. * @returns the cloned texture
  28804. */
  28805. clone(): Nullable<BaseTexture>;
  28806. /**
  28807. * Get the texture underlying type (INT, FLOAT...)
  28808. */
  28809. readonly textureType: number;
  28810. /**
  28811. * Get the texture underlying format (RGB, RGBA...)
  28812. */
  28813. readonly textureFormat: number;
  28814. /**
  28815. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28816. * This will returns an RGBA array buffer containing either in values (0-255) or
  28817. * float values (0-1) depending of the underlying buffer type.
  28818. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28819. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28820. * @param buffer defines a user defined buffer to fill with data (can be null)
  28821. * @returns The Array buffer containing the pixels data.
  28822. */
  28823. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28824. /**
  28825. * Release and destroy the underlying lower level texture aka internalTexture.
  28826. */
  28827. releaseInternalTexture(): void;
  28828. /**
  28829. * Get the polynomial representation of the texture data.
  28830. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28831. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28832. */
  28833. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28834. /** @hidden */
  28835. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28836. /** @hidden */
  28837. readonly _lodTextureMid: Nullable<BaseTexture>;
  28838. /** @hidden */
  28839. readonly _lodTextureLow: Nullable<BaseTexture>;
  28840. /**
  28841. * Dispose the texture and release its associated resources.
  28842. */
  28843. dispose(): void;
  28844. /**
  28845. * Serialize the texture into a JSON representation that can be parsed later on.
  28846. * @returns the JSON representation of the texture
  28847. */
  28848. serialize(): any;
  28849. /**
  28850. * Helper function to be called back once a list of texture contains only ready textures.
  28851. * @param textures Define the list of textures to wait for
  28852. * @param callback Define the callback triggered once the entire list will be ready
  28853. */
  28854. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28855. }
  28856. }
  28857. declare module "babylonjs/Materials/Textures/internalTexture" {
  28858. import { Observable } from "babylonjs/Misc/observable";
  28859. import { Nullable, int } from "babylonjs/types";
  28860. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28861. import { Engine } from "babylonjs/Engines/engine";
  28862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28863. /**
  28864. * Class used to store data associated with WebGL texture data for the engine
  28865. * This class should not be used directly
  28866. */
  28867. export class InternalTexture {
  28868. /** @hidden */
  28869. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28870. /**
  28871. * The source of the texture data is unknown
  28872. */
  28873. static DATASOURCE_UNKNOWN: number;
  28874. /**
  28875. * Texture data comes from an URL
  28876. */
  28877. static DATASOURCE_URL: number;
  28878. /**
  28879. * Texture data is only used for temporary storage
  28880. */
  28881. static DATASOURCE_TEMP: number;
  28882. /**
  28883. * Texture data comes from raw data (ArrayBuffer)
  28884. */
  28885. static DATASOURCE_RAW: number;
  28886. /**
  28887. * Texture content is dynamic (video or dynamic texture)
  28888. */
  28889. static DATASOURCE_DYNAMIC: number;
  28890. /**
  28891. * Texture content is generated by rendering to it
  28892. */
  28893. static DATASOURCE_RENDERTARGET: number;
  28894. /**
  28895. * Texture content is part of a multi render target process
  28896. */
  28897. static DATASOURCE_MULTIRENDERTARGET: number;
  28898. /**
  28899. * Texture data comes from a cube data file
  28900. */
  28901. static DATASOURCE_CUBE: number;
  28902. /**
  28903. * Texture data comes from a raw cube data
  28904. */
  28905. static DATASOURCE_CUBERAW: number;
  28906. /**
  28907. * Texture data come from a prefiltered cube data file
  28908. */
  28909. static DATASOURCE_CUBEPREFILTERED: number;
  28910. /**
  28911. * Texture content is raw 3D data
  28912. */
  28913. static DATASOURCE_RAW3D: number;
  28914. /**
  28915. * Texture content is a depth texture
  28916. */
  28917. static DATASOURCE_DEPTHTEXTURE: number;
  28918. /**
  28919. * Texture data comes from a raw cube data encoded with RGBD
  28920. */
  28921. static DATASOURCE_CUBERAW_RGBD: number;
  28922. /**
  28923. * Defines if the texture is ready
  28924. */
  28925. isReady: boolean;
  28926. /**
  28927. * Defines if the texture is a cube texture
  28928. */
  28929. isCube: boolean;
  28930. /**
  28931. * Defines if the texture contains 3D data
  28932. */
  28933. is3D: boolean;
  28934. /**
  28935. * Defines if the texture contains multiview data
  28936. */
  28937. isMultiview: boolean;
  28938. /**
  28939. * Gets the URL used to load this texture
  28940. */
  28941. url: string;
  28942. /**
  28943. * Gets the sampling mode of the texture
  28944. */
  28945. samplingMode: number;
  28946. /**
  28947. * Gets a boolean indicating if the texture needs mipmaps generation
  28948. */
  28949. generateMipMaps: boolean;
  28950. /**
  28951. * Gets the number of samples used by the texture (WebGL2+ only)
  28952. */
  28953. samples: number;
  28954. /**
  28955. * Gets the type of the texture (int, float...)
  28956. */
  28957. type: number;
  28958. /**
  28959. * Gets the format of the texture (RGB, RGBA...)
  28960. */
  28961. format: number;
  28962. /**
  28963. * Observable called when the texture is loaded
  28964. */
  28965. onLoadedObservable: Observable<InternalTexture>;
  28966. /**
  28967. * Gets the width of the texture
  28968. */
  28969. width: number;
  28970. /**
  28971. * Gets the height of the texture
  28972. */
  28973. height: number;
  28974. /**
  28975. * Gets the depth of the texture
  28976. */
  28977. depth: number;
  28978. /**
  28979. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28980. */
  28981. baseWidth: number;
  28982. /**
  28983. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28984. */
  28985. baseHeight: number;
  28986. /**
  28987. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28988. */
  28989. baseDepth: number;
  28990. /**
  28991. * Gets a boolean indicating if the texture is inverted on Y axis
  28992. */
  28993. invertY: boolean;
  28994. /** @hidden */
  28995. _invertVScale: boolean;
  28996. /** @hidden */
  28997. _associatedChannel: number;
  28998. /** @hidden */
  28999. _dataSource: number;
  29000. /** @hidden */
  29001. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  29002. /** @hidden */
  29003. _bufferView: Nullable<ArrayBufferView>;
  29004. /** @hidden */
  29005. _bufferViewArray: Nullable<ArrayBufferView[]>;
  29006. /** @hidden */
  29007. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29008. /** @hidden */
  29009. _size: number;
  29010. /** @hidden */
  29011. _extension: string;
  29012. /** @hidden */
  29013. _files: Nullable<string[]>;
  29014. /** @hidden */
  29015. _workingCanvas: Nullable<HTMLCanvasElement>;
  29016. /** @hidden */
  29017. _workingContext: Nullable<CanvasRenderingContext2D>;
  29018. /** @hidden */
  29019. _framebuffer: Nullable<WebGLFramebuffer>;
  29020. /** @hidden */
  29021. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29022. /** @hidden */
  29023. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29024. /** @hidden */
  29025. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29026. /** @hidden */
  29027. _attachments: Nullable<number[]>;
  29028. /** @hidden */
  29029. _cachedCoordinatesMode: Nullable<number>;
  29030. /** @hidden */
  29031. _cachedWrapU: Nullable<number>;
  29032. /** @hidden */
  29033. _cachedWrapV: Nullable<number>;
  29034. /** @hidden */
  29035. _cachedWrapR: Nullable<number>;
  29036. /** @hidden */
  29037. _cachedAnisotropicFilteringLevel: Nullable<number>;
  29038. /** @hidden */
  29039. _isDisabled: boolean;
  29040. /** @hidden */
  29041. _compression: Nullable<string>;
  29042. /** @hidden */
  29043. _generateStencilBuffer: boolean;
  29044. /** @hidden */
  29045. _generateDepthBuffer: boolean;
  29046. /** @hidden */
  29047. _comparisonFunction: number;
  29048. /** @hidden */
  29049. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29050. /** @hidden */
  29051. _lodGenerationScale: number;
  29052. /** @hidden */
  29053. _lodGenerationOffset: number;
  29054. /** @hidden */
  29055. _colorTextureArray: Nullable<WebGLTexture>;
  29056. /** @hidden */
  29057. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29058. /** @hidden */
  29059. _lodTextureHigh: Nullable<BaseTexture>;
  29060. /** @hidden */
  29061. _lodTextureMid: Nullable<BaseTexture>;
  29062. /** @hidden */
  29063. _lodTextureLow: Nullable<BaseTexture>;
  29064. /** @hidden */
  29065. _isRGBD: boolean;
  29066. /** @hidden */
  29067. _linearSpecularLOD: boolean;
  29068. /** @hidden */
  29069. _irradianceTexture: Nullable<BaseTexture>;
  29070. /** @hidden */
  29071. _webGLTexture: Nullable<WebGLTexture>;
  29072. /** @hidden */
  29073. _references: number;
  29074. private _engine;
  29075. /**
  29076. * Gets the Engine the texture belongs to.
  29077. * @returns The babylon engine
  29078. */
  29079. getEngine(): Engine;
  29080. /**
  29081. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29082. */
  29083. readonly dataSource: number;
  29084. /**
  29085. * Creates a new InternalTexture
  29086. * @param engine defines the engine to use
  29087. * @param dataSource defines the type of data that will be used
  29088. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29089. */
  29090. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29091. /**
  29092. * Increments the number of references (ie. the number of Texture that point to it)
  29093. */
  29094. incrementReferences(): void;
  29095. /**
  29096. * Change the size of the texture (not the size of the content)
  29097. * @param width defines the new width
  29098. * @param height defines the new height
  29099. * @param depth defines the new depth (1 by default)
  29100. */
  29101. updateSize(width: int, height: int, depth?: int): void;
  29102. /** @hidden */
  29103. _rebuild(): void;
  29104. /** @hidden */
  29105. _swapAndDie(target: InternalTexture): void;
  29106. /**
  29107. * Dispose the current allocated resources
  29108. */
  29109. dispose(): void;
  29110. }
  29111. }
  29112. declare module "babylonjs/Materials/effect" {
  29113. import { Observable } from "babylonjs/Misc/observable";
  29114. import { Nullable } from "babylonjs/types";
  29115. import { IDisposable } from "babylonjs/scene";
  29116. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29117. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29118. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29119. import { Engine } from "babylonjs/Engines/engine";
  29120. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29125. /**
  29126. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29127. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29128. */
  29129. export class EffectFallbacks {
  29130. private _defines;
  29131. private _currentRank;
  29132. private _maxRank;
  29133. private _mesh;
  29134. /**
  29135. * Removes the fallback from the bound mesh.
  29136. */
  29137. unBindMesh(): void;
  29138. /**
  29139. * Adds a fallback on the specified property.
  29140. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29141. * @param define The name of the define in the shader
  29142. */
  29143. addFallback(rank: number, define: string): void;
  29144. /**
  29145. * Sets the mesh to use CPU skinning when needing to fallback.
  29146. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29147. * @param mesh The mesh to use the fallbacks.
  29148. */
  29149. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29150. /**
  29151. * Checks to see if more fallbacks are still availible.
  29152. */
  29153. readonly hasMoreFallbacks: boolean;
  29154. /**
  29155. * Removes the defines that should be removed when falling back.
  29156. * @param currentDefines defines the current define statements for the shader.
  29157. * @param effect defines the current effect we try to compile
  29158. * @returns The resulting defines with defines of the current rank removed.
  29159. */
  29160. reduce(currentDefines: string, effect: Effect): string;
  29161. }
  29162. /**
  29163. * Options to be used when creating an effect.
  29164. */
  29165. export class EffectCreationOptions {
  29166. /**
  29167. * Atrributes that will be used in the shader.
  29168. */
  29169. attributes: string[];
  29170. /**
  29171. * Uniform varible names that will be set in the shader.
  29172. */
  29173. uniformsNames: string[];
  29174. /**
  29175. * Uniform buffer varible names that will be set in the shader.
  29176. */
  29177. uniformBuffersNames: string[];
  29178. /**
  29179. * Sampler texture variable names that will be set in the shader.
  29180. */
  29181. samplers: string[];
  29182. /**
  29183. * Define statements that will be set in the shader.
  29184. */
  29185. defines: any;
  29186. /**
  29187. * Possible fallbacks for this effect to improve performance when needed.
  29188. */
  29189. fallbacks: Nullable<EffectFallbacks>;
  29190. /**
  29191. * Callback that will be called when the shader is compiled.
  29192. */
  29193. onCompiled: Nullable<(effect: Effect) => void>;
  29194. /**
  29195. * Callback that will be called if an error occurs during shader compilation.
  29196. */
  29197. onError: Nullable<(effect: Effect, errors: string) => void>;
  29198. /**
  29199. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29200. */
  29201. indexParameters: any;
  29202. /**
  29203. * Max number of lights that can be used in the shader.
  29204. */
  29205. maxSimultaneousLights: number;
  29206. /**
  29207. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29208. */
  29209. transformFeedbackVaryings: Nullable<string[]>;
  29210. }
  29211. /**
  29212. * Effect containing vertex and fragment shader that can be executed on an object.
  29213. */
  29214. export class Effect implements IDisposable {
  29215. /**
  29216. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29217. */
  29218. static ShadersRepository: string;
  29219. /**
  29220. * Name of the effect.
  29221. */
  29222. name: any;
  29223. /**
  29224. * String container all the define statements that should be set on the shader.
  29225. */
  29226. defines: string;
  29227. /**
  29228. * Callback that will be called when the shader is compiled.
  29229. */
  29230. onCompiled: Nullable<(effect: Effect) => void>;
  29231. /**
  29232. * Callback that will be called if an error occurs during shader compilation.
  29233. */
  29234. onError: Nullable<(effect: Effect, errors: string) => void>;
  29235. /**
  29236. * Callback that will be called when effect is bound.
  29237. */
  29238. onBind: Nullable<(effect: Effect) => void>;
  29239. /**
  29240. * Unique ID of the effect.
  29241. */
  29242. uniqueId: number;
  29243. /**
  29244. * Observable that will be called when the shader is compiled.
  29245. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29246. */
  29247. onCompileObservable: Observable<Effect>;
  29248. /**
  29249. * Observable that will be called if an error occurs during shader compilation.
  29250. */
  29251. onErrorObservable: Observable<Effect>;
  29252. /** @hidden */
  29253. _onBindObservable: Nullable<Observable<Effect>>;
  29254. /**
  29255. * Observable that will be called when effect is bound.
  29256. */
  29257. readonly onBindObservable: Observable<Effect>;
  29258. /** @hidden */
  29259. _bonesComputationForcedToCPU: boolean;
  29260. private static _uniqueIdSeed;
  29261. private _engine;
  29262. private _uniformBuffersNames;
  29263. private _uniformsNames;
  29264. private _samplerList;
  29265. private _samplers;
  29266. private _isReady;
  29267. private _compilationError;
  29268. private _attributesNames;
  29269. private _attributes;
  29270. private _uniforms;
  29271. /**
  29272. * Key for the effect.
  29273. * @hidden
  29274. */
  29275. _key: string;
  29276. private _indexParameters;
  29277. private _fallbacks;
  29278. private _vertexSourceCode;
  29279. private _fragmentSourceCode;
  29280. private _vertexSourceCodeOverride;
  29281. private _fragmentSourceCodeOverride;
  29282. private _transformFeedbackVaryings;
  29283. /**
  29284. * Compiled shader to webGL program.
  29285. * @hidden
  29286. */
  29287. _pipelineContext: Nullable<IPipelineContext>;
  29288. private _valueCache;
  29289. private static _baseCache;
  29290. /**
  29291. * Instantiates an effect.
  29292. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29293. * @param baseName Name of the effect.
  29294. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29295. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29296. * @param samplers List of sampler variables that will be passed to the shader.
  29297. * @param engine Engine to be used to render the effect
  29298. * @param defines Define statements to be added to the shader.
  29299. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29300. * @param onCompiled Callback that will be called when the shader is compiled.
  29301. * @param onError Callback that will be called if an error occurs during shader compilation.
  29302. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29303. */
  29304. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29305. private _useFinalCode;
  29306. /**
  29307. * Unique key for this effect
  29308. */
  29309. readonly key: string;
  29310. /**
  29311. * If the effect has been compiled and prepared.
  29312. * @returns if the effect is compiled and prepared.
  29313. */
  29314. isReady(): boolean;
  29315. private _isReadyInternal;
  29316. /**
  29317. * The engine the effect was initialized with.
  29318. * @returns the engine.
  29319. */
  29320. getEngine(): Engine;
  29321. /**
  29322. * The pipeline context for this effect
  29323. * @returns the associated pipeline context
  29324. */
  29325. getPipelineContext(): Nullable<IPipelineContext>;
  29326. /**
  29327. * The set of names of attribute variables for the shader.
  29328. * @returns An array of attribute names.
  29329. */
  29330. getAttributesNames(): string[];
  29331. /**
  29332. * Returns the attribute at the given index.
  29333. * @param index The index of the attribute.
  29334. * @returns The location of the attribute.
  29335. */
  29336. getAttributeLocation(index: number): number;
  29337. /**
  29338. * Returns the attribute based on the name of the variable.
  29339. * @param name of the attribute to look up.
  29340. * @returns the attribute location.
  29341. */
  29342. getAttributeLocationByName(name: string): number;
  29343. /**
  29344. * The number of attributes.
  29345. * @returns the numnber of attributes.
  29346. */
  29347. getAttributesCount(): number;
  29348. /**
  29349. * Gets the index of a uniform variable.
  29350. * @param uniformName of the uniform to look up.
  29351. * @returns the index.
  29352. */
  29353. getUniformIndex(uniformName: string): number;
  29354. /**
  29355. * Returns the attribute based on the name of the variable.
  29356. * @param uniformName of the uniform to look up.
  29357. * @returns the location of the uniform.
  29358. */
  29359. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29360. /**
  29361. * Returns an array of sampler variable names
  29362. * @returns The array of sampler variable neames.
  29363. */
  29364. getSamplers(): string[];
  29365. /**
  29366. * The error from the last compilation.
  29367. * @returns the error string.
  29368. */
  29369. getCompilationError(): string;
  29370. /**
  29371. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29372. * @param func The callback to be used.
  29373. */
  29374. executeWhenCompiled(func: (effect: Effect) => void): void;
  29375. private _checkIsReady;
  29376. /** @hidden */
  29377. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29378. /** @hidden */
  29379. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29380. /** @hidden */
  29381. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29382. /**
  29383. * Recompiles the webGL program
  29384. * @param vertexSourceCode The source code for the vertex shader.
  29385. * @param fragmentSourceCode The source code for the fragment shader.
  29386. * @param onCompiled Callback called when completed.
  29387. * @param onError Callback called on error.
  29388. * @hidden
  29389. */
  29390. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29391. /**
  29392. * Prepares the effect
  29393. * @hidden
  29394. */
  29395. _prepareEffect(): void;
  29396. private _processCompilationErrors;
  29397. /**
  29398. * Checks if the effect is supported. (Must be called after compilation)
  29399. */
  29400. readonly isSupported: boolean;
  29401. /**
  29402. * Binds a texture to the engine to be used as output of the shader.
  29403. * @param channel Name of the output variable.
  29404. * @param texture Texture to bind.
  29405. * @hidden
  29406. */
  29407. _bindTexture(channel: string, texture: InternalTexture): void;
  29408. /**
  29409. * Sets a texture on the engine to be used in the shader.
  29410. * @param channel Name of the sampler variable.
  29411. * @param texture Texture to set.
  29412. */
  29413. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29414. /**
  29415. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29416. * @param channel Name of the sampler variable.
  29417. * @param texture Texture to set.
  29418. */
  29419. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29420. /**
  29421. * Sets an array of textures on the engine to be used in the shader.
  29422. * @param channel Name of the variable.
  29423. * @param textures Textures to set.
  29424. */
  29425. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29426. /**
  29427. * 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)
  29428. * @param channel Name of the sampler variable.
  29429. * @param postProcess Post process to get the input texture from.
  29430. */
  29431. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29432. /**
  29433. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29434. * 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)
  29435. * @param channel Name of the sampler variable.
  29436. * @param postProcess Post process to get the output texture from.
  29437. */
  29438. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29439. /** @hidden */
  29440. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29441. /** @hidden */
  29442. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29443. /** @hidden */
  29444. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29445. /** @hidden */
  29446. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29447. /**
  29448. * Binds a buffer to a uniform.
  29449. * @param buffer Buffer to bind.
  29450. * @param name Name of the uniform variable to bind to.
  29451. */
  29452. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29453. /**
  29454. * Binds block to a uniform.
  29455. * @param blockName Name of the block to bind.
  29456. * @param index Index to bind.
  29457. */
  29458. bindUniformBlock(blockName: string, index: number): void;
  29459. /**
  29460. * Sets an interger value on a uniform variable.
  29461. * @param uniformName Name of the variable.
  29462. * @param value Value to be set.
  29463. * @returns this effect.
  29464. */
  29465. setInt(uniformName: string, value: number): Effect;
  29466. /**
  29467. * Sets an int array on a uniform variable.
  29468. * @param uniformName Name of the variable.
  29469. * @param array array to be set.
  29470. * @returns this effect.
  29471. */
  29472. setIntArray(uniformName: string, array: Int32Array): Effect;
  29473. /**
  29474. * 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)
  29475. * @param uniformName Name of the variable.
  29476. * @param array array to be set.
  29477. * @returns this effect.
  29478. */
  29479. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29480. /**
  29481. * 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)
  29482. * @param uniformName Name of the variable.
  29483. * @param array array to be set.
  29484. * @returns this effect.
  29485. */
  29486. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29487. /**
  29488. * 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)
  29489. * @param uniformName Name of the variable.
  29490. * @param array array to be set.
  29491. * @returns this effect.
  29492. */
  29493. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29494. /**
  29495. * Sets an float array on a uniform variable.
  29496. * @param uniformName Name of the variable.
  29497. * @param array array to be set.
  29498. * @returns this effect.
  29499. */
  29500. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29501. /**
  29502. * 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)
  29503. * @param uniformName Name of the variable.
  29504. * @param array array to be set.
  29505. * @returns this effect.
  29506. */
  29507. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29508. /**
  29509. * 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)
  29510. * @param uniformName Name of the variable.
  29511. * @param array array to be set.
  29512. * @returns this effect.
  29513. */
  29514. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29515. /**
  29516. * 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)
  29517. * @param uniformName Name of the variable.
  29518. * @param array array to be set.
  29519. * @returns this effect.
  29520. */
  29521. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29522. /**
  29523. * Sets an array on a uniform variable.
  29524. * @param uniformName Name of the variable.
  29525. * @param array array to be set.
  29526. * @returns this effect.
  29527. */
  29528. setArray(uniformName: string, array: number[]): Effect;
  29529. /**
  29530. * 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)
  29531. * @param uniformName Name of the variable.
  29532. * @param array array to be set.
  29533. * @returns this effect.
  29534. */
  29535. setArray2(uniformName: string, array: number[]): Effect;
  29536. /**
  29537. * 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)
  29538. * @param uniformName Name of the variable.
  29539. * @param array array to be set.
  29540. * @returns this effect.
  29541. */
  29542. setArray3(uniformName: string, array: number[]): Effect;
  29543. /**
  29544. * 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)
  29545. * @param uniformName Name of the variable.
  29546. * @param array array to be set.
  29547. * @returns this effect.
  29548. */
  29549. setArray4(uniformName: string, array: number[]): Effect;
  29550. /**
  29551. * Sets matrices on a uniform variable.
  29552. * @param uniformName Name of the variable.
  29553. * @param matrices matrices to be set.
  29554. * @returns this effect.
  29555. */
  29556. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29557. /**
  29558. * Sets matrix on a uniform variable.
  29559. * @param uniformName Name of the variable.
  29560. * @param matrix matrix to be set.
  29561. * @returns this effect.
  29562. */
  29563. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29564. /**
  29565. * 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)
  29566. * @param uniformName Name of the variable.
  29567. * @param matrix matrix to be set.
  29568. * @returns this effect.
  29569. */
  29570. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29571. /**
  29572. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29573. * @param uniformName Name of the variable.
  29574. * @param matrix matrix to be set.
  29575. * @returns this effect.
  29576. */
  29577. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29578. /**
  29579. * Sets a float on a uniform variable.
  29580. * @param uniformName Name of the variable.
  29581. * @param value value to be set.
  29582. * @returns this effect.
  29583. */
  29584. setFloat(uniformName: string, value: number): Effect;
  29585. /**
  29586. * Sets a boolean on a uniform variable.
  29587. * @param uniformName Name of the variable.
  29588. * @param bool value to be set.
  29589. * @returns this effect.
  29590. */
  29591. setBool(uniformName: string, bool: boolean): Effect;
  29592. /**
  29593. * Sets a Vector2 on a uniform variable.
  29594. * @param uniformName Name of the variable.
  29595. * @param vector2 vector2 to be set.
  29596. * @returns this effect.
  29597. */
  29598. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29599. /**
  29600. * Sets a float2 on a uniform variable.
  29601. * @param uniformName Name of the variable.
  29602. * @param x First float in float2.
  29603. * @param y Second float in float2.
  29604. * @returns this effect.
  29605. */
  29606. setFloat2(uniformName: string, x: number, y: number): Effect;
  29607. /**
  29608. * Sets a Vector3 on a uniform variable.
  29609. * @param uniformName Name of the variable.
  29610. * @param vector3 Value to be set.
  29611. * @returns this effect.
  29612. */
  29613. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29614. /**
  29615. * Sets a float3 on a uniform variable.
  29616. * @param uniformName Name of the variable.
  29617. * @param x First float in float3.
  29618. * @param y Second float in float3.
  29619. * @param z Third float in float3.
  29620. * @returns this effect.
  29621. */
  29622. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29623. /**
  29624. * Sets a Vector4 on a uniform variable.
  29625. * @param uniformName Name of the variable.
  29626. * @param vector4 Value to be set.
  29627. * @returns this effect.
  29628. */
  29629. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29630. /**
  29631. * Sets a float4 on a uniform variable.
  29632. * @param uniformName Name of the variable.
  29633. * @param x First float in float4.
  29634. * @param y Second float in float4.
  29635. * @param z Third float in float4.
  29636. * @param w Fourth float in float4.
  29637. * @returns this effect.
  29638. */
  29639. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29640. /**
  29641. * Sets a Color3 on a uniform variable.
  29642. * @param uniformName Name of the variable.
  29643. * @param color3 Value to be set.
  29644. * @returns this effect.
  29645. */
  29646. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29647. /**
  29648. * Sets a Color4 on a uniform variable.
  29649. * @param uniformName Name of the variable.
  29650. * @param color3 Value to be set.
  29651. * @param alpha Alpha value to be set.
  29652. * @returns this effect.
  29653. */
  29654. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29655. /**
  29656. * Sets a Color4 on a uniform variable
  29657. * @param uniformName defines the name of the variable
  29658. * @param color4 defines the value to be set
  29659. * @returns this effect.
  29660. */
  29661. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29662. /** Release all associated resources */
  29663. dispose(): void;
  29664. /**
  29665. * This function will add a new shader to the shader store
  29666. * @param name the name of the shader
  29667. * @param pixelShader optional pixel shader content
  29668. * @param vertexShader optional vertex shader content
  29669. */
  29670. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29671. /**
  29672. * Store of each shader (The can be looked up using effect.key)
  29673. */
  29674. static ShadersStore: {
  29675. [key: string]: string;
  29676. };
  29677. /**
  29678. * Store of each included file for a shader (The can be looked up using effect.key)
  29679. */
  29680. static IncludesShadersStore: {
  29681. [key: string]: string;
  29682. };
  29683. /**
  29684. * Resets the cache of effects.
  29685. */
  29686. static ResetCache(): void;
  29687. }
  29688. }
  29689. declare module "babylonjs/Materials/uniformBuffer" {
  29690. import { Nullable, FloatArray } from "babylonjs/types";
  29691. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29692. import { Engine } from "babylonjs/Engines/engine";
  29693. import { Effect } from "babylonjs/Materials/effect";
  29694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29696. import { Color3 } from "babylonjs/Maths/math.color";
  29697. /**
  29698. * Uniform buffer objects.
  29699. *
  29700. * Handles blocks of uniform on the GPU.
  29701. *
  29702. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29703. *
  29704. * For more information, please refer to :
  29705. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29706. */
  29707. export class UniformBuffer {
  29708. private _engine;
  29709. private _buffer;
  29710. private _data;
  29711. private _bufferData;
  29712. private _dynamic?;
  29713. private _uniformLocations;
  29714. private _uniformSizes;
  29715. private _uniformLocationPointer;
  29716. private _needSync;
  29717. private _noUBO;
  29718. private _currentEffect;
  29719. private static _MAX_UNIFORM_SIZE;
  29720. private static _tempBuffer;
  29721. /**
  29722. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29723. * This is dynamic to allow compat with webgl 1 and 2.
  29724. * You will need to pass the name of the uniform as well as the value.
  29725. */
  29726. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29727. /**
  29728. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29729. * This is dynamic to allow compat with webgl 1 and 2.
  29730. * You will need to pass the name of the uniform as well as the value.
  29731. */
  29732. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29733. /**
  29734. * Lambda to Update a single float in a uniform buffer.
  29735. * This is dynamic to allow compat with webgl 1 and 2.
  29736. * You will need to pass the name of the uniform as well as the value.
  29737. */
  29738. updateFloat: (name: string, x: number) => void;
  29739. /**
  29740. * Lambda to Update a vec2 of float in a uniform buffer.
  29741. * This is dynamic to allow compat with webgl 1 and 2.
  29742. * You will need to pass the name of the uniform as well as the value.
  29743. */
  29744. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29745. /**
  29746. * Lambda to Update a vec3 of float in a uniform buffer.
  29747. * This is dynamic to allow compat with webgl 1 and 2.
  29748. * You will need to pass the name of the uniform as well as the value.
  29749. */
  29750. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29751. /**
  29752. * Lambda to Update a vec4 of float in a uniform buffer.
  29753. * This is dynamic to allow compat with webgl 1 and 2.
  29754. * You will need to pass the name of the uniform as well as the value.
  29755. */
  29756. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29757. /**
  29758. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29759. * This is dynamic to allow compat with webgl 1 and 2.
  29760. * You will need to pass the name of the uniform as well as the value.
  29761. */
  29762. updateMatrix: (name: string, mat: Matrix) => void;
  29763. /**
  29764. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29765. * This is dynamic to allow compat with webgl 1 and 2.
  29766. * You will need to pass the name of the uniform as well as the value.
  29767. */
  29768. updateVector3: (name: string, vector: Vector3) => void;
  29769. /**
  29770. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29771. * This is dynamic to allow compat with webgl 1 and 2.
  29772. * You will need to pass the name of the uniform as well as the value.
  29773. */
  29774. updateVector4: (name: string, vector: Vector4) => void;
  29775. /**
  29776. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29777. * This is dynamic to allow compat with webgl 1 and 2.
  29778. * You will need to pass the name of the uniform as well as the value.
  29779. */
  29780. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29781. /**
  29782. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29783. * This is dynamic to allow compat with webgl 1 and 2.
  29784. * You will need to pass the name of the uniform as well as the value.
  29785. */
  29786. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29787. /**
  29788. * Instantiates a new Uniform buffer objects.
  29789. *
  29790. * Handles blocks of uniform on the GPU.
  29791. *
  29792. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29793. *
  29794. * For more information, please refer to :
  29795. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29796. * @param engine Define the engine the buffer is associated with
  29797. * @param data Define the data contained in the buffer
  29798. * @param dynamic Define if the buffer is updatable
  29799. */
  29800. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29801. /**
  29802. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29803. * or just falling back on setUniformXXX calls.
  29804. */
  29805. readonly useUbo: boolean;
  29806. /**
  29807. * Indicates if the WebGL underlying uniform buffer is in sync
  29808. * with the javascript cache data.
  29809. */
  29810. readonly isSync: boolean;
  29811. /**
  29812. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29813. * Also, a dynamic UniformBuffer will disable cache verification and always
  29814. * update the underlying WebGL uniform buffer to the GPU.
  29815. * @returns if Dynamic, otherwise false
  29816. */
  29817. isDynamic(): boolean;
  29818. /**
  29819. * The data cache on JS side.
  29820. * @returns the underlying data as a float array
  29821. */
  29822. getData(): Float32Array;
  29823. /**
  29824. * The underlying WebGL Uniform buffer.
  29825. * @returns the webgl buffer
  29826. */
  29827. getBuffer(): Nullable<DataBuffer>;
  29828. /**
  29829. * std140 layout specifies how to align data within an UBO structure.
  29830. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29831. * for specs.
  29832. */
  29833. private _fillAlignment;
  29834. /**
  29835. * Adds an uniform in the buffer.
  29836. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29837. * for the layout to be correct !
  29838. * @param name Name of the uniform, as used in the uniform block in the shader.
  29839. * @param size Data size, or data directly.
  29840. */
  29841. addUniform(name: string, size: number | number[]): void;
  29842. /**
  29843. * Adds a Matrix 4x4 to the uniform buffer.
  29844. * @param name Name of the uniform, as used in the uniform block in the shader.
  29845. * @param mat A 4x4 matrix.
  29846. */
  29847. addMatrix(name: string, mat: Matrix): void;
  29848. /**
  29849. * Adds a vec2 to the uniform buffer.
  29850. * @param name Name of the uniform, as used in the uniform block in the shader.
  29851. * @param x Define the x component value of the vec2
  29852. * @param y Define the y component value of the vec2
  29853. */
  29854. addFloat2(name: string, x: number, y: number): void;
  29855. /**
  29856. * Adds a vec3 to the uniform buffer.
  29857. * @param name Name of the uniform, as used in the uniform block in the shader.
  29858. * @param x Define the x component value of the vec3
  29859. * @param y Define the y component value of the vec3
  29860. * @param z Define the z component value of the vec3
  29861. */
  29862. addFloat3(name: string, x: number, y: number, z: number): void;
  29863. /**
  29864. * Adds a vec3 to the uniform buffer.
  29865. * @param name Name of the uniform, as used in the uniform block in the shader.
  29866. * @param color Define the vec3 from a Color
  29867. */
  29868. addColor3(name: string, color: Color3): void;
  29869. /**
  29870. * Adds a vec4 to the uniform buffer.
  29871. * @param name Name of the uniform, as used in the uniform block in the shader.
  29872. * @param color Define the rgb components from a Color
  29873. * @param alpha Define the a component of the vec4
  29874. */
  29875. addColor4(name: string, color: Color3, alpha: number): void;
  29876. /**
  29877. * Adds a vec3 to the uniform buffer.
  29878. * @param name Name of the uniform, as used in the uniform block in the shader.
  29879. * @param vector Define the vec3 components from a Vector
  29880. */
  29881. addVector3(name: string, vector: Vector3): void;
  29882. /**
  29883. * Adds a Matrix 3x3 to the uniform buffer.
  29884. * @param name Name of the uniform, as used in the uniform block in the shader.
  29885. */
  29886. addMatrix3x3(name: string): void;
  29887. /**
  29888. * Adds a Matrix 2x2 to the uniform buffer.
  29889. * @param name Name of the uniform, as used in the uniform block in the shader.
  29890. */
  29891. addMatrix2x2(name: string): void;
  29892. /**
  29893. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29894. */
  29895. create(): void;
  29896. /** @hidden */
  29897. _rebuild(): void;
  29898. /**
  29899. * Updates the WebGL Uniform Buffer on the GPU.
  29900. * If the `dynamic` flag is set to true, no cache comparison is done.
  29901. * Otherwise, the buffer will be updated only if the cache differs.
  29902. */
  29903. update(): void;
  29904. /**
  29905. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29906. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29907. * @param data Define the flattened data
  29908. * @param size Define the size of the data.
  29909. */
  29910. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29911. private _valueCache;
  29912. private _cacheMatrix;
  29913. private _updateMatrix3x3ForUniform;
  29914. private _updateMatrix3x3ForEffect;
  29915. private _updateMatrix2x2ForEffect;
  29916. private _updateMatrix2x2ForUniform;
  29917. private _updateFloatForEffect;
  29918. private _updateFloatForUniform;
  29919. private _updateFloat2ForEffect;
  29920. private _updateFloat2ForUniform;
  29921. private _updateFloat3ForEffect;
  29922. private _updateFloat3ForUniform;
  29923. private _updateFloat4ForEffect;
  29924. private _updateFloat4ForUniform;
  29925. private _updateMatrixForEffect;
  29926. private _updateMatrixForUniform;
  29927. private _updateVector3ForEffect;
  29928. private _updateVector3ForUniform;
  29929. private _updateVector4ForEffect;
  29930. private _updateVector4ForUniform;
  29931. private _updateColor3ForEffect;
  29932. private _updateColor3ForUniform;
  29933. private _updateColor4ForEffect;
  29934. private _updateColor4ForUniform;
  29935. /**
  29936. * Sets a sampler uniform on the effect.
  29937. * @param name Define the name of the sampler.
  29938. * @param texture Define the texture to set in the sampler
  29939. */
  29940. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29941. /**
  29942. * Directly updates the value of the uniform in the cache AND on the GPU.
  29943. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29944. * @param data Define the flattened data
  29945. */
  29946. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29947. /**
  29948. * Binds this uniform buffer to an effect.
  29949. * @param effect Define the effect to bind the buffer to
  29950. * @param name Name of the uniform block in the shader.
  29951. */
  29952. bindToEffect(effect: Effect, name: string): void;
  29953. /**
  29954. * Disposes the uniform buffer.
  29955. */
  29956. dispose(): void;
  29957. }
  29958. }
  29959. declare module "babylonjs/Audio/analyser" {
  29960. import { Scene } from "babylonjs/scene";
  29961. /**
  29962. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29964. */
  29965. export class Analyser {
  29966. /**
  29967. * Gets or sets the smoothing
  29968. * @ignorenaming
  29969. */
  29970. SMOOTHING: number;
  29971. /**
  29972. * Gets or sets the FFT table size
  29973. * @ignorenaming
  29974. */
  29975. FFT_SIZE: number;
  29976. /**
  29977. * Gets or sets the bar graph amplitude
  29978. * @ignorenaming
  29979. */
  29980. BARGRAPHAMPLITUDE: number;
  29981. /**
  29982. * Gets or sets the position of the debug canvas
  29983. * @ignorenaming
  29984. */
  29985. DEBUGCANVASPOS: {
  29986. x: number;
  29987. y: number;
  29988. };
  29989. /**
  29990. * Gets or sets the debug canvas size
  29991. * @ignorenaming
  29992. */
  29993. DEBUGCANVASSIZE: {
  29994. width: number;
  29995. height: number;
  29996. };
  29997. private _byteFreqs;
  29998. private _byteTime;
  29999. private _floatFreqs;
  30000. private _webAudioAnalyser;
  30001. private _debugCanvas;
  30002. private _debugCanvasContext;
  30003. private _scene;
  30004. private _registerFunc;
  30005. private _audioEngine;
  30006. /**
  30007. * Creates a new analyser
  30008. * @param scene defines hosting scene
  30009. */
  30010. constructor(scene: Scene);
  30011. /**
  30012. * Get the number of data values you will have to play with for the visualization
  30013. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30014. * @returns a number
  30015. */
  30016. getFrequencyBinCount(): number;
  30017. /**
  30018. * Gets the current frequency data as a byte array
  30019. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30020. * @returns a Uint8Array
  30021. */
  30022. getByteFrequencyData(): Uint8Array;
  30023. /**
  30024. * Gets the current waveform as a byte array
  30025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30026. * @returns a Uint8Array
  30027. */
  30028. getByteTimeDomainData(): Uint8Array;
  30029. /**
  30030. * Gets the current frequency data as a float array
  30031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30032. * @returns a Float32Array
  30033. */
  30034. getFloatFrequencyData(): Float32Array;
  30035. /**
  30036. * Renders the debug canvas
  30037. */
  30038. drawDebugCanvas(): void;
  30039. /**
  30040. * Stops rendering the debug canvas and removes it
  30041. */
  30042. stopDebugCanvas(): void;
  30043. /**
  30044. * Connects two audio nodes
  30045. * @param inputAudioNode defines first node to connect
  30046. * @param outputAudioNode defines second node to connect
  30047. */
  30048. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30049. /**
  30050. * Releases all associated resources
  30051. */
  30052. dispose(): void;
  30053. }
  30054. }
  30055. declare module "babylonjs/Audio/audioEngine" {
  30056. import { IDisposable } from "babylonjs/scene";
  30057. import { Analyser } from "babylonjs/Audio/analyser";
  30058. import { Nullable } from "babylonjs/types";
  30059. import { Observable } from "babylonjs/Misc/observable";
  30060. /**
  30061. * This represents an audio engine and it is responsible
  30062. * to play, synchronize and analyse sounds throughout the application.
  30063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30064. */
  30065. export interface IAudioEngine extends IDisposable {
  30066. /**
  30067. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30068. */
  30069. readonly canUseWebAudio: boolean;
  30070. /**
  30071. * Gets the current AudioContext if available.
  30072. */
  30073. readonly audioContext: Nullable<AudioContext>;
  30074. /**
  30075. * The master gain node defines the global audio volume of your audio engine.
  30076. */
  30077. readonly masterGain: GainNode;
  30078. /**
  30079. * Gets whether or not mp3 are supported by your browser.
  30080. */
  30081. readonly isMP3supported: boolean;
  30082. /**
  30083. * Gets whether or not ogg are supported by your browser.
  30084. */
  30085. readonly isOGGsupported: boolean;
  30086. /**
  30087. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30088. * @ignoreNaming
  30089. */
  30090. WarnedWebAudioUnsupported: boolean;
  30091. /**
  30092. * Defines if the audio engine relies on a custom unlocked button.
  30093. * In this case, the embedded button will not be displayed.
  30094. */
  30095. useCustomUnlockedButton: boolean;
  30096. /**
  30097. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30098. */
  30099. readonly unlocked: boolean;
  30100. /**
  30101. * Event raised when audio has been unlocked on the browser.
  30102. */
  30103. onAudioUnlockedObservable: Observable<AudioEngine>;
  30104. /**
  30105. * Event raised when audio has been locked on the browser.
  30106. */
  30107. onAudioLockedObservable: Observable<AudioEngine>;
  30108. /**
  30109. * Flags the audio engine in Locked state.
  30110. * This happens due to new browser policies preventing audio to autoplay.
  30111. */
  30112. lock(): void;
  30113. /**
  30114. * Unlocks the audio engine once a user action has been done on the dom.
  30115. * This is helpful to resume play once browser policies have been satisfied.
  30116. */
  30117. unlock(): void;
  30118. }
  30119. /**
  30120. * This represents the default audio engine used in babylon.
  30121. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30123. */
  30124. export class AudioEngine implements IAudioEngine {
  30125. private _audioContext;
  30126. private _audioContextInitialized;
  30127. private _muteButton;
  30128. private _hostElement;
  30129. /**
  30130. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30131. */
  30132. canUseWebAudio: boolean;
  30133. /**
  30134. * The master gain node defines the global audio volume of your audio engine.
  30135. */
  30136. masterGain: GainNode;
  30137. /**
  30138. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30139. * @ignoreNaming
  30140. */
  30141. WarnedWebAudioUnsupported: boolean;
  30142. /**
  30143. * Gets whether or not mp3 are supported by your browser.
  30144. */
  30145. isMP3supported: boolean;
  30146. /**
  30147. * Gets whether or not ogg are supported by your browser.
  30148. */
  30149. isOGGsupported: boolean;
  30150. /**
  30151. * Gets whether audio has been unlocked on the device.
  30152. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30153. * a user interaction has happened.
  30154. */
  30155. unlocked: boolean;
  30156. /**
  30157. * Defines if the audio engine relies on a custom unlocked button.
  30158. * In this case, the embedded button will not be displayed.
  30159. */
  30160. useCustomUnlockedButton: boolean;
  30161. /**
  30162. * Event raised when audio has been unlocked on the browser.
  30163. */
  30164. onAudioUnlockedObservable: Observable<AudioEngine>;
  30165. /**
  30166. * Event raised when audio has been locked on the browser.
  30167. */
  30168. onAudioLockedObservable: Observable<AudioEngine>;
  30169. /**
  30170. * Gets the current AudioContext if available.
  30171. */
  30172. readonly audioContext: Nullable<AudioContext>;
  30173. private _connectedAnalyser;
  30174. /**
  30175. * Instantiates a new audio engine.
  30176. *
  30177. * There should be only one per page as some browsers restrict the number
  30178. * of audio contexts you can create.
  30179. * @param hostElement defines the host element where to display the mute icon if necessary
  30180. */
  30181. constructor(hostElement?: Nullable<HTMLElement>);
  30182. /**
  30183. * Flags the audio engine in Locked state.
  30184. * This happens due to new browser policies preventing audio to autoplay.
  30185. */
  30186. lock(): void;
  30187. /**
  30188. * Unlocks the audio engine once a user action has been done on the dom.
  30189. * This is helpful to resume play once browser policies have been satisfied.
  30190. */
  30191. unlock(): void;
  30192. private _resumeAudioContext;
  30193. private _initializeAudioContext;
  30194. private _tryToRun;
  30195. private _triggerRunningState;
  30196. private _triggerSuspendedState;
  30197. private _displayMuteButton;
  30198. private _moveButtonToTopLeft;
  30199. private _onResize;
  30200. private _hideMuteButton;
  30201. /**
  30202. * Destroy and release the resources associated with the audio ccontext.
  30203. */
  30204. dispose(): void;
  30205. /**
  30206. * Gets the global volume sets on the master gain.
  30207. * @returns the global volume if set or -1 otherwise
  30208. */
  30209. getGlobalVolume(): number;
  30210. /**
  30211. * Sets the global volume of your experience (sets on the master gain).
  30212. * @param newVolume Defines the new global volume of the application
  30213. */
  30214. setGlobalVolume(newVolume: number): void;
  30215. /**
  30216. * Connect the audio engine to an audio analyser allowing some amazing
  30217. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30219. * @param analyser The analyser to connect to the engine
  30220. */
  30221. connectToAnalyser(analyser: Analyser): void;
  30222. }
  30223. }
  30224. declare module "babylonjs/Loading/loadingScreen" {
  30225. /**
  30226. * Interface used to present a loading screen while loading a scene
  30227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30228. */
  30229. export interface ILoadingScreen {
  30230. /**
  30231. * Function called to display the loading screen
  30232. */
  30233. displayLoadingUI: () => void;
  30234. /**
  30235. * Function called to hide the loading screen
  30236. */
  30237. hideLoadingUI: () => void;
  30238. /**
  30239. * Gets or sets the color to use for the background
  30240. */
  30241. loadingUIBackgroundColor: string;
  30242. /**
  30243. * Gets or sets the text to display while loading
  30244. */
  30245. loadingUIText: string;
  30246. }
  30247. /**
  30248. * Class used for the default loading screen
  30249. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30250. */
  30251. export class DefaultLoadingScreen implements ILoadingScreen {
  30252. private _renderingCanvas;
  30253. private _loadingText;
  30254. private _loadingDivBackgroundColor;
  30255. private _loadingDiv;
  30256. private _loadingTextDiv;
  30257. /** Gets or sets the logo url to use for the default loading screen */
  30258. static DefaultLogoUrl: string;
  30259. /** Gets or sets the spinner url to use for the default loading screen */
  30260. static DefaultSpinnerUrl: string;
  30261. /**
  30262. * Creates a new default loading screen
  30263. * @param _renderingCanvas defines the canvas used to render the scene
  30264. * @param _loadingText defines the default text to display
  30265. * @param _loadingDivBackgroundColor defines the default background color
  30266. */
  30267. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30268. /**
  30269. * Function called to display the loading screen
  30270. */
  30271. displayLoadingUI(): void;
  30272. /**
  30273. * Function called to hide the loading screen
  30274. */
  30275. hideLoadingUI(): void;
  30276. /**
  30277. * Gets or sets the text to display while loading
  30278. */
  30279. loadingUIText: string;
  30280. /**
  30281. * Gets or sets the color to use for the background
  30282. */
  30283. loadingUIBackgroundColor: string;
  30284. private _resizeLoadingUI;
  30285. }
  30286. }
  30287. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30288. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30289. import { Engine } from "babylonjs/Engines/engine";
  30290. import { Nullable } from "babylonjs/types";
  30291. /** @hidden */
  30292. export class WebGLPipelineContext implements IPipelineContext {
  30293. engine: Engine;
  30294. program: Nullable<WebGLProgram>;
  30295. context?: WebGLRenderingContext;
  30296. vertexShader?: WebGLShader;
  30297. fragmentShader?: WebGLShader;
  30298. isParallelCompiled: boolean;
  30299. onCompiled?: () => void;
  30300. transformFeedback?: WebGLTransformFeedback | null;
  30301. readonly isAsync: boolean;
  30302. readonly isReady: boolean;
  30303. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30304. }
  30305. }
  30306. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30307. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30308. /** @hidden */
  30309. export class WebGLDataBuffer extends DataBuffer {
  30310. private _buffer;
  30311. constructor(resource: WebGLBuffer);
  30312. readonly underlyingResource: any;
  30313. }
  30314. }
  30315. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30316. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30317. /** @hidden */
  30318. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30319. attributeProcessor(attribute: string): string;
  30320. varyingProcessor(varying: string, isFragment: boolean): string;
  30321. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30322. }
  30323. }
  30324. declare module "babylonjs/Misc/perfCounter" {
  30325. /**
  30326. * This class is used to track a performance counter which is number based.
  30327. * The user has access to many properties which give statistics of different nature.
  30328. *
  30329. * The implementer can track two kinds of Performance Counter: time and count.
  30330. * 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.
  30331. * 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.
  30332. */
  30333. export class PerfCounter {
  30334. /**
  30335. * Gets or sets a global boolean to turn on and off all the counters
  30336. */
  30337. static Enabled: boolean;
  30338. /**
  30339. * Returns the smallest value ever
  30340. */
  30341. readonly min: number;
  30342. /**
  30343. * Returns the biggest value ever
  30344. */
  30345. readonly max: number;
  30346. /**
  30347. * Returns the average value since the performance counter is running
  30348. */
  30349. readonly average: number;
  30350. /**
  30351. * Returns the average value of the last second the counter was monitored
  30352. */
  30353. readonly lastSecAverage: number;
  30354. /**
  30355. * Returns the current value
  30356. */
  30357. readonly current: number;
  30358. /**
  30359. * Gets the accumulated total
  30360. */
  30361. readonly total: number;
  30362. /**
  30363. * Gets the total value count
  30364. */
  30365. readonly count: number;
  30366. /**
  30367. * Creates a new counter
  30368. */
  30369. constructor();
  30370. /**
  30371. * Call this method to start monitoring a new frame.
  30372. * 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.
  30373. */
  30374. fetchNewFrame(): void;
  30375. /**
  30376. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30377. * @param newCount the count value to add to the monitored count
  30378. * @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.
  30379. */
  30380. addCount(newCount: number, fetchResult: boolean): void;
  30381. /**
  30382. * Start monitoring this performance counter
  30383. */
  30384. beginMonitoring(): void;
  30385. /**
  30386. * Compute the time lapsed since the previous beginMonitoring() call.
  30387. * @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
  30388. */
  30389. endMonitoring(newFrame?: boolean): void;
  30390. private _fetchResult;
  30391. private _startMonitoringTime;
  30392. private _min;
  30393. private _max;
  30394. private _average;
  30395. private _current;
  30396. private _totalValueCount;
  30397. private _totalAccumulated;
  30398. private _lastSecAverage;
  30399. private _lastSecAccumulated;
  30400. private _lastSecTime;
  30401. private _lastSecValueCount;
  30402. }
  30403. }
  30404. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30405. /**
  30406. * Interface for any object that can request an animation frame
  30407. */
  30408. export interface ICustomAnimationFrameRequester {
  30409. /**
  30410. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30411. */
  30412. renderFunction?: Function;
  30413. /**
  30414. * Called to request the next frame to render to
  30415. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30416. */
  30417. requestAnimationFrame: Function;
  30418. /**
  30419. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30420. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30421. */
  30422. requestID?: number;
  30423. }
  30424. }
  30425. declare module "babylonjs/Materials/Textures/videoTexture" {
  30426. import { Observable } from "babylonjs/Misc/observable";
  30427. import { Nullable } from "babylonjs/types";
  30428. import { Scene } from "babylonjs/scene";
  30429. import { Texture } from "babylonjs/Materials/Textures/texture";
  30430. /**
  30431. * Settings for finer control over video usage
  30432. */
  30433. export interface VideoTextureSettings {
  30434. /**
  30435. * Applies `autoplay` to video, if specified
  30436. */
  30437. autoPlay?: boolean;
  30438. /**
  30439. * Applies `loop` to video, if specified
  30440. */
  30441. loop?: boolean;
  30442. /**
  30443. * Automatically updates internal texture from video at every frame in the render loop
  30444. */
  30445. autoUpdateTexture: boolean;
  30446. /**
  30447. * Image src displayed during the video loading or until the user interacts with the video.
  30448. */
  30449. poster?: string;
  30450. }
  30451. /**
  30452. * If you want to display a video in your scene, this is the special texture for that.
  30453. * This special texture works similar to other textures, with the exception of a few parameters.
  30454. * @see https://doc.babylonjs.com/how_to/video_texture
  30455. */
  30456. export class VideoTexture extends Texture {
  30457. /**
  30458. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30459. */
  30460. readonly autoUpdateTexture: boolean;
  30461. /**
  30462. * The video instance used by the texture internally
  30463. */
  30464. readonly video: HTMLVideoElement;
  30465. private _onUserActionRequestedObservable;
  30466. /**
  30467. * Event triggerd when a dom action is required by the user to play the video.
  30468. * This happens due to recent changes in browser policies preventing video to auto start.
  30469. */
  30470. readonly onUserActionRequestedObservable: Observable<Texture>;
  30471. private _generateMipMaps;
  30472. private _engine;
  30473. private _stillImageCaptured;
  30474. private _displayingPosterTexture;
  30475. private _settings;
  30476. private _createInternalTextureOnEvent;
  30477. private _frameId;
  30478. /**
  30479. * Creates a video texture.
  30480. * If you want to display a video in your scene, this is the special texture for that.
  30481. * This special texture works similar to other textures, with the exception of a few parameters.
  30482. * @see https://doc.babylonjs.com/how_to/video_texture
  30483. * @param name optional name, will detect from video source, if not defined
  30484. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30485. * @param scene is obviously the current scene.
  30486. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30487. * @param invertY is false by default but can be used to invert video on Y axis
  30488. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30489. * @param settings allows finer control over video usage
  30490. */
  30491. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30492. private _getName;
  30493. private _getVideo;
  30494. private _createInternalTexture;
  30495. private reset;
  30496. /**
  30497. * @hidden Internal method to initiate `update`.
  30498. */
  30499. _rebuild(): void;
  30500. /**
  30501. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30502. */
  30503. update(): void;
  30504. /**
  30505. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30506. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30507. */
  30508. updateTexture(isVisible: boolean): void;
  30509. protected _updateInternalTexture: () => void;
  30510. /**
  30511. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30512. * @param url New url.
  30513. */
  30514. updateURL(url: string): void;
  30515. /**
  30516. * Dispose the texture and release its associated resources.
  30517. */
  30518. dispose(): void;
  30519. /**
  30520. * Creates a video texture straight from a stream.
  30521. * @param scene Define the scene the texture should be created in
  30522. * @param stream Define the stream the texture should be created from
  30523. * @returns The created video texture as a promise
  30524. */
  30525. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30526. /**
  30527. * Creates a video texture straight from your WebCam video feed.
  30528. * @param scene Define the scene the texture should be created in
  30529. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30530. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30531. * @returns The created video texture as a promise
  30532. */
  30533. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30534. minWidth: number;
  30535. maxWidth: number;
  30536. minHeight: number;
  30537. maxHeight: number;
  30538. deviceId: string;
  30539. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30540. /**
  30541. * Creates a video texture straight from your WebCam video feed.
  30542. * @param scene Define the scene the texture should be created in
  30543. * @param onReady Define a callback to triggered once the texture will be ready
  30544. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30545. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30546. */
  30547. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30548. minWidth: number;
  30549. maxWidth: number;
  30550. minHeight: number;
  30551. maxHeight: number;
  30552. deviceId: string;
  30553. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30554. }
  30555. }
  30556. declare module "babylonjs/Engines/engine" {
  30557. import { Observable } from "babylonjs/Misc/observable";
  30558. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30559. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30560. import { Scene } from "babylonjs/scene";
  30561. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30562. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30563. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30564. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30567. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30568. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30569. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30570. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30571. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30572. import { WebRequest } from "babylonjs/Misc/webRequest";
  30573. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30574. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30575. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30576. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30577. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30578. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30579. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30580. import { Material } from "babylonjs/Materials/material";
  30581. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30583. /**
  30584. * Defines the interface used by objects containing a viewport (like a camera)
  30585. */
  30586. interface IViewportOwnerLike {
  30587. /**
  30588. * Gets or sets the viewport
  30589. */
  30590. viewport: IViewportLike;
  30591. }
  30592. /**
  30593. * Interface for attribute information associated with buffer instanciation
  30594. */
  30595. export class InstancingAttributeInfo {
  30596. /**
  30597. * Index/offset of the attribute in the vertex shader
  30598. */
  30599. index: number;
  30600. /**
  30601. * size of the attribute, 1, 2, 3 or 4
  30602. */
  30603. attributeSize: number;
  30604. /**
  30605. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30606. * default is FLOAT
  30607. */
  30608. attribyteType: number;
  30609. /**
  30610. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30611. */
  30612. normalized: boolean;
  30613. /**
  30614. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30615. */
  30616. offset: number;
  30617. /**
  30618. * Name of the GLSL attribute, for debugging purpose only
  30619. */
  30620. attributeName: string;
  30621. }
  30622. /**
  30623. * Define options used to create a depth texture
  30624. */
  30625. export class DepthTextureCreationOptions {
  30626. /** Specifies whether or not a stencil should be allocated in the texture */
  30627. generateStencil?: boolean;
  30628. /** Specifies whether or not bilinear filtering is enable on the texture */
  30629. bilinearFiltering?: boolean;
  30630. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30631. comparisonFunction?: number;
  30632. /** Specifies if the created texture is a cube texture */
  30633. isCube?: boolean;
  30634. }
  30635. /**
  30636. * Class used to describe the capabilities of the engine relatively to the current browser
  30637. */
  30638. export class EngineCapabilities {
  30639. /** Maximum textures units per fragment shader */
  30640. maxTexturesImageUnits: number;
  30641. /** Maximum texture units per vertex shader */
  30642. maxVertexTextureImageUnits: number;
  30643. /** Maximum textures units in the entire pipeline */
  30644. maxCombinedTexturesImageUnits: number;
  30645. /** Maximum texture size */
  30646. maxTextureSize: number;
  30647. /** Maximum cube texture size */
  30648. maxCubemapTextureSize: number;
  30649. /** Maximum render texture size */
  30650. maxRenderTextureSize: number;
  30651. /** Maximum number of vertex attributes */
  30652. maxVertexAttribs: number;
  30653. /** Maximum number of varyings */
  30654. maxVaryingVectors: number;
  30655. /** Maximum number of uniforms per vertex shader */
  30656. maxVertexUniformVectors: number;
  30657. /** Maximum number of uniforms per fragment shader */
  30658. maxFragmentUniformVectors: number;
  30659. /** Defines if standard derivates (dx/dy) are supported */
  30660. standardDerivatives: boolean;
  30661. /** Defines if s3tc texture compression is supported */
  30662. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30663. /** Defines if pvrtc texture compression is supported */
  30664. pvrtc: any;
  30665. /** Defines if etc1 texture compression is supported */
  30666. etc1: any;
  30667. /** Defines if etc2 texture compression is supported */
  30668. etc2: any;
  30669. /** Defines if astc texture compression is supported */
  30670. astc: any;
  30671. /** Defines if float textures are supported */
  30672. textureFloat: boolean;
  30673. /** Defines if vertex array objects are supported */
  30674. vertexArrayObject: boolean;
  30675. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30676. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30677. /** Gets the maximum level of anisotropy supported */
  30678. maxAnisotropy: number;
  30679. /** Defines if instancing is supported */
  30680. instancedArrays: boolean;
  30681. /** Defines if 32 bits indices are supported */
  30682. uintIndices: boolean;
  30683. /** Defines if high precision shaders are supported */
  30684. highPrecisionShaderSupported: boolean;
  30685. /** Defines if depth reading in the fragment shader is supported */
  30686. fragmentDepthSupported: boolean;
  30687. /** Defines if float texture linear filtering is supported*/
  30688. textureFloatLinearFiltering: boolean;
  30689. /** Defines if rendering to float textures is supported */
  30690. textureFloatRender: boolean;
  30691. /** Defines if half float textures are supported*/
  30692. textureHalfFloat: boolean;
  30693. /** Defines if half float texture linear filtering is supported*/
  30694. textureHalfFloatLinearFiltering: boolean;
  30695. /** Defines if rendering to half float textures is supported */
  30696. textureHalfFloatRender: boolean;
  30697. /** Defines if textureLOD shader command is supported */
  30698. textureLOD: boolean;
  30699. /** Defines if draw buffers extension is supported */
  30700. drawBuffersExtension: boolean;
  30701. /** Defines if depth textures are supported */
  30702. depthTextureExtension: boolean;
  30703. /** Defines if float color buffer are supported */
  30704. colorBufferFloat: boolean;
  30705. /** Gets disjoint timer query extension (null if not supported) */
  30706. timerQuery: EXT_disjoint_timer_query;
  30707. /** Defines if timestamp can be used with timer query */
  30708. canUseTimestampForTimerQuery: boolean;
  30709. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30710. multiview: any;
  30711. /** Function used to let the system compiles shaders in background */
  30712. parallelShaderCompile: {
  30713. COMPLETION_STATUS_KHR: number;
  30714. };
  30715. /** Max number of texture samples for MSAA */
  30716. maxMSAASamples: number;
  30717. /** Defines if the blend min max extension is supported */
  30718. blendMinMax: boolean;
  30719. }
  30720. /** Interface defining initialization parameters for Engine class */
  30721. export interface EngineOptions extends WebGLContextAttributes {
  30722. /**
  30723. * Defines if the engine should no exceed a specified device ratio
  30724. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30725. */
  30726. limitDeviceRatio?: number;
  30727. /**
  30728. * Defines if webvr should be enabled automatically
  30729. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30730. */
  30731. autoEnableWebVR?: boolean;
  30732. /**
  30733. * Defines if webgl2 should be turned off even if supported
  30734. * @see http://doc.babylonjs.com/features/webgl2
  30735. */
  30736. disableWebGL2Support?: boolean;
  30737. /**
  30738. * Defines if webaudio should be initialized as well
  30739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30740. */
  30741. audioEngine?: boolean;
  30742. /**
  30743. * Defines if animations should run using a deterministic lock step
  30744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30745. */
  30746. deterministicLockstep?: boolean;
  30747. /** Defines the maximum steps to use with deterministic lock step mode */
  30748. lockstepMaxSteps?: number;
  30749. /**
  30750. * Defines that engine should ignore context lost events
  30751. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30752. */
  30753. doNotHandleContextLost?: boolean;
  30754. /**
  30755. * Defines that engine should ignore modifying touch action attribute and style
  30756. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30757. */
  30758. doNotHandleTouchAction?: boolean;
  30759. /**
  30760. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30761. */
  30762. useHighPrecisionFloats?: boolean;
  30763. }
  30764. /**
  30765. * Defines the interface used by display changed events
  30766. */
  30767. export interface IDisplayChangedEventArgs {
  30768. /** Gets the vrDisplay object (if any) */
  30769. vrDisplay: Nullable<any>;
  30770. /** Gets a boolean indicating if webVR is supported */
  30771. vrSupported: boolean;
  30772. }
  30773. /**
  30774. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30775. */
  30776. export class Engine {
  30777. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30778. static ExceptionList: ({
  30779. key: string;
  30780. capture: string;
  30781. captureConstraint: number;
  30782. targets: string[];
  30783. } | {
  30784. key: string;
  30785. capture: null;
  30786. captureConstraint: null;
  30787. targets: string[];
  30788. })[];
  30789. /** Gets the list of created engines */
  30790. static readonly Instances: Engine[];
  30791. /**
  30792. * Gets the latest created engine
  30793. */
  30794. static readonly LastCreatedEngine: Nullable<Engine>;
  30795. /**
  30796. * Gets the latest created scene
  30797. */
  30798. static readonly LastCreatedScene: Nullable<Scene>;
  30799. /**
  30800. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30801. * @param flag defines which part of the materials must be marked as dirty
  30802. * @param predicate defines a predicate used to filter which materials should be affected
  30803. */
  30804. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30805. /** @hidden */
  30806. static _TextureLoaders: IInternalTextureLoader[];
  30807. /** Defines that alpha blending is disabled */
  30808. static readonly ALPHA_DISABLE: number;
  30809. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30810. static readonly ALPHA_ADD: number;
  30811. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30812. static readonly ALPHA_COMBINE: number;
  30813. /** Defines that alpha blending to DEST - SRC * DEST */
  30814. static readonly ALPHA_SUBTRACT: number;
  30815. /** Defines that alpha blending to SRC * DEST */
  30816. static readonly ALPHA_MULTIPLY: number;
  30817. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30818. static readonly ALPHA_MAXIMIZED: number;
  30819. /** Defines that alpha blending to SRC + DEST */
  30820. static readonly ALPHA_ONEONE: number;
  30821. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30822. static readonly ALPHA_PREMULTIPLIED: number;
  30823. /**
  30824. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30825. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30826. */
  30827. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30828. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30829. static readonly ALPHA_INTERPOLATE: number;
  30830. /**
  30831. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30832. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30833. */
  30834. static readonly ALPHA_SCREENMODE: number;
  30835. /** Defines that the ressource is not delayed*/
  30836. static readonly DELAYLOADSTATE_NONE: number;
  30837. /** Defines that the ressource was successfully delay loaded */
  30838. static readonly DELAYLOADSTATE_LOADED: number;
  30839. /** Defines that the ressource is currently delay loading */
  30840. static readonly DELAYLOADSTATE_LOADING: number;
  30841. /** Defines that the ressource is delayed and has not started loading */
  30842. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30843. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30844. static readonly NEVER: number;
  30845. /** 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 */
  30846. static readonly ALWAYS: number;
  30847. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30848. static readonly LESS: number;
  30849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30850. static readonly EQUAL: number;
  30851. /** 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 */
  30852. static readonly LEQUAL: number;
  30853. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30854. static readonly GREATER: number;
  30855. /** 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 */
  30856. static readonly GEQUAL: number;
  30857. /** 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 */
  30858. static readonly NOTEQUAL: number;
  30859. /** Passed to stencilOperation to specify that stencil value must be kept */
  30860. static readonly KEEP: number;
  30861. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30862. static readonly REPLACE: number;
  30863. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30864. static readonly INCR: number;
  30865. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30866. static readonly DECR: number;
  30867. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30868. static readonly INVERT: number;
  30869. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30870. static readonly INCR_WRAP: number;
  30871. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30872. static readonly DECR_WRAP: number;
  30873. /** Texture is not repeating outside of 0..1 UVs */
  30874. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30875. /** Texture is repeating outside of 0..1 UVs */
  30876. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30877. /** Texture is repeating and mirrored */
  30878. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30879. /** ALPHA */
  30880. static readonly TEXTUREFORMAT_ALPHA: number;
  30881. /** LUMINANCE */
  30882. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30883. /** LUMINANCE_ALPHA */
  30884. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30885. /** RGB */
  30886. static readonly TEXTUREFORMAT_RGB: number;
  30887. /** RGBA */
  30888. static readonly TEXTUREFORMAT_RGBA: number;
  30889. /** RED */
  30890. static readonly TEXTUREFORMAT_RED: number;
  30891. /** RED (2nd reference) */
  30892. static readonly TEXTUREFORMAT_R: number;
  30893. /** RG */
  30894. static readonly TEXTUREFORMAT_RG: number;
  30895. /** RED_INTEGER */
  30896. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30897. /** RED_INTEGER (2nd reference) */
  30898. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30899. /** RG_INTEGER */
  30900. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30901. /** RGB_INTEGER */
  30902. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30903. /** RGBA_INTEGER */
  30904. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30905. /** UNSIGNED_BYTE */
  30906. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30907. /** UNSIGNED_BYTE (2nd reference) */
  30908. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30909. /** FLOAT */
  30910. static readonly TEXTURETYPE_FLOAT: number;
  30911. /** HALF_FLOAT */
  30912. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30913. /** BYTE */
  30914. static readonly TEXTURETYPE_BYTE: number;
  30915. /** SHORT */
  30916. static readonly TEXTURETYPE_SHORT: number;
  30917. /** UNSIGNED_SHORT */
  30918. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30919. /** INT */
  30920. static readonly TEXTURETYPE_INT: number;
  30921. /** UNSIGNED_INT */
  30922. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30923. /** UNSIGNED_SHORT_4_4_4_4 */
  30924. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30925. /** UNSIGNED_SHORT_5_5_5_1 */
  30926. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30927. /** UNSIGNED_SHORT_5_6_5 */
  30928. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30929. /** UNSIGNED_INT_2_10_10_10_REV */
  30930. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30931. /** UNSIGNED_INT_24_8 */
  30932. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30933. /** UNSIGNED_INT_10F_11F_11F_REV */
  30934. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30935. /** UNSIGNED_INT_5_9_9_9_REV */
  30936. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30937. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30938. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30939. /** nearest is mag = nearest and min = nearest and mip = linear */
  30940. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30941. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30942. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30943. /** Trilinear is mag = linear and min = linear and mip = linear */
  30944. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30945. /** nearest is mag = nearest and min = nearest and mip = linear */
  30946. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30947. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30948. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30949. /** Trilinear is mag = linear and min = linear and mip = linear */
  30950. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30951. /** mag = nearest and min = nearest and mip = nearest */
  30952. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30953. /** mag = nearest and min = linear and mip = nearest */
  30954. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30955. /** mag = nearest and min = linear and mip = linear */
  30956. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30957. /** mag = nearest and min = linear and mip = none */
  30958. static readonly TEXTURE_NEAREST_LINEAR: number;
  30959. /** mag = nearest and min = nearest and mip = none */
  30960. static readonly TEXTURE_NEAREST_NEAREST: number;
  30961. /** mag = linear and min = nearest and mip = nearest */
  30962. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30963. /** mag = linear and min = nearest and mip = linear */
  30964. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30965. /** mag = linear and min = linear and mip = none */
  30966. static readonly TEXTURE_LINEAR_LINEAR: number;
  30967. /** mag = linear and min = nearest and mip = none */
  30968. static readonly TEXTURE_LINEAR_NEAREST: number;
  30969. /** Explicit coordinates mode */
  30970. static readonly TEXTURE_EXPLICIT_MODE: number;
  30971. /** Spherical coordinates mode */
  30972. static readonly TEXTURE_SPHERICAL_MODE: number;
  30973. /** Planar coordinates mode */
  30974. static readonly TEXTURE_PLANAR_MODE: number;
  30975. /** Cubic coordinates mode */
  30976. static readonly TEXTURE_CUBIC_MODE: number;
  30977. /** Projection coordinates mode */
  30978. static readonly TEXTURE_PROJECTION_MODE: number;
  30979. /** Skybox coordinates mode */
  30980. static readonly TEXTURE_SKYBOX_MODE: number;
  30981. /** Inverse Cubic coordinates mode */
  30982. static readonly TEXTURE_INVCUBIC_MODE: number;
  30983. /** Equirectangular coordinates mode */
  30984. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30985. /** Equirectangular Fixed coordinates mode */
  30986. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30987. /** Equirectangular Fixed Mirrored coordinates mode */
  30988. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30989. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30990. static readonly SCALEMODE_FLOOR: number;
  30991. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30992. static readonly SCALEMODE_NEAREST: number;
  30993. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30994. static readonly SCALEMODE_CEILING: number;
  30995. /**
  30996. * Returns the current npm package of the sdk
  30997. */
  30998. static readonly NpmPackage: string;
  30999. /**
  31000. * Returns the current version of the framework
  31001. */
  31002. static readonly Version: string;
  31003. /**
  31004. * Returns a string describing the current engine
  31005. */
  31006. readonly description: string;
  31007. /**
  31008. * Gets or sets the epsilon value used by collision engine
  31009. */
  31010. static CollisionsEpsilon: number;
  31011. /**
  31012. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31013. */
  31014. static ShadersRepository: string;
  31015. /**
  31016. * Method called to create the default loading screen.
  31017. * This can be overriden in your own app.
  31018. * @param canvas The rendering canvas element
  31019. * @returns The loading screen
  31020. */
  31021. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31022. /**
  31023. * Method called to create the default rescale post process on each engine.
  31024. */
  31025. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31026. /** @hidden */
  31027. _shaderProcessor: IShaderProcessor;
  31028. /**
  31029. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31030. */
  31031. forcePOTTextures: boolean;
  31032. /**
  31033. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31034. */
  31035. isFullscreen: boolean;
  31036. /**
  31037. * Gets a boolean indicating if the pointer is currently locked
  31038. */
  31039. isPointerLock: boolean;
  31040. /**
  31041. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31042. */
  31043. cullBackFaces: boolean;
  31044. /**
  31045. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31046. */
  31047. renderEvenInBackground: boolean;
  31048. /**
  31049. * Gets or sets a boolean indicating that cache can be kept between frames
  31050. */
  31051. preventCacheWipeBetweenFrames: boolean;
  31052. /**
  31053. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31054. **/
  31055. enableOfflineSupport: boolean;
  31056. /**
  31057. * 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)
  31058. **/
  31059. disableManifestCheck: boolean;
  31060. /**
  31061. * Gets the list of created scenes
  31062. */
  31063. scenes: Scene[];
  31064. /**
  31065. * Event raised when a new scene is created
  31066. */
  31067. onNewSceneAddedObservable: Observable<Scene>;
  31068. /**
  31069. * Gets the list of created postprocesses
  31070. */
  31071. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31072. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31073. validateShaderPrograms: boolean;
  31074. /**
  31075. * Observable event triggered each time the rendering canvas is resized
  31076. */
  31077. onResizeObservable: Observable<Engine>;
  31078. /**
  31079. * Observable event triggered each time the canvas loses focus
  31080. */
  31081. onCanvasBlurObservable: Observable<Engine>;
  31082. /**
  31083. * Observable event triggered each time the canvas gains focus
  31084. */
  31085. onCanvasFocusObservable: Observable<Engine>;
  31086. /**
  31087. * Observable event triggered each time the canvas receives pointerout event
  31088. */
  31089. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31090. /**
  31091. * Observable event triggered before each texture is initialized
  31092. */
  31093. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31094. /**
  31095. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31096. */
  31097. disableUniformBuffers: boolean;
  31098. /** @hidden */
  31099. _uniformBuffers: UniformBuffer[];
  31100. /**
  31101. * Gets a boolean indicating that the engine supports uniform buffers
  31102. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31103. */
  31104. readonly supportsUniformBuffers: boolean;
  31105. /**
  31106. * Observable raised when the engine begins a new frame
  31107. */
  31108. onBeginFrameObservable: Observable<Engine>;
  31109. /**
  31110. * If set, will be used to request the next animation frame for the render loop
  31111. */
  31112. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31113. /**
  31114. * Observable raised when the engine ends the current frame
  31115. */
  31116. onEndFrameObservable: Observable<Engine>;
  31117. /**
  31118. * Observable raised when the engine is about to compile a shader
  31119. */
  31120. onBeforeShaderCompilationObservable: Observable<Engine>;
  31121. /**
  31122. * Observable raised when the engine has jsut compiled a shader
  31123. */
  31124. onAfterShaderCompilationObservable: Observable<Engine>;
  31125. /** @hidden */
  31126. _gl: WebGLRenderingContext;
  31127. private _renderingCanvas;
  31128. private _windowIsBackground;
  31129. protected _webGLVersion: number;
  31130. protected _highPrecisionShadersAllowed: boolean;
  31131. /** @hidden */
  31132. readonly _shouldUseHighPrecisionShader: boolean;
  31133. /**
  31134. * Gets a boolean indicating that only power of 2 textures are supported
  31135. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31136. */
  31137. readonly needPOTTextures: boolean;
  31138. /** @hidden */
  31139. _badOS: boolean;
  31140. /** @hidden */
  31141. _badDesktopOS: boolean;
  31142. /**
  31143. * Gets the audio engine
  31144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31145. * @ignorenaming
  31146. */
  31147. static audioEngine: IAudioEngine;
  31148. /**
  31149. * Default AudioEngine factory responsible of creating the Audio Engine.
  31150. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31151. */
  31152. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31153. /**
  31154. * Default offline support factory responsible of creating a tool used to store data locally.
  31155. * By default, this will create a Database object if the workload has been embedded.
  31156. */
  31157. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31158. private _onFocus;
  31159. private _onBlur;
  31160. private _onCanvasPointerOut;
  31161. private _onCanvasBlur;
  31162. private _onCanvasFocus;
  31163. private _onFullscreenChange;
  31164. private _onPointerLockChange;
  31165. private _hardwareScalingLevel;
  31166. /** @hidden */
  31167. _caps: EngineCapabilities;
  31168. private _pointerLockRequested;
  31169. private _isStencilEnable;
  31170. protected _colorWrite: boolean;
  31171. private _loadingScreen;
  31172. /** @hidden */
  31173. _drawCalls: PerfCounter;
  31174. private _glVersion;
  31175. private _glRenderer;
  31176. private _glVendor;
  31177. private _videoTextureSupported;
  31178. private _renderingQueueLaunched;
  31179. private _activeRenderLoops;
  31180. private _deterministicLockstep;
  31181. private _lockstepMaxSteps;
  31182. /**
  31183. * Observable signaled when a context lost event is raised
  31184. */
  31185. onContextLostObservable: Observable<Engine>;
  31186. /**
  31187. * Observable signaled when a context restored event is raised
  31188. */
  31189. onContextRestoredObservable: Observable<Engine>;
  31190. private _onContextLost;
  31191. private _onContextRestored;
  31192. private _contextWasLost;
  31193. /** @hidden */
  31194. _doNotHandleContextLost: boolean;
  31195. /**
  31196. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31198. */
  31199. doNotHandleContextLost: boolean;
  31200. private _performanceMonitor;
  31201. private _fps;
  31202. private _deltaTime;
  31203. /**
  31204. * Turn this value on if you want to pause FPS computation when in background
  31205. */
  31206. disablePerformanceMonitorInBackground: boolean;
  31207. /**
  31208. * Gets the performance monitor attached to this engine
  31209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31210. */
  31211. readonly performanceMonitor: PerformanceMonitor;
  31212. /**
  31213. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31214. */
  31215. disableVertexArrayObjects: boolean;
  31216. /** @hidden */
  31217. protected _depthCullingState: _DepthCullingState;
  31218. /** @hidden */
  31219. protected _stencilState: _StencilState;
  31220. /** @hidden */
  31221. protected _alphaState: _AlphaState;
  31222. /** @hidden */
  31223. protected _alphaMode: number;
  31224. /** @hidden */
  31225. protected _alphaEquation: number;
  31226. /** @hidden */
  31227. _internalTexturesCache: InternalTexture[];
  31228. /** @hidden */
  31229. protected _activeChannel: number;
  31230. private _currentTextureChannel;
  31231. /** @hidden */
  31232. protected _boundTexturesCache: {
  31233. [key: string]: Nullable<InternalTexture>;
  31234. };
  31235. /** @hidden */
  31236. protected _currentEffect: Nullable<Effect>;
  31237. /** @hidden */
  31238. protected _currentProgram: Nullable<WebGLProgram>;
  31239. private _compiledEffects;
  31240. private _vertexAttribArraysEnabled;
  31241. /** @hidden */
  31242. protected _cachedViewport: Nullable<IViewportLike>;
  31243. private _cachedVertexArrayObject;
  31244. /** @hidden */
  31245. protected _cachedVertexBuffers: any;
  31246. /** @hidden */
  31247. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31248. /** @hidden */
  31249. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31250. /** @hidden */
  31251. _currentRenderTarget: Nullable<InternalTexture>;
  31252. private _uintIndicesCurrentlySet;
  31253. private _currentBoundBuffer;
  31254. /** @hidden */
  31255. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31256. private _currentBufferPointers;
  31257. private _currentInstanceLocations;
  31258. private _currentInstanceBuffers;
  31259. private _textureUnits;
  31260. /** @hidden */
  31261. _workingCanvas: Nullable<HTMLCanvasElement>;
  31262. /** @hidden */
  31263. _workingContext: Nullable<CanvasRenderingContext2D>;
  31264. private _rescalePostProcess;
  31265. private _dummyFramebuffer;
  31266. private _externalData;
  31267. /** @hidden */
  31268. _bindedRenderFunction: any;
  31269. private _vaoRecordInProgress;
  31270. private _mustWipeVertexAttributes;
  31271. private _emptyTexture;
  31272. private _emptyCubeTexture;
  31273. private _emptyTexture3D;
  31274. /** @hidden */
  31275. _frameHandler: number;
  31276. private _nextFreeTextureSlots;
  31277. private _maxSimultaneousTextures;
  31278. private _activeRequests;
  31279. private _texturesSupported;
  31280. /** @hidden */
  31281. _textureFormatInUse: Nullable<string>;
  31282. /**
  31283. * Gets the list of texture formats supported
  31284. */
  31285. readonly texturesSupported: Array<string>;
  31286. /**
  31287. * Gets the list of texture formats in use
  31288. */
  31289. readonly textureFormatInUse: Nullable<string>;
  31290. /**
  31291. * Gets the current viewport
  31292. */
  31293. readonly currentViewport: Nullable<IViewportLike>;
  31294. /**
  31295. * Gets the default empty texture
  31296. */
  31297. readonly emptyTexture: InternalTexture;
  31298. /**
  31299. * Gets the default empty 3D texture
  31300. */
  31301. readonly emptyTexture3D: InternalTexture;
  31302. /**
  31303. * Gets the default empty cube texture
  31304. */
  31305. readonly emptyCubeTexture: InternalTexture;
  31306. /**
  31307. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31308. */
  31309. readonly premultipliedAlpha: boolean;
  31310. /**
  31311. * Creates a new engine
  31312. * @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
  31313. * @param antialias defines enable antialiasing (default: false)
  31314. * @param options defines further options to be sent to the getContext() function
  31315. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31316. */
  31317. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31318. /**
  31319. * Initializes a webVR display and starts listening to display change events
  31320. * The onVRDisplayChangedObservable will be notified upon these changes
  31321. * @returns The onVRDisplayChangedObservable
  31322. */
  31323. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31324. /** @hidden */
  31325. _prepareVRComponent(): void;
  31326. /** @hidden */
  31327. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31328. /** @hidden */
  31329. _submitVRFrame(): void;
  31330. /**
  31331. * Call this function to leave webVR mode
  31332. * Will do nothing if webVR is not supported or if there is no webVR device
  31333. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31334. */
  31335. disableVR(): void;
  31336. /**
  31337. * Gets a boolean indicating that the system is in VR mode and is presenting
  31338. * @returns true if VR mode is engaged
  31339. */
  31340. isVRPresenting(): boolean;
  31341. /** @hidden */
  31342. _requestVRFrame(): void;
  31343. private _disableTouchAction;
  31344. private _rebuildInternalTextures;
  31345. private _rebuildEffects;
  31346. /**
  31347. * Gets a boolean indicating if all created effects are ready
  31348. * @returns true if all effects are ready
  31349. */
  31350. areAllEffectsReady(): boolean;
  31351. private _rebuildBuffers;
  31352. private _initGLContext;
  31353. /**
  31354. * Gets version of the current webGL context
  31355. */
  31356. readonly webGLVersion: number;
  31357. /**
  31358. * Gets a string idenfifying the name of the class
  31359. * @returns "Engine" string
  31360. */
  31361. getClassName(): string;
  31362. /**
  31363. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31364. */
  31365. readonly isStencilEnable: boolean;
  31366. /** @hidden */
  31367. _prepareWorkingCanvas(): void;
  31368. /**
  31369. * Reset the texture cache to empty state
  31370. */
  31371. resetTextureCache(): void;
  31372. /**
  31373. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31374. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31375. * @returns true if engine is in deterministic lock step mode
  31376. */
  31377. isDeterministicLockStep(): boolean;
  31378. /**
  31379. * Gets the max steps when engine is running in deterministic lock step
  31380. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31381. * @returns the max steps
  31382. */
  31383. getLockstepMaxSteps(): number;
  31384. /**
  31385. * Gets an object containing information about the current webGL context
  31386. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31387. */
  31388. getGlInfo(): {
  31389. vendor: string;
  31390. renderer: string;
  31391. version: string;
  31392. };
  31393. /**
  31394. * Gets current aspect ratio
  31395. * @param viewportOwner defines the camera to use to get the aspect ratio
  31396. * @param useScreen defines if screen size must be used (or the current render target if any)
  31397. * @returns a number defining the aspect ratio
  31398. */
  31399. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31400. /**
  31401. * Gets current screen aspect ratio
  31402. * @returns a number defining the aspect ratio
  31403. */
  31404. getScreenAspectRatio(): number;
  31405. /**
  31406. * Gets the current render width
  31407. * @param useScreen defines if screen size must be used (or the current render target if any)
  31408. * @returns a number defining the current render width
  31409. */
  31410. getRenderWidth(useScreen?: boolean): number;
  31411. /**
  31412. * Gets the current render height
  31413. * @param useScreen defines if screen size must be used (or the current render target if any)
  31414. * @returns a number defining the current render height
  31415. */
  31416. getRenderHeight(useScreen?: boolean): number;
  31417. /**
  31418. * Gets the HTML canvas attached with the current webGL context
  31419. * @returns a HTML canvas
  31420. */
  31421. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31422. /**
  31423. * Gets host window
  31424. * @returns the host window object
  31425. */
  31426. getHostWindow(): Window;
  31427. /**
  31428. * Gets host document
  31429. * @returns the host document object
  31430. */
  31431. getHostDocument(): Document;
  31432. /**
  31433. * Gets the client rect of the HTML canvas attached with the current webGL context
  31434. * @returns a client rectanglee
  31435. */
  31436. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31437. /**
  31438. * Defines the hardware scaling level.
  31439. * By default the hardware scaling level is computed from the window device ratio.
  31440. * 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.
  31441. * @param level defines the level to use
  31442. */
  31443. setHardwareScalingLevel(level: number): void;
  31444. /**
  31445. * Gets the current hardware scaling level.
  31446. * By default the hardware scaling level is computed from the window device ratio.
  31447. * 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.
  31448. * @returns a number indicating the current hardware scaling level
  31449. */
  31450. getHardwareScalingLevel(): number;
  31451. /**
  31452. * Gets the list of loaded textures
  31453. * @returns an array containing all loaded textures
  31454. */
  31455. getLoadedTexturesCache(): InternalTexture[];
  31456. /**
  31457. * Gets the object containing all engine capabilities
  31458. * @returns the EngineCapabilities object
  31459. */
  31460. getCaps(): EngineCapabilities;
  31461. /**
  31462. * Gets the current depth function
  31463. * @returns a number defining the depth function
  31464. */
  31465. getDepthFunction(): Nullable<number>;
  31466. /**
  31467. * Sets the current depth function
  31468. * @param depthFunc defines the function to use
  31469. */
  31470. setDepthFunction(depthFunc: number): void;
  31471. /**
  31472. * Sets the current depth function to GREATER
  31473. */
  31474. setDepthFunctionToGreater(): void;
  31475. /**
  31476. * Sets the current depth function to GEQUAL
  31477. */
  31478. setDepthFunctionToGreaterOrEqual(): void;
  31479. /**
  31480. * Sets the current depth function to LESS
  31481. */
  31482. setDepthFunctionToLess(): void;
  31483. private _cachedStencilBuffer;
  31484. private _cachedStencilFunction;
  31485. private _cachedStencilMask;
  31486. private _cachedStencilOperationPass;
  31487. private _cachedStencilOperationFail;
  31488. private _cachedStencilOperationDepthFail;
  31489. private _cachedStencilReference;
  31490. /**
  31491. * Caches the the state of the stencil buffer
  31492. */
  31493. cacheStencilState(): void;
  31494. /**
  31495. * Restores the state of the stencil buffer
  31496. */
  31497. restoreStencilState(): void;
  31498. /**
  31499. * Sets the current depth function to LEQUAL
  31500. */
  31501. setDepthFunctionToLessOrEqual(): void;
  31502. /**
  31503. * Gets a boolean indicating if stencil buffer is enabled
  31504. * @returns the current stencil buffer state
  31505. */
  31506. getStencilBuffer(): boolean;
  31507. /**
  31508. * Enable or disable the stencil buffer
  31509. * @param enable defines if the stencil buffer must be enabled or disabled
  31510. */
  31511. setStencilBuffer(enable: boolean): void;
  31512. /**
  31513. * Gets the current stencil mask
  31514. * @returns a number defining the new stencil mask to use
  31515. */
  31516. getStencilMask(): number;
  31517. /**
  31518. * Sets the current stencil mask
  31519. * @param mask defines the new stencil mask to use
  31520. */
  31521. setStencilMask(mask: number): void;
  31522. /**
  31523. * Gets the current stencil function
  31524. * @returns a number defining the stencil function to use
  31525. */
  31526. getStencilFunction(): number;
  31527. /**
  31528. * Gets the current stencil reference value
  31529. * @returns a number defining the stencil reference value to use
  31530. */
  31531. getStencilFunctionReference(): number;
  31532. /**
  31533. * Gets the current stencil mask
  31534. * @returns a number defining the stencil mask to use
  31535. */
  31536. getStencilFunctionMask(): number;
  31537. /**
  31538. * Sets the current stencil function
  31539. * @param stencilFunc defines the new stencil function to use
  31540. */
  31541. setStencilFunction(stencilFunc: number): void;
  31542. /**
  31543. * Sets the current stencil reference
  31544. * @param reference defines the new stencil reference to use
  31545. */
  31546. setStencilFunctionReference(reference: number): void;
  31547. /**
  31548. * Sets the current stencil mask
  31549. * @param mask defines the new stencil mask to use
  31550. */
  31551. setStencilFunctionMask(mask: number): void;
  31552. /**
  31553. * Gets the current stencil operation when stencil fails
  31554. * @returns a number defining stencil operation to use when stencil fails
  31555. */
  31556. getStencilOperationFail(): number;
  31557. /**
  31558. * Gets the current stencil operation when depth fails
  31559. * @returns a number defining stencil operation to use when depth fails
  31560. */
  31561. getStencilOperationDepthFail(): number;
  31562. /**
  31563. * Gets the current stencil operation when stencil passes
  31564. * @returns a number defining stencil operation to use when stencil passes
  31565. */
  31566. getStencilOperationPass(): number;
  31567. /**
  31568. * Sets the stencil operation to use when stencil fails
  31569. * @param operation defines the stencil operation to use when stencil fails
  31570. */
  31571. setStencilOperationFail(operation: number): void;
  31572. /**
  31573. * Sets the stencil operation to use when depth fails
  31574. * @param operation defines the stencil operation to use when depth fails
  31575. */
  31576. setStencilOperationDepthFail(operation: number): void;
  31577. /**
  31578. * Sets the stencil operation to use when stencil passes
  31579. * @param operation defines the stencil operation to use when stencil passes
  31580. */
  31581. setStencilOperationPass(operation: number): void;
  31582. /**
  31583. * Sets a boolean indicating if the dithering state is enabled or disabled
  31584. * @param value defines the dithering state
  31585. */
  31586. setDitheringState(value: boolean): void;
  31587. /**
  31588. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31589. * @param value defines the rasterizer state
  31590. */
  31591. setRasterizerState(value: boolean): void;
  31592. /**
  31593. * stop executing a render loop function and remove it from the execution array
  31594. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31595. */
  31596. stopRenderLoop(renderFunction?: () => void): void;
  31597. /** @hidden */
  31598. _renderLoop(): void;
  31599. /**
  31600. * Can be used to override the current requestAnimationFrame requester.
  31601. * @hidden
  31602. */
  31603. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31604. /**
  31605. * Register and execute a render loop. The engine can have more than one render function
  31606. * @param renderFunction defines the function to continuously execute
  31607. */
  31608. runRenderLoop(renderFunction: () => void): void;
  31609. /**
  31610. * Toggle full screen mode
  31611. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31612. */
  31613. switchFullscreen(requestPointerLock: boolean): void;
  31614. /**
  31615. * Enters full screen mode
  31616. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31617. */
  31618. enterFullscreen(requestPointerLock: boolean): void;
  31619. /**
  31620. * Exits full screen mode
  31621. */
  31622. exitFullscreen(): void;
  31623. /**
  31624. * Enters Pointerlock mode
  31625. */
  31626. enterPointerlock(): void;
  31627. /**
  31628. * Exits Pointerlock mode
  31629. */
  31630. exitPointerlock(): void;
  31631. /**
  31632. * Clear the current render buffer or the current render target (if any is set up)
  31633. * @param color defines the color to use
  31634. * @param backBuffer defines if the back buffer must be cleared
  31635. * @param depth defines if the depth buffer must be cleared
  31636. * @param stencil defines if the stencil buffer must be cleared
  31637. */
  31638. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31639. /**
  31640. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31641. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31642. * @param y defines the y-coordinate of the corner of the clear rectangle
  31643. * @param width defines the width of the clear rectangle
  31644. * @param height defines the height of the clear rectangle
  31645. * @param clearColor defines the clear color
  31646. */
  31647. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31648. /**
  31649. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31650. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31651. * @param y defines the y-coordinate of the corner of the clear rectangle
  31652. * @param width defines the width of the clear rectangle
  31653. * @param height defines the height of the clear rectangle
  31654. */
  31655. enableScissor(x: number, y: number, width: number, height: number): void;
  31656. /**
  31657. * Disable previously set scissor test rectangle
  31658. */
  31659. disableScissor(): void;
  31660. private _viewportCached;
  31661. /** @hidden */
  31662. _viewport(x: number, y: number, width: number, height: number): void;
  31663. /**
  31664. * Set the WebGL's viewport
  31665. * @param viewport defines the viewport element to be used
  31666. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31667. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31668. */
  31669. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31670. /**
  31671. * Directly set the WebGL Viewport
  31672. * @param x defines the x coordinate of the viewport (in screen space)
  31673. * @param y defines the y coordinate of the viewport (in screen space)
  31674. * @param width defines the width of the viewport (in screen space)
  31675. * @param height defines the height of the viewport (in screen space)
  31676. * @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
  31677. */
  31678. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31679. /**
  31680. * Begin a new frame
  31681. */
  31682. beginFrame(): void;
  31683. /**
  31684. * Enf the current frame
  31685. */
  31686. endFrame(): void;
  31687. /**
  31688. * Resize the view according to the canvas' size
  31689. */
  31690. resize(): void;
  31691. /**
  31692. * Force a specific size of the canvas
  31693. * @param width defines the new canvas' width
  31694. * @param height defines the new canvas' height
  31695. */
  31696. setSize(width: number, height: number): void;
  31697. /**
  31698. * Binds the frame buffer to the specified texture.
  31699. * @param texture The texture to render to or null for the default canvas
  31700. * @param faceIndex The face of the texture to render to in case of cube texture
  31701. * @param requiredWidth The width of the target to render to
  31702. * @param requiredHeight The height of the target to render to
  31703. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31704. * @param depthStencilTexture The depth stencil texture to use to render
  31705. * @param lodLevel defines le lod level to bind to the frame buffer
  31706. */
  31707. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31708. /** @hidden */
  31709. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31710. /**
  31711. * Unbind the current render target texture from the webGL context
  31712. * @param texture defines the render target texture to unbind
  31713. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31714. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31715. */
  31716. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31717. /**
  31718. * Force the mipmap generation for the given render target texture
  31719. * @param texture defines the render target texture to use
  31720. */
  31721. generateMipMapsForCubemap(texture: InternalTexture): void;
  31722. /**
  31723. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31724. */
  31725. flushFramebuffer(): void;
  31726. /**
  31727. * Unbind the current render target and bind the default framebuffer
  31728. */
  31729. restoreDefaultFramebuffer(): void;
  31730. /**
  31731. * Create an uniform buffer
  31732. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31733. * @param elements defines the content of the uniform buffer
  31734. * @returns the webGL uniform buffer
  31735. */
  31736. createUniformBuffer(elements: FloatArray): DataBuffer;
  31737. /**
  31738. * Create a dynamic uniform buffer
  31739. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31740. * @param elements defines the content of the uniform buffer
  31741. * @returns the webGL uniform buffer
  31742. */
  31743. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31744. /**
  31745. * Update an existing uniform buffer
  31746. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31747. * @param uniformBuffer defines the target uniform buffer
  31748. * @param elements defines the content to update
  31749. * @param offset defines the offset in the uniform buffer where update should start
  31750. * @param count defines the size of the data to update
  31751. */
  31752. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31753. private _resetVertexBufferBinding;
  31754. /**
  31755. * Creates a vertex buffer
  31756. * @param data the data for the vertex buffer
  31757. * @returns the new WebGL static buffer
  31758. */
  31759. createVertexBuffer(data: DataArray): DataBuffer;
  31760. /**
  31761. * Creates a dynamic vertex buffer
  31762. * @param data the data for the dynamic vertex buffer
  31763. * @returns the new WebGL dynamic buffer
  31764. */
  31765. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31766. /**
  31767. * Update a dynamic index buffer
  31768. * @param indexBuffer defines the target index buffer
  31769. * @param indices defines the data to update
  31770. * @param offset defines the offset in the target index buffer where update should start
  31771. */
  31772. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31773. /**
  31774. * Updates a dynamic vertex buffer.
  31775. * @param vertexBuffer the vertex buffer to update
  31776. * @param data the data used to update the vertex buffer
  31777. * @param byteOffset the byte offset of the data
  31778. * @param byteLength the byte length of the data
  31779. */
  31780. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31781. private _resetIndexBufferBinding;
  31782. /**
  31783. * Creates a new index buffer
  31784. * @param indices defines the content of the index buffer
  31785. * @param updatable defines if the index buffer must be updatable
  31786. * @returns a new webGL buffer
  31787. */
  31788. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31789. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31790. /**
  31791. * Bind a webGL buffer to the webGL context
  31792. * @param buffer defines the buffer to bind
  31793. */
  31794. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31795. /**
  31796. * Bind an uniform buffer to the current webGL context
  31797. * @param buffer defines the buffer to bind
  31798. */
  31799. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31800. /**
  31801. * Bind a buffer to the current webGL context at a given location
  31802. * @param buffer defines the buffer to bind
  31803. * @param location defines the index where to bind the buffer
  31804. */
  31805. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31806. /**
  31807. * Bind a specific block at a given index in a specific shader program
  31808. * @param pipelineContext defines the pipeline context to use
  31809. * @param blockName defines the block name
  31810. * @param index defines the index where to bind the block
  31811. */
  31812. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31813. private bindIndexBuffer;
  31814. private bindBuffer;
  31815. /**
  31816. * update the bound buffer with the given data
  31817. * @param data defines the data to update
  31818. */
  31819. updateArrayBuffer(data: Float32Array): void;
  31820. private _vertexAttribPointer;
  31821. private _bindIndexBufferWithCache;
  31822. private _bindVertexBuffersAttributes;
  31823. /**
  31824. * Records a vertex array object
  31825. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31826. * @param vertexBuffers defines the list of vertex buffers to store
  31827. * @param indexBuffer defines the index buffer to store
  31828. * @param effect defines the effect to store
  31829. * @returns the new vertex array object
  31830. */
  31831. recordVertexArrayObject(vertexBuffers: {
  31832. [key: string]: VertexBuffer;
  31833. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31834. /**
  31835. * Bind a specific vertex array object
  31836. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31837. * @param vertexArrayObject defines the vertex array object to bind
  31838. * @param indexBuffer defines the index buffer to bind
  31839. */
  31840. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31841. /**
  31842. * Bind webGl buffers directly to the webGL context
  31843. * @param vertexBuffer defines the vertex buffer to bind
  31844. * @param indexBuffer defines the index buffer to bind
  31845. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31846. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31847. * @param effect defines the effect associated with the vertex buffer
  31848. */
  31849. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31850. private _unbindVertexArrayObject;
  31851. /**
  31852. * Bind a list of vertex buffers to the webGL context
  31853. * @param vertexBuffers defines the list of vertex buffers to bind
  31854. * @param indexBuffer defines the index buffer to bind
  31855. * @param effect defines the effect associated with the vertex buffers
  31856. */
  31857. bindBuffers(vertexBuffers: {
  31858. [key: string]: Nullable<VertexBuffer>;
  31859. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31860. /**
  31861. * Unbind all instance attributes
  31862. */
  31863. unbindInstanceAttributes(): void;
  31864. /**
  31865. * Release and free the memory of a vertex array object
  31866. * @param vao defines the vertex array object to delete
  31867. */
  31868. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31869. /** @hidden */
  31870. _releaseBuffer(buffer: DataBuffer): boolean;
  31871. protected _deleteBuffer(buffer: DataBuffer): void;
  31872. /**
  31873. * Creates a webGL buffer to use with instanciation
  31874. * @param capacity defines the size of the buffer
  31875. * @returns the webGL buffer
  31876. */
  31877. createInstancesBuffer(capacity: number): DataBuffer;
  31878. /**
  31879. * Delete a webGL buffer used with instanciation
  31880. * @param buffer defines the webGL buffer to delete
  31881. */
  31882. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31883. /**
  31884. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31885. * @param instancesBuffer defines the webGL buffer to update and bind
  31886. * @param data defines the data to store in the buffer
  31887. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31888. */
  31889. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31890. /**
  31891. * Apply all cached states (depth, culling, stencil and alpha)
  31892. */
  31893. applyStates(): void;
  31894. /**
  31895. * Send a draw order
  31896. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31897. * @param indexStart defines the starting index
  31898. * @param indexCount defines the number of index to draw
  31899. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31900. */
  31901. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31902. /**
  31903. * Draw a list of points
  31904. * @param verticesStart defines the index of first vertex to draw
  31905. * @param verticesCount defines the count of vertices to draw
  31906. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31907. */
  31908. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31909. /**
  31910. * Draw a list of unindexed primitives
  31911. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31912. * @param verticesStart defines the index of first vertex to draw
  31913. * @param verticesCount defines the count of vertices to draw
  31914. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31915. */
  31916. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31917. /**
  31918. * Draw a list of indexed primitives
  31919. * @param fillMode defines the primitive to use
  31920. * @param indexStart defines the starting index
  31921. * @param indexCount defines the number of index to draw
  31922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31923. */
  31924. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31925. /**
  31926. * Draw a list of unindexed primitives
  31927. * @param fillMode defines the primitive to use
  31928. * @param verticesStart defines the index of first vertex to draw
  31929. * @param verticesCount defines the count of vertices to draw
  31930. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31931. */
  31932. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31933. private _drawMode;
  31934. /** @hidden */
  31935. _releaseEffect(effect: Effect): void;
  31936. /** @hidden */
  31937. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31938. /**
  31939. * Create a new effect (used to store vertex/fragment shaders)
  31940. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31941. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31942. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31943. * @param samplers defines an array of string used to represent textures
  31944. * @param defines defines the string containing the defines to use to compile the shaders
  31945. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31946. * @param onCompiled defines a function to call when the effect creation is successful
  31947. * @param onError defines a function to call when the effect creation has failed
  31948. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31949. * @returns the new Effect
  31950. */
  31951. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31952. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31953. private _compileShader;
  31954. private _compileRawShader;
  31955. /**
  31956. * Directly creates a webGL program
  31957. * @param pipelineContext defines the pipeline context to attach to
  31958. * @param vertexCode defines the vertex shader code to use
  31959. * @param fragmentCode defines the fragment shader code to use
  31960. * @param context defines the webGL context to use (if not set, the current one will be used)
  31961. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31962. * @returns the new webGL program
  31963. */
  31964. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31965. /**
  31966. * Creates a webGL program
  31967. * @param pipelineContext defines the pipeline context to attach to
  31968. * @param vertexCode defines the vertex shader code to use
  31969. * @param fragmentCode defines the fragment shader code to use
  31970. * @param defines defines the string containing the defines to use to compile the shaders
  31971. * @param context defines the webGL context to use (if not set, the current one will be used)
  31972. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31973. * @returns the new webGL program
  31974. */
  31975. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31976. /**
  31977. * Creates a new pipeline context
  31978. * @returns the new pipeline
  31979. */
  31980. createPipelineContext(): IPipelineContext;
  31981. private _createShaderProgram;
  31982. private _finalizePipelineContext;
  31983. /** @hidden */
  31984. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31985. /** @hidden */
  31986. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31987. /** @hidden */
  31988. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31989. /**
  31990. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31991. * @param pipelineContext defines the pipeline context to use
  31992. * @param uniformsNames defines the list of uniform names
  31993. * @returns an array of webGL uniform locations
  31994. */
  31995. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31996. /**
  31997. * Gets the lsit of active attributes for a given webGL program
  31998. * @param pipelineContext defines the pipeline context to use
  31999. * @param attributesNames defines the list of attribute names to get
  32000. * @returns an array of indices indicating the offset of each attribute
  32001. */
  32002. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32003. /**
  32004. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32005. * @param effect defines the effect to activate
  32006. */
  32007. enableEffect(effect: Nullable<Effect>): void;
  32008. /**
  32009. * Set the value of an uniform to an array of int32
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param array defines the array of int32 to store
  32012. */
  32013. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32014. /**
  32015. * Set the value of an uniform to an array of int32 (stored as vec2)
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param array defines the array of int32 to store
  32018. */
  32019. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32020. /**
  32021. * Set the value of an uniform to an array of int32 (stored as vec3)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param array defines the array of int32 to store
  32024. */
  32025. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32026. /**
  32027. * Set the value of an uniform to an array of int32 (stored as vec4)
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param array defines the array of int32 to store
  32030. */
  32031. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32032. /**
  32033. * Set the value of an uniform to an array of float32
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param array defines the array of float32 to store
  32036. */
  32037. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32038. /**
  32039. * Set the value of an uniform to an array of float32 (stored as vec2)
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param array defines the array of float32 to store
  32042. */
  32043. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32044. /**
  32045. * Set the value of an uniform to an array of float32 (stored as vec3)
  32046. * @param uniform defines the webGL uniform location where to store the value
  32047. * @param array defines the array of float32 to store
  32048. */
  32049. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32050. /**
  32051. * Set the value of an uniform to an array of float32 (stored as vec4)
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param array defines the array of float32 to store
  32054. */
  32055. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32056. /**
  32057. * Set the value of an uniform to an array of number
  32058. * @param uniform defines the webGL uniform location where to store the value
  32059. * @param array defines the array of number to store
  32060. */
  32061. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32062. /**
  32063. * Set the value of an uniform to an array of number (stored as vec2)
  32064. * @param uniform defines the webGL uniform location where to store the value
  32065. * @param array defines the array of number to store
  32066. */
  32067. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32068. /**
  32069. * Set the value of an uniform to an array of number (stored as vec3)
  32070. * @param uniform defines the webGL uniform location where to store the value
  32071. * @param array defines the array of number to store
  32072. */
  32073. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32074. /**
  32075. * Set the value of an uniform to an array of number (stored as vec4)
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param array defines the array of number to store
  32078. */
  32079. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32080. /**
  32081. * Set the value of an uniform to an array of float32 (stored as matrices)
  32082. * @param uniform defines the webGL uniform location where to store the value
  32083. * @param matrices defines the array of float32 to store
  32084. */
  32085. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32086. /**
  32087. * Set the value of an uniform to a matrix (3x3)
  32088. * @param uniform defines the webGL uniform location where to store the value
  32089. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32090. */
  32091. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32092. /**
  32093. * Set the value of an uniform to a matrix (2x2)
  32094. * @param uniform defines the webGL uniform location where to store the value
  32095. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32096. */
  32097. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32098. /**
  32099. * Set the value of an uniform to a number (int)
  32100. * @param uniform defines the webGL uniform location where to store the value
  32101. * @param value defines the int number to store
  32102. */
  32103. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32104. /**
  32105. * Set the value of an uniform to a number (float)
  32106. * @param uniform defines the webGL uniform location where to store the value
  32107. * @param value defines the float number to store
  32108. */
  32109. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32110. /**
  32111. * Set the value of an uniform to a vec2
  32112. * @param uniform defines the webGL uniform location where to store the value
  32113. * @param x defines the 1st component of the value
  32114. * @param y defines the 2nd component of the value
  32115. */
  32116. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32117. /**
  32118. * Set the value of an uniform to a vec3
  32119. * @param uniform defines the webGL uniform location where to store the value
  32120. * @param x defines the 1st component of the value
  32121. * @param y defines the 2nd component of the value
  32122. * @param z defines the 3rd component of the value
  32123. */
  32124. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32125. /**
  32126. * Set the value of an uniform to a boolean
  32127. * @param uniform defines the webGL uniform location where to store the value
  32128. * @param bool defines the boolean to store
  32129. */
  32130. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32131. /**
  32132. * Set the value of an uniform to a vec4
  32133. * @param uniform defines the webGL uniform location where to store the value
  32134. * @param x defines the 1st component of the value
  32135. * @param y defines the 2nd component of the value
  32136. * @param z defines the 3rd component of the value
  32137. * @param w defines the 4th component of the value
  32138. */
  32139. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32140. /**
  32141. * Sets a Color4 on a uniform variable
  32142. * @param uniform defines the uniform location
  32143. * @param color4 defines the value to be set
  32144. */
  32145. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32146. /**
  32147. * Set various states to the webGL context
  32148. * @param culling defines backface culling state
  32149. * @param zOffset defines the value to apply to zOffset (0 by default)
  32150. * @param force defines if states must be applied even if cache is up to date
  32151. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32152. */
  32153. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32154. /**
  32155. * Set the z offset to apply to current rendering
  32156. * @param value defines the offset to apply
  32157. */
  32158. setZOffset(value: number): void;
  32159. /**
  32160. * Gets the current value of the zOffset
  32161. * @returns the current zOffset state
  32162. */
  32163. getZOffset(): number;
  32164. /**
  32165. * Enable or disable depth buffering
  32166. * @param enable defines the state to set
  32167. */
  32168. setDepthBuffer(enable: boolean): void;
  32169. /**
  32170. * Gets a boolean indicating if depth writing is enabled
  32171. * @returns the current depth writing state
  32172. */
  32173. getDepthWrite(): boolean;
  32174. /**
  32175. * Enable or disable depth writing
  32176. * @param enable defines the state to set
  32177. */
  32178. setDepthWrite(enable: boolean): void;
  32179. /**
  32180. * Enable or disable color writing
  32181. * @param enable defines the state to set
  32182. */
  32183. setColorWrite(enable: boolean): void;
  32184. /**
  32185. * Gets a boolean indicating if color writing is enabled
  32186. * @returns the current color writing state
  32187. */
  32188. getColorWrite(): boolean;
  32189. /**
  32190. * Sets alpha constants used by some alpha blending modes
  32191. * @param r defines the red component
  32192. * @param g defines the green component
  32193. * @param b defines the blue component
  32194. * @param a defines the alpha component
  32195. */
  32196. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32197. /**
  32198. * Sets the current alpha mode
  32199. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32200. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32201. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32202. */
  32203. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32204. /**
  32205. * Gets the current alpha mode
  32206. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32207. * @returns the current alpha mode
  32208. */
  32209. getAlphaMode(): number;
  32210. /**
  32211. * Sets the current alpha equation
  32212. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32213. */
  32214. setAlphaEquation(equation: number): void;
  32215. /**
  32216. * Gets the current alpha equation.
  32217. * @returns the current alpha equation
  32218. */
  32219. getAlphaEquation(): number;
  32220. /**
  32221. * Clears the list of texture accessible through engine.
  32222. * This can help preventing texture load conflict due to name collision.
  32223. */
  32224. clearInternalTexturesCache(): void;
  32225. /**
  32226. * Force the entire cache to be cleared
  32227. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32228. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32229. */
  32230. wipeCaches(bruteForce?: boolean): void;
  32231. /**
  32232. * Set the compressed texture format to use, based on the formats you have, and the formats
  32233. * supported by the hardware / browser.
  32234. *
  32235. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32236. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32237. * to API arguments needed to compressed textures. This puts the burden on the container
  32238. * generator to house the arcane code for determining these for current & future formats.
  32239. *
  32240. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32241. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32242. *
  32243. * Note: The result of this call is not taken into account when a texture is base64.
  32244. *
  32245. * @param formatsAvailable defines the list of those format families you have created
  32246. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32247. *
  32248. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32249. * @returns The extension selected.
  32250. */
  32251. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32252. /** @hidden */
  32253. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32254. min: number;
  32255. mag: number;
  32256. };
  32257. /** @hidden */
  32258. _createTexture(): WebGLTexture;
  32259. /**
  32260. * Usually called from Texture.ts.
  32261. * Passed information to create a WebGLTexture
  32262. * @param urlArg defines a value which contains one of the following:
  32263. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32264. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32265. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32266. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32267. * @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)
  32268. * @param scene needed for loading to the correct scene
  32269. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32270. * @param onLoad optional callback to be called upon successful completion
  32271. * @param onError optional callback to be called upon failure
  32272. * @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
  32273. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32274. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32275. * @param forcedExtension defines the extension to use to pick the right loader
  32276. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32277. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32278. */
  32279. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32280. /**
  32281. * @hidden
  32282. * Rescales a texture
  32283. * @param source input texutre
  32284. * @param destination destination texture
  32285. * @param scene scene to use to render the resize
  32286. * @param internalFormat format to use when resizing
  32287. * @param onComplete callback to be called when resize has completed
  32288. */
  32289. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32290. private _unpackFlipYCached;
  32291. /**
  32292. * In case you are sharing the context with other applications, it might
  32293. * be interested to not cache the unpack flip y state to ensure a consistent
  32294. * value would be set.
  32295. */
  32296. enableUnpackFlipYCached: boolean;
  32297. /** @hidden */
  32298. _unpackFlipY(value: boolean): void;
  32299. /** @hidden */
  32300. _getUnpackAlignement(): number;
  32301. /**
  32302. * Creates a dynamic texture
  32303. * @param width defines the width of the texture
  32304. * @param height defines the height of the texture
  32305. * @param generateMipMaps defines if the engine should generate the mip levels
  32306. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32307. * @returns the dynamic texture inside an InternalTexture
  32308. */
  32309. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32310. /**
  32311. * Update the sampling mode of a given texture
  32312. * @param samplingMode defines the required sampling mode
  32313. * @param texture defines the texture to update
  32314. */
  32315. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32316. /**
  32317. * Update the content of a dynamic texture
  32318. * @param texture defines the texture to update
  32319. * @param canvas defines the canvas containing the source
  32320. * @param invertY defines if data must be stored with Y axis inverted
  32321. * @param premulAlpha defines if alpha is stored as premultiplied
  32322. * @param format defines the format of the data
  32323. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32324. */
  32325. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32326. /**
  32327. * Update a video texture
  32328. * @param texture defines the texture to update
  32329. * @param video defines the video element to use
  32330. * @param invertY defines if data must be stored with Y axis inverted
  32331. */
  32332. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32333. /**
  32334. * Updates a depth texture Comparison Mode and Function.
  32335. * If the comparison Function is equal to 0, the mode will be set to none.
  32336. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32337. * @param texture The texture to set the comparison function for
  32338. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32339. */
  32340. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32341. /** @hidden */
  32342. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32343. width: number;
  32344. height: number;
  32345. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32346. /**
  32347. * Creates a depth stencil texture.
  32348. * This is only available in WebGL 2 or with the depth texture extension available.
  32349. * @param size The size of face edge in the texture.
  32350. * @param options The options defining the texture.
  32351. * @returns The texture
  32352. */
  32353. createDepthStencilTexture(size: number | {
  32354. width: number;
  32355. height: number;
  32356. }, options: DepthTextureCreationOptions): InternalTexture;
  32357. /**
  32358. * Creates a depth stencil texture.
  32359. * This is only available in WebGL 2 or with the depth texture extension available.
  32360. * @param size The size of face edge in the texture.
  32361. * @param options The options defining the texture.
  32362. * @returns The texture
  32363. */
  32364. private _createDepthStencilTexture;
  32365. /**
  32366. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32367. * @param renderTarget The render target to set the frame buffer for
  32368. */
  32369. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32370. /**
  32371. * Creates a new render target texture
  32372. * @param size defines the size of the texture
  32373. * @param options defines the options used to create the texture
  32374. * @returns a new render target texture stored in an InternalTexture
  32375. */
  32376. createRenderTargetTexture(size: number | {
  32377. width: number;
  32378. height: number;
  32379. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32380. /** @hidden */
  32381. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32382. /**
  32383. * Updates the sample count of a render target texture
  32384. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32385. * @param texture defines the texture to update
  32386. * @param samples defines the sample count to set
  32387. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32388. */
  32389. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32390. /** @hidden */
  32391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32392. /** @hidden */
  32393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32394. /** @hidden */
  32395. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32396. /** @hidden */
  32397. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32398. /**
  32399. * @hidden
  32400. */
  32401. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32402. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32403. private _prepareWebGLTexture;
  32404. /** @hidden */
  32405. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32406. /** @hidden */
  32407. _releaseFramebufferObjects(texture: InternalTexture): void;
  32408. /** @hidden */
  32409. _releaseTexture(texture: InternalTexture): void;
  32410. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32411. protected _setProgram(program: WebGLProgram): void;
  32412. protected _boundUniforms: {
  32413. [key: number]: WebGLUniformLocation;
  32414. };
  32415. /**
  32416. * Binds an effect to the webGL context
  32417. * @param effect defines the effect to bind
  32418. */
  32419. bindSamplers(effect: Effect): void;
  32420. private _activateCurrentTexture;
  32421. /** @hidden */
  32422. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32423. /** @hidden */
  32424. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32425. /**
  32426. * Sets a texture to the webGL context from a postprocess
  32427. * @param channel defines the channel to use
  32428. * @param postProcess defines the source postprocess
  32429. */
  32430. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32431. /**
  32432. * Binds the output of the passed in post process to the texture channel specified
  32433. * @param channel The channel the texture should be bound to
  32434. * @param postProcess The post process which's output should be bound
  32435. */
  32436. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32437. /**
  32438. * Unbind all textures from the webGL context
  32439. */
  32440. unbindAllTextures(): void;
  32441. /**
  32442. * Sets a texture to the according uniform.
  32443. * @param channel The texture channel
  32444. * @param uniform The uniform to set
  32445. * @param texture The texture to apply
  32446. */
  32447. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32448. /**
  32449. * Sets a depth stencil texture from a render target to the according uniform.
  32450. * @param channel The texture channel
  32451. * @param uniform The uniform to set
  32452. * @param texture The render target texture containing the depth stencil texture to apply
  32453. */
  32454. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32455. private _bindSamplerUniformToChannel;
  32456. private _getTextureWrapMode;
  32457. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32458. /**
  32459. * Sets an array of texture to the webGL context
  32460. * @param channel defines the channel where the texture array must be set
  32461. * @param uniform defines the associated uniform location
  32462. * @param textures defines the array of textures to bind
  32463. */
  32464. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32465. /** @hidden */
  32466. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32467. private _setTextureParameterFloat;
  32468. private _setTextureParameterInteger;
  32469. /**
  32470. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32471. * @param x defines the x coordinate of the rectangle where pixels must be read
  32472. * @param y defines the y coordinate of the rectangle where pixels must be read
  32473. * @param width defines the width of the rectangle where pixels must be read
  32474. * @param height defines the height of the rectangle where pixels must be read
  32475. * @returns a Uint8Array containing RGBA colors
  32476. */
  32477. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32478. /**
  32479. * Add an externaly attached data from its key.
  32480. * This method call will fail and return false, if such key already exists.
  32481. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32482. * @param key the unique key that identifies the data
  32483. * @param data the data object to associate to the key for this Engine instance
  32484. * @return true if no such key were already present and the data was added successfully, false otherwise
  32485. */
  32486. addExternalData<T>(key: string, data: T): boolean;
  32487. /**
  32488. * Get an externaly attached data from its key
  32489. * @param key the unique key that identifies the data
  32490. * @return the associated data, if present (can be null), or undefined if not present
  32491. */
  32492. getExternalData<T>(key: string): T;
  32493. /**
  32494. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32495. * @param key the unique key that identifies the data
  32496. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32497. * @return the associated data, can be null if the factory returned null.
  32498. */
  32499. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32500. /**
  32501. * Remove an externaly attached data from the Engine instance
  32502. * @param key the unique key that identifies the data
  32503. * @return true if the data was successfully removed, false if it doesn't exist
  32504. */
  32505. removeExternalData(key: string): boolean;
  32506. /**
  32507. * Unbind all vertex attributes from the webGL context
  32508. */
  32509. unbindAllAttributes(): void;
  32510. /**
  32511. * 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
  32512. */
  32513. releaseEffects(): void;
  32514. /**
  32515. * Dispose and release all associated resources
  32516. */
  32517. dispose(): void;
  32518. /**
  32519. * Display the loading screen
  32520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32521. */
  32522. displayLoadingUI(): void;
  32523. /**
  32524. * Hide the loading screen
  32525. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32526. */
  32527. hideLoadingUI(): void;
  32528. /**
  32529. * Gets the current loading screen object
  32530. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32531. */
  32532. /**
  32533. * Sets the current loading screen object
  32534. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32535. */
  32536. loadingScreen: ILoadingScreen;
  32537. /**
  32538. * Sets the current loading screen text
  32539. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32540. */
  32541. loadingUIText: string;
  32542. /**
  32543. * Sets the current loading screen background color
  32544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32545. */
  32546. loadingUIBackgroundColor: string;
  32547. /**
  32548. * Attach a new callback raised when context lost event is fired
  32549. * @param callback defines the callback to call
  32550. */
  32551. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32552. /**
  32553. * Attach a new callback raised when context restored event is fired
  32554. * @param callback defines the callback to call
  32555. */
  32556. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32557. /**
  32558. * Gets the source code of the vertex shader associated with a specific webGL program
  32559. * @param program defines the program to use
  32560. * @returns a string containing the source code of the vertex shader associated with the program
  32561. */
  32562. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32563. /**
  32564. * Gets the source code of the fragment shader associated with a specific webGL program
  32565. * @param program defines the program to use
  32566. * @returns a string containing the source code of the fragment shader associated with the program
  32567. */
  32568. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32569. /**
  32570. * Get the current error code of the webGL context
  32571. * @returns the error code
  32572. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32573. */
  32574. getError(): number;
  32575. /**
  32576. * Gets the current framerate
  32577. * @returns a number representing the framerate
  32578. */
  32579. getFps(): number;
  32580. /**
  32581. * Gets the time spent between current and previous frame
  32582. * @returns a number representing the delta time in ms
  32583. */
  32584. getDeltaTime(): number;
  32585. private _measureFps;
  32586. /** @hidden */
  32587. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32588. private _canRenderToFloatFramebuffer;
  32589. private _canRenderToHalfFloatFramebuffer;
  32590. private _canRenderToFramebuffer;
  32591. /** @hidden */
  32592. _getWebGLTextureType(type: number): number;
  32593. /** @hidden */
  32594. _getInternalFormat(format: number): number;
  32595. /** @hidden */
  32596. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32597. /** @hidden */
  32598. _getRGBAMultiSampleBufferFormat(type: number): number;
  32599. /** @hidden */
  32600. _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;
  32601. /** @hidden */
  32602. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32603. /**
  32604. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32605. * @returns true if the engine can be created
  32606. * @ignorenaming
  32607. */
  32608. static isSupported(): boolean;
  32609. /**
  32610. * Find the next highest power of two.
  32611. * @param x Number to start search from.
  32612. * @return Next highest power of two.
  32613. */
  32614. static CeilingPOT(x: number): number;
  32615. /**
  32616. * Find the next lowest power of two.
  32617. * @param x Number to start search from.
  32618. * @return Next lowest power of two.
  32619. */
  32620. static FloorPOT(x: number): number;
  32621. /**
  32622. * Find the nearest power of two.
  32623. * @param x Number to start search from.
  32624. * @return Next nearest power of two.
  32625. */
  32626. static NearestPOT(x: number): number;
  32627. /**
  32628. * Get the closest exponent of two
  32629. * @param value defines the value to approximate
  32630. * @param max defines the maximum value to return
  32631. * @param mode defines how to define the closest value
  32632. * @returns closest exponent of two of the given value
  32633. */
  32634. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32635. /**
  32636. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32637. * @param func - the function to be called
  32638. * @param requester - the object that will request the next frame. Falls back to window.
  32639. * @returns frame number
  32640. */
  32641. static QueueNewFrame(func: () => void, requester?: any): number;
  32642. /**
  32643. * Ask the browser to promote the current element to pointerlock mode
  32644. * @param element defines the DOM element to promote
  32645. */
  32646. static _RequestPointerlock(element: HTMLElement): void;
  32647. /**
  32648. * Asks the browser to exit pointerlock mode
  32649. */
  32650. static _ExitPointerlock(): void;
  32651. /**
  32652. * Ask the browser to promote the current element to fullscreen rendering mode
  32653. * @param element defines the DOM element to promote
  32654. */
  32655. static _RequestFullscreen(element: HTMLElement): void;
  32656. /**
  32657. * Asks the browser to exit fullscreen mode
  32658. */
  32659. static _ExitFullscreen(): void;
  32660. }
  32661. }
  32662. declare module "babylonjs/Engines/engineStore" {
  32663. import { Nullable } from "babylonjs/types";
  32664. import { Engine } from "babylonjs/Engines/engine";
  32665. import { Scene } from "babylonjs/scene";
  32666. /**
  32667. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32668. * during the life time of the application.
  32669. */
  32670. export class EngineStore {
  32671. /** Gets the list of created engines */
  32672. static Instances: import("babylonjs/Engines/engine").Engine[];
  32673. /** @hidden */
  32674. static _LastCreatedScene: Nullable<Scene>;
  32675. /**
  32676. * Gets the latest created engine
  32677. */
  32678. static readonly LastCreatedEngine: Nullable<Engine>;
  32679. /**
  32680. * Gets the latest created scene
  32681. */
  32682. static readonly LastCreatedScene: Nullable<Scene>;
  32683. /**
  32684. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32685. * @ignorenaming
  32686. */
  32687. static UseFallbackTexture: boolean;
  32688. /**
  32689. * Texture content used if a texture cannot loaded
  32690. * @ignorenaming
  32691. */
  32692. static FallbackTexture: string;
  32693. }
  32694. }
  32695. declare module "babylonjs/Misc/promise" {
  32696. /**
  32697. * Helper class that provides a small promise polyfill
  32698. */
  32699. export class PromisePolyfill {
  32700. /**
  32701. * Static function used to check if the polyfill is required
  32702. * If this is the case then the function will inject the polyfill to window.Promise
  32703. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32704. */
  32705. static Apply(force?: boolean): void;
  32706. }
  32707. }
  32708. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32709. /**
  32710. * Interface for screenshot methods with describe argument called `size` as object with options
  32711. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32712. */
  32713. export interface IScreenshotSize {
  32714. /**
  32715. * number in pixels for canvas height
  32716. */
  32717. height?: number;
  32718. /**
  32719. * multiplier allowing render at a higher or lower resolution
  32720. * If value is defined then height and width will be ignored and taken from camera
  32721. */
  32722. precision?: number;
  32723. /**
  32724. * number in pixels for canvas width
  32725. */
  32726. width?: number;
  32727. }
  32728. }
  32729. declare module "babylonjs/Misc/tools" {
  32730. import { Nullable, float } from "babylonjs/types";
  32731. import { DomManagement } from "babylonjs/Misc/domManagement";
  32732. import { WebRequest } from "babylonjs/Misc/webRequest";
  32733. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32734. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32735. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32736. import { Camera } from "babylonjs/Cameras/camera";
  32737. import { Engine } from "babylonjs/Engines/engine";
  32738. interface IColor4Like {
  32739. r: float;
  32740. g: float;
  32741. b: float;
  32742. a: float;
  32743. }
  32744. /**
  32745. * Class containing a set of static utilities functions
  32746. */
  32747. export class Tools {
  32748. /**
  32749. * Gets or sets the base URL to use to load assets
  32750. */
  32751. static BaseUrl: string;
  32752. /**
  32753. * Enable/Disable Custom HTTP Request Headers globally.
  32754. * default = false
  32755. * @see CustomRequestHeaders
  32756. */
  32757. static UseCustomRequestHeaders: boolean;
  32758. /**
  32759. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32760. * i.e. when loading files, where the server/service expects an Authorization header
  32761. */
  32762. static CustomRequestHeaders: {
  32763. [key: string]: string;
  32764. };
  32765. /**
  32766. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32767. */
  32768. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32769. /**
  32770. * Default behaviour for cors in the application.
  32771. * It can be a string if the expected behavior is identical in the entire app.
  32772. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32773. */
  32774. static CorsBehavior: string | ((url: string | string[]) => string);
  32775. /**
  32776. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32777. * @ignorenaming
  32778. */
  32779. static UseFallbackTexture: boolean;
  32780. /**
  32781. * Use this object to register external classes like custom textures or material
  32782. * to allow the laoders to instantiate them
  32783. */
  32784. static RegisteredExternalClasses: {
  32785. [key: string]: Object;
  32786. };
  32787. /**
  32788. * Texture content used if a texture cannot loaded
  32789. * @ignorenaming
  32790. */
  32791. static fallbackTexture: string;
  32792. /**
  32793. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32794. * @param u defines the coordinate on X axis
  32795. * @param v defines the coordinate on Y axis
  32796. * @param width defines the width of the source data
  32797. * @param height defines the height of the source data
  32798. * @param pixels defines the source byte array
  32799. * @param color defines the output color
  32800. */
  32801. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32802. /**
  32803. * Interpolates between a and b via alpha
  32804. * @param a The lower value (returned when alpha = 0)
  32805. * @param b The upper value (returned when alpha = 1)
  32806. * @param alpha The interpolation-factor
  32807. * @return The mixed value
  32808. */
  32809. static Mix(a: number, b: number, alpha: number): number;
  32810. /**
  32811. * Tries to instantiate a new object from a given class name
  32812. * @param className defines the class name to instantiate
  32813. * @returns the new object or null if the system was not able to do the instantiation
  32814. */
  32815. static Instantiate(className: string): any;
  32816. /**
  32817. * Provides a slice function that will work even on IE
  32818. * @param data defines the array to slice
  32819. * @param start defines the start of the data (optional)
  32820. * @param end defines the end of the data (optional)
  32821. * @returns the new sliced array
  32822. */
  32823. static Slice<T>(data: T, start?: number, end?: number): T;
  32824. /**
  32825. * Polyfill for setImmediate
  32826. * @param action defines the action to execute after the current execution block
  32827. */
  32828. static SetImmediate(action: () => void): void;
  32829. /**
  32830. * Function indicating if a number is an exponent of 2
  32831. * @param value defines the value to test
  32832. * @returns true if the value is an exponent of 2
  32833. */
  32834. static IsExponentOfTwo(value: number): boolean;
  32835. private static _tmpFloatArray;
  32836. /**
  32837. * Returns the nearest 32-bit single precision float representation of a Number
  32838. * @param value A Number. If the parameter is of a different type, it will get converted
  32839. * to a number or to NaN if it cannot be converted
  32840. * @returns number
  32841. */
  32842. static FloatRound(value: number): number;
  32843. /**
  32844. * Extracts the filename from a path
  32845. * @param path defines the path to use
  32846. * @returns the filename
  32847. */
  32848. static GetFilename(path: string): string;
  32849. /**
  32850. * Extracts the "folder" part of a path (everything before the filename).
  32851. * @param uri The URI to extract the info from
  32852. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32853. * @returns The "folder" part of the path
  32854. */
  32855. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32856. /**
  32857. * Extracts text content from a DOM element hierarchy
  32858. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32859. */
  32860. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32861. /**
  32862. * Convert an angle in radians to degrees
  32863. * @param angle defines the angle to convert
  32864. * @returns the angle in degrees
  32865. */
  32866. static ToDegrees(angle: number): number;
  32867. /**
  32868. * Convert an angle in degrees to radians
  32869. * @param angle defines the angle to convert
  32870. * @returns the angle in radians
  32871. */
  32872. static ToRadians(angle: number): number;
  32873. /**
  32874. * Encode a buffer to a base64 string
  32875. * @param buffer defines the buffer to encode
  32876. * @returns the encoded string
  32877. */
  32878. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32879. /**
  32880. * Returns an array if obj is not an array
  32881. * @param obj defines the object to evaluate as an array
  32882. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32883. * @returns either obj directly if obj is an array or a new array containing obj
  32884. */
  32885. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32886. /**
  32887. * Gets the pointer prefix to use
  32888. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32889. */
  32890. static GetPointerPrefix(): string;
  32891. /**
  32892. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32893. * @param url define the url we are trying
  32894. * @param element define the dom element where to configure the cors policy
  32895. */
  32896. static SetCorsBehavior(url: string | string[], element: {
  32897. crossOrigin: string | null;
  32898. }): void;
  32899. /**
  32900. * Removes unwanted characters from an url
  32901. * @param url defines the url to clean
  32902. * @returns the cleaned url
  32903. */
  32904. static CleanUrl(url: string): string;
  32905. /**
  32906. * Gets or sets a function used to pre-process url before using them to load assets
  32907. */
  32908. static PreprocessUrl: (url: string) => string;
  32909. /**
  32910. * Loads an image as an HTMLImageElement.
  32911. * @param input url string, ArrayBuffer, or Blob to load
  32912. * @param onLoad callback called when the image successfully loads
  32913. * @param onError callback called when the image fails to load
  32914. * @param offlineProvider offline provider for caching
  32915. * @returns the HTMLImageElement of the loaded image
  32916. */
  32917. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32918. /**
  32919. * Loads a file
  32920. * @param url url string, ArrayBuffer, or Blob to load
  32921. * @param onSuccess callback called when the file successfully loads
  32922. * @param onProgress callback called while file is loading (if the server supports this mode)
  32923. * @param offlineProvider defines the offline provider for caching
  32924. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32925. * @param onError callback called when the file fails to load
  32926. * @returns a file request object
  32927. */
  32928. 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;
  32929. /**
  32930. * Loads a file from a url
  32931. * @param url the file url to load
  32932. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32933. */
  32934. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32935. /**
  32936. * Load a script (identified by an url). When the url returns, the
  32937. * content of this file is added into a new script element, attached to the DOM (body element)
  32938. * @param scriptUrl defines the url of the script to laod
  32939. * @param onSuccess defines the callback called when the script is loaded
  32940. * @param onError defines the callback to call if an error occurs
  32941. * @param scriptId defines the id of the script element
  32942. */
  32943. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32944. /**
  32945. * Load an asynchronous script (identified by an url). When the url returns, the
  32946. * content of this file is added into a new script element, attached to the DOM (body element)
  32947. * @param scriptUrl defines the url of the script to laod
  32948. * @param scriptId defines the id of the script element
  32949. * @returns a promise request object
  32950. */
  32951. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32952. /**
  32953. * Loads a file from a blob
  32954. * @param fileToLoad defines the blob to use
  32955. * @param callback defines the callback to call when data is loaded
  32956. * @param progressCallback defines the callback to call during loading process
  32957. * @returns a file request object
  32958. */
  32959. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32960. /**
  32961. * Loads a file
  32962. * @param fileToLoad defines the file to load
  32963. * @param callback defines the callback to call when data is loaded
  32964. * @param progressCallBack defines the callback to call during loading process
  32965. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32966. * @returns a file request object
  32967. */
  32968. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32969. /**
  32970. * Creates a data url from a given string content
  32971. * @param content defines the content to convert
  32972. * @returns the new data url link
  32973. */
  32974. static FileAsURL(content: string): string;
  32975. /**
  32976. * Format the given number to a specific decimal format
  32977. * @param value defines the number to format
  32978. * @param decimals defines the number of decimals to use
  32979. * @returns the formatted string
  32980. */
  32981. static Format(value: number, decimals?: number): string;
  32982. /**
  32983. * Tries to copy an object by duplicating every property
  32984. * @param source defines the source object
  32985. * @param destination defines the target object
  32986. * @param doNotCopyList defines a list of properties to avoid
  32987. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32988. */
  32989. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32990. /**
  32991. * Gets a boolean indicating if the given object has no own property
  32992. * @param obj defines the object to test
  32993. * @returns true if object has no own property
  32994. */
  32995. static IsEmpty(obj: any): boolean;
  32996. /**
  32997. * Function used to register events at window level
  32998. * @param windowElement defines the Window object to use
  32999. * @param events defines the events to register
  33000. */
  33001. static RegisterTopRootEvents(windowElement: Window, events: {
  33002. name: string;
  33003. handler: Nullable<(e: FocusEvent) => any>;
  33004. }[]): void;
  33005. /**
  33006. * Function used to unregister events from window level
  33007. * @param windowElement defines the Window object to use
  33008. * @param events defines the events to unregister
  33009. */
  33010. static UnregisterTopRootEvents(windowElement: Window, events: {
  33011. name: string;
  33012. handler: Nullable<(e: FocusEvent) => any>;
  33013. }[]): void;
  33014. /**
  33015. * @ignore
  33016. */
  33017. static _ScreenshotCanvas: HTMLCanvasElement;
  33018. /**
  33019. * Dumps the current bound framebuffer
  33020. * @param width defines the rendering width
  33021. * @param height defines the rendering height
  33022. * @param engine defines the hosting engine
  33023. * @param successCallback defines the callback triggered once the data are available
  33024. * @param mimeType defines the mime type of the result
  33025. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33026. */
  33027. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33028. /**
  33029. * Converts the canvas data to blob.
  33030. * This acts as a polyfill for browsers not supporting the to blob function.
  33031. * @param canvas Defines the canvas to extract the data from
  33032. * @param successCallback Defines the callback triggered once the data are available
  33033. * @param mimeType Defines the mime type of the result
  33034. */
  33035. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33036. /**
  33037. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33038. * @param successCallback defines the callback triggered once the data are available
  33039. * @param mimeType defines the mime type of the result
  33040. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33041. */
  33042. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33043. /**
  33044. * Downloads a blob in the browser
  33045. * @param blob defines the blob to download
  33046. * @param fileName defines the name of the downloaded file
  33047. */
  33048. static Download(blob: Blob, fileName: string): void;
  33049. /**
  33050. * Captures a screenshot of the current rendering
  33051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33052. * @param engine defines the rendering engine
  33053. * @param camera defines the source camera
  33054. * @param size This parameter can be set to a single number or to an object with the
  33055. * following (optional) properties: precision, width, height. If a single number is passed,
  33056. * it will be used for both width and height. If an object is passed, the screenshot size
  33057. * will be derived from the parameters. The precision property is a multiplier allowing
  33058. * rendering at a higher or lower resolution
  33059. * @param successCallback defines the callback receives a single parameter which contains the
  33060. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33061. * src parameter of an <img> to display it
  33062. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33063. * Check your browser for supported MIME types
  33064. */
  33065. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33066. /**
  33067. * Captures a screenshot of the current rendering
  33068. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33069. * @param engine defines the rendering engine
  33070. * @param camera defines the source camera
  33071. * @param size This parameter can be set to a single number or to an object with the
  33072. * following (optional) properties: precision, width, height. If a single number is passed,
  33073. * it will be used for both width and height. If an object is passed, the screenshot size
  33074. * will be derived from the parameters. The precision property is a multiplier allowing
  33075. * rendering at a higher or lower resolution
  33076. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33077. * Check your browser for supported MIME types
  33078. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33079. * to the src parameter of an <img> to display it
  33080. */
  33081. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33082. /**
  33083. * Generates an image screenshot from the specified camera.
  33084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33085. * @param engine The engine to use for rendering
  33086. * @param camera The camera to use for rendering
  33087. * @param size This parameter can be set to a single number or to an object with the
  33088. * following (optional) properties: precision, width, height. If a single number is passed,
  33089. * it will be used for both width and height. If an object is passed, the screenshot size
  33090. * will be derived from the parameters. The precision property is a multiplier allowing
  33091. * rendering at a higher or lower resolution
  33092. * @param successCallback The callback receives a single parameter which contains the
  33093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33094. * src parameter of an <img> to display it
  33095. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33096. * Check your browser for supported MIME types
  33097. * @param samples Texture samples (default: 1)
  33098. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33099. * @param fileName A name for for the downloaded file.
  33100. */
  33101. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33102. /**
  33103. * Generates an image screenshot from the specified camera.
  33104. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33105. * @param engine The engine to use for rendering
  33106. * @param camera The camera to use for rendering
  33107. * @param size This parameter can be set to a single number or to an object with the
  33108. * following (optional) properties: precision, width, height. If a single number is passed,
  33109. * it will be used for both width and height. If an object is passed, the screenshot size
  33110. * will be derived from the parameters. The precision property is a multiplier allowing
  33111. * rendering at a higher or lower resolution
  33112. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33113. * Check your browser for supported MIME types
  33114. * @param samples Texture samples (default: 1)
  33115. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33116. * @param fileName A name for for the downloaded file.
  33117. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33118. * to the src parameter of an <img> to display it
  33119. */
  33120. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33121. /**
  33122. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33123. * Be aware Math.random() could cause collisions, but:
  33124. * "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"
  33125. * @returns a pseudo random id
  33126. */
  33127. static RandomId(): string;
  33128. /**
  33129. * Test if the given uri is a base64 string
  33130. * @param uri The uri to test
  33131. * @return True if the uri is a base64 string or false otherwise
  33132. */
  33133. static IsBase64(uri: string): boolean;
  33134. /**
  33135. * Decode the given base64 uri.
  33136. * @param uri The uri to decode
  33137. * @return The decoded base64 data.
  33138. */
  33139. static DecodeBase64(uri: string): ArrayBuffer;
  33140. /**
  33141. * Gets the absolute url.
  33142. * @param url the input url
  33143. * @return the absolute url
  33144. */
  33145. static GetAbsoluteUrl(url: string): string;
  33146. /**
  33147. * No log
  33148. */
  33149. static readonly NoneLogLevel: number;
  33150. /**
  33151. * Only message logs
  33152. */
  33153. static readonly MessageLogLevel: number;
  33154. /**
  33155. * Only warning logs
  33156. */
  33157. static readonly WarningLogLevel: number;
  33158. /**
  33159. * Only error logs
  33160. */
  33161. static readonly ErrorLogLevel: number;
  33162. /**
  33163. * All logs
  33164. */
  33165. static readonly AllLogLevel: number;
  33166. /**
  33167. * Gets a value indicating the number of loading errors
  33168. * @ignorenaming
  33169. */
  33170. static readonly errorsCount: number;
  33171. /**
  33172. * Callback called when a new log is added
  33173. */
  33174. static OnNewCacheEntry: (entry: string) => void;
  33175. /**
  33176. * Log a message to the console
  33177. * @param message defines the message to log
  33178. */
  33179. static Log(message: string): void;
  33180. /**
  33181. * Write a warning message to the console
  33182. * @param message defines the message to log
  33183. */
  33184. static Warn(message: string): void;
  33185. /**
  33186. * Write an error message to the console
  33187. * @param message defines the message to log
  33188. */
  33189. static Error(message: string): void;
  33190. /**
  33191. * Gets current log cache (list of logs)
  33192. */
  33193. static readonly LogCache: string;
  33194. /**
  33195. * Clears the log cache
  33196. */
  33197. static ClearLogCache(): void;
  33198. /**
  33199. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33200. */
  33201. static LogLevels: number;
  33202. /**
  33203. * Checks if the window object exists
  33204. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33205. */
  33206. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33207. /**
  33208. * No performance log
  33209. */
  33210. static readonly PerformanceNoneLogLevel: number;
  33211. /**
  33212. * Use user marks to log performance
  33213. */
  33214. static readonly PerformanceUserMarkLogLevel: number;
  33215. /**
  33216. * Log performance to the console
  33217. */
  33218. static readonly PerformanceConsoleLogLevel: number;
  33219. private static _performance;
  33220. /**
  33221. * Sets the current performance log level
  33222. */
  33223. static PerformanceLogLevel: number;
  33224. private static _StartPerformanceCounterDisabled;
  33225. private static _EndPerformanceCounterDisabled;
  33226. private static _StartUserMark;
  33227. private static _EndUserMark;
  33228. private static _StartPerformanceConsole;
  33229. private static _EndPerformanceConsole;
  33230. /**
  33231. * Starts a performance counter
  33232. */
  33233. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33234. /**
  33235. * Ends a specific performance coutner
  33236. */
  33237. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33238. /**
  33239. * Gets either window.performance.now() if supported or Date.now() else
  33240. */
  33241. static readonly Now: number;
  33242. /**
  33243. * This method will return the name of the class used to create the instance of the given object.
  33244. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33245. * @param object the object to get the class name from
  33246. * @param isType defines if the object is actually a type
  33247. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33248. */
  33249. static GetClassName(object: any, isType?: boolean): string;
  33250. /**
  33251. * Gets the first element of an array satisfying a given predicate
  33252. * @param array defines the array to browse
  33253. * @param predicate defines the predicate to use
  33254. * @returns null if not found or the element
  33255. */
  33256. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33257. /**
  33258. * This method will return the name of the full name of the class, including its owning module (if any).
  33259. * 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).
  33260. * @param object the object to get the class name from
  33261. * @param isType defines if the object is actually a type
  33262. * @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.
  33263. * @ignorenaming
  33264. */
  33265. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33266. /**
  33267. * Returns a promise that resolves after the given amount of time.
  33268. * @param delay Number of milliseconds to delay
  33269. * @returns Promise that resolves after the given amount of time
  33270. */
  33271. static DelayAsync(delay: number): Promise<void>;
  33272. }
  33273. /**
  33274. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33275. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33276. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33277. * @param name The name of the class, case should be preserved
  33278. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33279. */
  33280. export function className(name: string, module?: string): (target: Object) => void;
  33281. /**
  33282. * An implementation of a loop for asynchronous functions.
  33283. */
  33284. export class AsyncLoop {
  33285. /**
  33286. * Defines the number of iterations for the loop
  33287. */
  33288. iterations: number;
  33289. /**
  33290. * Defines the current index of the loop.
  33291. */
  33292. index: number;
  33293. private _done;
  33294. private _fn;
  33295. private _successCallback;
  33296. /**
  33297. * Constructor.
  33298. * @param iterations the number of iterations.
  33299. * @param func the function to run each iteration
  33300. * @param successCallback the callback that will be called upon succesful execution
  33301. * @param offset starting offset.
  33302. */
  33303. constructor(
  33304. /**
  33305. * Defines the number of iterations for the loop
  33306. */
  33307. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33308. /**
  33309. * Execute the next iteration. Must be called after the last iteration was finished.
  33310. */
  33311. executeNext(): void;
  33312. /**
  33313. * Break the loop and run the success callback.
  33314. */
  33315. breakLoop(): void;
  33316. /**
  33317. * Create and run an async loop.
  33318. * @param iterations the number of iterations.
  33319. * @param fn the function to run each iteration
  33320. * @param successCallback the callback that will be called upon succesful execution
  33321. * @param offset starting offset.
  33322. * @returns the created async loop object
  33323. */
  33324. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33325. /**
  33326. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33327. * @param iterations total number of iterations
  33328. * @param syncedIterations number of synchronous iterations in each async iteration.
  33329. * @param fn the function to call each iteration.
  33330. * @param callback a success call back that will be called when iterating stops.
  33331. * @param breakFunction a break condition (optional)
  33332. * @param timeout timeout settings for the setTimeout function. default - 0.
  33333. * @returns the created async loop object
  33334. */
  33335. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33336. }
  33337. }
  33338. declare module "babylonjs/Collisions/collisionCoordinator" {
  33339. import { Nullable } from "babylonjs/types";
  33340. import { Scene } from "babylonjs/scene";
  33341. import { Vector3 } from "babylonjs/Maths/math.vector";
  33342. import { Collider } from "babylonjs/Collisions/collider";
  33343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33344. /** @hidden */
  33345. export interface ICollisionCoordinator {
  33346. createCollider(): Collider;
  33347. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33348. init(scene: Scene): void;
  33349. }
  33350. /** @hidden */
  33351. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33352. private _scene;
  33353. private _scaledPosition;
  33354. private _scaledVelocity;
  33355. private _finalPosition;
  33356. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33357. createCollider(): Collider;
  33358. init(scene: Scene): void;
  33359. private _collideWithWorld;
  33360. }
  33361. }
  33362. declare module "babylonjs/Inputs/scene.inputManager" {
  33363. import { Nullable } from "babylonjs/types";
  33364. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33365. import { Vector2 } from "babylonjs/Maths/math.vector";
  33366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33367. import { Scene } from "babylonjs/scene";
  33368. /**
  33369. * Class used to manage all inputs for the scene.
  33370. */
  33371. export class InputManager {
  33372. /** The distance in pixel that you have to move to prevent some events */
  33373. static DragMovementThreshold: number;
  33374. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33375. static LongPressDelay: number;
  33376. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33377. static DoubleClickDelay: number;
  33378. /** If you need to check double click without raising a single click at first click, enable this flag */
  33379. static ExclusiveDoubleClickMode: boolean;
  33380. private _wheelEventName;
  33381. private _onPointerMove;
  33382. private _onPointerDown;
  33383. private _onPointerUp;
  33384. private _initClickEvent;
  33385. private _initActionManager;
  33386. private _delayedSimpleClick;
  33387. private _delayedSimpleClickTimeout;
  33388. private _previousDelayedSimpleClickTimeout;
  33389. private _meshPickProceed;
  33390. private _previousButtonPressed;
  33391. private _currentPickResult;
  33392. private _previousPickResult;
  33393. private _totalPointersPressed;
  33394. private _doubleClickOccured;
  33395. private _pointerOverMesh;
  33396. private _pickedDownMesh;
  33397. private _pickedUpMesh;
  33398. private _pointerX;
  33399. private _pointerY;
  33400. private _unTranslatedPointerX;
  33401. private _unTranslatedPointerY;
  33402. private _startingPointerPosition;
  33403. private _previousStartingPointerPosition;
  33404. private _startingPointerTime;
  33405. private _previousStartingPointerTime;
  33406. private _pointerCaptures;
  33407. private _onKeyDown;
  33408. private _onKeyUp;
  33409. private _onCanvasFocusObserver;
  33410. private _onCanvasBlurObserver;
  33411. private _scene;
  33412. /**
  33413. * Creates a new InputManager
  33414. * @param scene defines the hosting scene
  33415. */
  33416. constructor(scene: Scene);
  33417. /**
  33418. * Gets the mesh that is currently under the pointer
  33419. */
  33420. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33421. /**
  33422. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33423. */
  33424. readonly unTranslatedPointer: Vector2;
  33425. /**
  33426. * Gets or sets the current on-screen X position of the pointer
  33427. */
  33428. pointerX: number;
  33429. /**
  33430. * Gets or sets the current on-screen Y position of the pointer
  33431. */
  33432. pointerY: number;
  33433. private _updatePointerPosition;
  33434. private _processPointerMove;
  33435. private _setRayOnPointerInfo;
  33436. private _checkPrePointerObservable;
  33437. /**
  33438. * Use this method to simulate a pointer move on a mesh
  33439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33442. */
  33443. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33444. /**
  33445. * Use this method to simulate a pointer down on a mesh
  33446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33449. */
  33450. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33451. private _processPointerDown;
  33452. /** @hidden */
  33453. _isPointerSwiping(): boolean;
  33454. /**
  33455. * Use this method to simulate a pointer up on a mesh
  33456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33459. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33460. */
  33461. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33462. private _processPointerUp;
  33463. /**
  33464. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33465. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33466. * @returns true if the pointer was captured
  33467. */
  33468. isPointerCaptured(pointerId?: number): boolean;
  33469. /**
  33470. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33471. * @param attachUp defines if you want to attach events to pointerup
  33472. * @param attachDown defines if you want to attach events to pointerdown
  33473. * @param attachMove defines if you want to attach events to pointermove
  33474. */
  33475. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33476. /**
  33477. * Detaches all event handlers
  33478. */
  33479. detachControl(): void;
  33480. /**
  33481. * Force the value of meshUnderPointer
  33482. * @param mesh defines the mesh to use
  33483. */
  33484. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33485. /**
  33486. * Gets the mesh under the pointer
  33487. * @returns a Mesh or null if no mesh is under the pointer
  33488. */
  33489. getPointerOverMesh(): Nullable<AbstractMesh>;
  33490. }
  33491. }
  33492. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33493. /**
  33494. * Helper class used to generate session unique ID
  33495. */
  33496. export class UniqueIdGenerator {
  33497. private static _UniqueIdCounter;
  33498. /**
  33499. * Gets an unique (relatively to the current scene) Id
  33500. */
  33501. static readonly UniqueId: number;
  33502. }
  33503. }
  33504. declare module "babylonjs/Animations/animationGroup" {
  33505. import { Animatable } from "babylonjs/Animations/animatable";
  33506. import { Animation } from "babylonjs/Animations/animation";
  33507. import { Scene, IDisposable } from "babylonjs/scene";
  33508. import { Observable } from "babylonjs/Misc/observable";
  33509. import { Nullable } from "babylonjs/types";
  33510. import "babylonjs/Animations/animatable";
  33511. /**
  33512. * This class defines the direct association between an animation and a target
  33513. */
  33514. export class TargetedAnimation {
  33515. /**
  33516. * Animation to perform
  33517. */
  33518. animation: Animation;
  33519. /**
  33520. * Target to animate
  33521. */
  33522. target: any;
  33523. /**
  33524. * Serialize the object
  33525. * @returns the JSON object representing the current entity
  33526. */
  33527. serialize(): any;
  33528. }
  33529. /**
  33530. * Use this class to create coordinated animations on multiple targets
  33531. */
  33532. export class AnimationGroup implements IDisposable {
  33533. /** The name of the animation group */
  33534. name: string;
  33535. private _scene;
  33536. private _targetedAnimations;
  33537. private _animatables;
  33538. private _from;
  33539. private _to;
  33540. private _isStarted;
  33541. private _isPaused;
  33542. private _speedRatio;
  33543. private _loopAnimation;
  33544. /**
  33545. * Gets or sets the unique id of the node
  33546. */
  33547. uniqueId: number;
  33548. /**
  33549. * This observable will notify when one animation have ended
  33550. */
  33551. onAnimationEndObservable: Observable<TargetedAnimation>;
  33552. /**
  33553. * Observer raised when one animation loops
  33554. */
  33555. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33556. /**
  33557. * This observable will notify when all animations have ended.
  33558. */
  33559. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33560. /**
  33561. * This observable will notify when all animations have paused.
  33562. */
  33563. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33564. /**
  33565. * This observable will notify when all animations are playing.
  33566. */
  33567. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33568. /**
  33569. * Gets the first frame
  33570. */
  33571. readonly from: number;
  33572. /**
  33573. * Gets the last frame
  33574. */
  33575. readonly to: number;
  33576. /**
  33577. * Define if the animations are started
  33578. */
  33579. readonly isStarted: boolean;
  33580. /**
  33581. * Gets a value indicating that the current group is playing
  33582. */
  33583. readonly isPlaying: boolean;
  33584. /**
  33585. * Gets or sets the speed ratio to use for all animations
  33586. */
  33587. /**
  33588. * Gets or sets the speed ratio to use for all animations
  33589. */
  33590. speedRatio: number;
  33591. /**
  33592. * Gets or sets if all animations should loop or not
  33593. */
  33594. loopAnimation: boolean;
  33595. /**
  33596. * Gets the targeted animations for this animation group
  33597. */
  33598. readonly targetedAnimations: Array<TargetedAnimation>;
  33599. /**
  33600. * returning the list of animatables controlled by this animation group.
  33601. */
  33602. readonly animatables: Array<Animatable>;
  33603. /**
  33604. * Instantiates a new Animation Group.
  33605. * This helps managing several animations at once.
  33606. * @see http://doc.babylonjs.com/how_to/group
  33607. * @param name Defines the name of the group
  33608. * @param scene Defines the scene the group belongs to
  33609. */
  33610. constructor(
  33611. /** The name of the animation group */
  33612. name: string, scene?: Nullable<Scene>);
  33613. /**
  33614. * Add an animation (with its target) in the group
  33615. * @param animation defines the animation we want to add
  33616. * @param target defines the target of the animation
  33617. * @returns the TargetedAnimation object
  33618. */
  33619. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33620. /**
  33621. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33622. * It can add constant keys at begin or end
  33623. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33624. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33625. * @returns the animation group
  33626. */
  33627. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33628. /**
  33629. * Start all animations on given targets
  33630. * @param loop defines if animations must loop
  33631. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33632. * @param from defines the from key (optional)
  33633. * @param to defines the to key (optional)
  33634. * @returns the current animation group
  33635. */
  33636. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33637. /**
  33638. * Pause all animations
  33639. * @returns the animation group
  33640. */
  33641. pause(): AnimationGroup;
  33642. /**
  33643. * Play all animations to initial state
  33644. * This function will start() the animations if they were not started or will restart() them if they were paused
  33645. * @param loop defines if animations must loop
  33646. * @returns the animation group
  33647. */
  33648. play(loop?: boolean): AnimationGroup;
  33649. /**
  33650. * Reset all animations to initial state
  33651. * @returns the animation group
  33652. */
  33653. reset(): AnimationGroup;
  33654. /**
  33655. * Restart animations from key 0
  33656. * @returns the animation group
  33657. */
  33658. restart(): AnimationGroup;
  33659. /**
  33660. * Stop all animations
  33661. * @returns the animation group
  33662. */
  33663. stop(): AnimationGroup;
  33664. /**
  33665. * Set animation weight for all animatables
  33666. * @param weight defines the weight to use
  33667. * @return the animationGroup
  33668. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33669. */
  33670. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33671. /**
  33672. * Synchronize and normalize all animatables with a source animatable
  33673. * @param root defines the root animatable to synchronize with
  33674. * @return the animationGroup
  33675. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33676. */
  33677. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33678. /**
  33679. * Goes to a specific frame in this animation group
  33680. * @param frame the frame number to go to
  33681. * @return the animationGroup
  33682. */
  33683. goToFrame(frame: number): AnimationGroup;
  33684. /**
  33685. * Dispose all associated resources
  33686. */
  33687. dispose(): void;
  33688. private _checkAnimationGroupEnded;
  33689. /**
  33690. * Clone the current animation group and returns a copy
  33691. * @param newName defines the name of the new group
  33692. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33693. * @returns the new aniamtion group
  33694. */
  33695. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33696. /**
  33697. * Serializes the animationGroup to an object
  33698. * @returns Serialized object
  33699. */
  33700. serialize(): any;
  33701. /**
  33702. * Returns a new AnimationGroup object parsed from the source provided.
  33703. * @param parsedAnimationGroup defines the source
  33704. * @param scene defines the scene that will receive the animationGroup
  33705. * @returns a new AnimationGroup
  33706. */
  33707. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33708. /**
  33709. * Returns the string "AnimationGroup"
  33710. * @returns "AnimationGroup"
  33711. */
  33712. getClassName(): string;
  33713. /**
  33714. * Creates a detailled string about the object
  33715. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33716. * @returns a string representing the object
  33717. */
  33718. toString(fullDetails?: boolean): string;
  33719. }
  33720. }
  33721. declare module "babylonjs/scene" {
  33722. import { Nullable } from "babylonjs/types";
  33723. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33724. import { Observable } from "babylonjs/Misc/observable";
  33725. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33726. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33727. import { Geometry } from "babylonjs/Meshes/geometry";
  33728. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33729. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33731. import { Mesh } from "babylonjs/Meshes/mesh";
  33732. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33733. import { Bone } from "babylonjs/Bones/bone";
  33734. import { Skeleton } from "babylonjs/Bones/skeleton";
  33735. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33736. import { Camera } from "babylonjs/Cameras/camera";
  33737. import { AbstractScene } from "babylonjs/abstractScene";
  33738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33740. import { Material } from "babylonjs/Materials/material";
  33741. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33742. import { Effect } from "babylonjs/Materials/effect";
  33743. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33744. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33745. import { Light } from "babylonjs/Lights/light";
  33746. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33747. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33748. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33749. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33750. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33751. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33752. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33753. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33754. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33755. import { Engine } from "babylonjs/Engines/engine";
  33756. import { Node } from "babylonjs/node";
  33757. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33759. import { WebRequest } from "babylonjs/Misc/webRequest";
  33760. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33761. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33762. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33763. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33764. import { Plane } from "babylonjs/Maths/math.plane";
  33765. import { Ray } from "babylonjs/Culling/ray";
  33766. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33767. import { Animation } from "babylonjs/Animations/animation";
  33768. import { Animatable } from "babylonjs/Animations/animatable";
  33769. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33770. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33771. import { Collider } from "babylonjs/Collisions/collider";
  33772. /**
  33773. * Define an interface for all classes that will hold resources
  33774. */
  33775. export interface IDisposable {
  33776. /**
  33777. * Releases all held resources
  33778. */
  33779. dispose(): void;
  33780. }
  33781. /** Interface defining initialization parameters for Scene class */
  33782. export interface SceneOptions {
  33783. /**
  33784. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33785. * It will improve performance when the number of geometries becomes important.
  33786. */
  33787. useGeometryUniqueIdsMap?: boolean;
  33788. /**
  33789. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33790. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33791. */
  33792. useMaterialMeshMap?: boolean;
  33793. /**
  33794. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33795. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33796. */
  33797. useClonedMeshhMap?: boolean;
  33798. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33799. virtual?: boolean;
  33800. }
  33801. /**
  33802. * Represents a scene to be rendered by the engine.
  33803. * @see http://doc.babylonjs.com/features/scene
  33804. */
  33805. export class Scene extends AbstractScene implements IAnimatable {
  33806. /** The fog is deactivated */
  33807. static readonly FOGMODE_NONE: number;
  33808. /** The fog density is following an exponential function */
  33809. static readonly FOGMODE_EXP: number;
  33810. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33811. static readonly FOGMODE_EXP2: number;
  33812. /** The fog density is following a linear function. */
  33813. static readonly FOGMODE_LINEAR: number;
  33814. /**
  33815. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33817. */
  33818. static MinDeltaTime: number;
  33819. /**
  33820. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33822. */
  33823. static MaxDeltaTime: number;
  33824. /**
  33825. * Factory used to create the default material.
  33826. * @param name The name of the material to create
  33827. * @param scene The scene to create the material for
  33828. * @returns The default material
  33829. */
  33830. static DefaultMaterialFactory(scene: Scene): Material;
  33831. /**
  33832. * Factory used to create the a collision coordinator.
  33833. * @returns The collision coordinator
  33834. */
  33835. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33836. /** @hidden */
  33837. _inputManager: InputManager;
  33838. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33839. cameraToUseForPointers: Nullable<Camera>;
  33840. /** @hidden */
  33841. readonly _isScene: boolean;
  33842. /**
  33843. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33844. */
  33845. autoClear: boolean;
  33846. /**
  33847. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33848. */
  33849. autoClearDepthAndStencil: boolean;
  33850. /**
  33851. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33852. */
  33853. clearColor: Color4;
  33854. /**
  33855. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33856. */
  33857. ambientColor: Color3;
  33858. /**
  33859. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33860. * It should only be one of the following (if not the default embedded one):
  33861. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33862. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33863. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33864. * The material properties need to be setup according to the type of texture in use.
  33865. */
  33866. environmentBRDFTexture: BaseTexture;
  33867. /** @hidden */
  33868. protected _environmentTexture: Nullable<BaseTexture>;
  33869. /**
  33870. * Texture used in all pbr material as the reflection texture.
  33871. * As in the majority of the scene they are the same (exception for multi room and so on),
  33872. * this is easier to reference from here than from all the materials.
  33873. */
  33874. /**
  33875. * Texture used in all pbr material as the reflection texture.
  33876. * As in the majority of the scene they are the same (exception for multi room and so on),
  33877. * this is easier to set here than in all the materials.
  33878. */
  33879. environmentTexture: Nullable<BaseTexture>;
  33880. /** @hidden */
  33881. protected _environmentIntensity: number;
  33882. /**
  33883. * Intensity of the environment in all pbr material.
  33884. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33885. * As in the majority of the scene they are the same (exception for multi room and so on),
  33886. * this is easier to reference from here than from all the materials.
  33887. */
  33888. /**
  33889. * Intensity of the environment in all pbr material.
  33890. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33891. * As in the majority of the scene they are the same (exception for multi room and so on),
  33892. * this is easier to set here than in all the materials.
  33893. */
  33894. environmentIntensity: number;
  33895. /** @hidden */
  33896. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33897. /**
  33898. * Default image processing configuration used either in the rendering
  33899. * Forward main pass or through the imageProcessingPostProcess if present.
  33900. * As in the majority of the scene they are the same (exception for multi camera),
  33901. * this is easier to reference from here than from all the materials and post process.
  33902. *
  33903. * No setter as we it is a shared configuration, you can set the values instead.
  33904. */
  33905. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33906. private _forceWireframe;
  33907. /**
  33908. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33909. */
  33910. forceWireframe: boolean;
  33911. private _forcePointsCloud;
  33912. /**
  33913. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33914. */
  33915. forcePointsCloud: boolean;
  33916. /**
  33917. * Gets or sets the active clipplane 1
  33918. */
  33919. clipPlane: Nullable<Plane>;
  33920. /**
  33921. * Gets or sets the active clipplane 2
  33922. */
  33923. clipPlane2: Nullable<Plane>;
  33924. /**
  33925. * Gets or sets the active clipplane 3
  33926. */
  33927. clipPlane3: Nullable<Plane>;
  33928. /**
  33929. * Gets or sets the active clipplane 4
  33930. */
  33931. clipPlane4: Nullable<Plane>;
  33932. /**
  33933. * Gets or sets a boolean indicating if animations are enabled
  33934. */
  33935. animationsEnabled: boolean;
  33936. private _animationPropertiesOverride;
  33937. /**
  33938. * Gets or sets the animation properties override
  33939. */
  33940. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33941. /**
  33942. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33943. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33944. */
  33945. useConstantAnimationDeltaTime: boolean;
  33946. /**
  33947. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33948. * Please note that it requires to run a ray cast through the scene on every frame
  33949. */
  33950. constantlyUpdateMeshUnderPointer: boolean;
  33951. /**
  33952. * Defines the HTML cursor to use when hovering over interactive elements
  33953. */
  33954. hoverCursor: string;
  33955. /**
  33956. * Defines the HTML default cursor to use (empty by default)
  33957. */
  33958. defaultCursor: string;
  33959. /**
  33960. * This is used to call preventDefault() on pointer down
  33961. * in order to block unwanted artifacts like system double clicks
  33962. */
  33963. preventDefaultOnPointerDown: boolean;
  33964. /**
  33965. * This is used to call preventDefault() on pointer up
  33966. * in order to block unwanted artifacts like system double clicks
  33967. */
  33968. preventDefaultOnPointerUp: boolean;
  33969. /**
  33970. * Gets or sets user defined metadata
  33971. */
  33972. metadata: any;
  33973. /**
  33974. * For internal use only. Please do not use.
  33975. */
  33976. reservedDataStore: any;
  33977. /**
  33978. * Gets the name of the plugin used to load this scene (null by default)
  33979. */
  33980. loadingPluginName: string;
  33981. /**
  33982. * Use this array to add regular expressions used to disable offline support for specific urls
  33983. */
  33984. disableOfflineSupportExceptionRules: RegExp[];
  33985. /**
  33986. * An event triggered when the scene is disposed.
  33987. */
  33988. onDisposeObservable: Observable<Scene>;
  33989. private _onDisposeObserver;
  33990. /** Sets a function to be executed when this scene is disposed. */
  33991. onDispose: () => void;
  33992. /**
  33993. * An event triggered before rendering the scene (right after animations and physics)
  33994. */
  33995. onBeforeRenderObservable: Observable<Scene>;
  33996. private _onBeforeRenderObserver;
  33997. /** Sets a function to be executed before rendering this scene */
  33998. beforeRender: Nullable<() => void>;
  33999. /**
  34000. * An event triggered after rendering the scene
  34001. */
  34002. onAfterRenderObservable: Observable<Scene>;
  34003. /**
  34004. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34005. */
  34006. onAfterRenderCameraObservable: Observable<Camera>;
  34007. private _onAfterRenderObserver;
  34008. /** Sets a function to be executed after rendering this scene */
  34009. afterRender: Nullable<() => void>;
  34010. /**
  34011. * An event triggered before animating the scene
  34012. */
  34013. onBeforeAnimationsObservable: Observable<Scene>;
  34014. /**
  34015. * An event triggered after animations processing
  34016. */
  34017. onAfterAnimationsObservable: Observable<Scene>;
  34018. /**
  34019. * An event triggered before draw calls are ready to be sent
  34020. */
  34021. onBeforeDrawPhaseObservable: Observable<Scene>;
  34022. /**
  34023. * An event triggered after draw calls have been sent
  34024. */
  34025. onAfterDrawPhaseObservable: Observable<Scene>;
  34026. /**
  34027. * An event triggered when the scene is ready
  34028. */
  34029. onReadyObservable: Observable<Scene>;
  34030. /**
  34031. * An event triggered before rendering a camera
  34032. */
  34033. onBeforeCameraRenderObservable: Observable<Camera>;
  34034. private _onBeforeCameraRenderObserver;
  34035. /** Sets a function to be executed before rendering a camera*/
  34036. beforeCameraRender: () => void;
  34037. /**
  34038. * An event triggered after rendering a camera
  34039. */
  34040. onAfterCameraRenderObservable: Observable<Camera>;
  34041. private _onAfterCameraRenderObserver;
  34042. /** Sets a function to be executed after rendering a camera*/
  34043. afterCameraRender: () => void;
  34044. /**
  34045. * An event triggered when active meshes evaluation is about to start
  34046. */
  34047. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34048. /**
  34049. * An event triggered when active meshes evaluation is done
  34050. */
  34051. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34052. /**
  34053. * An event triggered when particles rendering is about to start
  34054. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34055. */
  34056. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34057. /**
  34058. * An event triggered when particles rendering is done
  34059. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34060. */
  34061. onAfterParticlesRenderingObservable: Observable<Scene>;
  34062. /**
  34063. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34064. */
  34065. onDataLoadedObservable: Observable<Scene>;
  34066. /**
  34067. * An event triggered when a camera is created
  34068. */
  34069. onNewCameraAddedObservable: Observable<Camera>;
  34070. /**
  34071. * An event triggered when a camera is removed
  34072. */
  34073. onCameraRemovedObservable: Observable<Camera>;
  34074. /**
  34075. * An event triggered when a light is created
  34076. */
  34077. onNewLightAddedObservable: Observable<Light>;
  34078. /**
  34079. * An event triggered when a light is removed
  34080. */
  34081. onLightRemovedObservable: Observable<Light>;
  34082. /**
  34083. * An event triggered when a geometry is created
  34084. */
  34085. onNewGeometryAddedObservable: Observable<Geometry>;
  34086. /**
  34087. * An event triggered when a geometry is removed
  34088. */
  34089. onGeometryRemovedObservable: Observable<Geometry>;
  34090. /**
  34091. * An event triggered when a transform node is created
  34092. */
  34093. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34094. /**
  34095. * An event triggered when a transform node is removed
  34096. */
  34097. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34098. /**
  34099. * An event triggered when a mesh is created
  34100. */
  34101. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34102. /**
  34103. * An event triggered when a mesh is removed
  34104. */
  34105. onMeshRemovedObservable: Observable<AbstractMesh>;
  34106. /**
  34107. * An event triggered when a skeleton is created
  34108. */
  34109. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34110. /**
  34111. * An event triggered when a skeleton is removed
  34112. */
  34113. onSkeletonRemovedObservable: Observable<Skeleton>;
  34114. /**
  34115. * An event triggered when a material is created
  34116. */
  34117. onNewMaterialAddedObservable: Observable<Material>;
  34118. /**
  34119. * An event triggered when a material is removed
  34120. */
  34121. onMaterialRemovedObservable: Observable<Material>;
  34122. /**
  34123. * An event triggered when a texture is created
  34124. */
  34125. onNewTextureAddedObservable: Observable<BaseTexture>;
  34126. /**
  34127. * An event triggered when a texture is removed
  34128. */
  34129. onTextureRemovedObservable: Observable<BaseTexture>;
  34130. /**
  34131. * An event triggered when render targets are about to be rendered
  34132. * Can happen multiple times per frame.
  34133. */
  34134. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34135. /**
  34136. * An event triggered when render targets were rendered.
  34137. * Can happen multiple times per frame.
  34138. */
  34139. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34140. /**
  34141. * An event triggered before calculating deterministic simulation step
  34142. */
  34143. onBeforeStepObservable: Observable<Scene>;
  34144. /**
  34145. * An event triggered after calculating deterministic simulation step
  34146. */
  34147. onAfterStepObservable: Observable<Scene>;
  34148. /**
  34149. * An event triggered when the activeCamera property is updated
  34150. */
  34151. onActiveCameraChanged: Observable<Scene>;
  34152. /**
  34153. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34154. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34155. * 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)
  34156. */
  34157. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34158. /**
  34159. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34160. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34161. * 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)
  34162. */
  34163. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34164. /**
  34165. * This Observable will when a mesh has been imported into the scene.
  34166. */
  34167. onMeshImportedObservable: Observable<AbstractMesh>;
  34168. /**
  34169. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34170. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34171. */
  34172. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34173. /** @hidden */
  34174. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34175. /**
  34176. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34177. */
  34178. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34179. /**
  34180. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34181. */
  34182. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34183. /**
  34184. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34185. */
  34186. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34187. /** Callback called when a pointer move is detected */
  34188. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34189. /** Callback called when a pointer down is detected */
  34190. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34191. /** Callback called when a pointer up is detected */
  34192. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34193. /** Callback called when a pointer pick is detected */
  34194. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34195. /**
  34196. * 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).
  34197. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34198. */
  34199. onPrePointerObservable: Observable<PointerInfoPre>;
  34200. /**
  34201. * Observable event triggered each time an input event is received from the rendering canvas
  34202. */
  34203. onPointerObservable: Observable<PointerInfo>;
  34204. /**
  34205. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34206. */
  34207. readonly unTranslatedPointer: Vector2;
  34208. /**
  34209. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34210. */
  34211. static DragMovementThreshold: number;
  34212. /**
  34213. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34214. */
  34215. static LongPressDelay: number;
  34216. /**
  34217. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34218. */
  34219. static DoubleClickDelay: number;
  34220. /** If you need to check double click without raising a single click at first click, enable this flag */
  34221. static ExclusiveDoubleClickMode: boolean;
  34222. /** @hidden */
  34223. _mirroredCameraPosition: Nullable<Vector3>;
  34224. /**
  34225. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34226. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34227. */
  34228. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34229. /**
  34230. * Observable event triggered each time an keyboard event is received from the hosting window
  34231. */
  34232. onKeyboardObservable: Observable<KeyboardInfo>;
  34233. private _useRightHandedSystem;
  34234. /**
  34235. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34236. */
  34237. useRightHandedSystem: boolean;
  34238. private _timeAccumulator;
  34239. private _currentStepId;
  34240. private _currentInternalStep;
  34241. /**
  34242. * Sets the step Id used by deterministic lock step
  34243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34244. * @param newStepId defines the step Id
  34245. */
  34246. setStepId(newStepId: number): void;
  34247. /**
  34248. * Gets the step Id used by deterministic lock step
  34249. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34250. * @returns the step Id
  34251. */
  34252. getStepId(): number;
  34253. /**
  34254. * Gets the internal step used by deterministic lock step
  34255. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34256. * @returns the internal step
  34257. */
  34258. getInternalStep(): number;
  34259. private _fogEnabled;
  34260. /**
  34261. * Gets or sets a boolean indicating if fog is enabled on this scene
  34262. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34263. * (Default is true)
  34264. */
  34265. fogEnabled: boolean;
  34266. private _fogMode;
  34267. /**
  34268. * Gets or sets the fog mode to use
  34269. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34270. * | mode | value |
  34271. * | --- | --- |
  34272. * | FOGMODE_NONE | 0 |
  34273. * | FOGMODE_EXP | 1 |
  34274. * | FOGMODE_EXP2 | 2 |
  34275. * | FOGMODE_LINEAR | 3 |
  34276. */
  34277. fogMode: number;
  34278. /**
  34279. * Gets or sets the fog color to use
  34280. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34281. * (Default is Color3(0.2, 0.2, 0.3))
  34282. */
  34283. fogColor: Color3;
  34284. /**
  34285. * Gets or sets the fog density to use
  34286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34287. * (Default is 0.1)
  34288. */
  34289. fogDensity: number;
  34290. /**
  34291. * Gets or sets the fog start distance to use
  34292. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34293. * (Default is 0)
  34294. */
  34295. fogStart: number;
  34296. /**
  34297. * Gets or sets the fog end distance to use
  34298. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34299. * (Default is 1000)
  34300. */
  34301. fogEnd: number;
  34302. private _shadowsEnabled;
  34303. /**
  34304. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34305. */
  34306. shadowsEnabled: boolean;
  34307. private _lightsEnabled;
  34308. /**
  34309. * Gets or sets a boolean indicating if lights are enabled on this scene
  34310. */
  34311. lightsEnabled: boolean;
  34312. /** All of the active cameras added to this scene. */
  34313. activeCameras: Camera[];
  34314. /** @hidden */
  34315. _activeCamera: Nullable<Camera>;
  34316. /** Gets or sets the current active camera */
  34317. activeCamera: Nullable<Camera>;
  34318. private _defaultMaterial;
  34319. /** The default material used on meshes when no material is affected */
  34320. /** The default material used on meshes when no material is affected */
  34321. defaultMaterial: Material;
  34322. private _texturesEnabled;
  34323. /**
  34324. * Gets or sets a boolean indicating if textures are enabled on this scene
  34325. */
  34326. texturesEnabled: boolean;
  34327. /**
  34328. * Gets or sets a boolean indicating if particles are enabled on this scene
  34329. */
  34330. particlesEnabled: boolean;
  34331. /**
  34332. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34333. */
  34334. spritesEnabled: boolean;
  34335. private _skeletonsEnabled;
  34336. /**
  34337. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34338. */
  34339. skeletonsEnabled: boolean;
  34340. /**
  34341. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34342. */
  34343. lensFlaresEnabled: boolean;
  34344. /**
  34345. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34347. */
  34348. collisionsEnabled: boolean;
  34349. private _collisionCoordinator;
  34350. /** @hidden */
  34351. readonly collisionCoordinator: ICollisionCoordinator;
  34352. /**
  34353. * Defines the gravity applied to this scene (used only for collisions)
  34354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34355. */
  34356. gravity: Vector3;
  34357. /**
  34358. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34359. */
  34360. postProcessesEnabled: boolean;
  34361. /**
  34362. * The list of postprocesses added to the scene
  34363. */
  34364. postProcesses: PostProcess[];
  34365. /**
  34366. * Gets the current postprocess manager
  34367. */
  34368. postProcessManager: PostProcessManager;
  34369. /**
  34370. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34371. */
  34372. renderTargetsEnabled: boolean;
  34373. /**
  34374. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34375. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34376. */
  34377. dumpNextRenderTargets: boolean;
  34378. /**
  34379. * The list of user defined render targets added to the scene
  34380. */
  34381. customRenderTargets: RenderTargetTexture[];
  34382. /**
  34383. * Defines if texture loading must be delayed
  34384. * If true, textures will only be loaded when they need to be rendered
  34385. */
  34386. useDelayedTextureLoading: boolean;
  34387. /**
  34388. * Gets the list of meshes imported to the scene through SceneLoader
  34389. */
  34390. importedMeshesFiles: String[];
  34391. /**
  34392. * Gets or sets a boolean indicating if probes are enabled on this scene
  34393. */
  34394. probesEnabled: boolean;
  34395. /**
  34396. * Gets or sets the current offline provider to use to store scene data
  34397. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34398. */
  34399. offlineProvider: IOfflineProvider;
  34400. /**
  34401. * Gets or sets the action manager associated with the scene
  34402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34403. */
  34404. actionManager: AbstractActionManager;
  34405. private _meshesForIntersections;
  34406. /**
  34407. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34408. */
  34409. proceduralTexturesEnabled: boolean;
  34410. private _engine;
  34411. private _totalVertices;
  34412. /** @hidden */
  34413. _activeIndices: PerfCounter;
  34414. /** @hidden */
  34415. _activeParticles: PerfCounter;
  34416. /** @hidden */
  34417. _activeBones: PerfCounter;
  34418. private _animationRatio;
  34419. /** @hidden */
  34420. _animationTimeLast: number;
  34421. /** @hidden */
  34422. _animationTime: number;
  34423. /**
  34424. * Gets or sets a general scale for animation speed
  34425. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34426. */
  34427. animationTimeScale: number;
  34428. /** @hidden */
  34429. _cachedMaterial: Nullable<Material>;
  34430. /** @hidden */
  34431. _cachedEffect: Nullable<Effect>;
  34432. /** @hidden */
  34433. _cachedVisibility: Nullable<number>;
  34434. private _renderId;
  34435. private _frameId;
  34436. private _executeWhenReadyTimeoutId;
  34437. private _intermediateRendering;
  34438. private _viewUpdateFlag;
  34439. private _projectionUpdateFlag;
  34440. /** @hidden */
  34441. _toBeDisposed: Nullable<IDisposable>[];
  34442. private _activeRequests;
  34443. /** @hidden */
  34444. _pendingData: any[];
  34445. private _isDisposed;
  34446. /**
  34447. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34448. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34449. */
  34450. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34451. private _activeMeshes;
  34452. private _processedMaterials;
  34453. private _renderTargets;
  34454. /** @hidden */
  34455. _activeParticleSystems: SmartArray<IParticleSystem>;
  34456. private _activeSkeletons;
  34457. private _softwareSkinnedMeshes;
  34458. private _renderingManager;
  34459. /** @hidden */
  34460. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34461. private _transformMatrix;
  34462. private _sceneUbo;
  34463. /** @hidden */
  34464. _viewMatrix: Matrix;
  34465. private _projectionMatrix;
  34466. /** @hidden */
  34467. _forcedViewPosition: Nullable<Vector3>;
  34468. /** @hidden */
  34469. _frustumPlanes: Plane[];
  34470. /**
  34471. * Gets the list of frustum planes (built from the active camera)
  34472. */
  34473. readonly frustumPlanes: Plane[];
  34474. /**
  34475. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34476. * This is useful if there are more lights that the maximum simulteanous authorized
  34477. */
  34478. requireLightSorting: boolean;
  34479. /** @hidden */
  34480. readonly useMaterialMeshMap: boolean;
  34481. /** @hidden */
  34482. readonly useClonedMeshhMap: boolean;
  34483. private _externalData;
  34484. private _uid;
  34485. /**
  34486. * @hidden
  34487. * Backing store of defined scene components.
  34488. */
  34489. _components: ISceneComponent[];
  34490. /**
  34491. * @hidden
  34492. * Backing store of defined scene components.
  34493. */
  34494. _serializableComponents: ISceneSerializableComponent[];
  34495. /**
  34496. * List of components to register on the next registration step.
  34497. */
  34498. private _transientComponents;
  34499. /**
  34500. * Registers the transient components if needed.
  34501. */
  34502. private _registerTransientComponents;
  34503. /**
  34504. * @hidden
  34505. * Add a component to the scene.
  34506. * Note that the ccomponent could be registered on th next frame if this is called after
  34507. * the register component stage.
  34508. * @param component Defines the component to add to the scene
  34509. */
  34510. _addComponent(component: ISceneComponent): void;
  34511. /**
  34512. * @hidden
  34513. * Gets a component from the scene.
  34514. * @param name defines the name of the component to retrieve
  34515. * @returns the component or null if not present
  34516. */
  34517. _getComponent(name: string): Nullable<ISceneComponent>;
  34518. /**
  34519. * @hidden
  34520. * Defines the actions happening before camera updates.
  34521. */
  34522. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34523. /**
  34524. * @hidden
  34525. * Defines the actions happening before clear the canvas.
  34526. */
  34527. _beforeClearStage: Stage<SimpleStageAction>;
  34528. /**
  34529. * @hidden
  34530. * Defines the actions when collecting render targets for the frame.
  34531. */
  34532. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34533. /**
  34534. * @hidden
  34535. * Defines the actions happening for one camera in the frame.
  34536. */
  34537. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34538. /**
  34539. * @hidden
  34540. * Defines the actions happening during the per mesh ready checks.
  34541. */
  34542. _isReadyForMeshStage: Stage<MeshStageAction>;
  34543. /**
  34544. * @hidden
  34545. * Defines the actions happening before evaluate active mesh checks.
  34546. */
  34547. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34548. /**
  34549. * @hidden
  34550. * Defines the actions happening during the evaluate sub mesh checks.
  34551. */
  34552. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34553. /**
  34554. * @hidden
  34555. * Defines the actions happening during the active mesh stage.
  34556. */
  34557. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34558. /**
  34559. * @hidden
  34560. * Defines the actions happening during the per camera render target step.
  34561. */
  34562. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34563. /**
  34564. * @hidden
  34565. * Defines the actions happening just before the active camera is drawing.
  34566. */
  34567. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34568. /**
  34569. * @hidden
  34570. * Defines the actions happening just before a render target is drawing.
  34571. */
  34572. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34573. /**
  34574. * @hidden
  34575. * Defines the actions happening just before a rendering group is drawing.
  34576. */
  34577. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34578. /**
  34579. * @hidden
  34580. * Defines the actions happening just before a mesh is drawing.
  34581. */
  34582. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34583. /**
  34584. * @hidden
  34585. * Defines the actions happening just after a mesh has been drawn.
  34586. */
  34587. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34588. /**
  34589. * @hidden
  34590. * Defines the actions happening just after a rendering group has been drawn.
  34591. */
  34592. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34593. /**
  34594. * @hidden
  34595. * Defines the actions happening just after the active camera has been drawn.
  34596. */
  34597. _afterCameraDrawStage: Stage<CameraStageAction>;
  34598. /**
  34599. * @hidden
  34600. * Defines the actions happening just after a render target has been drawn.
  34601. */
  34602. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34603. /**
  34604. * @hidden
  34605. * Defines the actions happening just after rendering all cameras and computing intersections.
  34606. */
  34607. _afterRenderStage: Stage<SimpleStageAction>;
  34608. /**
  34609. * @hidden
  34610. * Defines the actions happening when a pointer move event happens.
  34611. */
  34612. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34613. /**
  34614. * @hidden
  34615. * Defines the actions happening when a pointer down event happens.
  34616. */
  34617. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34618. /**
  34619. * @hidden
  34620. * Defines the actions happening when a pointer up event happens.
  34621. */
  34622. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34623. /**
  34624. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34625. */
  34626. private geometriesByUniqueId;
  34627. /**
  34628. * Creates a new Scene
  34629. * @param engine defines the engine to use to render this scene
  34630. * @param options defines the scene options
  34631. */
  34632. constructor(engine: Engine, options?: SceneOptions);
  34633. /**
  34634. * Gets a string idenfifying the name of the class
  34635. * @returns "Scene" string
  34636. */
  34637. getClassName(): string;
  34638. private _defaultMeshCandidates;
  34639. /**
  34640. * @hidden
  34641. */
  34642. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34643. private _defaultSubMeshCandidates;
  34644. /**
  34645. * @hidden
  34646. */
  34647. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34648. /**
  34649. * Sets the default candidate providers for the scene.
  34650. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34651. * and getCollidingSubMeshCandidates to their default function
  34652. */
  34653. setDefaultCandidateProviders(): void;
  34654. /**
  34655. * Gets the mesh that is currently under the pointer
  34656. */
  34657. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34658. /**
  34659. * Gets or sets the current on-screen X position of the pointer
  34660. */
  34661. pointerX: number;
  34662. /**
  34663. * Gets or sets the current on-screen Y position of the pointer
  34664. */
  34665. pointerY: number;
  34666. /**
  34667. * Gets the cached material (ie. the latest rendered one)
  34668. * @returns the cached material
  34669. */
  34670. getCachedMaterial(): Nullable<Material>;
  34671. /**
  34672. * Gets the cached effect (ie. the latest rendered one)
  34673. * @returns the cached effect
  34674. */
  34675. getCachedEffect(): Nullable<Effect>;
  34676. /**
  34677. * Gets the cached visibility state (ie. the latest rendered one)
  34678. * @returns the cached visibility state
  34679. */
  34680. getCachedVisibility(): Nullable<number>;
  34681. /**
  34682. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34683. * @param material defines the current material
  34684. * @param effect defines the current effect
  34685. * @param visibility defines the current visibility state
  34686. * @returns true if one parameter is not cached
  34687. */
  34688. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34689. /**
  34690. * Gets the engine associated with the scene
  34691. * @returns an Engine
  34692. */
  34693. getEngine(): Engine;
  34694. /**
  34695. * Gets the total number of vertices rendered per frame
  34696. * @returns the total number of vertices rendered per frame
  34697. */
  34698. getTotalVertices(): number;
  34699. /**
  34700. * Gets the performance counter for total vertices
  34701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34702. */
  34703. readonly totalVerticesPerfCounter: PerfCounter;
  34704. /**
  34705. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34706. * @returns the total number of active indices rendered per frame
  34707. */
  34708. getActiveIndices(): number;
  34709. /**
  34710. * Gets the performance counter for active indices
  34711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34712. */
  34713. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34714. /**
  34715. * Gets the total number of active particles rendered per frame
  34716. * @returns the total number of active particles rendered per frame
  34717. */
  34718. getActiveParticles(): number;
  34719. /**
  34720. * Gets the performance counter for active particles
  34721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34722. */
  34723. readonly activeParticlesPerfCounter: PerfCounter;
  34724. /**
  34725. * Gets the total number of active bones rendered per frame
  34726. * @returns the total number of active bones rendered per frame
  34727. */
  34728. getActiveBones(): number;
  34729. /**
  34730. * Gets the performance counter for active bones
  34731. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34732. */
  34733. readonly activeBonesPerfCounter: PerfCounter;
  34734. /**
  34735. * Gets the array of active meshes
  34736. * @returns an array of AbstractMesh
  34737. */
  34738. getActiveMeshes(): SmartArray<AbstractMesh>;
  34739. /**
  34740. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34741. * @returns a number
  34742. */
  34743. getAnimationRatio(): number;
  34744. /**
  34745. * Gets an unique Id for the current render phase
  34746. * @returns a number
  34747. */
  34748. getRenderId(): number;
  34749. /**
  34750. * Gets an unique Id for the current frame
  34751. * @returns a number
  34752. */
  34753. getFrameId(): number;
  34754. /** Call this function if you want to manually increment the render Id*/
  34755. incrementRenderId(): void;
  34756. private _createUbo;
  34757. /**
  34758. * Use this method to simulate a pointer move on a mesh
  34759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34762. * @returns the current scene
  34763. */
  34764. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34765. /**
  34766. * Use this method to simulate a pointer down on a mesh
  34767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34770. * @returns the current scene
  34771. */
  34772. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34773. /**
  34774. * Use this method to simulate a pointer up on a mesh
  34775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34778. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34779. * @returns the current scene
  34780. */
  34781. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34782. /**
  34783. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34784. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34785. * @returns true if the pointer was captured
  34786. */
  34787. isPointerCaptured(pointerId?: number): boolean;
  34788. /**
  34789. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34790. * @param attachUp defines if you want to attach events to pointerup
  34791. * @param attachDown defines if you want to attach events to pointerdown
  34792. * @param attachMove defines if you want to attach events to pointermove
  34793. */
  34794. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34795. /** Detaches all event handlers*/
  34796. detachControl(): void;
  34797. /**
  34798. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34799. * Delay loaded resources are not taking in account
  34800. * @return true if all required resources are ready
  34801. */
  34802. isReady(): boolean;
  34803. /** Resets all cached information relative to material (including effect and visibility) */
  34804. resetCachedMaterial(): void;
  34805. /**
  34806. * Registers a function to be called before every frame render
  34807. * @param func defines the function to register
  34808. */
  34809. registerBeforeRender(func: () => void): void;
  34810. /**
  34811. * Unregisters a function called before every frame render
  34812. * @param func defines the function to unregister
  34813. */
  34814. unregisterBeforeRender(func: () => void): void;
  34815. /**
  34816. * Registers a function to be called after every frame render
  34817. * @param func defines the function to register
  34818. */
  34819. registerAfterRender(func: () => void): void;
  34820. /**
  34821. * Unregisters a function called after every frame render
  34822. * @param func defines the function to unregister
  34823. */
  34824. unregisterAfterRender(func: () => void): void;
  34825. private _executeOnceBeforeRender;
  34826. /**
  34827. * The provided function will run before render once and will be disposed afterwards.
  34828. * A timeout delay can be provided so that the function will be executed in N ms.
  34829. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34830. * @param func The function to be executed.
  34831. * @param timeout optional delay in ms
  34832. */
  34833. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34834. /** @hidden */
  34835. _addPendingData(data: any): void;
  34836. /** @hidden */
  34837. _removePendingData(data: any): void;
  34838. /**
  34839. * Returns the number of items waiting to be loaded
  34840. * @returns the number of items waiting to be loaded
  34841. */
  34842. getWaitingItemsCount(): number;
  34843. /**
  34844. * Returns a boolean indicating if the scene is still loading data
  34845. */
  34846. readonly isLoading: boolean;
  34847. /**
  34848. * Registers a function to be executed when the scene is ready
  34849. * @param {Function} func - the function to be executed
  34850. */
  34851. executeWhenReady(func: () => void): void;
  34852. /**
  34853. * Returns a promise that resolves when the scene is ready
  34854. * @returns A promise that resolves when the scene is ready
  34855. */
  34856. whenReadyAsync(): Promise<void>;
  34857. /** @hidden */
  34858. _checkIsReady(): void;
  34859. /**
  34860. * Gets all animatable attached to the scene
  34861. */
  34862. readonly animatables: Animatable[];
  34863. /**
  34864. * Resets the last animation time frame.
  34865. * Useful to override when animations start running when loading a scene for the first time.
  34866. */
  34867. resetLastAnimationTimeFrame(): void;
  34868. /**
  34869. * Gets the current view matrix
  34870. * @returns a Matrix
  34871. */
  34872. getViewMatrix(): Matrix;
  34873. /**
  34874. * Gets the current projection matrix
  34875. * @returns a Matrix
  34876. */
  34877. getProjectionMatrix(): Matrix;
  34878. /**
  34879. * Gets the current transform matrix
  34880. * @returns a Matrix made of View * Projection
  34881. */
  34882. getTransformMatrix(): Matrix;
  34883. /**
  34884. * Sets the current transform matrix
  34885. * @param viewL defines the View matrix to use
  34886. * @param projectionL defines the Projection matrix to use
  34887. * @param viewR defines the right View matrix to use (if provided)
  34888. * @param projectionR defines the right Projection matrix to use (if provided)
  34889. */
  34890. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34891. /**
  34892. * Gets the uniform buffer used to store scene data
  34893. * @returns a UniformBuffer
  34894. */
  34895. getSceneUniformBuffer(): UniformBuffer;
  34896. /**
  34897. * Gets an unique (relatively to the current scene) Id
  34898. * @returns an unique number for the scene
  34899. */
  34900. getUniqueId(): number;
  34901. /**
  34902. * Add a mesh to the list of scene's meshes
  34903. * @param newMesh defines the mesh to add
  34904. * @param recursive if all child meshes should also be added to the scene
  34905. */
  34906. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34907. /**
  34908. * Remove a mesh for the list of scene's meshes
  34909. * @param toRemove defines the mesh to remove
  34910. * @param recursive if all child meshes should also be removed from the scene
  34911. * @returns the index where the mesh was in the mesh list
  34912. */
  34913. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34914. /**
  34915. * Add a transform node to the list of scene's transform nodes
  34916. * @param newTransformNode defines the transform node to add
  34917. */
  34918. addTransformNode(newTransformNode: TransformNode): void;
  34919. /**
  34920. * Remove a transform node for the list of scene's transform nodes
  34921. * @param toRemove defines the transform node to remove
  34922. * @returns the index where the transform node was in the transform node list
  34923. */
  34924. removeTransformNode(toRemove: TransformNode): number;
  34925. /**
  34926. * Remove a skeleton for the list of scene's skeletons
  34927. * @param toRemove defines the skeleton to remove
  34928. * @returns the index where the skeleton was in the skeleton list
  34929. */
  34930. removeSkeleton(toRemove: Skeleton): number;
  34931. /**
  34932. * Remove a morph target for the list of scene's morph targets
  34933. * @param toRemove defines the morph target to remove
  34934. * @returns the index where the morph target was in the morph target list
  34935. */
  34936. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34937. /**
  34938. * Remove a light for the list of scene's lights
  34939. * @param toRemove defines the light to remove
  34940. * @returns the index where the light was in the light list
  34941. */
  34942. removeLight(toRemove: Light): number;
  34943. /**
  34944. * Remove a camera for the list of scene's cameras
  34945. * @param toRemove defines the camera to remove
  34946. * @returns the index where the camera was in the camera list
  34947. */
  34948. removeCamera(toRemove: Camera): number;
  34949. /**
  34950. * Remove a particle system for the list of scene's particle systems
  34951. * @param toRemove defines the particle system to remove
  34952. * @returns the index where the particle system was in the particle system list
  34953. */
  34954. removeParticleSystem(toRemove: IParticleSystem): number;
  34955. /**
  34956. * Remove a animation for the list of scene's animations
  34957. * @param toRemove defines the animation to remove
  34958. * @returns the index where the animation was in the animation list
  34959. */
  34960. removeAnimation(toRemove: Animation): number;
  34961. /**
  34962. * Will stop the animation of the given target
  34963. * @param target - the target
  34964. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34965. * @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)
  34966. */
  34967. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34968. /**
  34969. * Removes the given animation group from this scene.
  34970. * @param toRemove The animation group to remove
  34971. * @returns The index of the removed animation group
  34972. */
  34973. removeAnimationGroup(toRemove: AnimationGroup): number;
  34974. /**
  34975. * Removes the given multi-material from this scene.
  34976. * @param toRemove The multi-material to remove
  34977. * @returns The index of the removed multi-material
  34978. */
  34979. removeMultiMaterial(toRemove: MultiMaterial): number;
  34980. /**
  34981. * Removes the given material from this scene.
  34982. * @param toRemove The material to remove
  34983. * @returns The index of the removed material
  34984. */
  34985. removeMaterial(toRemove: Material): number;
  34986. /**
  34987. * Removes the given action manager from this scene.
  34988. * @param toRemove The action manager to remove
  34989. * @returns The index of the removed action manager
  34990. */
  34991. removeActionManager(toRemove: AbstractActionManager): number;
  34992. /**
  34993. * Removes the given texture from this scene.
  34994. * @param toRemove The texture to remove
  34995. * @returns The index of the removed texture
  34996. */
  34997. removeTexture(toRemove: BaseTexture): number;
  34998. /**
  34999. * Adds the given light to this scene
  35000. * @param newLight The light to add
  35001. */
  35002. addLight(newLight: Light): void;
  35003. /**
  35004. * Sorts the list list based on light priorities
  35005. */
  35006. sortLightsByPriority(): void;
  35007. /**
  35008. * Adds the given camera to this scene
  35009. * @param newCamera The camera to add
  35010. */
  35011. addCamera(newCamera: Camera): void;
  35012. /**
  35013. * Adds the given skeleton to this scene
  35014. * @param newSkeleton The skeleton to add
  35015. */
  35016. addSkeleton(newSkeleton: Skeleton): void;
  35017. /**
  35018. * Adds the given particle system to this scene
  35019. * @param newParticleSystem The particle system to add
  35020. */
  35021. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35022. /**
  35023. * Adds the given animation to this scene
  35024. * @param newAnimation The animation to add
  35025. */
  35026. addAnimation(newAnimation: Animation): void;
  35027. /**
  35028. * Adds the given animation group to this scene.
  35029. * @param newAnimationGroup The animation group to add
  35030. */
  35031. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35032. /**
  35033. * Adds the given multi-material to this scene
  35034. * @param newMultiMaterial The multi-material to add
  35035. */
  35036. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35037. /**
  35038. * Adds the given material to this scene
  35039. * @param newMaterial The material to add
  35040. */
  35041. addMaterial(newMaterial: Material): void;
  35042. /**
  35043. * Adds the given morph target to this scene
  35044. * @param newMorphTargetManager The morph target to add
  35045. */
  35046. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35047. /**
  35048. * Adds the given geometry to this scene
  35049. * @param newGeometry The geometry to add
  35050. */
  35051. addGeometry(newGeometry: Geometry): void;
  35052. /**
  35053. * Adds the given action manager to this scene
  35054. * @param newActionManager The action manager to add
  35055. */
  35056. addActionManager(newActionManager: AbstractActionManager): void;
  35057. /**
  35058. * Adds the given texture to this scene.
  35059. * @param newTexture The texture to add
  35060. */
  35061. addTexture(newTexture: BaseTexture): void;
  35062. /**
  35063. * Switch active camera
  35064. * @param newCamera defines the new active camera
  35065. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35066. */
  35067. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35068. /**
  35069. * sets the active camera of the scene using its ID
  35070. * @param id defines the camera's ID
  35071. * @return the new active camera or null if none found.
  35072. */
  35073. setActiveCameraByID(id: string): Nullable<Camera>;
  35074. /**
  35075. * sets the active camera of the scene using its name
  35076. * @param name defines the camera's name
  35077. * @returns the new active camera or null if none found.
  35078. */
  35079. setActiveCameraByName(name: string): Nullable<Camera>;
  35080. /**
  35081. * get an animation group using its name
  35082. * @param name defines the material's name
  35083. * @return the animation group or null if none found.
  35084. */
  35085. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35086. /**
  35087. * Get a material using its unique id
  35088. * @param uniqueId defines the material's unique id
  35089. * @return the material or null if none found.
  35090. */
  35091. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35092. /**
  35093. * get a material using its id
  35094. * @param id defines the material's ID
  35095. * @return the material or null if none found.
  35096. */
  35097. getMaterialByID(id: string): Nullable<Material>;
  35098. /**
  35099. * Gets a the last added material using a given id
  35100. * @param id defines the material's ID
  35101. * @return the last material with the given id or null if none found.
  35102. */
  35103. getLastMaterialByID(id: string): Nullable<Material>;
  35104. /**
  35105. * Gets a material using its name
  35106. * @param name defines the material's name
  35107. * @return the material or null if none found.
  35108. */
  35109. getMaterialByName(name: string): Nullable<Material>;
  35110. /**
  35111. * Get a texture using its unique id
  35112. * @param uniqueId defines the texture's unique id
  35113. * @return the texture or null if none found.
  35114. */
  35115. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35116. /**
  35117. * Gets a camera using its id
  35118. * @param id defines the id to look for
  35119. * @returns the camera or null if not found
  35120. */
  35121. getCameraByID(id: string): Nullable<Camera>;
  35122. /**
  35123. * Gets a camera using its unique id
  35124. * @param uniqueId defines the unique id to look for
  35125. * @returns the camera or null if not found
  35126. */
  35127. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35128. /**
  35129. * Gets a camera using its name
  35130. * @param name defines the camera's name
  35131. * @return the camera or null if none found.
  35132. */
  35133. getCameraByName(name: string): Nullable<Camera>;
  35134. /**
  35135. * Gets a bone using its id
  35136. * @param id defines the bone's id
  35137. * @return the bone or null if not found
  35138. */
  35139. getBoneByID(id: string): Nullable<Bone>;
  35140. /**
  35141. * Gets a bone using its id
  35142. * @param name defines the bone's name
  35143. * @return the bone or null if not found
  35144. */
  35145. getBoneByName(name: string): Nullable<Bone>;
  35146. /**
  35147. * Gets a light node using its name
  35148. * @param name defines the the light's name
  35149. * @return the light or null if none found.
  35150. */
  35151. getLightByName(name: string): Nullable<Light>;
  35152. /**
  35153. * Gets a light node using its id
  35154. * @param id defines the light's id
  35155. * @return the light or null if none found.
  35156. */
  35157. getLightByID(id: string): Nullable<Light>;
  35158. /**
  35159. * Gets a light node using its scene-generated unique ID
  35160. * @param uniqueId defines the light's unique id
  35161. * @return the light or null if none found.
  35162. */
  35163. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35164. /**
  35165. * Gets a particle system by id
  35166. * @param id defines the particle system id
  35167. * @return the corresponding system or null if none found
  35168. */
  35169. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35170. /**
  35171. * Gets a geometry using its ID
  35172. * @param id defines the geometry's id
  35173. * @return the geometry or null if none found.
  35174. */
  35175. getGeometryByID(id: string): Nullable<Geometry>;
  35176. private _getGeometryByUniqueID;
  35177. /**
  35178. * Add a new geometry to this scene
  35179. * @param geometry defines the geometry to be added to the scene.
  35180. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35181. * @return a boolean defining if the geometry was added or not
  35182. */
  35183. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35184. /**
  35185. * Removes an existing geometry
  35186. * @param geometry defines the geometry to be removed from the scene
  35187. * @return a boolean defining if the geometry was removed or not
  35188. */
  35189. removeGeometry(geometry: Geometry): boolean;
  35190. /**
  35191. * Gets the list of geometries attached to the scene
  35192. * @returns an array of Geometry
  35193. */
  35194. getGeometries(): Geometry[];
  35195. /**
  35196. * Gets the first added mesh found of a given ID
  35197. * @param id defines the id to search for
  35198. * @return the mesh found or null if not found at all
  35199. */
  35200. getMeshByID(id: string): Nullable<AbstractMesh>;
  35201. /**
  35202. * Gets a list of meshes using their id
  35203. * @param id defines the id to search for
  35204. * @returns a list of meshes
  35205. */
  35206. getMeshesByID(id: string): Array<AbstractMesh>;
  35207. /**
  35208. * Gets the first added transform node found of a given ID
  35209. * @param id defines the id to search for
  35210. * @return the found transform node or null if not found at all.
  35211. */
  35212. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35213. /**
  35214. * Gets a transform node with its auto-generated unique id
  35215. * @param uniqueId efines the unique id to search for
  35216. * @return the found transform node or null if not found at all.
  35217. */
  35218. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35219. /**
  35220. * Gets a list of transform nodes using their id
  35221. * @param id defines the id to search for
  35222. * @returns a list of transform nodes
  35223. */
  35224. getTransformNodesByID(id: string): Array<TransformNode>;
  35225. /**
  35226. * Gets a mesh with its auto-generated unique id
  35227. * @param uniqueId defines the unique id to search for
  35228. * @return the found mesh or null if not found at all.
  35229. */
  35230. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35231. /**
  35232. * Gets a the last added mesh using a given id
  35233. * @param id defines the id to search for
  35234. * @return the found mesh or null if not found at all.
  35235. */
  35236. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35237. /**
  35238. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35239. * @param id defines the id to search for
  35240. * @return the found node or null if not found at all
  35241. */
  35242. getLastEntryByID(id: string): Nullable<Node>;
  35243. /**
  35244. * Gets a node (Mesh, Camera, Light) using a given id
  35245. * @param id defines the id to search for
  35246. * @return the found node or null if not found at all
  35247. */
  35248. getNodeByID(id: string): Nullable<Node>;
  35249. /**
  35250. * Gets a node (Mesh, Camera, Light) using a given name
  35251. * @param name defines the name to search for
  35252. * @return the found node or null if not found at all.
  35253. */
  35254. getNodeByName(name: string): Nullable<Node>;
  35255. /**
  35256. * Gets a mesh using a given name
  35257. * @param name defines the name to search for
  35258. * @return the found mesh or null if not found at all.
  35259. */
  35260. getMeshByName(name: string): Nullable<AbstractMesh>;
  35261. /**
  35262. * Gets a transform node using a given name
  35263. * @param name defines the name to search for
  35264. * @return the found transform node or null if not found at all.
  35265. */
  35266. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35267. /**
  35268. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35269. * @param id defines the id to search for
  35270. * @return the found skeleton or null if not found at all.
  35271. */
  35272. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35273. /**
  35274. * Gets a skeleton using a given auto generated unique id
  35275. * @param uniqueId defines the unique id to search for
  35276. * @return the found skeleton or null if not found at all.
  35277. */
  35278. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35279. /**
  35280. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35281. * @param id defines the id to search for
  35282. * @return the found skeleton or null if not found at all.
  35283. */
  35284. getSkeletonById(id: string): Nullable<Skeleton>;
  35285. /**
  35286. * Gets a skeleton using a given name
  35287. * @param name defines the name to search for
  35288. * @return the found skeleton or null if not found at all.
  35289. */
  35290. getSkeletonByName(name: string): Nullable<Skeleton>;
  35291. /**
  35292. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35293. * @param id defines the id to search for
  35294. * @return the found morph target manager or null if not found at all.
  35295. */
  35296. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35297. /**
  35298. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35299. * @param id defines the id to search for
  35300. * @return the found morph target or null if not found at all.
  35301. */
  35302. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35303. /**
  35304. * Gets a boolean indicating if the given mesh is active
  35305. * @param mesh defines the mesh to look for
  35306. * @returns true if the mesh is in the active list
  35307. */
  35308. isActiveMesh(mesh: AbstractMesh): boolean;
  35309. /**
  35310. * Return a unique id as a string which can serve as an identifier for the scene
  35311. */
  35312. readonly uid: string;
  35313. /**
  35314. * Add an externaly attached data from its key.
  35315. * This method call will fail and return false, if such key already exists.
  35316. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35317. * @param key the unique key that identifies the data
  35318. * @param data the data object to associate to the key for this Engine instance
  35319. * @return true if no such key were already present and the data was added successfully, false otherwise
  35320. */
  35321. addExternalData<T>(key: string, data: T): boolean;
  35322. /**
  35323. * Get an externaly attached data from its key
  35324. * @param key the unique key that identifies the data
  35325. * @return the associated data, if present (can be null), or undefined if not present
  35326. */
  35327. getExternalData<T>(key: string): Nullable<T>;
  35328. /**
  35329. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35330. * @param key the unique key that identifies the data
  35331. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35332. * @return the associated data, can be null if the factory returned null.
  35333. */
  35334. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35335. /**
  35336. * Remove an externaly attached data from the Engine instance
  35337. * @param key the unique key that identifies the data
  35338. * @return true if the data was successfully removed, false if it doesn't exist
  35339. */
  35340. removeExternalData(key: string): boolean;
  35341. private _evaluateSubMesh;
  35342. /**
  35343. * Clear the processed materials smart array preventing retention point in material dispose.
  35344. */
  35345. freeProcessedMaterials(): void;
  35346. private _preventFreeActiveMeshesAndRenderingGroups;
  35347. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35348. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35349. * when disposing several meshes in a row or a hierarchy of meshes.
  35350. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35351. */
  35352. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35353. /**
  35354. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35355. */
  35356. freeActiveMeshes(): void;
  35357. /**
  35358. * Clear the info related to rendering groups preventing retention points during dispose.
  35359. */
  35360. freeRenderingGroups(): void;
  35361. /** @hidden */
  35362. _isInIntermediateRendering(): boolean;
  35363. /**
  35364. * Lambda returning the list of potentially active meshes.
  35365. */
  35366. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35367. /**
  35368. * Lambda returning the list of potentially active sub meshes.
  35369. */
  35370. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35371. /**
  35372. * Lambda returning the list of potentially intersecting sub meshes.
  35373. */
  35374. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35375. /**
  35376. * Lambda returning the list of potentially colliding sub meshes.
  35377. */
  35378. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35379. private _activeMeshesFrozen;
  35380. /**
  35381. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35382. * @returns the current scene
  35383. */
  35384. freezeActiveMeshes(): Scene;
  35385. /**
  35386. * Use this function to restart evaluating active meshes on every frame
  35387. * @returns the current scene
  35388. */
  35389. unfreezeActiveMeshes(): Scene;
  35390. private _evaluateActiveMeshes;
  35391. private _activeMesh;
  35392. /**
  35393. * Update the transform matrix to update from the current active camera
  35394. * @param force defines a boolean used to force the update even if cache is up to date
  35395. */
  35396. updateTransformMatrix(force?: boolean): void;
  35397. private _bindFrameBuffer;
  35398. /** @hidden */
  35399. _allowPostProcessClearColor: boolean;
  35400. /** @hidden */
  35401. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35402. private _processSubCameras;
  35403. private _checkIntersections;
  35404. /** @hidden */
  35405. _advancePhysicsEngineStep(step: number): void;
  35406. /**
  35407. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35408. */
  35409. getDeterministicFrameTime: () => number;
  35410. /** @hidden */
  35411. _animate(): void;
  35412. /** Execute all animations (for a frame) */
  35413. animate(): void;
  35414. /**
  35415. * Render the scene
  35416. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35417. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35418. */
  35419. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35420. /**
  35421. * Freeze all materials
  35422. * A frozen material will not be updatable but should be faster to render
  35423. */
  35424. freezeMaterials(): void;
  35425. /**
  35426. * Unfreeze all materials
  35427. * A frozen material will not be updatable but should be faster to render
  35428. */
  35429. unfreezeMaterials(): void;
  35430. /**
  35431. * Releases all held ressources
  35432. */
  35433. dispose(): void;
  35434. /**
  35435. * Gets if the scene is already disposed
  35436. */
  35437. readonly isDisposed: boolean;
  35438. /**
  35439. * Call this function to reduce memory footprint of the scene.
  35440. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35441. */
  35442. clearCachedVertexData(): void;
  35443. /**
  35444. * This function will remove the local cached buffer data from texture.
  35445. * It will save memory but will prevent the texture from being rebuilt
  35446. */
  35447. cleanCachedTextureBuffer(): void;
  35448. /**
  35449. * Get the world extend vectors with an optional filter
  35450. *
  35451. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35452. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35453. */
  35454. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35455. min: Vector3;
  35456. max: Vector3;
  35457. };
  35458. /**
  35459. * Creates a ray that can be used to pick in the scene
  35460. * @param x defines the x coordinate of the origin (on-screen)
  35461. * @param y defines the y coordinate of the origin (on-screen)
  35462. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35463. * @param camera defines the camera to use for the picking
  35464. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35465. * @returns a Ray
  35466. */
  35467. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35468. /**
  35469. * Creates a ray that can be used to pick in the scene
  35470. * @param x defines the x coordinate of the origin (on-screen)
  35471. * @param y defines the y coordinate of the origin (on-screen)
  35472. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35473. * @param result defines the ray where to store the picking ray
  35474. * @param camera defines the camera to use for the picking
  35475. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35476. * @returns the current scene
  35477. */
  35478. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35479. /**
  35480. * Creates a ray that can be used to pick in the scene
  35481. * @param x defines the x coordinate of the origin (on-screen)
  35482. * @param y defines the y coordinate of the origin (on-screen)
  35483. * @param camera defines the camera to use for the picking
  35484. * @returns a Ray
  35485. */
  35486. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35487. /**
  35488. * Creates a ray that can be used to pick in the scene
  35489. * @param x defines the x coordinate of the origin (on-screen)
  35490. * @param y defines the y coordinate of the origin (on-screen)
  35491. * @param result defines the ray where to store the picking ray
  35492. * @param camera defines the camera to use for the picking
  35493. * @returns the current scene
  35494. */
  35495. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35496. /** Launch a ray to try to pick a mesh in the scene
  35497. * @param x position on screen
  35498. * @param y position on screen
  35499. * @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
  35500. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35501. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35502. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35503. * @returns a PickingInfo
  35504. */
  35505. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35506. /** Use the given ray to pick a mesh in the scene
  35507. * @param ray The ray to use to pick meshes
  35508. * @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
  35509. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35511. * @returns a PickingInfo
  35512. */
  35513. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35514. /**
  35515. * Launch a ray to try to pick a mesh in the scene
  35516. * @param x X position on screen
  35517. * @param y Y position on screen
  35518. * @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
  35519. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35521. * @returns an array of PickingInfo
  35522. */
  35523. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35524. /**
  35525. * Launch a ray to try to pick a mesh in the scene
  35526. * @param ray Ray to use
  35527. * @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
  35528. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35529. * @returns an array of PickingInfo
  35530. */
  35531. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35532. /**
  35533. * Force the value of meshUnderPointer
  35534. * @param mesh defines the mesh to use
  35535. */
  35536. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35537. /**
  35538. * Gets the mesh under the pointer
  35539. * @returns a Mesh or null if no mesh is under the pointer
  35540. */
  35541. getPointerOverMesh(): Nullable<AbstractMesh>;
  35542. /** @hidden */
  35543. _rebuildGeometries(): void;
  35544. /** @hidden */
  35545. _rebuildTextures(): void;
  35546. private _getByTags;
  35547. /**
  35548. * Get a list of meshes by tags
  35549. * @param tagsQuery defines the tags query to use
  35550. * @param forEach defines a predicate used to filter results
  35551. * @returns an array of Mesh
  35552. */
  35553. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35554. /**
  35555. * Get a list of cameras by tags
  35556. * @param tagsQuery defines the tags query to use
  35557. * @param forEach defines a predicate used to filter results
  35558. * @returns an array of Camera
  35559. */
  35560. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35561. /**
  35562. * Get a list of lights by tags
  35563. * @param tagsQuery defines the tags query to use
  35564. * @param forEach defines a predicate used to filter results
  35565. * @returns an array of Light
  35566. */
  35567. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35568. /**
  35569. * Get a list of materials by tags
  35570. * @param tagsQuery defines the tags query to use
  35571. * @param forEach defines a predicate used to filter results
  35572. * @returns an array of Material
  35573. */
  35574. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35575. /**
  35576. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35577. * This allowed control for front to back rendering or reversly depending of the special needs.
  35578. *
  35579. * @param renderingGroupId The rendering group id corresponding to its index
  35580. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35581. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35582. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35583. */
  35584. 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;
  35585. /**
  35586. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35587. *
  35588. * @param renderingGroupId The rendering group id corresponding to its index
  35589. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35590. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35591. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35592. */
  35593. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35594. /**
  35595. * Gets the current auto clear configuration for one rendering group of the rendering
  35596. * manager.
  35597. * @param index the rendering group index to get the information for
  35598. * @returns The auto clear setup for the requested rendering group
  35599. */
  35600. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35601. private _blockMaterialDirtyMechanism;
  35602. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35603. blockMaterialDirtyMechanism: boolean;
  35604. /**
  35605. * Will flag all materials as dirty to trigger new shader compilation
  35606. * @param flag defines the flag used to specify which material part must be marked as dirty
  35607. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35608. */
  35609. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35610. /** @hidden */
  35611. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35612. /** @hidden */
  35613. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35614. }
  35615. }
  35616. declare module "babylonjs/assetContainer" {
  35617. import { AbstractScene } from "babylonjs/abstractScene";
  35618. import { Scene } from "babylonjs/scene";
  35619. import { Mesh } from "babylonjs/Meshes/mesh";
  35620. /**
  35621. * Set of assets to keep when moving a scene into an asset container.
  35622. */
  35623. export class KeepAssets extends AbstractScene {
  35624. }
  35625. /**
  35626. * Container with a set of assets that can be added or removed from a scene.
  35627. */
  35628. export class AssetContainer extends AbstractScene {
  35629. /**
  35630. * The scene the AssetContainer belongs to.
  35631. */
  35632. scene: Scene;
  35633. /**
  35634. * Instantiates an AssetContainer.
  35635. * @param scene The scene the AssetContainer belongs to.
  35636. */
  35637. constructor(scene: Scene);
  35638. /**
  35639. * Adds all the assets from the container to the scene.
  35640. */
  35641. addAllToScene(): void;
  35642. /**
  35643. * Removes all the assets in the container from the scene
  35644. */
  35645. removeAllFromScene(): void;
  35646. /**
  35647. * Disposes all the assets in the container
  35648. */
  35649. dispose(): void;
  35650. private _moveAssets;
  35651. /**
  35652. * Removes all the assets contained in the scene and adds them to the container.
  35653. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35654. */
  35655. moveAllFromScene(keepAssets?: KeepAssets): void;
  35656. /**
  35657. * 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.
  35658. * @returns the root mesh
  35659. */
  35660. createRootMesh(): Mesh;
  35661. }
  35662. }
  35663. declare module "babylonjs/abstractScene" {
  35664. import { Scene } from "babylonjs/scene";
  35665. import { Nullable } from "babylonjs/types";
  35666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35667. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35668. import { Geometry } from "babylonjs/Meshes/geometry";
  35669. import { Skeleton } from "babylonjs/Bones/skeleton";
  35670. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35671. import { AssetContainer } from "babylonjs/assetContainer";
  35672. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35673. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35675. import { Material } from "babylonjs/Materials/material";
  35676. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35677. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35678. import { Camera } from "babylonjs/Cameras/camera";
  35679. import { Light } from "babylonjs/Lights/light";
  35680. import { Node } from "babylonjs/node";
  35681. import { Animation } from "babylonjs/Animations/animation";
  35682. /**
  35683. * Defines how the parser contract is defined.
  35684. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35685. */
  35686. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35687. /**
  35688. * Defines how the individual parser contract is defined.
  35689. * These parser can parse an individual asset
  35690. */
  35691. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35692. /**
  35693. * Base class of the scene acting as a container for the different elements composing a scene.
  35694. * This class is dynamically extended by the different components of the scene increasing
  35695. * flexibility and reducing coupling
  35696. */
  35697. export abstract class AbstractScene {
  35698. /**
  35699. * Stores the list of available parsers in the application.
  35700. */
  35701. private static _BabylonFileParsers;
  35702. /**
  35703. * Stores the list of available individual parsers in the application.
  35704. */
  35705. private static _IndividualBabylonFileParsers;
  35706. /**
  35707. * Adds a parser in the list of available ones
  35708. * @param name Defines the name of the parser
  35709. * @param parser Defines the parser to add
  35710. */
  35711. static AddParser(name: string, parser: BabylonFileParser): void;
  35712. /**
  35713. * Gets a general parser from the list of avaialble ones
  35714. * @param name Defines the name of the parser
  35715. * @returns the requested parser or null
  35716. */
  35717. static GetParser(name: string): Nullable<BabylonFileParser>;
  35718. /**
  35719. * Adds n individual parser in the list of available ones
  35720. * @param name Defines the name of the parser
  35721. * @param parser Defines the parser to add
  35722. */
  35723. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35724. /**
  35725. * Gets an individual parser from the list of avaialble ones
  35726. * @param name Defines the name of the parser
  35727. * @returns the requested parser or null
  35728. */
  35729. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35730. /**
  35731. * Parser json data and populate both a scene and its associated container object
  35732. * @param jsonData Defines the data to parse
  35733. * @param scene Defines the scene to parse the data for
  35734. * @param container Defines the container attached to the parsing sequence
  35735. * @param rootUrl Defines the root url of the data
  35736. */
  35737. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35738. /**
  35739. * Gets the list of root nodes (ie. nodes with no parent)
  35740. */
  35741. rootNodes: Node[];
  35742. /** All of the cameras added to this scene
  35743. * @see http://doc.babylonjs.com/babylon101/cameras
  35744. */
  35745. cameras: Camera[];
  35746. /**
  35747. * All of the lights added to this scene
  35748. * @see http://doc.babylonjs.com/babylon101/lights
  35749. */
  35750. lights: Light[];
  35751. /**
  35752. * All of the (abstract) meshes added to this scene
  35753. */
  35754. meshes: AbstractMesh[];
  35755. /**
  35756. * The list of skeletons added to the scene
  35757. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35758. */
  35759. skeletons: Skeleton[];
  35760. /**
  35761. * All of the particle systems added to this scene
  35762. * @see http://doc.babylonjs.com/babylon101/particles
  35763. */
  35764. particleSystems: IParticleSystem[];
  35765. /**
  35766. * Gets a list of Animations associated with the scene
  35767. */
  35768. animations: Animation[];
  35769. /**
  35770. * All of the animation groups added to this scene
  35771. * @see http://doc.babylonjs.com/how_to/group
  35772. */
  35773. animationGroups: AnimationGroup[];
  35774. /**
  35775. * All of the multi-materials added to this scene
  35776. * @see http://doc.babylonjs.com/how_to/multi_materials
  35777. */
  35778. multiMaterials: MultiMaterial[];
  35779. /**
  35780. * All of the materials added to this scene
  35781. * In the context of a Scene, it is not supposed to be modified manually.
  35782. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35783. * Note also that the order of the Material wihin the array is not significant and might change.
  35784. * @see http://doc.babylonjs.com/babylon101/materials
  35785. */
  35786. materials: Material[];
  35787. /**
  35788. * The list of morph target managers added to the scene
  35789. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35790. */
  35791. morphTargetManagers: MorphTargetManager[];
  35792. /**
  35793. * The list of geometries used in the scene.
  35794. */
  35795. geometries: Geometry[];
  35796. /**
  35797. * All of the tranform nodes added to this scene
  35798. * In the context of a Scene, it is not supposed to be modified manually.
  35799. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35800. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35801. * @see http://doc.babylonjs.com/how_to/transformnode
  35802. */
  35803. transformNodes: TransformNode[];
  35804. /**
  35805. * ActionManagers available on the scene.
  35806. */
  35807. actionManagers: AbstractActionManager[];
  35808. /**
  35809. * Textures to keep.
  35810. */
  35811. textures: BaseTexture[];
  35812. /**
  35813. * Environment texture for the scene
  35814. */
  35815. environmentTexture: Nullable<BaseTexture>;
  35816. }
  35817. }
  35818. declare module "babylonjs/Audio/sound" {
  35819. import { Observable } from "babylonjs/Misc/observable";
  35820. import { Vector3 } from "babylonjs/Maths/math.vector";
  35821. import { Nullable } from "babylonjs/types";
  35822. import { Scene } from "babylonjs/scene";
  35823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35824. /**
  35825. * Interface used to define options for Sound class
  35826. */
  35827. export interface ISoundOptions {
  35828. /**
  35829. * Does the sound autoplay once loaded.
  35830. */
  35831. autoplay?: boolean;
  35832. /**
  35833. * Does the sound loop after it finishes playing once.
  35834. */
  35835. loop?: boolean;
  35836. /**
  35837. * Sound's volume
  35838. */
  35839. volume?: number;
  35840. /**
  35841. * Is it a spatial sound?
  35842. */
  35843. spatialSound?: boolean;
  35844. /**
  35845. * Maximum distance to hear that sound
  35846. */
  35847. maxDistance?: number;
  35848. /**
  35849. * Uses user defined attenuation function
  35850. */
  35851. useCustomAttenuation?: boolean;
  35852. /**
  35853. * Define the roll off factor of spatial sounds.
  35854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35855. */
  35856. rolloffFactor?: number;
  35857. /**
  35858. * Define the reference distance the sound should be heard perfectly.
  35859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35860. */
  35861. refDistance?: number;
  35862. /**
  35863. * Define the distance attenuation model the sound will follow.
  35864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35865. */
  35866. distanceModel?: string;
  35867. /**
  35868. * Defines the playback speed (1 by default)
  35869. */
  35870. playbackRate?: number;
  35871. /**
  35872. * Defines if the sound is from a streaming source
  35873. */
  35874. streaming?: boolean;
  35875. /**
  35876. * Defines an optional length (in seconds) inside the sound file
  35877. */
  35878. length?: number;
  35879. /**
  35880. * Defines an optional offset (in seconds) inside the sound file
  35881. */
  35882. offset?: number;
  35883. /**
  35884. * If true, URLs will not be required to state the audio file codec to use.
  35885. */
  35886. skipCodecCheck?: boolean;
  35887. }
  35888. /**
  35889. * Defines a sound that can be played in the application.
  35890. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35892. */
  35893. export class Sound {
  35894. /**
  35895. * The name of the sound in the scene.
  35896. */
  35897. name: string;
  35898. /**
  35899. * Does the sound autoplay once loaded.
  35900. */
  35901. autoplay: boolean;
  35902. /**
  35903. * Does the sound loop after it finishes playing once.
  35904. */
  35905. loop: boolean;
  35906. /**
  35907. * Does the sound use a custom attenuation curve to simulate the falloff
  35908. * happening when the source gets further away from the camera.
  35909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35910. */
  35911. useCustomAttenuation: boolean;
  35912. /**
  35913. * The sound track id this sound belongs to.
  35914. */
  35915. soundTrackId: number;
  35916. /**
  35917. * Is this sound currently played.
  35918. */
  35919. isPlaying: boolean;
  35920. /**
  35921. * Is this sound currently paused.
  35922. */
  35923. isPaused: boolean;
  35924. /**
  35925. * Does this sound enables spatial sound.
  35926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35927. */
  35928. spatialSound: boolean;
  35929. /**
  35930. * Define the reference distance the sound should be heard perfectly.
  35931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35932. */
  35933. refDistance: number;
  35934. /**
  35935. * Define the roll off factor of spatial sounds.
  35936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35937. */
  35938. rolloffFactor: number;
  35939. /**
  35940. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35942. */
  35943. maxDistance: number;
  35944. /**
  35945. * Define the distance attenuation model the sound will follow.
  35946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35947. */
  35948. distanceModel: string;
  35949. /**
  35950. * @hidden
  35951. * Back Compat
  35952. **/
  35953. onended: () => any;
  35954. /**
  35955. * Observable event when the current playing sound finishes.
  35956. */
  35957. onEndedObservable: Observable<Sound>;
  35958. private _panningModel;
  35959. private _playbackRate;
  35960. private _streaming;
  35961. private _startTime;
  35962. private _startOffset;
  35963. private _position;
  35964. /** @hidden */
  35965. _positionInEmitterSpace: boolean;
  35966. private _localDirection;
  35967. private _volume;
  35968. private _isReadyToPlay;
  35969. private _isDirectional;
  35970. private _readyToPlayCallback;
  35971. private _audioBuffer;
  35972. private _soundSource;
  35973. private _streamingSource;
  35974. private _soundPanner;
  35975. private _soundGain;
  35976. private _inputAudioNode;
  35977. private _outputAudioNode;
  35978. private _coneInnerAngle;
  35979. private _coneOuterAngle;
  35980. private _coneOuterGain;
  35981. private _scene;
  35982. private _connectedTransformNode;
  35983. private _customAttenuationFunction;
  35984. private _registerFunc;
  35985. private _isOutputConnected;
  35986. private _htmlAudioElement;
  35987. private _urlType;
  35988. private _length?;
  35989. private _offset?;
  35990. /** @hidden */
  35991. static _SceneComponentInitialization: (scene: Scene) => void;
  35992. /**
  35993. * Create a sound and attach it to a scene
  35994. * @param name Name of your sound
  35995. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35996. * @param scene defines the scene the sound belongs to
  35997. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35998. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35999. */
  36000. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36001. /**
  36002. * Release the sound and its associated resources
  36003. */
  36004. dispose(): void;
  36005. /**
  36006. * Gets if the sounds is ready to be played or not.
  36007. * @returns true if ready, otherwise false
  36008. */
  36009. isReady(): boolean;
  36010. private _soundLoaded;
  36011. /**
  36012. * Sets the data of the sound from an audiobuffer
  36013. * @param audioBuffer The audioBuffer containing the data
  36014. */
  36015. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36016. /**
  36017. * Updates the current sounds options such as maxdistance, loop...
  36018. * @param options A JSON object containing values named as the object properties
  36019. */
  36020. updateOptions(options: ISoundOptions): void;
  36021. private _createSpatialParameters;
  36022. private _updateSpatialParameters;
  36023. /**
  36024. * Switch the panning model to HRTF:
  36025. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36027. */
  36028. switchPanningModelToHRTF(): void;
  36029. /**
  36030. * Switch the panning model to Equal Power:
  36031. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36033. */
  36034. switchPanningModelToEqualPower(): void;
  36035. private _switchPanningModel;
  36036. /**
  36037. * Connect this sound to a sound track audio node like gain...
  36038. * @param soundTrackAudioNode the sound track audio node to connect to
  36039. */
  36040. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36041. /**
  36042. * Transform this sound into a directional source
  36043. * @param coneInnerAngle Size of the inner cone in degree
  36044. * @param coneOuterAngle Size of the outer cone in degree
  36045. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36046. */
  36047. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36048. /**
  36049. * Gets or sets the inner angle for the directional cone.
  36050. */
  36051. /**
  36052. * Gets or sets the inner angle for the directional cone.
  36053. */
  36054. directionalConeInnerAngle: number;
  36055. /**
  36056. * Gets or sets the outer angle for the directional cone.
  36057. */
  36058. /**
  36059. * Gets or sets the outer angle for the directional cone.
  36060. */
  36061. directionalConeOuterAngle: number;
  36062. /**
  36063. * Sets the position of the emitter if spatial sound is enabled
  36064. * @param newPosition Defines the new posisiton
  36065. */
  36066. setPosition(newPosition: Vector3): void;
  36067. /**
  36068. * Sets the local direction of the emitter if spatial sound is enabled
  36069. * @param newLocalDirection Defines the new local direction
  36070. */
  36071. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36072. private _updateDirection;
  36073. /** @hidden */
  36074. updateDistanceFromListener(): void;
  36075. /**
  36076. * Sets a new custom attenuation function for the sound.
  36077. * @param callback Defines the function used for the attenuation
  36078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36079. */
  36080. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36081. /**
  36082. * Play the sound
  36083. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36084. * @param offset (optional) Start the sound at a specific time in seconds
  36085. * @param length (optional) Sound duration (in seconds)
  36086. */
  36087. play(time?: number, offset?: number, length?: number): void;
  36088. private _onended;
  36089. /**
  36090. * Stop the sound
  36091. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36092. */
  36093. stop(time?: number): void;
  36094. /**
  36095. * Put the sound in pause
  36096. */
  36097. pause(): void;
  36098. /**
  36099. * Sets a dedicated volume for this sounds
  36100. * @param newVolume Define the new volume of the sound
  36101. * @param time Define time for gradual change to new volume
  36102. */
  36103. setVolume(newVolume: number, time?: number): void;
  36104. /**
  36105. * Set the sound play back rate
  36106. * @param newPlaybackRate Define the playback rate the sound should be played at
  36107. */
  36108. setPlaybackRate(newPlaybackRate: number): void;
  36109. /**
  36110. * Gets the volume of the sound.
  36111. * @returns the volume of the sound
  36112. */
  36113. getVolume(): number;
  36114. /**
  36115. * Attach the sound to a dedicated mesh
  36116. * @param transformNode The transform node to connect the sound with
  36117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36118. */
  36119. attachToMesh(transformNode: TransformNode): void;
  36120. /**
  36121. * Detach the sound from the previously attached mesh
  36122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36123. */
  36124. detachFromMesh(): void;
  36125. private _onRegisterAfterWorldMatrixUpdate;
  36126. /**
  36127. * Clone the current sound in the scene.
  36128. * @returns the new sound clone
  36129. */
  36130. clone(): Nullable<Sound>;
  36131. /**
  36132. * Gets the current underlying audio buffer containing the data
  36133. * @returns the audio buffer
  36134. */
  36135. getAudioBuffer(): Nullable<AudioBuffer>;
  36136. /**
  36137. * Serializes the Sound in a JSON representation
  36138. * @returns the JSON representation of the sound
  36139. */
  36140. serialize(): any;
  36141. /**
  36142. * Parse a JSON representation of a sound to innstantiate in a given scene
  36143. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36144. * @param scene Define the scene the new parsed sound should be created in
  36145. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36146. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36147. * @returns the newly parsed sound
  36148. */
  36149. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36150. }
  36151. }
  36152. declare module "babylonjs/Actions/directAudioActions" {
  36153. import { Action } from "babylonjs/Actions/action";
  36154. import { Condition } from "babylonjs/Actions/condition";
  36155. import { Sound } from "babylonjs/Audio/sound";
  36156. /**
  36157. * This defines an action helpful to play a defined sound on a triggered action.
  36158. */
  36159. export class PlaySoundAction extends Action {
  36160. private _sound;
  36161. /**
  36162. * Instantiate the action
  36163. * @param triggerOptions defines the trigger options
  36164. * @param sound defines the sound to play
  36165. * @param condition defines the trigger related conditions
  36166. */
  36167. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36168. /** @hidden */
  36169. _prepare(): void;
  36170. /**
  36171. * Execute the action and play the sound.
  36172. */
  36173. execute(): void;
  36174. /**
  36175. * Serializes the actions and its related information.
  36176. * @param parent defines the object to serialize in
  36177. * @returns the serialized object
  36178. */
  36179. serialize(parent: any): any;
  36180. }
  36181. /**
  36182. * This defines an action helpful to stop a defined sound on a triggered action.
  36183. */
  36184. export class StopSoundAction extends Action {
  36185. private _sound;
  36186. /**
  36187. * Instantiate the action
  36188. * @param triggerOptions defines the trigger options
  36189. * @param sound defines the sound to stop
  36190. * @param condition defines the trigger related conditions
  36191. */
  36192. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36193. /** @hidden */
  36194. _prepare(): void;
  36195. /**
  36196. * Execute the action and stop the sound.
  36197. */
  36198. execute(): void;
  36199. /**
  36200. * Serializes the actions and its related information.
  36201. * @param parent defines the object to serialize in
  36202. * @returns the serialized object
  36203. */
  36204. serialize(parent: any): any;
  36205. }
  36206. }
  36207. declare module "babylonjs/Actions/interpolateValueAction" {
  36208. import { Action } from "babylonjs/Actions/action";
  36209. import { Condition } from "babylonjs/Actions/condition";
  36210. import { Observable } from "babylonjs/Misc/observable";
  36211. /**
  36212. * This defines an action responsible to change the value of a property
  36213. * by interpolating between its current value and the newly set one once triggered.
  36214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36215. */
  36216. export class InterpolateValueAction extends Action {
  36217. /**
  36218. * Defines the path of the property where the value should be interpolated
  36219. */
  36220. propertyPath: string;
  36221. /**
  36222. * Defines the target value at the end of the interpolation.
  36223. */
  36224. value: any;
  36225. /**
  36226. * Defines the time it will take for the property to interpolate to the value.
  36227. */
  36228. duration: number;
  36229. /**
  36230. * Defines if the other scene animations should be stopped when the action has been triggered
  36231. */
  36232. stopOtherAnimations?: boolean;
  36233. /**
  36234. * Defines a callback raised once the interpolation animation has been done.
  36235. */
  36236. onInterpolationDone?: () => void;
  36237. /**
  36238. * Observable triggered once the interpolation animation has been done.
  36239. */
  36240. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36241. private _target;
  36242. private _effectiveTarget;
  36243. private _property;
  36244. /**
  36245. * Instantiate the action
  36246. * @param triggerOptions defines the trigger options
  36247. * @param target defines the object containing the value to interpolate
  36248. * @param propertyPath defines the path to the property in the target object
  36249. * @param value defines the target value at the end of the interpolation
  36250. * @param duration deines the time it will take for the property to interpolate to the value.
  36251. * @param condition defines the trigger related conditions
  36252. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36253. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36254. */
  36255. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36256. /** @hidden */
  36257. _prepare(): void;
  36258. /**
  36259. * Execute the action starts the value interpolation.
  36260. */
  36261. execute(): void;
  36262. /**
  36263. * Serializes the actions and its related information.
  36264. * @param parent defines the object to serialize in
  36265. * @returns the serialized object
  36266. */
  36267. serialize(parent: any): any;
  36268. }
  36269. }
  36270. declare module "babylonjs/Actions/index" {
  36271. export * from "babylonjs/Actions/abstractActionManager";
  36272. export * from "babylonjs/Actions/action";
  36273. export * from "babylonjs/Actions/actionEvent";
  36274. export * from "babylonjs/Actions/actionManager";
  36275. export * from "babylonjs/Actions/condition";
  36276. export * from "babylonjs/Actions/directActions";
  36277. export * from "babylonjs/Actions/directAudioActions";
  36278. export * from "babylonjs/Actions/interpolateValueAction";
  36279. }
  36280. declare module "babylonjs/Animations/index" {
  36281. export * from "babylonjs/Animations/animatable";
  36282. export * from "babylonjs/Animations/animation";
  36283. export * from "babylonjs/Animations/animationGroup";
  36284. export * from "babylonjs/Animations/animationPropertiesOverride";
  36285. export * from "babylonjs/Animations/easing";
  36286. export * from "babylonjs/Animations/runtimeAnimation";
  36287. export * from "babylonjs/Animations/animationEvent";
  36288. export * from "babylonjs/Animations/animationGroup";
  36289. export * from "babylonjs/Animations/animationKey";
  36290. export * from "babylonjs/Animations/animationRange";
  36291. export * from "babylonjs/Animations/animatable.interface";
  36292. }
  36293. declare module "babylonjs/Audio/soundTrack" {
  36294. import { Sound } from "babylonjs/Audio/sound";
  36295. import { Analyser } from "babylonjs/Audio/analyser";
  36296. import { Scene } from "babylonjs/scene";
  36297. /**
  36298. * Options allowed during the creation of a sound track.
  36299. */
  36300. export interface ISoundTrackOptions {
  36301. /**
  36302. * The volume the sound track should take during creation
  36303. */
  36304. volume?: number;
  36305. /**
  36306. * Define if the sound track is the main sound track of the scene
  36307. */
  36308. mainTrack?: boolean;
  36309. }
  36310. /**
  36311. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36312. * It will be also used in a future release to apply effects on a specific track.
  36313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36314. */
  36315. export class SoundTrack {
  36316. /**
  36317. * The unique identifier of the sound track in the scene.
  36318. */
  36319. id: number;
  36320. /**
  36321. * The list of sounds included in the sound track.
  36322. */
  36323. soundCollection: Array<Sound>;
  36324. private _outputAudioNode;
  36325. private _scene;
  36326. private _isMainTrack;
  36327. private _connectedAnalyser;
  36328. private _options;
  36329. private _isInitialized;
  36330. /**
  36331. * Creates a new sound track.
  36332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36333. * @param scene Define the scene the sound track belongs to
  36334. * @param options
  36335. */
  36336. constructor(scene: Scene, options?: ISoundTrackOptions);
  36337. private _initializeSoundTrackAudioGraph;
  36338. /**
  36339. * Release the sound track and its associated resources
  36340. */
  36341. dispose(): void;
  36342. /**
  36343. * Adds a sound to this sound track
  36344. * @param sound define the cound to add
  36345. * @ignoreNaming
  36346. */
  36347. AddSound(sound: Sound): void;
  36348. /**
  36349. * Removes a sound to this sound track
  36350. * @param sound define the cound to remove
  36351. * @ignoreNaming
  36352. */
  36353. RemoveSound(sound: Sound): void;
  36354. /**
  36355. * Set a global volume for the full sound track.
  36356. * @param newVolume Define the new volume of the sound track
  36357. */
  36358. setVolume(newVolume: number): void;
  36359. /**
  36360. * Switch the panning model to HRTF:
  36361. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36363. */
  36364. switchPanningModelToHRTF(): void;
  36365. /**
  36366. * Switch the panning model to Equal Power:
  36367. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36369. */
  36370. switchPanningModelToEqualPower(): void;
  36371. /**
  36372. * Connect the sound track to an audio analyser allowing some amazing
  36373. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36375. * @param analyser The analyser to connect to the engine
  36376. */
  36377. connectToAnalyser(analyser: Analyser): void;
  36378. }
  36379. }
  36380. declare module "babylonjs/Audio/audioSceneComponent" {
  36381. import { Sound } from "babylonjs/Audio/sound";
  36382. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36383. import { Nullable } from "babylonjs/types";
  36384. import { Vector3 } from "babylonjs/Maths/math.vector";
  36385. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36386. import { Scene } from "babylonjs/scene";
  36387. import { AbstractScene } from "babylonjs/abstractScene";
  36388. import "babylonjs/Audio/audioEngine";
  36389. module "babylonjs/abstractScene" {
  36390. interface AbstractScene {
  36391. /**
  36392. * The list of sounds used in the scene.
  36393. */
  36394. sounds: Nullable<Array<Sound>>;
  36395. }
  36396. }
  36397. module "babylonjs/scene" {
  36398. interface Scene {
  36399. /**
  36400. * @hidden
  36401. * Backing field
  36402. */
  36403. _mainSoundTrack: SoundTrack;
  36404. /**
  36405. * The main sound track played by the scene.
  36406. * It cotains your primary collection of sounds.
  36407. */
  36408. mainSoundTrack: SoundTrack;
  36409. /**
  36410. * The list of sound tracks added to the scene
  36411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36412. */
  36413. soundTracks: Nullable<Array<SoundTrack>>;
  36414. /**
  36415. * Gets a sound using a given name
  36416. * @param name defines the name to search for
  36417. * @return the found sound or null if not found at all.
  36418. */
  36419. getSoundByName(name: string): Nullable<Sound>;
  36420. /**
  36421. * Gets or sets if audio support is enabled
  36422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36423. */
  36424. audioEnabled: boolean;
  36425. /**
  36426. * Gets or sets if audio will be output to headphones
  36427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36428. */
  36429. headphone: boolean;
  36430. /**
  36431. * Gets or sets custom audio listener position provider
  36432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36433. */
  36434. audioListenerPositionProvider: Nullable<() => Vector3>;
  36435. }
  36436. }
  36437. /**
  36438. * Defines the sound scene component responsible to manage any sounds
  36439. * in a given scene.
  36440. */
  36441. export class AudioSceneComponent implements ISceneSerializableComponent {
  36442. /**
  36443. * The component name helpfull to identify the component in the list of scene components.
  36444. */
  36445. readonly name: string;
  36446. /**
  36447. * The scene the component belongs to.
  36448. */
  36449. scene: Scene;
  36450. private _audioEnabled;
  36451. /**
  36452. * Gets whether audio is enabled or not.
  36453. * Please use related enable/disable method to switch state.
  36454. */
  36455. readonly audioEnabled: boolean;
  36456. private _headphone;
  36457. /**
  36458. * Gets whether audio is outputing to headphone or not.
  36459. * Please use the according Switch methods to change output.
  36460. */
  36461. readonly headphone: boolean;
  36462. private _audioListenerPositionProvider;
  36463. /**
  36464. * Gets the current audio listener position provider
  36465. */
  36466. /**
  36467. * Sets a custom listener position for all sounds in the scene
  36468. * By default, this is the position of the first active camera
  36469. */
  36470. audioListenerPositionProvider: Nullable<() => Vector3>;
  36471. /**
  36472. * Creates a new instance of the component for the given scene
  36473. * @param scene Defines the scene to register the component in
  36474. */
  36475. constructor(scene: Scene);
  36476. /**
  36477. * Registers the component in a given scene
  36478. */
  36479. register(): void;
  36480. /**
  36481. * Rebuilds the elements related to this component in case of
  36482. * context lost for instance.
  36483. */
  36484. rebuild(): void;
  36485. /**
  36486. * Serializes the component data to the specified json object
  36487. * @param serializationObject The object to serialize to
  36488. */
  36489. serialize(serializationObject: any): void;
  36490. /**
  36491. * Adds all the elements from the container to the scene
  36492. * @param container the container holding the elements
  36493. */
  36494. addFromContainer(container: AbstractScene): void;
  36495. /**
  36496. * Removes all the elements in the container from the scene
  36497. * @param container contains the elements to remove
  36498. * @param dispose if the removed element should be disposed (default: false)
  36499. */
  36500. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36501. /**
  36502. * Disposes the component and the associated ressources.
  36503. */
  36504. dispose(): void;
  36505. /**
  36506. * Disables audio in the associated scene.
  36507. */
  36508. disableAudio(): void;
  36509. /**
  36510. * Enables audio in the associated scene.
  36511. */
  36512. enableAudio(): void;
  36513. /**
  36514. * Switch audio to headphone output.
  36515. */
  36516. switchAudioModeForHeadphones(): void;
  36517. /**
  36518. * Switch audio to normal speakers.
  36519. */
  36520. switchAudioModeForNormalSpeakers(): void;
  36521. private _afterRender;
  36522. }
  36523. }
  36524. declare module "babylonjs/Audio/weightedsound" {
  36525. import { Sound } from "babylonjs/Audio/sound";
  36526. /**
  36527. * Wraps one or more Sound objects and selects one with random weight for playback.
  36528. */
  36529. export class WeightedSound {
  36530. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36531. loop: boolean;
  36532. private _coneInnerAngle;
  36533. private _coneOuterAngle;
  36534. private _volume;
  36535. /** A Sound is currently playing. */
  36536. isPlaying: boolean;
  36537. /** A Sound is currently paused. */
  36538. isPaused: boolean;
  36539. private _sounds;
  36540. private _weights;
  36541. private _currentIndex?;
  36542. /**
  36543. * Creates a new WeightedSound from the list of sounds given.
  36544. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36545. * @param sounds Array of Sounds that will be selected from.
  36546. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36547. */
  36548. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36549. /**
  36550. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36551. */
  36552. /**
  36553. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36554. */
  36555. directionalConeInnerAngle: number;
  36556. /**
  36557. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36558. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36559. */
  36560. /**
  36561. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36562. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36563. */
  36564. directionalConeOuterAngle: number;
  36565. /**
  36566. * Playback volume.
  36567. */
  36568. /**
  36569. * Playback volume.
  36570. */
  36571. volume: number;
  36572. private _onended;
  36573. /**
  36574. * Suspend playback
  36575. */
  36576. pause(): void;
  36577. /**
  36578. * Stop playback
  36579. */
  36580. stop(): void;
  36581. /**
  36582. * Start playback.
  36583. * @param startOffset Position the clip head at a specific time in seconds.
  36584. */
  36585. play(startOffset?: number): void;
  36586. }
  36587. }
  36588. declare module "babylonjs/Audio/index" {
  36589. export * from "babylonjs/Audio/analyser";
  36590. export * from "babylonjs/Audio/audioEngine";
  36591. export * from "babylonjs/Audio/audioSceneComponent";
  36592. export * from "babylonjs/Audio/sound";
  36593. export * from "babylonjs/Audio/soundTrack";
  36594. export * from "babylonjs/Audio/weightedsound";
  36595. }
  36596. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36597. import { Behavior } from "babylonjs/Behaviors/behavior";
  36598. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36599. import { BackEase } from "babylonjs/Animations/easing";
  36600. /**
  36601. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36602. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36603. */
  36604. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36605. /**
  36606. * Gets the name of the behavior.
  36607. */
  36608. readonly name: string;
  36609. /**
  36610. * The easing function used by animations
  36611. */
  36612. static EasingFunction: BackEase;
  36613. /**
  36614. * The easing mode used by animations
  36615. */
  36616. static EasingMode: number;
  36617. /**
  36618. * The duration of the animation, in milliseconds
  36619. */
  36620. transitionDuration: number;
  36621. /**
  36622. * Length of the distance animated by the transition when lower radius is reached
  36623. */
  36624. lowerRadiusTransitionRange: number;
  36625. /**
  36626. * Length of the distance animated by the transition when upper radius is reached
  36627. */
  36628. upperRadiusTransitionRange: number;
  36629. private _autoTransitionRange;
  36630. /**
  36631. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36632. */
  36633. /**
  36634. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36635. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36636. */
  36637. autoTransitionRange: boolean;
  36638. private _attachedCamera;
  36639. private _onAfterCheckInputsObserver;
  36640. private _onMeshTargetChangedObserver;
  36641. /**
  36642. * Initializes the behavior.
  36643. */
  36644. init(): void;
  36645. /**
  36646. * Attaches the behavior to its arc rotate camera.
  36647. * @param camera Defines the camera to attach the behavior to
  36648. */
  36649. attach(camera: ArcRotateCamera): void;
  36650. /**
  36651. * Detaches the behavior from its current arc rotate camera.
  36652. */
  36653. detach(): void;
  36654. private _radiusIsAnimating;
  36655. private _radiusBounceTransition;
  36656. private _animatables;
  36657. private _cachedWheelPrecision;
  36658. /**
  36659. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36660. * @param radiusLimit The limit to check against.
  36661. * @return Bool to indicate if at limit.
  36662. */
  36663. private _isRadiusAtLimit;
  36664. /**
  36665. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36666. * @param radiusDelta The delta by which to animate to. Can be negative.
  36667. */
  36668. private _applyBoundRadiusAnimation;
  36669. /**
  36670. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36671. */
  36672. protected _clearAnimationLocks(): void;
  36673. /**
  36674. * Stops and removes all animations that have been applied to the camera
  36675. */
  36676. stopAllAnimations(): void;
  36677. }
  36678. }
  36679. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36680. import { Behavior } from "babylonjs/Behaviors/behavior";
  36681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36682. import { ExponentialEase } from "babylonjs/Animations/easing";
  36683. import { Nullable } from "babylonjs/types";
  36684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36685. import { Vector3 } from "babylonjs/Maths/math.vector";
  36686. /**
  36687. * 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.
  36688. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36689. */
  36690. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36691. /**
  36692. * Gets the name of the behavior.
  36693. */
  36694. readonly name: string;
  36695. private _mode;
  36696. private _radiusScale;
  36697. private _positionScale;
  36698. private _defaultElevation;
  36699. private _elevationReturnTime;
  36700. private _elevationReturnWaitTime;
  36701. private _zoomStopsAnimation;
  36702. private _framingTime;
  36703. /**
  36704. * The easing function used by animations
  36705. */
  36706. static EasingFunction: ExponentialEase;
  36707. /**
  36708. * The easing mode used by animations
  36709. */
  36710. static EasingMode: number;
  36711. /**
  36712. * Sets the current mode used by the behavior
  36713. */
  36714. /**
  36715. * Gets current mode used by the behavior.
  36716. */
  36717. mode: number;
  36718. /**
  36719. * Sets the scale applied to the radius (1 by default)
  36720. */
  36721. /**
  36722. * Gets the scale applied to the radius
  36723. */
  36724. radiusScale: number;
  36725. /**
  36726. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36727. */
  36728. /**
  36729. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36730. */
  36731. positionScale: number;
  36732. /**
  36733. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36734. * behaviour is triggered, in radians.
  36735. */
  36736. /**
  36737. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36738. * behaviour is triggered, in radians.
  36739. */
  36740. defaultElevation: number;
  36741. /**
  36742. * Sets the time (in milliseconds) taken to return to the default beta position.
  36743. * Negative value indicates camera should not return to default.
  36744. */
  36745. /**
  36746. * Gets the time (in milliseconds) taken to return to the default beta position.
  36747. * Negative value indicates camera should not return to default.
  36748. */
  36749. elevationReturnTime: number;
  36750. /**
  36751. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36752. */
  36753. /**
  36754. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36755. */
  36756. elevationReturnWaitTime: number;
  36757. /**
  36758. * Sets the flag that indicates if user zooming should stop animation.
  36759. */
  36760. /**
  36761. * Gets the flag that indicates if user zooming should stop animation.
  36762. */
  36763. zoomStopsAnimation: boolean;
  36764. /**
  36765. * Sets the transition time when framing the mesh, in milliseconds
  36766. */
  36767. /**
  36768. * Gets the transition time when framing the mesh, in milliseconds
  36769. */
  36770. framingTime: number;
  36771. /**
  36772. * Define if the behavior should automatically change the configured
  36773. * camera limits and sensibilities.
  36774. */
  36775. autoCorrectCameraLimitsAndSensibility: boolean;
  36776. private _onPrePointerObservableObserver;
  36777. private _onAfterCheckInputsObserver;
  36778. private _onMeshTargetChangedObserver;
  36779. private _attachedCamera;
  36780. private _isPointerDown;
  36781. private _lastInteractionTime;
  36782. /**
  36783. * Initializes the behavior.
  36784. */
  36785. init(): void;
  36786. /**
  36787. * Attaches the behavior to its arc rotate camera.
  36788. * @param camera Defines the camera to attach the behavior to
  36789. */
  36790. attach(camera: ArcRotateCamera): void;
  36791. /**
  36792. * Detaches the behavior from its current arc rotate camera.
  36793. */
  36794. detach(): void;
  36795. private _animatables;
  36796. private _betaIsAnimating;
  36797. private _betaTransition;
  36798. private _radiusTransition;
  36799. private _vectorTransition;
  36800. /**
  36801. * Targets the given mesh and updates zoom level accordingly.
  36802. * @param mesh The mesh to target.
  36803. * @param radius Optional. If a cached radius position already exists, overrides default.
  36804. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36807. */
  36808. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36809. /**
  36810. * Targets the given mesh with its children and updates zoom level accordingly.
  36811. * @param mesh The mesh to target.
  36812. * @param radius Optional. If a cached radius position already exists, overrides default.
  36813. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36814. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36815. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36816. */
  36817. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36818. /**
  36819. * Targets the given meshes with their children and updates zoom level accordingly.
  36820. * @param meshes The mesh to target.
  36821. * @param radius Optional. If a cached radius position already exists, overrides default.
  36822. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36823. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36824. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36825. */
  36826. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36827. /**
  36828. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36829. * @param minimumWorld Determines the smaller position of the bounding box extend
  36830. * @param maximumWorld Determines the bigger position of the bounding box extend
  36831. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36832. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36833. */
  36834. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36835. /**
  36836. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36837. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36838. * frustum width.
  36839. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36840. * to fully enclose the mesh in the viewing frustum.
  36841. */
  36842. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36843. /**
  36844. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36845. * is automatically returned to its default position (expected to be above ground plane).
  36846. */
  36847. private _maintainCameraAboveGround;
  36848. /**
  36849. * Returns the frustum slope based on the canvas ratio and camera FOV
  36850. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36851. */
  36852. private _getFrustumSlope;
  36853. /**
  36854. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36855. */
  36856. private _clearAnimationLocks;
  36857. /**
  36858. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36859. */
  36860. private _applyUserInteraction;
  36861. /**
  36862. * Stops and removes all animations that have been applied to the camera
  36863. */
  36864. stopAllAnimations(): void;
  36865. /**
  36866. * Gets a value indicating if the user is moving the camera
  36867. */
  36868. readonly isUserIsMoving: boolean;
  36869. /**
  36870. * The camera can move all the way towards the mesh.
  36871. */
  36872. static IgnoreBoundsSizeMode: number;
  36873. /**
  36874. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36875. */
  36876. static FitFrustumSidesMode: number;
  36877. }
  36878. }
  36879. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36880. import { Nullable } from "babylonjs/types";
  36881. import { Camera } from "babylonjs/Cameras/camera";
  36882. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36883. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36884. /**
  36885. * Base class for Camera Pointer Inputs.
  36886. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36887. * for example usage.
  36888. */
  36889. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36890. /**
  36891. * Defines the camera the input is attached to.
  36892. */
  36893. abstract camera: Camera;
  36894. /**
  36895. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36896. */
  36897. protected _altKey: boolean;
  36898. protected _ctrlKey: boolean;
  36899. protected _metaKey: boolean;
  36900. protected _shiftKey: boolean;
  36901. /**
  36902. * Which mouse buttons were pressed at time of last mouse event.
  36903. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36904. */
  36905. protected _buttonsPressed: number;
  36906. /**
  36907. * Defines the buttons associated with the input to handle camera move.
  36908. */
  36909. buttons: number[];
  36910. /**
  36911. * Attach the input controls to a specific dom element to get the input from.
  36912. * @param element Defines the element the controls should be listened from
  36913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36914. */
  36915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36916. /**
  36917. * Detach the current controls from the specified dom element.
  36918. * @param element Defines the element to stop listening the inputs from
  36919. */
  36920. detachControl(element: Nullable<HTMLElement>): void;
  36921. /**
  36922. * Gets the class name of the current input.
  36923. * @returns the class name
  36924. */
  36925. getClassName(): string;
  36926. /**
  36927. * Get the friendly name associated with the input class.
  36928. * @returns the input friendly name
  36929. */
  36930. getSimpleName(): string;
  36931. /**
  36932. * Called on pointer POINTERDOUBLETAP event.
  36933. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36934. */
  36935. protected onDoubleTap(type: string): void;
  36936. /**
  36937. * Called on pointer POINTERMOVE event if only a single touch is active.
  36938. * Override this method to provide functionality.
  36939. */
  36940. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36941. /**
  36942. * Called on pointer POINTERMOVE event if multiple touches are active.
  36943. * Override this method to provide functionality.
  36944. */
  36945. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36946. /**
  36947. * Called on JS contextmenu event.
  36948. * Override this method to provide functionality.
  36949. */
  36950. protected onContextMenu(evt: PointerEvent): void;
  36951. /**
  36952. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36953. * press.
  36954. * Override this method to provide functionality.
  36955. */
  36956. protected onButtonDown(evt: PointerEvent): void;
  36957. /**
  36958. * Called each time a new POINTERUP event occurs. Ie, for each button
  36959. * release.
  36960. * Override this method to provide functionality.
  36961. */
  36962. protected onButtonUp(evt: PointerEvent): void;
  36963. /**
  36964. * Called when window becomes inactive.
  36965. * Override this method to provide functionality.
  36966. */
  36967. protected onLostFocus(): void;
  36968. private _pointerInput;
  36969. private _observer;
  36970. private _onLostFocus;
  36971. private pointA;
  36972. private pointB;
  36973. }
  36974. }
  36975. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36976. import { Nullable } from "babylonjs/types";
  36977. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36978. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36979. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36980. /**
  36981. * Manage the pointers inputs to control an arc rotate camera.
  36982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36983. */
  36984. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36985. /**
  36986. * Defines the camera the input is attached to.
  36987. */
  36988. camera: ArcRotateCamera;
  36989. /**
  36990. * Gets the class name of the current input.
  36991. * @returns the class name
  36992. */
  36993. getClassName(): string;
  36994. /**
  36995. * Defines the buttons associated with the input to handle camera move.
  36996. */
  36997. buttons: number[];
  36998. /**
  36999. * Defines the pointer angular sensibility along the X axis or how fast is
  37000. * the camera rotating.
  37001. */
  37002. angularSensibilityX: number;
  37003. /**
  37004. * Defines the pointer angular sensibility along the Y axis or how fast is
  37005. * the camera rotating.
  37006. */
  37007. angularSensibilityY: number;
  37008. /**
  37009. * Defines the pointer pinch precision or how fast is the camera zooming.
  37010. */
  37011. pinchPrecision: number;
  37012. /**
  37013. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37014. * from 0.
  37015. * It defines the percentage of current camera.radius to use as delta when
  37016. * pinch zoom is used.
  37017. */
  37018. pinchDeltaPercentage: number;
  37019. /**
  37020. * Defines the pointer panning sensibility or how fast is the camera moving.
  37021. */
  37022. panningSensibility: number;
  37023. /**
  37024. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37025. */
  37026. multiTouchPanning: boolean;
  37027. /**
  37028. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37029. * zoom (pinch) through multitouch.
  37030. */
  37031. multiTouchPanAndZoom: boolean;
  37032. /**
  37033. * Revers pinch action direction.
  37034. */
  37035. pinchInwards: boolean;
  37036. private _isPanClick;
  37037. private _twoFingerActivityCount;
  37038. private _isPinching;
  37039. /**
  37040. * Called on pointer POINTERMOVE event if only a single touch is active.
  37041. */
  37042. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37043. /**
  37044. * Called on pointer POINTERDOUBLETAP event.
  37045. */
  37046. protected onDoubleTap(type: string): void;
  37047. /**
  37048. * Called on pointer POINTERMOVE event if multiple touches are active.
  37049. */
  37050. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37051. /**
  37052. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37053. * press.
  37054. */
  37055. protected onButtonDown(evt: PointerEvent): void;
  37056. /**
  37057. * Called each time a new POINTERUP event occurs. Ie, for each button
  37058. * release.
  37059. */
  37060. protected onButtonUp(evt: PointerEvent): void;
  37061. /**
  37062. * Called when window becomes inactive.
  37063. */
  37064. protected onLostFocus(): void;
  37065. }
  37066. }
  37067. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37068. import { Nullable } from "babylonjs/types";
  37069. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37070. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37071. /**
  37072. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37074. */
  37075. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37076. /**
  37077. * Defines the camera the input is attached to.
  37078. */
  37079. camera: ArcRotateCamera;
  37080. /**
  37081. * Defines the list of key codes associated with the up action (increase alpha)
  37082. */
  37083. keysUp: number[];
  37084. /**
  37085. * Defines the list of key codes associated with the down action (decrease alpha)
  37086. */
  37087. keysDown: number[];
  37088. /**
  37089. * Defines the list of key codes associated with the left action (increase beta)
  37090. */
  37091. keysLeft: number[];
  37092. /**
  37093. * Defines the list of key codes associated with the right action (decrease beta)
  37094. */
  37095. keysRight: number[];
  37096. /**
  37097. * Defines the list of key codes associated with the reset action.
  37098. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37099. */
  37100. keysReset: number[];
  37101. /**
  37102. * Defines the panning sensibility of the inputs.
  37103. * (How fast is the camera paning)
  37104. */
  37105. panningSensibility: number;
  37106. /**
  37107. * Defines the zooming sensibility of the inputs.
  37108. * (How fast is the camera zooming)
  37109. */
  37110. zoomingSensibility: number;
  37111. /**
  37112. * Defines wether maintaining the alt key down switch the movement mode from
  37113. * orientation to zoom.
  37114. */
  37115. useAltToZoom: boolean;
  37116. /**
  37117. * Rotation speed of the camera
  37118. */
  37119. angularSpeed: number;
  37120. private _keys;
  37121. private _ctrlPressed;
  37122. private _altPressed;
  37123. private _onCanvasBlurObserver;
  37124. private _onKeyboardObserver;
  37125. private _engine;
  37126. private _scene;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Update the current camera state depending on the inputs that have been used this frame.
  37140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37141. */
  37142. checkInputs(): void;
  37143. /**
  37144. * Gets the class name of the current intput.
  37145. * @returns the class name
  37146. */
  37147. getClassName(): string;
  37148. /**
  37149. * Get the friendly name associated with the input class.
  37150. * @returns the input friendly name
  37151. */
  37152. getSimpleName(): string;
  37153. }
  37154. }
  37155. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37156. import { Nullable } from "babylonjs/types";
  37157. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37159. /**
  37160. * Manage the mouse wheel inputs to control an arc rotate camera.
  37161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37162. */
  37163. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37164. /**
  37165. * Defines the camera the input is attached to.
  37166. */
  37167. camera: ArcRotateCamera;
  37168. /**
  37169. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37170. */
  37171. wheelPrecision: number;
  37172. /**
  37173. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37174. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37175. */
  37176. wheelDeltaPercentage: number;
  37177. private _wheel;
  37178. private _observer;
  37179. private computeDeltaFromMouseWheelLegacyEvent;
  37180. /**
  37181. * Attach the input controls to a specific dom element to get the input from.
  37182. * @param element Defines the element the controls should be listened from
  37183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37184. */
  37185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37186. /**
  37187. * Detach the current controls from the specified dom element.
  37188. * @param element Defines the element to stop listening the inputs from
  37189. */
  37190. detachControl(element: Nullable<HTMLElement>): void;
  37191. /**
  37192. * Gets the class name of the current intput.
  37193. * @returns the class name
  37194. */
  37195. getClassName(): string;
  37196. /**
  37197. * Get the friendly name associated with the input class.
  37198. * @returns the input friendly name
  37199. */
  37200. getSimpleName(): string;
  37201. }
  37202. }
  37203. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37204. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37206. /**
  37207. * Default Inputs manager for the ArcRotateCamera.
  37208. * It groups all the default supported inputs for ease of use.
  37209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37210. */
  37211. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37212. /**
  37213. * Instantiates a new ArcRotateCameraInputsManager.
  37214. * @param camera Defines the camera the inputs belong to
  37215. */
  37216. constructor(camera: ArcRotateCamera);
  37217. /**
  37218. * Add mouse wheel input support to the input manager.
  37219. * @returns the current input manager
  37220. */
  37221. addMouseWheel(): ArcRotateCameraInputsManager;
  37222. /**
  37223. * Add pointers input support to the input manager.
  37224. * @returns the current input manager
  37225. */
  37226. addPointers(): ArcRotateCameraInputsManager;
  37227. /**
  37228. * Add keyboard input support to the input manager.
  37229. * @returns the current input manager
  37230. */
  37231. addKeyboard(): ArcRotateCameraInputsManager;
  37232. }
  37233. }
  37234. declare module "babylonjs/Cameras/arcRotateCamera" {
  37235. import { Observable } from "babylonjs/Misc/observable";
  37236. import { Nullable } from "babylonjs/types";
  37237. import { Scene } from "babylonjs/scene";
  37238. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37240. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37241. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37242. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37243. import { Camera } from "babylonjs/Cameras/camera";
  37244. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37245. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37246. import { Collider } from "babylonjs/Collisions/collider";
  37247. /**
  37248. * This represents an orbital type of camera.
  37249. *
  37250. * 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.
  37251. * 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.
  37252. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37253. */
  37254. export class ArcRotateCamera extends TargetCamera {
  37255. /**
  37256. * Defines the rotation angle of the camera along the longitudinal axis.
  37257. */
  37258. alpha: number;
  37259. /**
  37260. * Defines the rotation angle of the camera along the latitudinal axis.
  37261. */
  37262. beta: number;
  37263. /**
  37264. * Defines the radius of the camera from it s target point.
  37265. */
  37266. radius: number;
  37267. protected _target: Vector3;
  37268. protected _targetHost: Nullable<AbstractMesh>;
  37269. /**
  37270. * Defines the target point of the camera.
  37271. * The camera looks towards it form the radius distance.
  37272. */
  37273. target: Vector3;
  37274. /**
  37275. * Define the current local position of the camera in the scene
  37276. */
  37277. position: Vector3;
  37278. protected _upVector: Vector3;
  37279. protected _upToYMatrix: Matrix;
  37280. protected _YToUpMatrix: Matrix;
  37281. /**
  37282. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37283. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37284. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37285. */
  37286. upVector: Vector3;
  37287. /**
  37288. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37289. */
  37290. setMatUp(): void;
  37291. /**
  37292. * Current inertia value on the longitudinal axis.
  37293. * The bigger this number the longer it will take for the camera to stop.
  37294. */
  37295. inertialAlphaOffset: number;
  37296. /**
  37297. * Current inertia value on the latitudinal axis.
  37298. * The bigger this number the longer it will take for the camera to stop.
  37299. */
  37300. inertialBetaOffset: number;
  37301. /**
  37302. * Current inertia value on the radius axis.
  37303. * The bigger this number the longer it will take for the camera to stop.
  37304. */
  37305. inertialRadiusOffset: number;
  37306. /**
  37307. * Minimum allowed angle on the longitudinal axis.
  37308. * This can help limiting how the Camera is able to move in the scene.
  37309. */
  37310. lowerAlphaLimit: Nullable<number>;
  37311. /**
  37312. * Maximum allowed angle on the longitudinal axis.
  37313. * This can help limiting how the Camera is able to move in the scene.
  37314. */
  37315. upperAlphaLimit: Nullable<number>;
  37316. /**
  37317. * Minimum allowed angle on the latitudinal axis.
  37318. * This can help limiting how the Camera is able to move in the scene.
  37319. */
  37320. lowerBetaLimit: number;
  37321. /**
  37322. * Maximum allowed angle on the latitudinal axis.
  37323. * This can help limiting how the Camera is able to move in the scene.
  37324. */
  37325. upperBetaLimit: number;
  37326. /**
  37327. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37328. * This can help limiting how the Camera is able to move in the scene.
  37329. */
  37330. lowerRadiusLimit: Nullable<number>;
  37331. /**
  37332. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37333. * This can help limiting how the Camera is able to move in the scene.
  37334. */
  37335. upperRadiusLimit: Nullable<number>;
  37336. /**
  37337. * Defines the current inertia value used during panning of the camera along the X axis.
  37338. */
  37339. inertialPanningX: number;
  37340. /**
  37341. * Defines the current inertia value used during panning of the camera along the Y axis.
  37342. */
  37343. inertialPanningY: number;
  37344. /**
  37345. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37346. * Basically if your fingers moves away from more than this distance you will be considered
  37347. * in pinch mode.
  37348. */
  37349. pinchToPanMaxDistance: number;
  37350. /**
  37351. * Defines the maximum distance the camera can pan.
  37352. * This could help keeping the cammera always in your scene.
  37353. */
  37354. panningDistanceLimit: Nullable<number>;
  37355. /**
  37356. * Defines the target of the camera before paning.
  37357. */
  37358. panningOriginTarget: Vector3;
  37359. /**
  37360. * Defines the value of the inertia used during panning.
  37361. * 0 would mean stop inertia and one would mean no decelleration at all.
  37362. */
  37363. panningInertia: number;
  37364. /**
  37365. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37366. */
  37367. angularSensibilityX: number;
  37368. /**
  37369. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37370. */
  37371. angularSensibilityY: number;
  37372. /**
  37373. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37374. */
  37375. pinchPrecision: number;
  37376. /**
  37377. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37378. * It will be used instead of pinchDeltaPrecision if different from 0.
  37379. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37380. */
  37381. pinchDeltaPercentage: number;
  37382. /**
  37383. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37384. */
  37385. panningSensibility: number;
  37386. /**
  37387. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37388. */
  37389. keysUp: number[];
  37390. /**
  37391. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37392. */
  37393. keysDown: number[];
  37394. /**
  37395. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37396. */
  37397. keysLeft: number[];
  37398. /**
  37399. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37400. */
  37401. keysRight: number[];
  37402. /**
  37403. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37404. */
  37405. wheelPrecision: number;
  37406. /**
  37407. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37408. * It will be used instead of pinchDeltaPrecision if different from 0.
  37409. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37410. */
  37411. wheelDeltaPercentage: number;
  37412. /**
  37413. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37414. */
  37415. zoomOnFactor: number;
  37416. /**
  37417. * Defines a screen offset for the camera position.
  37418. */
  37419. targetScreenOffset: Vector2;
  37420. /**
  37421. * Allows the camera to be completely reversed.
  37422. * If false the camera can not arrive upside down.
  37423. */
  37424. allowUpsideDown: boolean;
  37425. /**
  37426. * Define if double tap/click is used to restore the previously saved state of the camera.
  37427. */
  37428. useInputToRestoreState: boolean;
  37429. /** @hidden */
  37430. _viewMatrix: Matrix;
  37431. /** @hidden */
  37432. _useCtrlForPanning: boolean;
  37433. /** @hidden */
  37434. _panningMouseButton: number;
  37435. /**
  37436. * Defines the input associated to the camera.
  37437. */
  37438. inputs: ArcRotateCameraInputsManager;
  37439. /** @hidden */
  37440. _reset: () => void;
  37441. /**
  37442. * Defines the allowed panning axis.
  37443. */
  37444. panningAxis: Vector3;
  37445. protected _localDirection: Vector3;
  37446. protected _transformedDirection: Vector3;
  37447. private _bouncingBehavior;
  37448. /**
  37449. * Gets the bouncing behavior of the camera if it has been enabled.
  37450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37451. */
  37452. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37453. /**
  37454. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37455. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37456. */
  37457. useBouncingBehavior: boolean;
  37458. private _framingBehavior;
  37459. /**
  37460. * Gets the framing behavior of the camera if it has been enabled.
  37461. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37462. */
  37463. readonly framingBehavior: Nullable<FramingBehavior>;
  37464. /**
  37465. * Defines if the framing behavior of the camera is enabled on the camera.
  37466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37467. */
  37468. useFramingBehavior: boolean;
  37469. private _autoRotationBehavior;
  37470. /**
  37471. * Gets the auto rotation behavior of the camera if it has been enabled.
  37472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37473. */
  37474. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37475. /**
  37476. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37478. */
  37479. useAutoRotationBehavior: boolean;
  37480. /**
  37481. * Observable triggered when the mesh target has been changed on the camera.
  37482. */
  37483. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37484. /**
  37485. * Event raised when the camera is colliding with a mesh.
  37486. */
  37487. onCollide: (collidedMesh: AbstractMesh) => void;
  37488. /**
  37489. * Defines whether the camera should check collision with the objects oh the scene.
  37490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37491. */
  37492. checkCollisions: boolean;
  37493. /**
  37494. * Defines the collision radius of the camera.
  37495. * This simulates a sphere around the camera.
  37496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37497. */
  37498. collisionRadius: Vector3;
  37499. protected _collider: Collider;
  37500. protected _previousPosition: Vector3;
  37501. protected _collisionVelocity: Vector3;
  37502. protected _newPosition: Vector3;
  37503. protected _previousAlpha: number;
  37504. protected _previousBeta: number;
  37505. protected _previousRadius: number;
  37506. protected _collisionTriggered: boolean;
  37507. protected _targetBoundingCenter: Nullable<Vector3>;
  37508. private _computationVector;
  37509. /**
  37510. * Instantiates a new ArcRotateCamera in a given scene
  37511. * @param name Defines the name of the camera
  37512. * @param alpha Defines the camera rotation along the logitudinal axis
  37513. * @param beta Defines the camera rotation along the latitudinal axis
  37514. * @param radius Defines the camera distance from its target
  37515. * @param target Defines the camera target
  37516. * @param scene Defines the scene the camera belongs to
  37517. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37518. */
  37519. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37520. /** @hidden */
  37521. _initCache(): void;
  37522. /** @hidden */
  37523. _updateCache(ignoreParentClass?: boolean): void;
  37524. protected _getTargetPosition(): Vector3;
  37525. private _storedAlpha;
  37526. private _storedBeta;
  37527. private _storedRadius;
  37528. private _storedTarget;
  37529. private _storedTargetScreenOffset;
  37530. /**
  37531. * Stores the current state of the camera (alpha, beta, radius and target)
  37532. * @returns the camera itself
  37533. */
  37534. storeState(): Camera;
  37535. /**
  37536. * @hidden
  37537. * Restored camera state. You must call storeState() first
  37538. */
  37539. _restoreStateValues(): boolean;
  37540. /** @hidden */
  37541. _isSynchronizedViewMatrix(): boolean;
  37542. /**
  37543. * Attached controls to the current camera.
  37544. * @param element Defines the element the controls should be listened from
  37545. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37546. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37547. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37548. */
  37549. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37550. /**
  37551. * Detach the current controls from the camera.
  37552. * The camera will stop reacting to inputs.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: HTMLElement): void;
  37556. /** @hidden */
  37557. _checkInputs(): void;
  37558. protected _checkLimits(): void;
  37559. /**
  37560. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37561. */
  37562. rebuildAnglesAndRadius(): void;
  37563. /**
  37564. * Use a position to define the current camera related information like aplha, beta and radius
  37565. * @param position Defines the position to set the camera at
  37566. */
  37567. setPosition(position: Vector3): void;
  37568. /**
  37569. * Defines the target the camera should look at.
  37570. * This will automatically adapt alpha beta and radius to fit within the new target.
  37571. * @param target Defines the new target as a Vector or a mesh
  37572. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37573. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37574. */
  37575. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37576. /** @hidden */
  37577. _getViewMatrix(): Matrix;
  37578. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37579. /**
  37580. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37581. * @param meshes Defines the mesh to zoom on
  37582. * @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)
  37583. */
  37584. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37585. /**
  37586. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37587. * The target will be changed but the radius
  37588. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37589. * @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)
  37590. */
  37591. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37592. min: Vector3;
  37593. max: Vector3;
  37594. distance: number;
  37595. }, doNotUpdateMaxZ?: boolean): void;
  37596. /**
  37597. * @override
  37598. * Override Camera.createRigCamera
  37599. */
  37600. createRigCamera(name: string, cameraIndex: number): Camera;
  37601. /**
  37602. * @hidden
  37603. * @override
  37604. * Override Camera._updateRigCameras
  37605. */
  37606. _updateRigCameras(): void;
  37607. /**
  37608. * Destroy the camera and release the current resources hold by it.
  37609. */
  37610. dispose(): void;
  37611. /**
  37612. * Gets the current object class name.
  37613. * @return the class name
  37614. */
  37615. getClassName(): string;
  37616. }
  37617. }
  37618. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37619. import { Behavior } from "babylonjs/Behaviors/behavior";
  37620. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37621. /**
  37622. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37623. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37624. */
  37625. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37626. /**
  37627. * Gets the name of the behavior.
  37628. */
  37629. readonly name: string;
  37630. private _zoomStopsAnimation;
  37631. private _idleRotationSpeed;
  37632. private _idleRotationWaitTime;
  37633. private _idleRotationSpinupTime;
  37634. /**
  37635. * Sets the flag that indicates if user zooming should stop animation.
  37636. */
  37637. /**
  37638. * Gets the flag that indicates if user zooming should stop animation.
  37639. */
  37640. zoomStopsAnimation: boolean;
  37641. /**
  37642. * Sets the default speed at which the camera rotates around the model.
  37643. */
  37644. /**
  37645. * Gets the default speed at which the camera rotates around the model.
  37646. */
  37647. idleRotationSpeed: number;
  37648. /**
  37649. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37650. */
  37651. /**
  37652. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37653. */
  37654. idleRotationWaitTime: number;
  37655. /**
  37656. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37657. */
  37658. /**
  37659. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37660. */
  37661. idleRotationSpinupTime: number;
  37662. /**
  37663. * Gets a value indicating if the camera is currently rotating because of this behavior
  37664. */
  37665. readonly rotationInProgress: boolean;
  37666. private _onPrePointerObservableObserver;
  37667. private _onAfterCheckInputsObserver;
  37668. private _attachedCamera;
  37669. private _isPointerDown;
  37670. private _lastFrameTime;
  37671. private _lastInteractionTime;
  37672. private _cameraRotationSpeed;
  37673. /**
  37674. * Initializes the behavior.
  37675. */
  37676. init(): void;
  37677. /**
  37678. * Attaches the behavior to its arc rotate camera.
  37679. * @param camera Defines the camera to attach the behavior to
  37680. */
  37681. attach(camera: ArcRotateCamera): void;
  37682. /**
  37683. * Detaches the behavior from its current arc rotate camera.
  37684. */
  37685. detach(): void;
  37686. /**
  37687. * Returns true if user is scrolling.
  37688. * @return true if user is scrolling.
  37689. */
  37690. private _userIsZooming;
  37691. private _lastFrameRadius;
  37692. private _shouldAnimationStopForInteraction;
  37693. /**
  37694. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37695. */
  37696. private _applyUserInteraction;
  37697. private _userIsMoving;
  37698. }
  37699. }
  37700. declare module "babylonjs/Behaviors/Cameras/index" {
  37701. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37702. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37703. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37704. }
  37705. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37706. import { Mesh } from "babylonjs/Meshes/mesh";
  37707. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37708. import { Behavior } from "babylonjs/Behaviors/behavior";
  37709. /**
  37710. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37711. */
  37712. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37713. private ui;
  37714. /**
  37715. * The name of the behavior
  37716. */
  37717. name: string;
  37718. /**
  37719. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37720. */
  37721. distanceAwayFromFace: number;
  37722. /**
  37723. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37724. */
  37725. distanceAwayFromBottomOfFace: number;
  37726. private _faceVectors;
  37727. private _target;
  37728. private _scene;
  37729. private _onRenderObserver;
  37730. private _tmpMatrix;
  37731. private _tmpVector;
  37732. /**
  37733. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37734. * @param ui The transform node that should be attched to the mesh
  37735. */
  37736. constructor(ui: TransformNode);
  37737. /**
  37738. * Initializes the behavior
  37739. */
  37740. init(): void;
  37741. private _closestFace;
  37742. private _zeroVector;
  37743. private _lookAtTmpMatrix;
  37744. private _lookAtToRef;
  37745. /**
  37746. * Attaches the AttachToBoxBehavior to the passed in mesh
  37747. * @param target The mesh that the specified node will be attached to
  37748. */
  37749. attach(target: Mesh): void;
  37750. /**
  37751. * Detaches the behavior from the mesh
  37752. */
  37753. detach(): void;
  37754. }
  37755. }
  37756. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37757. import { Behavior } from "babylonjs/Behaviors/behavior";
  37758. import { Mesh } from "babylonjs/Meshes/mesh";
  37759. /**
  37760. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37761. */
  37762. export class FadeInOutBehavior implements Behavior<Mesh> {
  37763. /**
  37764. * Time in milliseconds to delay before fading in (Default: 0)
  37765. */
  37766. delay: number;
  37767. /**
  37768. * Time in milliseconds for the mesh to fade in (Default: 300)
  37769. */
  37770. fadeInTime: number;
  37771. private _millisecondsPerFrame;
  37772. private _hovered;
  37773. private _hoverValue;
  37774. private _ownerNode;
  37775. /**
  37776. * Instatiates the FadeInOutBehavior
  37777. */
  37778. constructor();
  37779. /**
  37780. * The name of the behavior
  37781. */
  37782. readonly name: string;
  37783. /**
  37784. * Initializes the behavior
  37785. */
  37786. init(): void;
  37787. /**
  37788. * Attaches the fade behavior on the passed in mesh
  37789. * @param ownerNode The mesh that will be faded in/out once attached
  37790. */
  37791. attach(ownerNode: Mesh): void;
  37792. /**
  37793. * Detaches the behavior from the mesh
  37794. */
  37795. detach(): void;
  37796. /**
  37797. * Triggers the mesh to begin fading in or out
  37798. * @param value if the object should fade in or out (true to fade in)
  37799. */
  37800. fadeIn(value: boolean): void;
  37801. private _update;
  37802. private _setAllVisibility;
  37803. }
  37804. }
  37805. declare module "babylonjs/Misc/pivotTools" {
  37806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37807. /**
  37808. * Class containing a set of static utilities functions for managing Pivots
  37809. * @hidden
  37810. */
  37811. export class PivotTools {
  37812. private static _PivotCached;
  37813. private static _OldPivotPoint;
  37814. private static _PivotTranslation;
  37815. private static _PivotTmpVector;
  37816. /** @hidden */
  37817. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37818. /** @hidden */
  37819. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37820. }
  37821. }
  37822. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37823. import { Scene } from "babylonjs/scene";
  37824. import { Vector4 } from "babylonjs/Maths/math.vector";
  37825. import { Mesh } from "babylonjs/Meshes/mesh";
  37826. import { Nullable } from "babylonjs/types";
  37827. import { Plane } from "babylonjs/Maths/math.plane";
  37828. /**
  37829. * Class containing static functions to help procedurally build meshes
  37830. */
  37831. export class PlaneBuilder {
  37832. /**
  37833. * Creates a plane mesh
  37834. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37835. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37836. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37840. * @param name defines the name of the mesh
  37841. * @param options defines the options used to create the mesh
  37842. * @param scene defines the hosting scene
  37843. * @returns the plane mesh
  37844. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37845. */
  37846. static CreatePlane(name: string, options: {
  37847. size?: number;
  37848. width?: number;
  37849. height?: number;
  37850. sideOrientation?: number;
  37851. frontUVs?: Vector4;
  37852. backUVs?: Vector4;
  37853. updatable?: boolean;
  37854. sourcePlane?: Plane;
  37855. }, scene?: Nullable<Scene>): Mesh;
  37856. }
  37857. }
  37858. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37859. import { Behavior } from "babylonjs/Behaviors/behavior";
  37860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37861. import { Observable } from "babylonjs/Misc/observable";
  37862. import { Vector3 } from "babylonjs/Maths/math.vector";
  37863. import { Ray } from "babylonjs/Culling/ray";
  37864. import "babylonjs/Meshes/Builders/planeBuilder";
  37865. /**
  37866. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37867. */
  37868. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37869. private static _AnyMouseID;
  37870. /**
  37871. * Abstract mesh the behavior is set on
  37872. */
  37873. attachedNode: AbstractMesh;
  37874. private _dragPlane;
  37875. private _scene;
  37876. private _pointerObserver;
  37877. private _beforeRenderObserver;
  37878. private static _planeScene;
  37879. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37880. /**
  37881. * 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)
  37882. */
  37883. maxDragAngle: number;
  37884. /**
  37885. * @hidden
  37886. */
  37887. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37888. /**
  37889. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37890. */
  37891. currentDraggingPointerID: number;
  37892. /**
  37893. * The last position where the pointer hit the drag plane in world space
  37894. */
  37895. lastDragPosition: Vector3;
  37896. /**
  37897. * If the behavior is currently in a dragging state
  37898. */
  37899. dragging: boolean;
  37900. /**
  37901. * 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)
  37902. */
  37903. dragDeltaRatio: number;
  37904. /**
  37905. * If the drag plane orientation should be updated during the dragging (Default: true)
  37906. */
  37907. updateDragPlane: boolean;
  37908. private _debugMode;
  37909. private _moving;
  37910. /**
  37911. * Fires each time the attached mesh is dragged with the pointer
  37912. * * delta between last drag position and current drag position in world space
  37913. * * dragDistance along the drag axis
  37914. * * dragPlaneNormal normal of the current drag plane used during the drag
  37915. * * dragPlanePoint in world space where the drag intersects the drag plane
  37916. */
  37917. onDragObservable: Observable<{
  37918. delta: Vector3;
  37919. dragPlanePoint: Vector3;
  37920. dragPlaneNormal: Vector3;
  37921. dragDistance: number;
  37922. pointerId: number;
  37923. }>;
  37924. /**
  37925. * Fires each time a drag begins (eg. mouse down on mesh)
  37926. */
  37927. onDragStartObservable: Observable<{
  37928. dragPlanePoint: Vector3;
  37929. pointerId: number;
  37930. }>;
  37931. /**
  37932. * Fires each time a drag ends (eg. mouse release after drag)
  37933. */
  37934. onDragEndObservable: Observable<{
  37935. dragPlanePoint: Vector3;
  37936. pointerId: number;
  37937. }>;
  37938. /**
  37939. * If the attached mesh should be moved when dragged
  37940. */
  37941. moveAttached: boolean;
  37942. /**
  37943. * If the drag behavior will react to drag events (Default: true)
  37944. */
  37945. enabled: boolean;
  37946. /**
  37947. * If pointer events should start and release the drag (Default: true)
  37948. */
  37949. startAndReleaseDragOnPointerEvents: boolean;
  37950. /**
  37951. * If camera controls should be detached during the drag
  37952. */
  37953. detachCameraControls: boolean;
  37954. /**
  37955. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37956. */
  37957. useObjectOrienationForDragging: boolean;
  37958. private _options;
  37959. /**
  37960. * Creates a pointer drag behavior that can be attached to a mesh
  37961. * @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)
  37962. */
  37963. constructor(options?: {
  37964. dragAxis?: Vector3;
  37965. dragPlaneNormal?: Vector3;
  37966. });
  37967. /**
  37968. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37969. */
  37970. validateDrag: (targetPosition: Vector3) => boolean;
  37971. /**
  37972. * The name of the behavior
  37973. */
  37974. readonly name: string;
  37975. /**
  37976. * Initializes the behavior
  37977. */
  37978. init(): void;
  37979. private _tmpVector;
  37980. private _alternatePickedPoint;
  37981. private _worldDragAxis;
  37982. private _targetPosition;
  37983. private _attachedElement;
  37984. /**
  37985. * Attaches the drag behavior the passed in mesh
  37986. * @param ownerNode The mesh that will be dragged around once attached
  37987. * @param predicate Predicate to use for pick filtering
  37988. */
  37989. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37990. /**
  37991. * Force relase the drag action by code.
  37992. */
  37993. releaseDrag(): void;
  37994. private _startDragRay;
  37995. private _lastPointerRay;
  37996. /**
  37997. * Simulates the start of a pointer drag event on the behavior
  37998. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37999. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38000. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38001. */
  38002. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38003. private _startDrag;
  38004. private _dragDelta;
  38005. private _moveDrag;
  38006. private _pickWithRayOnDragPlane;
  38007. private _pointA;
  38008. private _pointB;
  38009. private _pointC;
  38010. private _lineA;
  38011. private _lineB;
  38012. private _localAxis;
  38013. private _lookAt;
  38014. private _updateDragPlanePosition;
  38015. /**
  38016. * Detaches the behavior from the mesh
  38017. */
  38018. detach(): void;
  38019. }
  38020. }
  38021. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38022. import { Mesh } from "babylonjs/Meshes/mesh";
  38023. import { Behavior } from "babylonjs/Behaviors/behavior";
  38024. /**
  38025. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38026. */
  38027. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38028. private _dragBehaviorA;
  38029. private _dragBehaviorB;
  38030. private _startDistance;
  38031. private _initialScale;
  38032. private _targetScale;
  38033. private _ownerNode;
  38034. private _sceneRenderObserver;
  38035. /**
  38036. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38037. */
  38038. constructor();
  38039. /**
  38040. * The name of the behavior
  38041. */
  38042. readonly name: string;
  38043. /**
  38044. * Initializes the behavior
  38045. */
  38046. init(): void;
  38047. private _getCurrentDistance;
  38048. /**
  38049. * Attaches the scale behavior the passed in mesh
  38050. * @param ownerNode The mesh that will be scaled around once attached
  38051. */
  38052. attach(ownerNode: Mesh): void;
  38053. /**
  38054. * Detaches the behavior from the mesh
  38055. */
  38056. detach(): void;
  38057. }
  38058. }
  38059. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38060. import { Behavior } from "babylonjs/Behaviors/behavior";
  38061. import { Mesh } from "babylonjs/Meshes/mesh";
  38062. import { Observable } from "babylonjs/Misc/observable";
  38063. /**
  38064. * 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
  38065. */
  38066. export class SixDofDragBehavior implements Behavior<Mesh> {
  38067. private static _virtualScene;
  38068. private _ownerNode;
  38069. private _sceneRenderObserver;
  38070. private _scene;
  38071. private _targetPosition;
  38072. private _virtualOriginMesh;
  38073. private _virtualDragMesh;
  38074. private _pointerObserver;
  38075. private _moving;
  38076. private _startingOrientation;
  38077. /**
  38078. * 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)
  38079. */
  38080. private zDragFactor;
  38081. /**
  38082. * If the object should rotate to face the drag origin
  38083. */
  38084. rotateDraggedObject: boolean;
  38085. /**
  38086. * If the behavior is currently in a dragging state
  38087. */
  38088. dragging: boolean;
  38089. /**
  38090. * 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)
  38091. */
  38092. dragDeltaRatio: number;
  38093. /**
  38094. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38095. */
  38096. currentDraggingPointerID: number;
  38097. /**
  38098. * If camera controls should be detached during the drag
  38099. */
  38100. detachCameraControls: boolean;
  38101. /**
  38102. * Fires each time a drag starts
  38103. */
  38104. onDragStartObservable: Observable<{}>;
  38105. /**
  38106. * Fires each time a drag ends (eg. mouse release after drag)
  38107. */
  38108. onDragEndObservable: Observable<{}>;
  38109. /**
  38110. * 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
  38111. */
  38112. constructor();
  38113. /**
  38114. * The name of the behavior
  38115. */
  38116. readonly name: string;
  38117. /**
  38118. * Initializes the behavior
  38119. */
  38120. init(): void;
  38121. /**
  38122. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38123. */
  38124. private readonly _pointerCamera;
  38125. /**
  38126. * Attaches the scale behavior the passed in mesh
  38127. * @param ownerNode The mesh that will be scaled around once attached
  38128. */
  38129. attach(ownerNode: Mesh): void;
  38130. /**
  38131. * Detaches the behavior from the mesh
  38132. */
  38133. detach(): void;
  38134. }
  38135. }
  38136. declare module "babylonjs/Behaviors/Meshes/index" {
  38137. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38138. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38139. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38140. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38141. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38142. }
  38143. declare module "babylonjs/Behaviors/index" {
  38144. export * from "babylonjs/Behaviors/behavior";
  38145. export * from "babylonjs/Behaviors/Cameras/index";
  38146. export * from "babylonjs/Behaviors/Meshes/index";
  38147. }
  38148. declare module "babylonjs/Bones/boneIKController" {
  38149. import { Bone } from "babylonjs/Bones/bone";
  38150. import { Vector3 } from "babylonjs/Maths/math.vector";
  38151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38152. import { Nullable } from "babylonjs/types";
  38153. /**
  38154. * Class used to apply inverse kinematics to bones
  38155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38156. */
  38157. export class BoneIKController {
  38158. private static _tmpVecs;
  38159. private static _tmpQuat;
  38160. private static _tmpMats;
  38161. /**
  38162. * Gets or sets the target mesh
  38163. */
  38164. targetMesh: AbstractMesh;
  38165. /** Gets or sets the mesh used as pole */
  38166. poleTargetMesh: AbstractMesh;
  38167. /**
  38168. * Gets or sets the bone used as pole
  38169. */
  38170. poleTargetBone: Nullable<Bone>;
  38171. /**
  38172. * Gets or sets the target position
  38173. */
  38174. targetPosition: Vector3;
  38175. /**
  38176. * Gets or sets the pole target position
  38177. */
  38178. poleTargetPosition: Vector3;
  38179. /**
  38180. * Gets or sets the pole target local offset
  38181. */
  38182. poleTargetLocalOffset: Vector3;
  38183. /**
  38184. * Gets or sets the pole angle
  38185. */
  38186. poleAngle: number;
  38187. /**
  38188. * Gets or sets the mesh associated with the controller
  38189. */
  38190. mesh: AbstractMesh;
  38191. /**
  38192. * 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)
  38193. */
  38194. slerpAmount: number;
  38195. private _bone1Quat;
  38196. private _bone1Mat;
  38197. private _bone2Ang;
  38198. private _bone1;
  38199. private _bone2;
  38200. private _bone1Length;
  38201. private _bone2Length;
  38202. private _maxAngle;
  38203. private _maxReach;
  38204. private _rightHandedSystem;
  38205. private _bendAxis;
  38206. private _slerping;
  38207. private _adjustRoll;
  38208. /**
  38209. * Gets or sets maximum allowed angle
  38210. */
  38211. maxAngle: number;
  38212. /**
  38213. * Creates a new BoneIKController
  38214. * @param mesh defines the mesh to control
  38215. * @param bone defines the bone to control
  38216. * @param options defines options to set up the controller
  38217. */
  38218. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38219. targetMesh?: AbstractMesh;
  38220. poleTargetMesh?: AbstractMesh;
  38221. poleTargetBone?: Bone;
  38222. poleTargetLocalOffset?: Vector3;
  38223. poleAngle?: number;
  38224. bendAxis?: Vector3;
  38225. maxAngle?: number;
  38226. slerpAmount?: number;
  38227. });
  38228. private _setMaxAngle;
  38229. /**
  38230. * Force the controller to update the bones
  38231. */
  38232. update(): void;
  38233. }
  38234. }
  38235. declare module "babylonjs/Bones/boneLookController" {
  38236. import { Vector3 } from "babylonjs/Maths/math.vector";
  38237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38238. import { Bone } from "babylonjs/Bones/bone";
  38239. import { Space } from "babylonjs/Maths/math.axis";
  38240. /**
  38241. * Class used to make a bone look toward a point in space
  38242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38243. */
  38244. export class BoneLookController {
  38245. private static _tmpVecs;
  38246. private static _tmpQuat;
  38247. private static _tmpMats;
  38248. /**
  38249. * The target Vector3 that the bone will look at
  38250. */
  38251. target: Vector3;
  38252. /**
  38253. * The mesh that the bone is attached to
  38254. */
  38255. mesh: AbstractMesh;
  38256. /**
  38257. * The bone that will be looking to the target
  38258. */
  38259. bone: Bone;
  38260. /**
  38261. * The up axis of the coordinate system that is used when the bone is rotated
  38262. */
  38263. upAxis: Vector3;
  38264. /**
  38265. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38266. */
  38267. upAxisSpace: Space;
  38268. /**
  38269. * Used to make an adjustment to the yaw of the bone
  38270. */
  38271. adjustYaw: number;
  38272. /**
  38273. * Used to make an adjustment to the pitch of the bone
  38274. */
  38275. adjustPitch: number;
  38276. /**
  38277. * Used to make an adjustment to the roll of the bone
  38278. */
  38279. adjustRoll: number;
  38280. /**
  38281. * 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)
  38282. */
  38283. slerpAmount: number;
  38284. private _minYaw;
  38285. private _maxYaw;
  38286. private _minPitch;
  38287. private _maxPitch;
  38288. private _minYawSin;
  38289. private _minYawCos;
  38290. private _maxYawSin;
  38291. private _maxYawCos;
  38292. private _midYawConstraint;
  38293. private _minPitchTan;
  38294. private _maxPitchTan;
  38295. private _boneQuat;
  38296. private _slerping;
  38297. private _transformYawPitch;
  38298. private _transformYawPitchInv;
  38299. private _firstFrameSkipped;
  38300. private _yawRange;
  38301. private _fowardAxis;
  38302. /**
  38303. * Gets or sets the minimum yaw angle that the bone can look to
  38304. */
  38305. minYaw: number;
  38306. /**
  38307. * Gets or sets the maximum yaw angle that the bone can look to
  38308. */
  38309. maxYaw: number;
  38310. /**
  38311. * Gets or sets the minimum pitch angle that the bone can look to
  38312. */
  38313. minPitch: number;
  38314. /**
  38315. * Gets or sets the maximum pitch angle that the bone can look to
  38316. */
  38317. maxPitch: number;
  38318. /**
  38319. * Create a BoneLookController
  38320. * @param mesh the mesh that the bone belongs to
  38321. * @param bone the bone that will be looking to the target
  38322. * @param target the target Vector3 to look at
  38323. * @param options optional settings:
  38324. * * maxYaw: the maximum angle the bone will yaw to
  38325. * * minYaw: the minimum angle the bone will yaw to
  38326. * * maxPitch: the maximum angle the bone will pitch to
  38327. * * minPitch: the minimum angle the bone will yaw to
  38328. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38329. * * upAxis: the up axis of the coordinate system
  38330. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38331. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38332. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38333. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38334. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38335. * * adjustRoll: used to make an adjustment to the roll of the bone
  38336. **/
  38337. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38338. maxYaw?: number;
  38339. minYaw?: number;
  38340. maxPitch?: number;
  38341. minPitch?: number;
  38342. slerpAmount?: number;
  38343. upAxis?: Vector3;
  38344. upAxisSpace?: Space;
  38345. yawAxis?: Vector3;
  38346. pitchAxis?: Vector3;
  38347. adjustYaw?: number;
  38348. adjustPitch?: number;
  38349. adjustRoll?: number;
  38350. });
  38351. /**
  38352. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38353. */
  38354. update(): void;
  38355. private _getAngleDiff;
  38356. private _getAngleBetween;
  38357. private _isAngleBetween;
  38358. }
  38359. }
  38360. declare module "babylonjs/Bones/index" {
  38361. export * from "babylonjs/Bones/bone";
  38362. export * from "babylonjs/Bones/boneIKController";
  38363. export * from "babylonjs/Bones/boneLookController";
  38364. export * from "babylonjs/Bones/skeleton";
  38365. }
  38366. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38367. import { Nullable } from "babylonjs/types";
  38368. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38369. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38370. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38371. /**
  38372. * Manage the gamepad inputs to control an arc rotate camera.
  38373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38374. */
  38375. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38376. /**
  38377. * Defines the camera the input is attached to.
  38378. */
  38379. camera: ArcRotateCamera;
  38380. /**
  38381. * Defines the gamepad the input is gathering event from.
  38382. */
  38383. gamepad: Nullable<Gamepad>;
  38384. /**
  38385. * Defines the gamepad rotation sensiblity.
  38386. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38387. */
  38388. gamepadRotationSensibility: number;
  38389. /**
  38390. * Defines the gamepad move sensiblity.
  38391. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38392. */
  38393. gamepadMoveSensibility: number;
  38394. private _onGamepadConnectedObserver;
  38395. private _onGamepadDisconnectedObserver;
  38396. /**
  38397. * Attach the input controls to a specific dom element to get the input from.
  38398. * @param element Defines the element the controls should be listened from
  38399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38400. */
  38401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38402. /**
  38403. * Detach the current controls from the specified dom element.
  38404. * @param element Defines the element to stop listening the inputs from
  38405. */
  38406. detachControl(element: Nullable<HTMLElement>): void;
  38407. /**
  38408. * Update the current camera state depending on the inputs that have been used this frame.
  38409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38410. */
  38411. checkInputs(): void;
  38412. /**
  38413. * Gets the class name of the current intput.
  38414. * @returns the class name
  38415. */
  38416. getClassName(): string;
  38417. /**
  38418. * Get the friendly name associated with the input class.
  38419. * @returns the input friendly name
  38420. */
  38421. getSimpleName(): string;
  38422. }
  38423. }
  38424. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38425. import { Nullable } from "babylonjs/types";
  38426. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38427. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38428. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38429. interface ArcRotateCameraInputsManager {
  38430. /**
  38431. * Add orientation input support to the input manager.
  38432. * @returns the current input manager
  38433. */
  38434. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38435. }
  38436. }
  38437. /**
  38438. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38440. */
  38441. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38442. /**
  38443. * Defines the camera the input is attached to.
  38444. */
  38445. camera: ArcRotateCamera;
  38446. /**
  38447. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38448. */
  38449. alphaCorrection: number;
  38450. /**
  38451. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38452. */
  38453. gammaCorrection: number;
  38454. private _alpha;
  38455. private _gamma;
  38456. private _dirty;
  38457. private _deviceOrientationHandler;
  38458. /**
  38459. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38460. */
  38461. constructor();
  38462. /**
  38463. * Attach the input controls to a specific dom element to get the input from.
  38464. * @param element Defines the element the controls should be listened from
  38465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38466. */
  38467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38468. /** @hidden */
  38469. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38470. /**
  38471. * Update the current camera state depending on the inputs that have been used this frame.
  38472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38473. */
  38474. checkInputs(): void;
  38475. /**
  38476. * Detach the current controls from the specified dom element.
  38477. * @param element Defines the element to stop listening the inputs from
  38478. */
  38479. detachControl(element: Nullable<HTMLElement>): void;
  38480. /**
  38481. * Gets the class name of the current intput.
  38482. * @returns the class name
  38483. */
  38484. getClassName(): string;
  38485. /**
  38486. * Get the friendly name associated with the input class.
  38487. * @returns the input friendly name
  38488. */
  38489. getSimpleName(): string;
  38490. }
  38491. }
  38492. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38493. import { Nullable } from "babylonjs/types";
  38494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38495. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38496. /**
  38497. * Listen to mouse events to control the camera.
  38498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38499. */
  38500. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38501. /**
  38502. * Defines the camera the input is attached to.
  38503. */
  38504. camera: FlyCamera;
  38505. /**
  38506. * Defines if touch is enabled. (Default is true.)
  38507. */
  38508. touchEnabled: boolean;
  38509. /**
  38510. * Defines the buttons associated with the input to handle camera rotation.
  38511. */
  38512. buttons: number[];
  38513. /**
  38514. * Assign buttons for Yaw control.
  38515. */
  38516. buttonsYaw: number[];
  38517. /**
  38518. * Assign buttons for Pitch control.
  38519. */
  38520. buttonsPitch: number[];
  38521. /**
  38522. * Assign buttons for Roll control.
  38523. */
  38524. buttonsRoll: number[];
  38525. /**
  38526. * Detect if any button is being pressed while mouse is moved.
  38527. * -1 = Mouse locked.
  38528. * 0 = Left button.
  38529. * 1 = Middle Button.
  38530. * 2 = Right Button.
  38531. */
  38532. activeButton: number;
  38533. /**
  38534. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38535. * Higher values reduce its sensitivity.
  38536. */
  38537. angularSensibility: number;
  38538. private _mousemoveCallback;
  38539. private _observer;
  38540. private _rollObserver;
  38541. private previousPosition;
  38542. private noPreventDefault;
  38543. private element;
  38544. /**
  38545. * Listen to mouse events to control the camera.
  38546. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38548. */
  38549. constructor(touchEnabled?: boolean);
  38550. /**
  38551. * Attach the mouse control to the HTML DOM element.
  38552. * @param element Defines the element that listens to the input events.
  38553. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38554. */
  38555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38556. /**
  38557. * Detach the current controls from the specified dom element.
  38558. * @param element Defines the element to stop listening the inputs from
  38559. */
  38560. detachControl(element: Nullable<HTMLElement>): void;
  38561. /**
  38562. * Gets the class name of the current input.
  38563. * @returns the class name.
  38564. */
  38565. getClassName(): string;
  38566. /**
  38567. * Get the friendly name associated with the input class.
  38568. * @returns the input's friendly name.
  38569. */
  38570. getSimpleName(): string;
  38571. private _pointerInput;
  38572. private _onMouseMove;
  38573. /**
  38574. * Rotate camera by mouse offset.
  38575. */
  38576. private rotateCamera;
  38577. }
  38578. }
  38579. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38580. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38581. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38582. /**
  38583. * Default Inputs manager for the FlyCamera.
  38584. * It groups all the default supported inputs for ease of use.
  38585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38586. */
  38587. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38588. /**
  38589. * Instantiates a new FlyCameraInputsManager.
  38590. * @param camera Defines the camera the inputs belong to.
  38591. */
  38592. constructor(camera: FlyCamera);
  38593. /**
  38594. * Add keyboard input support to the input manager.
  38595. * @returns the new FlyCameraKeyboardMoveInput().
  38596. */
  38597. addKeyboard(): FlyCameraInputsManager;
  38598. /**
  38599. * Add mouse input support to the input manager.
  38600. * @param touchEnabled Enable touch screen support.
  38601. * @returns the new FlyCameraMouseInput().
  38602. */
  38603. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38604. }
  38605. }
  38606. declare module "babylonjs/Cameras/flyCamera" {
  38607. import { Scene } from "babylonjs/scene";
  38608. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38610. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38611. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38612. /**
  38613. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38614. * such as in a 3D Space Shooter or a Flight Simulator.
  38615. */
  38616. export class FlyCamera extends TargetCamera {
  38617. /**
  38618. * Define the collision ellipsoid of the camera.
  38619. * This is helpful for simulating a camera body, like a player's body.
  38620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38621. */
  38622. ellipsoid: Vector3;
  38623. /**
  38624. * Define an offset for the position of the ellipsoid around the camera.
  38625. * This can be helpful if the camera is attached away from the player's body center,
  38626. * such as at its head.
  38627. */
  38628. ellipsoidOffset: Vector3;
  38629. /**
  38630. * Enable or disable collisions of the camera with the rest of the scene objects.
  38631. */
  38632. checkCollisions: boolean;
  38633. /**
  38634. * Enable or disable gravity on the camera.
  38635. */
  38636. applyGravity: boolean;
  38637. /**
  38638. * Define the current direction the camera is moving to.
  38639. */
  38640. cameraDirection: Vector3;
  38641. /**
  38642. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38643. * This overrides and empties cameraRotation.
  38644. */
  38645. rotationQuaternion: Quaternion;
  38646. /**
  38647. * Track Roll to maintain the wanted Rolling when looking around.
  38648. */
  38649. _trackRoll: number;
  38650. /**
  38651. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38652. */
  38653. rollCorrect: number;
  38654. /**
  38655. * Mimic a banked turn, Rolling the camera when Yawing.
  38656. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38657. */
  38658. bankedTurn: boolean;
  38659. /**
  38660. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38661. */
  38662. bankedTurnLimit: number;
  38663. /**
  38664. * Value of 0 disables the banked Roll.
  38665. * Value of 1 is equal to the Yaw angle in radians.
  38666. */
  38667. bankedTurnMultiplier: number;
  38668. /**
  38669. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38670. */
  38671. inputs: FlyCameraInputsManager;
  38672. /**
  38673. * Gets the input sensibility for mouse input.
  38674. * Higher values reduce sensitivity.
  38675. */
  38676. /**
  38677. * Sets the input sensibility for a mouse input.
  38678. * Higher values reduce sensitivity.
  38679. */
  38680. angularSensibility: number;
  38681. /**
  38682. * Get the keys for camera movement forward.
  38683. */
  38684. /**
  38685. * Set the keys for camera movement forward.
  38686. */
  38687. keysForward: number[];
  38688. /**
  38689. * Get the keys for camera movement backward.
  38690. */
  38691. keysBackward: number[];
  38692. /**
  38693. * Get the keys for camera movement up.
  38694. */
  38695. /**
  38696. * Set the keys for camera movement up.
  38697. */
  38698. keysUp: number[];
  38699. /**
  38700. * Get the keys for camera movement down.
  38701. */
  38702. /**
  38703. * Set the keys for camera movement down.
  38704. */
  38705. keysDown: number[];
  38706. /**
  38707. * Get the keys for camera movement left.
  38708. */
  38709. /**
  38710. * Set the keys for camera movement left.
  38711. */
  38712. keysLeft: number[];
  38713. /**
  38714. * Set the keys for camera movement right.
  38715. */
  38716. /**
  38717. * Set the keys for camera movement right.
  38718. */
  38719. keysRight: number[];
  38720. /**
  38721. * Event raised when the camera collides with a mesh in the scene.
  38722. */
  38723. onCollide: (collidedMesh: AbstractMesh) => void;
  38724. private _collider;
  38725. private _needMoveForGravity;
  38726. private _oldPosition;
  38727. private _diffPosition;
  38728. private _newPosition;
  38729. /** @hidden */
  38730. _localDirection: Vector3;
  38731. /** @hidden */
  38732. _transformedDirection: Vector3;
  38733. /**
  38734. * Instantiates a FlyCamera.
  38735. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38736. * such as in a 3D Space Shooter or a Flight Simulator.
  38737. * @param name Define the name of the camera in the scene.
  38738. * @param position Define the starting position of the camera in the scene.
  38739. * @param scene Define the scene the camera belongs to.
  38740. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38741. */
  38742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38743. /**
  38744. * Attach a control to the HTML DOM element.
  38745. * @param element Defines the element that listens to the input events.
  38746. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38747. */
  38748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38749. /**
  38750. * Detach a control from the HTML DOM element.
  38751. * The camera will stop reacting to that input.
  38752. * @param element Defines the element that listens to the input events.
  38753. */
  38754. detachControl(element: HTMLElement): void;
  38755. private _collisionMask;
  38756. /**
  38757. * Get the mask that the camera ignores in collision events.
  38758. */
  38759. /**
  38760. * Set the mask that the camera ignores in collision events.
  38761. */
  38762. collisionMask: number;
  38763. /** @hidden */
  38764. _collideWithWorld(displacement: Vector3): void;
  38765. /** @hidden */
  38766. private _onCollisionPositionChange;
  38767. /** @hidden */
  38768. _checkInputs(): void;
  38769. /** @hidden */
  38770. _decideIfNeedsToMove(): boolean;
  38771. /** @hidden */
  38772. _updatePosition(): void;
  38773. /**
  38774. * Restore the Roll to its target value at the rate specified.
  38775. * @param rate - Higher means slower restoring.
  38776. * @hidden
  38777. */
  38778. restoreRoll(rate: number): void;
  38779. /**
  38780. * Destroy the camera and release the current resources held by it.
  38781. */
  38782. dispose(): void;
  38783. /**
  38784. * Get the current object class name.
  38785. * @returns the class name.
  38786. */
  38787. getClassName(): string;
  38788. }
  38789. }
  38790. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38791. import { Nullable } from "babylonjs/types";
  38792. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38793. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38794. /**
  38795. * Listen to keyboard events to control the camera.
  38796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38797. */
  38798. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38799. /**
  38800. * Defines the camera the input is attached to.
  38801. */
  38802. camera: FlyCamera;
  38803. /**
  38804. * The list of keyboard keys used to control the forward move of the camera.
  38805. */
  38806. keysForward: number[];
  38807. /**
  38808. * The list of keyboard keys used to control the backward move of the camera.
  38809. */
  38810. keysBackward: number[];
  38811. /**
  38812. * The list of keyboard keys used to control the forward move of the camera.
  38813. */
  38814. keysUp: number[];
  38815. /**
  38816. * The list of keyboard keys used to control the backward move of the camera.
  38817. */
  38818. keysDown: number[];
  38819. /**
  38820. * The list of keyboard keys used to control the right strafe move of the camera.
  38821. */
  38822. keysRight: number[];
  38823. /**
  38824. * The list of keyboard keys used to control the left strafe move of the camera.
  38825. */
  38826. keysLeft: number[];
  38827. private _keys;
  38828. private _onCanvasBlurObserver;
  38829. private _onKeyboardObserver;
  38830. private _engine;
  38831. private _scene;
  38832. /**
  38833. * Attach the input controls to a specific dom element to get the input from.
  38834. * @param element Defines the element the controls should be listened from
  38835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38836. */
  38837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38838. /**
  38839. * Detach the current controls from the specified dom element.
  38840. * @param element Defines the element to stop listening the inputs from
  38841. */
  38842. detachControl(element: Nullable<HTMLElement>): void;
  38843. /**
  38844. * Gets the class name of the current intput.
  38845. * @returns the class name
  38846. */
  38847. getClassName(): string;
  38848. /** @hidden */
  38849. _onLostFocus(e: FocusEvent): void;
  38850. /**
  38851. * Get the friendly name associated with the input class.
  38852. * @returns the input friendly name
  38853. */
  38854. getSimpleName(): string;
  38855. /**
  38856. * Update the current camera state depending on the inputs that have been used this frame.
  38857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38858. */
  38859. checkInputs(): void;
  38860. }
  38861. }
  38862. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38863. import { Nullable } from "babylonjs/types";
  38864. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38865. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38866. /**
  38867. * Manage the mouse wheel inputs to control a follow camera.
  38868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38869. */
  38870. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38871. /**
  38872. * Defines the camera the input is attached to.
  38873. */
  38874. camera: FollowCamera;
  38875. /**
  38876. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38877. */
  38878. axisControlRadius: boolean;
  38879. /**
  38880. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38881. */
  38882. axisControlHeight: boolean;
  38883. /**
  38884. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38885. */
  38886. axisControlRotation: boolean;
  38887. /**
  38888. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38889. * relation to mouseWheel events.
  38890. */
  38891. wheelPrecision: number;
  38892. /**
  38893. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38894. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38895. */
  38896. wheelDeltaPercentage: number;
  38897. private _wheel;
  38898. private _observer;
  38899. /**
  38900. * Attach the input controls to a specific dom element to get the input from.
  38901. * @param element Defines the element the controls should be listened from
  38902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38903. */
  38904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38905. /**
  38906. * Detach the current controls from the specified dom element.
  38907. * @param element Defines the element to stop listening the inputs from
  38908. */
  38909. detachControl(element: Nullable<HTMLElement>): void;
  38910. /**
  38911. * Gets the class name of the current intput.
  38912. * @returns the class name
  38913. */
  38914. getClassName(): string;
  38915. /**
  38916. * Get the friendly name associated with the input class.
  38917. * @returns the input friendly name
  38918. */
  38919. getSimpleName(): string;
  38920. }
  38921. }
  38922. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38923. import { Nullable } from "babylonjs/types";
  38924. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38925. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38926. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38927. /**
  38928. * Manage the pointers inputs to control an follow camera.
  38929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38930. */
  38931. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38932. /**
  38933. * Defines the camera the input is attached to.
  38934. */
  38935. camera: FollowCamera;
  38936. /**
  38937. * Gets the class name of the current input.
  38938. * @returns the class name
  38939. */
  38940. getClassName(): string;
  38941. /**
  38942. * Defines the pointer angular sensibility along the X axis or how fast is
  38943. * the camera rotating.
  38944. * A negative number will reverse the axis direction.
  38945. */
  38946. angularSensibilityX: number;
  38947. /**
  38948. * Defines the pointer angular sensibility along the Y axis or how fast is
  38949. * the camera rotating.
  38950. * A negative number will reverse the axis direction.
  38951. */
  38952. angularSensibilityY: number;
  38953. /**
  38954. * Defines the pointer pinch precision or how fast is the camera zooming.
  38955. * A negative number will reverse the axis direction.
  38956. */
  38957. pinchPrecision: number;
  38958. /**
  38959. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38960. * from 0.
  38961. * It defines the percentage of current camera.radius to use as delta when
  38962. * pinch zoom is used.
  38963. */
  38964. pinchDeltaPercentage: number;
  38965. /**
  38966. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38967. */
  38968. axisXControlRadius: boolean;
  38969. /**
  38970. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38971. */
  38972. axisXControlHeight: boolean;
  38973. /**
  38974. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38975. */
  38976. axisXControlRotation: boolean;
  38977. /**
  38978. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38979. */
  38980. axisYControlRadius: boolean;
  38981. /**
  38982. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38983. */
  38984. axisYControlHeight: boolean;
  38985. /**
  38986. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38987. */
  38988. axisYControlRotation: boolean;
  38989. /**
  38990. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38991. */
  38992. axisPinchControlRadius: boolean;
  38993. /**
  38994. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38995. */
  38996. axisPinchControlHeight: boolean;
  38997. /**
  38998. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38999. */
  39000. axisPinchControlRotation: boolean;
  39001. /**
  39002. * Log error messages if basic misconfiguration has occurred.
  39003. */
  39004. warningEnable: boolean;
  39005. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39006. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39007. private _warningCounter;
  39008. private _warning;
  39009. }
  39010. }
  39011. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39012. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39013. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39014. /**
  39015. * Default Inputs manager for the FollowCamera.
  39016. * It groups all the default supported inputs for ease of use.
  39017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39018. */
  39019. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39020. /**
  39021. * Instantiates a new FollowCameraInputsManager.
  39022. * @param camera Defines the camera the inputs belong to
  39023. */
  39024. constructor(camera: FollowCamera);
  39025. /**
  39026. * Add keyboard input support to the input manager.
  39027. * @returns the current input manager
  39028. */
  39029. addKeyboard(): FollowCameraInputsManager;
  39030. /**
  39031. * Add mouse wheel input support to the input manager.
  39032. * @returns the current input manager
  39033. */
  39034. addMouseWheel(): FollowCameraInputsManager;
  39035. /**
  39036. * Add pointers input support to the input manager.
  39037. * @returns the current input manager
  39038. */
  39039. addPointers(): FollowCameraInputsManager;
  39040. /**
  39041. * Add orientation input support to the input manager.
  39042. * @returns the current input manager
  39043. */
  39044. addVRDeviceOrientation(): FollowCameraInputsManager;
  39045. }
  39046. }
  39047. declare module "babylonjs/Cameras/followCamera" {
  39048. import { Nullable } from "babylonjs/types";
  39049. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39050. import { Scene } from "babylonjs/scene";
  39051. import { Vector3 } from "babylonjs/Maths/math.vector";
  39052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39053. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39054. /**
  39055. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39056. * an arc rotate version arcFollowCamera are available.
  39057. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39058. */
  39059. export class FollowCamera extends TargetCamera {
  39060. /**
  39061. * Distance the follow camera should follow an object at
  39062. */
  39063. radius: number;
  39064. /**
  39065. * Minimum allowed distance of the camera to the axis of rotation
  39066. * (The camera can not get closer).
  39067. * This can help limiting how the Camera is able to move in the scene.
  39068. */
  39069. lowerRadiusLimit: Nullable<number>;
  39070. /**
  39071. * Maximum allowed distance of the camera to the axis of rotation
  39072. * (The camera can not get further).
  39073. * This can help limiting how the Camera is able to move in the scene.
  39074. */
  39075. upperRadiusLimit: Nullable<number>;
  39076. /**
  39077. * Define a rotation offset between the camera and the object it follows
  39078. */
  39079. rotationOffset: number;
  39080. /**
  39081. * Minimum allowed angle to camera position relative to target object.
  39082. * This can help limiting how the Camera is able to move in the scene.
  39083. */
  39084. lowerRotationOffsetLimit: Nullable<number>;
  39085. /**
  39086. * Maximum allowed angle to camera position relative to target object.
  39087. * This can help limiting how the Camera is able to move in the scene.
  39088. */
  39089. upperRotationOffsetLimit: Nullable<number>;
  39090. /**
  39091. * Define a height offset between the camera and the object it follows.
  39092. * It can help following an object from the top (like a car chaing a plane)
  39093. */
  39094. heightOffset: number;
  39095. /**
  39096. * Minimum allowed height of camera position relative to target object.
  39097. * This can help limiting how the Camera is able to move in the scene.
  39098. */
  39099. lowerHeightOffsetLimit: Nullable<number>;
  39100. /**
  39101. * Maximum allowed height of camera position relative to target object.
  39102. * This can help limiting how the Camera is able to move in the scene.
  39103. */
  39104. upperHeightOffsetLimit: Nullable<number>;
  39105. /**
  39106. * Define how fast the camera can accelerate to follow it s target.
  39107. */
  39108. cameraAcceleration: number;
  39109. /**
  39110. * Define the speed limit of the camera following an object.
  39111. */
  39112. maxCameraSpeed: number;
  39113. /**
  39114. * Define the target of the camera.
  39115. */
  39116. lockedTarget: Nullable<AbstractMesh>;
  39117. /**
  39118. * Defines the input associated with the camera.
  39119. */
  39120. inputs: FollowCameraInputsManager;
  39121. /**
  39122. * Instantiates the follow camera.
  39123. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39124. * @param name Define the name of the camera in the scene
  39125. * @param position Define the position of the camera
  39126. * @param scene Define the scene the camera belong to
  39127. * @param lockedTarget Define the target of the camera
  39128. */
  39129. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39130. private _follow;
  39131. /**
  39132. * Attached controls to the current camera.
  39133. * @param element Defines the element the controls should be listened from
  39134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39135. */
  39136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39137. /**
  39138. * Detach the current controls from the camera.
  39139. * The camera will stop reacting to inputs.
  39140. * @param element Defines the element to stop listening the inputs from
  39141. */
  39142. detachControl(element: HTMLElement): void;
  39143. /** @hidden */
  39144. _checkInputs(): void;
  39145. private _checkLimits;
  39146. /**
  39147. * Gets the camera class name.
  39148. * @returns the class name
  39149. */
  39150. getClassName(): string;
  39151. }
  39152. /**
  39153. * Arc Rotate version of the follow camera.
  39154. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39155. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39156. */
  39157. export class ArcFollowCamera extends TargetCamera {
  39158. /** The longitudinal angle of the camera */
  39159. alpha: number;
  39160. /** The latitudinal angle of the camera */
  39161. beta: number;
  39162. /** The radius of the camera from its target */
  39163. radius: number;
  39164. /** Define the camera target (the messh it should follow) */
  39165. target: Nullable<AbstractMesh>;
  39166. private _cartesianCoordinates;
  39167. /**
  39168. * Instantiates a new ArcFollowCamera
  39169. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39170. * @param name Define the name of the camera
  39171. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39172. * @param beta Define the rotation angle of the camera around the elevation axis
  39173. * @param radius Define the radius of the camera from its target point
  39174. * @param target Define the target of the camera
  39175. * @param scene Define the scene the camera belongs to
  39176. */
  39177. constructor(name: string,
  39178. /** The longitudinal angle of the camera */
  39179. alpha: number,
  39180. /** The latitudinal angle of the camera */
  39181. beta: number,
  39182. /** The radius of the camera from its target */
  39183. radius: number,
  39184. /** Define the camera target (the messh it should follow) */
  39185. target: Nullable<AbstractMesh>, scene: Scene);
  39186. private _follow;
  39187. /** @hidden */
  39188. _checkInputs(): void;
  39189. /**
  39190. * Returns the class name of the object.
  39191. * It is mostly used internally for serialization purposes.
  39192. */
  39193. getClassName(): string;
  39194. }
  39195. }
  39196. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39197. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39198. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39199. import { Nullable } from "babylonjs/types";
  39200. /**
  39201. * Manage the keyboard inputs to control the movement of a follow camera.
  39202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39203. */
  39204. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39205. /**
  39206. * Defines the camera the input is attached to.
  39207. */
  39208. camera: FollowCamera;
  39209. /**
  39210. * Defines the list of key codes associated with the up action (increase heightOffset)
  39211. */
  39212. keysHeightOffsetIncr: number[];
  39213. /**
  39214. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39215. */
  39216. keysHeightOffsetDecr: number[];
  39217. /**
  39218. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39219. */
  39220. keysHeightOffsetModifierAlt: boolean;
  39221. /**
  39222. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39223. */
  39224. keysHeightOffsetModifierCtrl: boolean;
  39225. /**
  39226. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39227. */
  39228. keysHeightOffsetModifierShift: boolean;
  39229. /**
  39230. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39231. */
  39232. keysRotationOffsetIncr: number[];
  39233. /**
  39234. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39235. */
  39236. keysRotationOffsetDecr: number[];
  39237. /**
  39238. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39239. */
  39240. keysRotationOffsetModifierAlt: boolean;
  39241. /**
  39242. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39243. */
  39244. keysRotationOffsetModifierCtrl: boolean;
  39245. /**
  39246. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39247. */
  39248. keysRotationOffsetModifierShift: boolean;
  39249. /**
  39250. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39251. */
  39252. keysRadiusIncr: number[];
  39253. /**
  39254. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39255. */
  39256. keysRadiusDecr: number[];
  39257. /**
  39258. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39259. */
  39260. keysRadiusModifierAlt: boolean;
  39261. /**
  39262. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39263. */
  39264. keysRadiusModifierCtrl: boolean;
  39265. /**
  39266. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39267. */
  39268. keysRadiusModifierShift: boolean;
  39269. /**
  39270. * Defines the rate of change of heightOffset.
  39271. */
  39272. heightSensibility: number;
  39273. /**
  39274. * Defines the rate of change of rotationOffset.
  39275. */
  39276. rotationSensibility: number;
  39277. /**
  39278. * Defines the rate of change of radius.
  39279. */
  39280. radiusSensibility: number;
  39281. private _keys;
  39282. private _ctrlPressed;
  39283. private _altPressed;
  39284. private _shiftPressed;
  39285. private _onCanvasBlurObserver;
  39286. private _onKeyboardObserver;
  39287. private _engine;
  39288. private _scene;
  39289. /**
  39290. * Attach the input controls to a specific dom element to get the input from.
  39291. * @param element Defines the element the controls should be listened from
  39292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39293. */
  39294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39295. /**
  39296. * Detach the current controls from the specified dom element.
  39297. * @param element Defines the element to stop listening the inputs from
  39298. */
  39299. detachControl(element: Nullable<HTMLElement>): void;
  39300. /**
  39301. * Update the current camera state depending on the inputs that have been used this frame.
  39302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39303. */
  39304. checkInputs(): void;
  39305. /**
  39306. * Gets the class name of the current input.
  39307. * @returns the class name
  39308. */
  39309. getClassName(): string;
  39310. /**
  39311. * Get the friendly name associated with the input class.
  39312. * @returns the input friendly name
  39313. */
  39314. getSimpleName(): string;
  39315. /**
  39316. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39317. * allow modification of the heightOffset value.
  39318. */
  39319. private _modifierHeightOffset;
  39320. /**
  39321. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39322. * allow modification of the rotationOffset value.
  39323. */
  39324. private _modifierRotationOffset;
  39325. /**
  39326. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39327. * allow modification of the radius value.
  39328. */
  39329. private _modifierRadius;
  39330. }
  39331. }
  39332. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39333. import { Nullable } from "babylonjs/types";
  39334. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39335. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39336. import { Observable } from "babylonjs/Misc/observable";
  39337. module "babylonjs/Cameras/freeCameraInputsManager" {
  39338. interface FreeCameraInputsManager {
  39339. /**
  39340. * @hidden
  39341. */
  39342. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39343. /**
  39344. * Add orientation input support to the input manager.
  39345. * @returns the current input manager
  39346. */
  39347. addDeviceOrientation(): FreeCameraInputsManager;
  39348. }
  39349. }
  39350. /**
  39351. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39352. * Screen rotation is taken into account.
  39353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39354. */
  39355. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39356. private _camera;
  39357. private _screenOrientationAngle;
  39358. private _constantTranform;
  39359. private _screenQuaternion;
  39360. private _alpha;
  39361. private _beta;
  39362. private _gamma;
  39363. /**
  39364. * Can be used to detect if a device orientation sensor is availible on a device
  39365. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39366. * @returns a promise that will resolve on orientation change
  39367. */
  39368. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39369. /**
  39370. * @hidden
  39371. */
  39372. _onDeviceOrientationChangedObservable: Observable<void>;
  39373. /**
  39374. * Instantiates a new input
  39375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39376. */
  39377. constructor();
  39378. /**
  39379. * Define the camera controlled by the input.
  39380. */
  39381. camera: FreeCamera;
  39382. /**
  39383. * Attach the input controls to a specific dom element to get the input from.
  39384. * @param element Defines the element the controls should be listened from
  39385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39386. */
  39387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39388. private _orientationChanged;
  39389. private _deviceOrientation;
  39390. /**
  39391. * Detach the current controls from the specified dom element.
  39392. * @param element Defines the element to stop listening the inputs from
  39393. */
  39394. detachControl(element: Nullable<HTMLElement>): void;
  39395. /**
  39396. * Update the current camera state depending on the inputs that have been used this frame.
  39397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39398. */
  39399. checkInputs(): void;
  39400. /**
  39401. * Gets the class name of the current intput.
  39402. * @returns the class name
  39403. */
  39404. getClassName(): string;
  39405. /**
  39406. * Get the friendly name associated with the input class.
  39407. * @returns the input friendly name
  39408. */
  39409. getSimpleName(): string;
  39410. }
  39411. }
  39412. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39413. import { Nullable } from "babylonjs/types";
  39414. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39415. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39416. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39417. /**
  39418. * Manage the gamepad inputs to control a free camera.
  39419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39420. */
  39421. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39422. /**
  39423. * Define the camera the input is attached to.
  39424. */
  39425. camera: FreeCamera;
  39426. /**
  39427. * Define the Gamepad controlling the input
  39428. */
  39429. gamepad: Nullable<Gamepad>;
  39430. /**
  39431. * Defines the gamepad rotation sensiblity.
  39432. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39433. */
  39434. gamepadAngularSensibility: number;
  39435. /**
  39436. * Defines the gamepad move sensiblity.
  39437. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39438. */
  39439. gamepadMoveSensibility: number;
  39440. private _onGamepadConnectedObserver;
  39441. private _onGamepadDisconnectedObserver;
  39442. private _cameraTransform;
  39443. private _deltaTransform;
  39444. private _vector3;
  39445. private _vector2;
  39446. /**
  39447. * Attach the input controls to a specific dom element to get the input from.
  39448. * @param element Defines the element the controls should be listened from
  39449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39450. */
  39451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39452. /**
  39453. * Detach the current controls from the specified dom element.
  39454. * @param element Defines the element to stop listening the inputs from
  39455. */
  39456. detachControl(element: Nullable<HTMLElement>): void;
  39457. /**
  39458. * Update the current camera state depending on the inputs that have been used this frame.
  39459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39460. */
  39461. checkInputs(): void;
  39462. /**
  39463. * Gets the class name of the current intput.
  39464. * @returns the class name
  39465. */
  39466. getClassName(): string;
  39467. /**
  39468. * Get the friendly name associated with the input class.
  39469. * @returns the input friendly name
  39470. */
  39471. getSimpleName(): string;
  39472. }
  39473. }
  39474. declare module "babylonjs/Misc/virtualJoystick" {
  39475. import { Nullable } from "babylonjs/types";
  39476. import { Vector3 } from "babylonjs/Maths/math.vector";
  39477. /**
  39478. * Defines the potential axis of a Joystick
  39479. */
  39480. export enum JoystickAxis {
  39481. /** X axis */
  39482. X = 0,
  39483. /** Y axis */
  39484. Y = 1,
  39485. /** Z axis */
  39486. Z = 2
  39487. }
  39488. /**
  39489. * Class used to define virtual joystick (used in touch mode)
  39490. */
  39491. export class VirtualJoystick {
  39492. /**
  39493. * Gets or sets a boolean indicating that left and right values must be inverted
  39494. */
  39495. reverseLeftRight: boolean;
  39496. /**
  39497. * Gets or sets a boolean indicating that up and down values must be inverted
  39498. */
  39499. reverseUpDown: boolean;
  39500. /**
  39501. * Gets the offset value for the position (ie. the change of the position value)
  39502. */
  39503. deltaPosition: Vector3;
  39504. /**
  39505. * Gets a boolean indicating if the virtual joystick was pressed
  39506. */
  39507. pressed: boolean;
  39508. /**
  39509. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39510. */
  39511. static Canvas: Nullable<HTMLCanvasElement>;
  39512. private static _globalJoystickIndex;
  39513. private static vjCanvasContext;
  39514. private static vjCanvasWidth;
  39515. private static vjCanvasHeight;
  39516. private static halfWidth;
  39517. private _action;
  39518. private _axisTargetedByLeftAndRight;
  39519. private _axisTargetedByUpAndDown;
  39520. private _joystickSensibility;
  39521. private _inversedSensibility;
  39522. private _joystickPointerID;
  39523. private _joystickColor;
  39524. private _joystickPointerPos;
  39525. private _joystickPreviousPointerPos;
  39526. private _joystickPointerStartPos;
  39527. private _deltaJoystickVector;
  39528. private _leftJoystick;
  39529. private _touches;
  39530. private _onPointerDownHandlerRef;
  39531. private _onPointerMoveHandlerRef;
  39532. private _onPointerUpHandlerRef;
  39533. private _onResize;
  39534. /**
  39535. * Creates a new virtual joystick
  39536. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39537. */
  39538. constructor(leftJoystick?: boolean);
  39539. /**
  39540. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39541. * @param newJoystickSensibility defines the new sensibility
  39542. */
  39543. setJoystickSensibility(newJoystickSensibility: number): void;
  39544. private _onPointerDown;
  39545. private _onPointerMove;
  39546. private _onPointerUp;
  39547. /**
  39548. * Change the color of the virtual joystick
  39549. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39550. */
  39551. setJoystickColor(newColor: string): void;
  39552. /**
  39553. * Defines a callback to call when the joystick is touched
  39554. * @param action defines the callback
  39555. */
  39556. setActionOnTouch(action: () => any): void;
  39557. /**
  39558. * Defines which axis you'd like to control for left & right
  39559. * @param axis defines the axis to use
  39560. */
  39561. setAxisForLeftRight(axis: JoystickAxis): void;
  39562. /**
  39563. * Defines which axis you'd like to control for up & down
  39564. * @param axis defines the axis to use
  39565. */
  39566. setAxisForUpDown(axis: JoystickAxis): void;
  39567. private _drawVirtualJoystick;
  39568. /**
  39569. * Release internal HTML canvas
  39570. */
  39571. releaseCanvas(): void;
  39572. }
  39573. }
  39574. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39575. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39576. import { Nullable } from "babylonjs/types";
  39577. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39578. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39579. module "babylonjs/Cameras/freeCameraInputsManager" {
  39580. interface FreeCameraInputsManager {
  39581. /**
  39582. * Add virtual joystick input support to the input manager.
  39583. * @returns the current input manager
  39584. */
  39585. addVirtualJoystick(): FreeCameraInputsManager;
  39586. }
  39587. }
  39588. /**
  39589. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39591. */
  39592. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39593. /**
  39594. * Defines the camera the input is attached to.
  39595. */
  39596. camera: FreeCamera;
  39597. private _leftjoystick;
  39598. private _rightjoystick;
  39599. /**
  39600. * Gets the left stick of the virtual joystick.
  39601. * @returns The virtual Joystick
  39602. */
  39603. getLeftJoystick(): VirtualJoystick;
  39604. /**
  39605. * Gets the right stick of the virtual joystick.
  39606. * @returns The virtual Joystick
  39607. */
  39608. getRightJoystick(): VirtualJoystick;
  39609. /**
  39610. * Update the current camera state depending on the inputs that have been used this frame.
  39611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39612. */
  39613. checkInputs(): void;
  39614. /**
  39615. * Attach the input controls to a specific dom element to get the input from.
  39616. * @param element Defines the element the controls should be listened from
  39617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39618. */
  39619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39620. /**
  39621. * Detach the current controls from the specified dom element.
  39622. * @param element Defines the element to stop listening the inputs from
  39623. */
  39624. detachControl(element: Nullable<HTMLElement>): void;
  39625. /**
  39626. * Gets the class name of the current intput.
  39627. * @returns the class name
  39628. */
  39629. getClassName(): string;
  39630. /**
  39631. * Get the friendly name associated with the input class.
  39632. * @returns the input friendly name
  39633. */
  39634. getSimpleName(): string;
  39635. }
  39636. }
  39637. declare module "babylonjs/Cameras/Inputs/index" {
  39638. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39639. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39640. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39641. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39642. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39643. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39644. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39645. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39646. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39647. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39648. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39649. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39650. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39651. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39652. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39653. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39654. }
  39655. declare module "babylonjs/Cameras/touchCamera" {
  39656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39657. import { Scene } from "babylonjs/scene";
  39658. import { Vector3 } from "babylonjs/Maths/math.vector";
  39659. /**
  39660. * This represents a FPS type of camera controlled by touch.
  39661. * This is like a universal camera minus the Gamepad controls.
  39662. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39663. */
  39664. export class TouchCamera extends FreeCamera {
  39665. /**
  39666. * Defines the touch sensibility for rotation.
  39667. * The higher the faster.
  39668. */
  39669. touchAngularSensibility: number;
  39670. /**
  39671. * Defines the touch sensibility for move.
  39672. * The higher the faster.
  39673. */
  39674. touchMoveSensibility: number;
  39675. /**
  39676. * Instantiates a new touch camera.
  39677. * This represents a FPS type of camera controlled by touch.
  39678. * This is like a universal camera minus the Gamepad controls.
  39679. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39680. * @param name Define the name of the camera in the scene
  39681. * @param position Define the start position of the camera in the scene
  39682. * @param scene Define the scene the camera belongs to
  39683. */
  39684. constructor(name: string, position: Vector3, scene: Scene);
  39685. /**
  39686. * Gets the current object class name.
  39687. * @return the class name
  39688. */
  39689. getClassName(): string;
  39690. /** @hidden */
  39691. _setupInputs(): void;
  39692. }
  39693. }
  39694. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39695. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39696. import { Scene } from "babylonjs/scene";
  39697. import { Vector3 } from "babylonjs/Maths/math.vector";
  39698. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39699. import { Axis } from "babylonjs/Maths/math.axis";
  39700. /**
  39701. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39702. * being tilted forward or back and left or right.
  39703. */
  39704. export class DeviceOrientationCamera extends FreeCamera {
  39705. private _initialQuaternion;
  39706. private _quaternionCache;
  39707. private _tmpDragQuaternion;
  39708. private _disablePointerInputWhenUsingDeviceOrientation;
  39709. /**
  39710. * Creates a new device orientation camera
  39711. * @param name The name of the camera
  39712. * @param position The start position camera
  39713. * @param scene The scene the camera belongs to
  39714. */
  39715. constructor(name: string, position: Vector3, scene: Scene);
  39716. /**
  39717. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39718. */
  39719. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39720. private _dragFactor;
  39721. /**
  39722. * Enabled turning on the y axis when the orientation sensor is active
  39723. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39724. */
  39725. enableHorizontalDragging(dragFactor?: number): void;
  39726. /**
  39727. * Gets the current instance class name ("DeviceOrientationCamera").
  39728. * This helps avoiding instanceof at run time.
  39729. * @returns the class name
  39730. */
  39731. getClassName(): string;
  39732. /**
  39733. * @hidden
  39734. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39735. */
  39736. _checkInputs(): void;
  39737. /**
  39738. * Reset the camera to its default orientation on the specified axis only.
  39739. * @param axis The axis to reset
  39740. */
  39741. resetToCurrentRotation(axis?: Axis): void;
  39742. }
  39743. }
  39744. declare module "babylonjs/Gamepads/xboxGamepad" {
  39745. import { Observable } from "babylonjs/Misc/observable";
  39746. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39747. /**
  39748. * Defines supported buttons for XBox360 compatible gamepads
  39749. */
  39750. export enum Xbox360Button {
  39751. /** A */
  39752. A = 0,
  39753. /** B */
  39754. B = 1,
  39755. /** X */
  39756. X = 2,
  39757. /** Y */
  39758. Y = 3,
  39759. /** Start */
  39760. Start = 4,
  39761. /** Back */
  39762. Back = 5,
  39763. /** Left button */
  39764. LB = 6,
  39765. /** Right button */
  39766. RB = 7,
  39767. /** Left stick */
  39768. LeftStick = 8,
  39769. /** Right stick */
  39770. RightStick = 9
  39771. }
  39772. /** Defines values for XBox360 DPad */
  39773. export enum Xbox360Dpad {
  39774. /** Up */
  39775. Up = 0,
  39776. /** Down */
  39777. Down = 1,
  39778. /** Left */
  39779. Left = 2,
  39780. /** Right */
  39781. Right = 3
  39782. }
  39783. /**
  39784. * Defines a XBox360 gamepad
  39785. */
  39786. export class Xbox360Pad extends Gamepad {
  39787. private _leftTrigger;
  39788. private _rightTrigger;
  39789. private _onlefttriggerchanged;
  39790. private _onrighttriggerchanged;
  39791. private _onbuttondown;
  39792. private _onbuttonup;
  39793. private _ondpaddown;
  39794. private _ondpadup;
  39795. /** Observable raised when a button is pressed */
  39796. onButtonDownObservable: Observable<Xbox360Button>;
  39797. /** Observable raised when a button is released */
  39798. onButtonUpObservable: Observable<Xbox360Button>;
  39799. /** Observable raised when a pad is pressed */
  39800. onPadDownObservable: Observable<Xbox360Dpad>;
  39801. /** Observable raised when a pad is released */
  39802. onPadUpObservable: Observable<Xbox360Dpad>;
  39803. private _buttonA;
  39804. private _buttonB;
  39805. private _buttonX;
  39806. private _buttonY;
  39807. private _buttonBack;
  39808. private _buttonStart;
  39809. private _buttonLB;
  39810. private _buttonRB;
  39811. private _buttonLeftStick;
  39812. private _buttonRightStick;
  39813. private _dPadUp;
  39814. private _dPadDown;
  39815. private _dPadLeft;
  39816. private _dPadRight;
  39817. private _isXboxOnePad;
  39818. /**
  39819. * Creates a new XBox360 gamepad object
  39820. * @param id defines the id of this gamepad
  39821. * @param index defines its index
  39822. * @param gamepad defines the internal HTML gamepad object
  39823. * @param xboxOne defines if it is a XBox One gamepad
  39824. */
  39825. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39826. /**
  39827. * Defines the callback to call when left trigger is pressed
  39828. * @param callback defines the callback to use
  39829. */
  39830. onlefttriggerchanged(callback: (value: number) => void): void;
  39831. /**
  39832. * Defines the callback to call when right trigger is pressed
  39833. * @param callback defines the callback to use
  39834. */
  39835. onrighttriggerchanged(callback: (value: number) => void): void;
  39836. /**
  39837. * Gets the left trigger value
  39838. */
  39839. /**
  39840. * Sets the left trigger value
  39841. */
  39842. leftTrigger: number;
  39843. /**
  39844. * Gets the right trigger value
  39845. */
  39846. /**
  39847. * Sets the right trigger value
  39848. */
  39849. rightTrigger: number;
  39850. /**
  39851. * Defines the callback to call when a button is pressed
  39852. * @param callback defines the callback to use
  39853. */
  39854. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39855. /**
  39856. * Defines the callback to call when a button is released
  39857. * @param callback defines the callback to use
  39858. */
  39859. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39860. /**
  39861. * Defines the callback to call when a pad is pressed
  39862. * @param callback defines the callback to use
  39863. */
  39864. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39865. /**
  39866. * Defines the callback to call when a pad is released
  39867. * @param callback defines the callback to use
  39868. */
  39869. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39870. private _setButtonValue;
  39871. private _setDPadValue;
  39872. /**
  39873. * Gets the value of the `A` button
  39874. */
  39875. /**
  39876. * Sets the value of the `A` button
  39877. */
  39878. buttonA: number;
  39879. /**
  39880. * Gets the value of the `B` button
  39881. */
  39882. /**
  39883. * Sets the value of the `B` button
  39884. */
  39885. buttonB: number;
  39886. /**
  39887. * Gets the value of the `X` button
  39888. */
  39889. /**
  39890. * Sets the value of the `X` button
  39891. */
  39892. buttonX: number;
  39893. /**
  39894. * Gets the value of the `Y` button
  39895. */
  39896. /**
  39897. * Sets the value of the `Y` button
  39898. */
  39899. buttonY: number;
  39900. /**
  39901. * Gets the value of the `Start` button
  39902. */
  39903. /**
  39904. * Sets the value of the `Start` button
  39905. */
  39906. buttonStart: number;
  39907. /**
  39908. * Gets the value of the `Back` button
  39909. */
  39910. /**
  39911. * Sets the value of the `Back` button
  39912. */
  39913. buttonBack: number;
  39914. /**
  39915. * Gets the value of the `Left` button
  39916. */
  39917. /**
  39918. * Sets the value of the `Left` button
  39919. */
  39920. buttonLB: number;
  39921. /**
  39922. * Gets the value of the `Right` button
  39923. */
  39924. /**
  39925. * Sets the value of the `Right` button
  39926. */
  39927. buttonRB: number;
  39928. /**
  39929. * Gets the value of the Left joystick
  39930. */
  39931. /**
  39932. * Sets the value of the Left joystick
  39933. */
  39934. buttonLeftStick: number;
  39935. /**
  39936. * Gets the value of the Right joystick
  39937. */
  39938. /**
  39939. * Sets the value of the Right joystick
  39940. */
  39941. buttonRightStick: number;
  39942. /**
  39943. * Gets the value of D-pad up
  39944. */
  39945. /**
  39946. * Sets the value of D-pad up
  39947. */
  39948. dPadUp: number;
  39949. /**
  39950. * Gets the value of D-pad down
  39951. */
  39952. /**
  39953. * Sets the value of D-pad down
  39954. */
  39955. dPadDown: number;
  39956. /**
  39957. * Gets the value of D-pad left
  39958. */
  39959. /**
  39960. * Sets the value of D-pad left
  39961. */
  39962. dPadLeft: number;
  39963. /**
  39964. * Gets the value of D-pad right
  39965. */
  39966. /**
  39967. * Sets the value of D-pad right
  39968. */
  39969. dPadRight: number;
  39970. /**
  39971. * Force the gamepad to synchronize with device values
  39972. */
  39973. update(): void;
  39974. /**
  39975. * Disposes the gamepad
  39976. */
  39977. dispose(): void;
  39978. }
  39979. }
  39980. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39981. import { Observable } from "babylonjs/Misc/observable";
  39982. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39983. /**
  39984. * Defines supported buttons for DualShock compatible gamepads
  39985. */
  39986. export enum DualShockButton {
  39987. /** Cross */
  39988. Cross = 0,
  39989. /** Circle */
  39990. Circle = 1,
  39991. /** Square */
  39992. Square = 2,
  39993. /** Triangle */
  39994. Triangle = 3,
  39995. /** Options */
  39996. Options = 4,
  39997. /** Share */
  39998. Share = 5,
  39999. /** L1 */
  40000. L1 = 6,
  40001. /** R1 */
  40002. R1 = 7,
  40003. /** Left stick */
  40004. LeftStick = 8,
  40005. /** Right stick */
  40006. RightStick = 9
  40007. }
  40008. /** Defines values for DualShock DPad */
  40009. export enum DualShockDpad {
  40010. /** Up */
  40011. Up = 0,
  40012. /** Down */
  40013. Down = 1,
  40014. /** Left */
  40015. Left = 2,
  40016. /** Right */
  40017. Right = 3
  40018. }
  40019. /**
  40020. * Defines a DualShock gamepad
  40021. */
  40022. export class DualShockPad extends Gamepad {
  40023. private _leftTrigger;
  40024. private _rightTrigger;
  40025. private _onlefttriggerchanged;
  40026. private _onrighttriggerchanged;
  40027. private _onbuttondown;
  40028. private _onbuttonup;
  40029. private _ondpaddown;
  40030. private _ondpadup;
  40031. /** Observable raised when a button is pressed */
  40032. onButtonDownObservable: Observable<DualShockButton>;
  40033. /** Observable raised when a button is released */
  40034. onButtonUpObservable: Observable<DualShockButton>;
  40035. /** Observable raised when a pad is pressed */
  40036. onPadDownObservable: Observable<DualShockDpad>;
  40037. /** Observable raised when a pad is released */
  40038. onPadUpObservable: Observable<DualShockDpad>;
  40039. private _buttonCross;
  40040. private _buttonCircle;
  40041. private _buttonSquare;
  40042. private _buttonTriangle;
  40043. private _buttonShare;
  40044. private _buttonOptions;
  40045. private _buttonL1;
  40046. private _buttonR1;
  40047. private _buttonLeftStick;
  40048. private _buttonRightStick;
  40049. private _dPadUp;
  40050. private _dPadDown;
  40051. private _dPadLeft;
  40052. private _dPadRight;
  40053. /**
  40054. * Creates a new DualShock gamepad object
  40055. * @param id defines the id of this gamepad
  40056. * @param index defines its index
  40057. * @param gamepad defines the internal HTML gamepad object
  40058. */
  40059. constructor(id: string, index: number, gamepad: any);
  40060. /**
  40061. * Defines the callback to call when left trigger is pressed
  40062. * @param callback defines the callback to use
  40063. */
  40064. onlefttriggerchanged(callback: (value: number) => void): void;
  40065. /**
  40066. * Defines the callback to call when right trigger is pressed
  40067. * @param callback defines the callback to use
  40068. */
  40069. onrighttriggerchanged(callback: (value: number) => void): void;
  40070. /**
  40071. * Gets the left trigger value
  40072. */
  40073. /**
  40074. * Sets the left trigger value
  40075. */
  40076. leftTrigger: number;
  40077. /**
  40078. * Gets the right trigger value
  40079. */
  40080. /**
  40081. * Sets the right trigger value
  40082. */
  40083. rightTrigger: number;
  40084. /**
  40085. * Defines the callback to call when a button is pressed
  40086. * @param callback defines the callback to use
  40087. */
  40088. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40089. /**
  40090. * Defines the callback to call when a button is released
  40091. * @param callback defines the callback to use
  40092. */
  40093. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40094. /**
  40095. * Defines the callback to call when a pad is pressed
  40096. * @param callback defines the callback to use
  40097. */
  40098. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40099. /**
  40100. * Defines the callback to call when a pad is released
  40101. * @param callback defines the callback to use
  40102. */
  40103. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40104. private _setButtonValue;
  40105. private _setDPadValue;
  40106. /**
  40107. * Gets the value of the `Cross` button
  40108. */
  40109. /**
  40110. * Sets the value of the `Cross` button
  40111. */
  40112. buttonCross: number;
  40113. /**
  40114. * Gets the value of the `Circle` button
  40115. */
  40116. /**
  40117. * Sets the value of the `Circle` button
  40118. */
  40119. buttonCircle: number;
  40120. /**
  40121. * Gets the value of the `Square` button
  40122. */
  40123. /**
  40124. * Sets the value of the `Square` button
  40125. */
  40126. buttonSquare: number;
  40127. /**
  40128. * Gets the value of the `Triangle` button
  40129. */
  40130. /**
  40131. * Sets the value of the `Triangle` button
  40132. */
  40133. buttonTriangle: number;
  40134. /**
  40135. * Gets the value of the `Options` button
  40136. */
  40137. /**
  40138. * Sets the value of the `Options` button
  40139. */
  40140. buttonOptions: number;
  40141. /**
  40142. * Gets the value of the `Share` button
  40143. */
  40144. /**
  40145. * Sets the value of the `Share` button
  40146. */
  40147. buttonShare: number;
  40148. /**
  40149. * Gets the value of the `L1` button
  40150. */
  40151. /**
  40152. * Sets the value of the `L1` button
  40153. */
  40154. buttonL1: number;
  40155. /**
  40156. * Gets the value of the `R1` button
  40157. */
  40158. /**
  40159. * Sets the value of the `R1` button
  40160. */
  40161. buttonR1: number;
  40162. /**
  40163. * Gets the value of the Left joystick
  40164. */
  40165. /**
  40166. * Sets the value of the Left joystick
  40167. */
  40168. buttonLeftStick: number;
  40169. /**
  40170. * Gets the value of the Right joystick
  40171. */
  40172. /**
  40173. * Sets the value of the Right joystick
  40174. */
  40175. buttonRightStick: number;
  40176. /**
  40177. * Gets the value of D-pad up
  40178. */
  40179. /**
  40180. * Sets the value of D-pad up
  40181. */
  40182. dPadUp: number;
  40183. /**
  40184. * Gets the value of D-pad down
  40185. */
  40186. /**
  40187. * Sets the value of D-pad down
  40188. */
  40189. dPadDown: number;
  40190. /**
  40191. * Gets the value of D-pad left
  40192. */
  40193. /**
  40194. * Sets the value of D-pad left
  40195. */
  40196. dPadLeft: number;
  40197. /**
  40198. * Gets the value of D-pad right
  40199. */
  40200. /**
  40201. * Sets the value of D-pad right
  40202. */
  40203. dPadRight: number;
  40204. /**
  40205. * Force the gamepad to synchronize with device values
  40206. */
  40207. update(): void;
  40208. /**
  40209. * Disposes the gamepad
  40210. */
  40211. dispose(): void;
  40212. }
  40213. }
  40214. declare module "babylonjs/Gamepads/gamepadManager" {
  40215. import { Observable } from "babylonjs/Misc/observable";
  40216. import { Nullable } from "babylonjs/types";
  40217. import { Scene } from "babylonjs/scene";
  40218. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40219. /**
  40220. * Manager for handling gamepads
  40221. */
  40222. export class GamepadManager {
  40223. private _scene?;
  40224. private _babylonGamepads;
  40225. private _oneGamepadConnected;
  40226. /** @hidden */
  40227. _isMonitoring: boolean;
  40228. private _gamepadEventSupported;
  40229. private _gamepadSupport;
  40230. /**
  40231. * observable to be triggered when the gamepad controller has been connected
  40232. */
  40233. onGamepadConnectedObservable: Observable<Gamepad>;
  40234. /**
  40235. * observable to be triggered when the gamepad controller has been disconnected
  40236. */
  40237. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40238. private _onGamepadConnectedEvent;
  40239. private _onGamepadDisconnectedEvent;
  40240. /**
  40241. * Initializes the gamepad manager
  40242. * @param _scene BabylonJS scene
  40243. */
  40244. constructor(_scene?: Scene | undefined);
  40245. /**
  40246. * The gamepads in the game pad manager
  40247. */
  40248. readonly gamepads: Gamepad[];
  40249. /**
  40250. * Get the gamepad controllers based on type
  40251. * @param type The type of gamepad controller
  40252. * @returns Nullable gamepad
  40253. */
  40254. getGamepadByType(type?: number): Nullable<Gamepad>;
  40255. /**
  40256. * Disposes the gamepad manager
  40257. */
  40258. dispose(): void;
  40259. private _addNewGamepad;
  40260. private _startMonitoringGamepads;
  40261. private _stopMonitoringGamepads;
  40262. /** @hidden */
  40263. _checkGamepadsStatus(): void;
  40264. private _updateGamepadObjects;
  40265. }
  40266. }
  40267. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40268. import { Nullable } from "babylonjs/types";
  40269. import { Scene } from "babylonjs/scene";
  40270. import { ISceneComponent } from "babylonjs/sceneComponent";
  40271. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40272. module "babylonjs/scene" {
  40273. interface Scene {
  40274. /** @hidden */
  40275. _gamepadManager: Nullable<GamepadManager>;
  40276. /**
  40277. * Gets the gamepad manager associated with the scene
  40278. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40279. */
  40280. gamepadManager: GamepadManager;
  40281. }
  40282. }
  40283. module "babylonjs/Cameras/freeCameraInputsManager" {
  40284. /**
  40285. * Interface representing a free camera inputs manager
  40286. */
  40287. interface FreeCameraInputsManager {
  40288. /**
  40289. * Adds gamepad input support to the FreeCameraInputsManager.
  40290. * @returns the FreeCameraInputsManager
  40291. */
  40292. addGamepad(): FreeCameraInputsManager;
  40293. }
  40294. }
  40295. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40296. /**
  40297. * Interface representing an arc rotate camera inputs manager
  40298. */
  40299. interface ArcRotateCameraInputsManager {
  40300. /**
  40301. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40302. * @returns the camera inputs manager
  40303. */
  40304. addGamepad(): ArcRotateCameraInputsManager;
  40305. }
  40306. }
  40307. /**
  40308. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40309. */
  40310. export class GamepadSystemSceneComponent implements ISceneComponent {
  40311. /**
  40312. * The component name helpfull to identify the component in the list of scene components.
  40313. */
  40314. readonly name: string;
  40315. /**
  40316. * The scene the component belongs to.
  40317. */
  40318. scene: Scene;
  40319. /**
  40320. * Creates a new instance of the component for the given scene
  40321. * @param scene Defines the scene to register the component in
  40322. */
  40323. constructor(scene: Scene);
  40324. /**
  40325. * Registers the component in a given scene
  40326. */
  40327. register(): void;
  40328. /**
  40329. * Rebuilds the elements related to this component in case of
  40330. * context lost for instance.
  40331. */
  40332. rebuild(): void;
  40333. /**
  40334. * Disposes the component and the associated ressources
  40335. */
  40336. dispose(): void;
  40337. private _beforeCameraUpdate;
  40338. }
  40339. }
  40340. declare module "babylonjs/Cameras/universalCamera" {
  40341. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40342. import { Scene } from "babylonjs/scene";
  40343. import { Vector3 } from "babylonjs/Maths/math.vector";
  40344. import "babylonjs/Gamepads/gamepadSceneComponent";
  40345. /**
  40346. * 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,
  40347. * which still works and will still be found in many Playgrounds.
  40348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40349. */
  40350. export class UniversalCamera extends TouchCamera {
  40351. /**
  40352. * Defines the gamepad rotation sensiblity.
  40353. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40354. */
  40355. gamepadAngularSensibility: number;
  40356. /**
  40357. * Defines the gamepad move sensiblity.
  40358. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40359. */
  40360. gamepadMoveSensibility: number;
  40361. /**
  40362. * 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,
  40363. * which still works and will still be found in many Playgrounds.
  40364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40365. * @param name Define the name of the camera in the scene
  40366. * @param position Define the start position of the camera in the scene
  40367. * @param scene Define the scene the camera belongs to
  40368. */
  40369. constructor(name: string, position: Vector3, scene: Scene);
  40370. /**
  40371. * Gets the current object class name.
  40372. * @return the class name
  40373. */
  40374. getClassName(): string;
  40375. }
  40376. }
  40377. declare module "babylonjs/Cameras/gamepadCamera" {
  40378. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40379. import { Scene } from "babylonjs/scene";
  40380. import { Vector3 } from "babylonjs/Maths/math.vector";
  40381. /**
  40382. * This represents a FPS type of camera. This is only here for back compat purpose.
  40383. * Please use the UniversalCamera instead as both are identical.
  40384. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40385. */
  40386. export class GamepadCamera extends UniversalCamera {
  40387. /**
  40388. * Instantiates a new Gamepad Camera
  40389. * This represents a FPS type of camera. This is only here for back compat purpose.
  40390. * Please use the UniversalCamera instead as both are identical.
  40391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40392. * @param name Define the name of the camera in the scene
  40393. * @param position Define the start position of the camera in the scene
  40394. * @param scene Define the scene the camera belongs to
  40395. */
  40396. constructor(name: string, position: Vector3, scene: Scene);
  40397. /**
  40398. * Gets the current object class name.
  40399. * @return the class name
  40400. */
  40401. getClassName(): string;
  40402. }
  40403. }
  40404. declare module "babylonjs/Shaders/pass.fragment" {
  40405. /** @hidden */
  40406. export var passPixelShader: {
  40407. name: string;
  40408. shader: string;
  40409. };
  40410. }
  40411. declare module "babylonjs/Shaders/passCube.fragment" {
  40412. /** @hidden */
  40413. export var passCubePixelShader: {
  40414. name: string;
  40415. shader: string;
  40416. };
  40417. }
  40418. declare module "babylonjs/PostProcesses/passPostProcess" {
  40419. import { Nullable } from "babylonjs/types";
  40420. import { Camera } from "babylonjs/Cameras/camera";
  40421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40422. import { Engine } from "babylonjs/Engines/engine";
  40423. import "babylonjs/Shaders/pass.fragment";
  40424. import "babylonjs/Shaders/passCube.fragment";
  40425. /**
  40426. * PassPostProcess which produces an output the same as it's input
  40427. */
  40428. export class PassPostProcess extends PostProcess {
  40429. /**
  40430. * Creates the PassPostProcess
  40431. * @param name The name of the effect.
  40432. * @param options The required width/height ratio to downsize to before computing the render pass.
  40433. * @param camera The camera to apply the render pass to.
  40434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40435. * @param engine The engine which the post process will be applied. (default: current engine)
  40436. * @param reusable If the post process can be reused on the same frame. (default: false)
  40437. * @param textureType The type of texture to be used when performing the post processing.
  40438. * @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)
  40439. */
  40440. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40441. }
  40442. /**
  40443. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40444. */
  40445. export class PassCubePostProcess extends PostProcess {
  40446. private _face;
  40447. /**
  40448. * Gets or sets the cube face to display.
  40449. * * 0 is +X
  40450. * * 1 is -X
  40451. * * 2 is +Y
  40452. * * 3 is -Y
  40453. * * 4 is +Z
  40454. * * 5 is -Z
  40455. */
  40456. face: number;
  40457. /**
  40458. * Creates the PassCubePostProcess
  40459. * @param name The name of the effect.
  40460. * @param options The required width/height ratio to downsize to before computing the render pass.
  40461. * @param camera The camera to apply the render pass to.
  40462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40463. * @param engine The engine which the post process will be applied. (default: current engine)
  40464. * @param reusable If the post process can be reused on the same frame. (default: false)
  40465. * @param textureType The type of texture to be used when performing the post processing.
  40466. * @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)
  40467. */
  40468. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40469. }
  40470. }
  40471. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40472. /** @hidden */
  40473. export var anaglyphPixelShader: {
  40474. name: string;
  40475. shader: string;
  40476. };
  40477. }
  40478. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40479. import { Engine } from "babylonjs/Engines/engine";
  40480. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40481. import { Camera } from "babylonjs/Cameras/camera";
  40482. import "babylonjs/Shaders/anaglyph.fragment";
  40483. /**
  40484. * Postprocess used to generate anaglyphic rendering
  40485. */
  40486. export class AnaglyphPostProcess extends PostProcess {
  40487. private _passedProcess;
  40488. /**
  40489. * Creates a new AnaglyphPostProcess
  40490. * @param name defines postprocess name
  40491. * @param options defines creation options or target ratio scale
  40492. * @param rigCameras defines cameras using this postprocess
  40493. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40494. * @param engine defines hosting engine
  40495. * @param reusable defines if the postprocess will be reused multiple times per frame
  40496. */
  40497. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40498. }
  40499. }
  40500. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40502. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40503. import { Scene } from "babylonjs/scene";
  40504. import { Vector3 } from "babylonjs/Maths/math.vector";
  40505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40506. /**
  40507. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40509. */
  40510. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40511. /**
  40512. * Creates a new AnaglyphArcRotateCamera
  40513. * @param name defines camera name
  40514. * @param alpha defines alpha angle (in radians)
  40515. * @param beta defines beta angle (in radians)
  40516. * @param radius defines radius
  40517. * @param target defines camera target
  40518. * @param interaxialDistance defines distance between each color axis
  40519. * @param scene defines the hosting scene
  40520. */
  40521. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40522. /**
  40523. * Gets camera class name
  40524. * @returns AnaglyphArcRotateCamera
  40525. */
  40526. getClassName(): string;
  40527. }
  40528. }
  40529. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40531. import { Scene } from "babylonjs/scene";
  40532. import { Vector3 } from "babylonjs/Maths/math.vector";
  40533. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40534. /**
  40535. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40536. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40537. */
  40538. export class AnaglyphFreeCamera extends FreeCamera {
  40539. /**
  40540. * Creates a new AnaglyphFreeCamera
  40541. * @param name defines camera name
  40542. * @param position defines initial position
  40543. * @param interaxialDistance defines distance between each color axis
  40544. * @param scene defines the hosting scene
  40545. */
  40546. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40547. /**
  40548. * Gets camera class name
  40549. * @returns AnaglyphFreeCamera
  40550. */
  40551. getClassName(): string;
  40552. }
  40553. }
  40554. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40555. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40556. import { Scene } from "babylonjs/scene";
  40557. import { Vector3 } from "babylonjs/Maths/math.vector";
  40558. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40559. /**
  40560. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40561. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40562. */
  40563. export class AnaglyphGamepadCamera extends GamepadCamera {
  40564. /**
  40565. * Creates a new AnaglyphGamepadCamera
  40566. * @param name defines camera name
  40567. * @param position defines initial position
  40568. * @param interaxialDistance defines distance between each color axis
  40569. * @param scene defines the hosting scene
  40570. */
  40571. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40572. /**
  40573. * Gets camera class name
  40574. * @returns AnaglyphGamepadCamera
  40575. */
  40576. getClassName(): string;
  40577. }
  40578. }
  40579. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40580. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40581. import { Scene } from "babylonjs/scene";
  40582. import { Vector3 } from "babylonjs/Maths/math.vector";
  40583. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40584. /**
  40585. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40586. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40587. */
  40588. export class AnaglyphUniversalCamera extends UniversalCamera {
  40589. /**
  40590. * Creates a new AnaglyphUniversalCamera
  40591. * @param name defines camera name
  40592. * @param position defines initial position
  40593. * @param interaxialDistance defines distance between each color axis
  40594. * @param scene defines the hosting scene
  40595. */
  40596. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40597. /**
  40598. * Gets camera class name
  40599. * @returns AnaglyphUniversalCamera
  40600. */
  40601. getClassName(): string;
  40602. }
  40603. }
  40604. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40605. /** @hidden */
  40606. export var stereoscopicInterlacePixelShader: {
  40607. name: string;
  40608. shader: string;
  40609. };
  40610. }
  40611. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40612. import { Camera } from "babylonjs/Cameras/camera";
  40613. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40614. import { Engine } from "babylonjs/Engines/engine";
  40615. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40616. /**
  40617. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40618. */
  40619. export class StereoscopicInterlacePostProcess extends PostProcess {
  40620. private _stepSize;
  40621. private _passedProcess;
  40622. /**
  40623. * Initializes a StereoscopicInterlacePostProcess
  40624. * @param name The name of the effect.
  40625. * @param rigCameras The rig cameras to be appled to the post process
  40626. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40628. * @param engine The engine which the post process will be applied. (default: current engine)
  40629. * @param reusable If the post process can be reused on the same frame. (default: false)
  40630. */
  40631. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40632. }
  40633. }
  40634. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40635. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40636. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40637. import { Scene } from "babylonjs/scene";
  40638. import { Vector3 } from "babylonjs/Maths/math.vector";
  40639. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40640. /**
  40641. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40642. * @see http://doc.babylonjs.com/features/cameras
  40643. */
  40644. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40645. /**
  40646. * Creates a new StereoscopicArcRotateCamera
  40647. * @param name defines camera name
  40648. * @param alpha defines alpha angle (in radians)
  40649. * @param beta defines beta angle (in radians)
  40650. * @param radius defines radius
  40651. * @param target defines camera target
  40652. * @param interaxialDistance defines distance between each color axis
  40653. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40654. * @param scene defines the hosting scene
  40655. */
  40656. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40657. /**
  40658. * Gets camera class name
  40659. * @returns StereoscopicArcRotateCamera
  40660. */
  40661. getClassName(): string;
  40662. }
  40663. }
  40664. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40665. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40666. import { Scene } from "babylonjs/scene";
  40667. import { Vector3 } from "babylonjs/Maths/math.vector";
  40668. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40669. /**
  40670. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40671. * @see http://doc.babylonjs.com/features/cameras
  40672. */
  40673. export class StereoscopicFreeCamera extends FreeCamera {
  40674. /**
  40675. * Creates a new StereoscopicFreeCamera
  40676. * @param name defines camera name
  40677. * @param position defines initial position
  40678. * @param interaxialDistance defines distance between each color axis
  40679. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40680. * @param scene defines the hosting scene
  40681. */
  40682. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40683. /**
  40684. * Gets camera class name
  40685. * @returns StereoscopicFreeCamera
  40686. */
  40687. getClassName(): string;
  40688. }
  40689. }
  40690. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40691. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40692. import { Scene } from "babylonjs/scene";
  40693. import { Vector3 } from "babylonjs/Maths/math.vector";
  40694. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40695. /**
  40696. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40697. * @see http://doc.babylonjs.com/features/cameras
  40698. */
  40699. export class StereoscopicGamepadCamera extends GamepadCamera {
  40700. /**
  40701. * Creates a new StereoscopicGamepadCamera
  40702. * @param name defines camera name
  40703. * @param position defines initial position
  40704. * @param interaxialDistance defines distance between each color axis
  40705. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40706. * @param scene defines the hosting scene
  40707. */
  40708. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40709. /**
  40710. * Gets camera class name
  40711. * @returns StereoscopicGamepadCamera
  40712. */
  40713. getClassName(): string;
  40714. }
  40715. }
  40716. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40717. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40718. import { Scene } from "babylonjs/scene";
  40719. import { Vector3 } from "babylonjs/Maths/math.vector";
  40720. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40721. /**
  40722. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40723. * @see http://doc.babylonjs.com/features/cameras
  40724. */
  40725. export class StereoscopicUniversalCamera extends UniversalCamera {
  40726. /**
  40727. * Creates a new StereoscopicUniversalCamera
  40728. * @param name defines camera name
  40729. * @param position defines initial position
  40730. * @param interaxialDistance defines distance between each color axis
  40731. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40732. * @param scene defines the hosting scene
  40733. */
  40734. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40735. /**
  40736. * Gets camera class name
  40737. * @returns StereoscopicUniversalCamera
  40738. */
  40739. getClassName(): string;
  40740. }
  40741. }
  40742. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40743. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40744. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40745. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40746. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40747. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40748. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40749. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40750. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40751. }
  40752. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40753. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40754. import { Scene } from "babylonjs/scene";
  40755. import { Vector3 } from "babylonjs/Maths/math.vector";
  40756. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40757. /**
  40758. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40759. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40760. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40761. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40762. */
  40763. export class VirtualJoysticksCamera extends FreeCamera {
  40764. /**
  40765. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40766. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40767. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40768. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40769. * @param name Define the name of the camera in the scene
  40770. * @param position Define the start position of the camera in the scene
  40771. * @param scene Define the scene the camera belongs to
  40772. */
  40773. constructor(name: string, position: Vector3, scene: Scene);
  40774. /**
  40775. * Gets the current object class name.
  40776. * @return the class name
  40777. */
  40778. getClassName(): string;
  40779. }
  40780. }
  40781. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40782. import { Matrix } from "babylonjs/Maths/math.vector";
  40783. /**
  40784. * This represents all the required metrics to create a VR camera.
  40785. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40786. */
  40787. export class VRCameraMetrics {
  40788. /**
  40789. * Define the horizontal resolution off the screen.
  40790. */
  40791. hResolution: number;
  40792. /**
  40793. * Define the vertical resolution off the screen.
  40794. */
  40795. vResolution: number;
  40796. /**
  40797. * Define the horizontal screen size.
  40798. */
  40799. hScreenSize: number;
  40800. /**
  40801. * Define the vertical screen size.
  40802. */
  40803. vScreenSize: number;
  40804. /**
  40805. * Define the vertical screen center position.
  40806. */
  40807. vScreenCenter: number;
  40808. /**
  40809. * Define the distance of the eyes to the screen.
  40810. */
  40811. eyeToScreenDistance: number;
  40812. /**
  40813. * Define the distance between both lenses
  40814. */
  40815. lensSeparationDistance: number;
  40816. /**
  40817. * Define the distance between both viewer's eyes.
  40818. */
  40819. interpupillaryDistance: number;
  40820. /**
  40821. * Define the distortion factor of the VR postprocess.
  40822. * Please, touch with care.
  40823. */
  40824. distortionK: number[];
  40825. /**
  40826. * Define the chromatic aberration correction factors for the VR post process.
  40827. */
  40828. chromaAbCorrection: number[];
  40829. /**
  40830. * Define the scale factor of the post process.
  40831. * The smaller the better but the slower.
  40832. */
  40833. postProcessScaleFactor: number;
  40834. /**
  40835. * Define an offset for the lens center.
  40836. */
  40837. lensCenterOffset: number;
  40838. /**
  40839. * Define if the current vr camera should compensate the distortion of the lense or not.
  40840. */
  40841. compensateDistortion: boolean;
  40842. /**
  40843. * Defines if multiview should be enabled when rendering (Default: false)
  40844. */
  40845. multiviewEnabled: boolean;
  40846. /**
  40847. * Gets the rendering aspect ratio based on the provided resolutions.
  40848. */
  40849. readonly aspectRatio: number;
  40850. /**
  40851. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40852. */
  40853. readonly aspectRatioFov: number;
  40854. /**
  40855. * @hidden
  40856. */
  40857. readonly leftHMatrix: Matrix;
  40858. /**
  40859. * @hidden
  40860. */
  40861. readonly rightHMatrix: Matrix;
  40862. /**
  40863. * @hidden
  40864. */
  40865. readonly leftPreViewMatrix: Matrix;
  40866. /**
  40867. * @hidden
  40868. */
  40869. readonly rightPreViewMatrix: Matrix;
  40870. /**
  40871. * Get the default VRMetrics based on the most generic setup.
  40872. * @returns the default vr metrics
  40873. */
  40874. static GetDefault(): VRCameraMetrics;
  40875. }
  40876. }
  40877. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40878. /** @hidden */
  40879. export var vrDistortionCorrectionPixelShader: {
  40880. name: string;
  40881. shader: string;
  40882. };
  40883. }
  40884. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40885. import { Camera } from "babylonjs/Cameras/camera";
  40886. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40888. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40889. /**
  40890. * VRDistortionCorrectionPostProcess used for mobile VR
  40891. */
  40892. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40893. private _isRightEye;
  40894. private _distortionFactors;
  40895. private _postProcessScaleFactor;
  40896. private _lensCenterOffset;
  40897. private _scaleIn;
  40898. private _scaleFactor;
  40899. private _lensCenter;
  40900. /**
  40901. * Initializes the VRDistortionCorrectionPostProcess
  40902. * @param name The name of the effect.
  40903. * @param camera The camera to apply the render pass to.
  40904. * @param isRightEye If this is for the right eye distortion
  40905. * @param vrMetrics All the required metrics for the VR camera
  40906. */
  40907. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40908. }
  40909. }
  40910. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40911. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40912. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40913. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40914. import { Scene } from "babylonjs/scene";
  40915. import { Vector3 } from "babylonjs/Maths/math.vector";
  40916. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40917. import "babylonjs/Cameras/RigModes/vrRigMode";
  40918. /**
  40919. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40920. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40921. */
  40922. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40923. /**
  40924. * Creates a new VRDeviceOrientationArcRotateCamera
  40925. * @param name defines camera name
  40926. * @param alpha defines the camera rotation along the logitudinal axis
  40927. * @param beta defines the camera rotation along the latitudinal axis
  40928. * @param radius defines the camera distance from its target
  40929. * @param target defines the camera target
  40930. * @param scene defines the scene the camera belongs to
  40931. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40932. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40933. */
  40934. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40935. /**
  40936. * Gets camera class name
  40937. * @returns VRDeviceOrientationArcRotateCamera
  40938. */
  40939. getClassName(): string;
  40940. }
  40941. }
  40942. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40943. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40944. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Vector3 } from "babylonjs/Maths/math.vector";
  40947. import "babylonjs/Cameras/RigModes/vrRigMode";
  40948. /**
  40949. * Camera used to simulate VR rendering (based on FreeCamera)
  40950. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40951. */
  40952. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40953. /**
  40954. * Creates a new VRDeviceOrientationFreeCamera
  40955. * @param name defines camera name
  40956. * @param position defines the start position of the camera
  40957. * @param scene defines the scene the camera belongs to
  40958. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40959. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40960. */
  40961. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40962. /**
  40963. * Gets camera class name
  40964. * @returns VRDeviceOrientationFreeCamera
  40965. */
  40966. getClassName(): string;
  40967. }
  40968. }
  40969. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40970. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40971. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40972. import { Scene } from "babylonjs/scene";
  40973. import { Vector3 } from "babylonjs/Maths/math.vector";
  40974. import "babylonjs/Gamepads/gamepadSceneComponent";
  40975. /**
  40976. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40977. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40978. */
  40979. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40980. /**
  40981. * Creates a new VRDeviceOrientationGamepadCamera
  40982. * @param name defines camera name
  40983. * @param position defines the start position of the camera
  40984. * @param scene defines the scene the camera belongs to
  40985. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40986. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40987. */
  40988. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40989. /**
  40990. * Gets camera class name
  40991. * @returns VRDeviceOrientationGamepadCamera
  40992. */
  40993. getClassName(): string;
  40994. }
  40995. }
  40996. declare module "babylonjs/Materials/pushMaterial" {
  40997. import { Nullable } from "babylonjs/types";
  40998. import { Scene } from "babylonjs/scene";
  40999. import { Matrix } from "babylonjs/Maths/math.vector";
  41000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41001. import { Mesh } from "babylonjs/Meshes/mesh";
  41002. import { Material } from "babylonjs/Materials/material";
  41003. import { Effect } from "babylonjs/Materials/effect";
  41004. /**
  41005. * Base class of materials working in push mode in babylon JS
  41006. * @hidden
  41007. */
  41008. export class PushMaterial extends Material {
  41009. protected _activeEffect: Effect;
  41010. protected _normalMatrix: Matrix;
  41011. /**
  41012. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41013. * This means that the material can keep using a previous shader while a new one is being compiled.
  41014. * This is mostly used when shader parallel compilation is supported (true by default)
  41015. */
  41016. allowShaderHotSwapping: boolean;
  41017. constructor(name: string, scene: Scene);
  41018. getEffect(): Effect;
  41019. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41020. /**
  41021. * Binds the given world matrix to the active effect
  41022. *
  41023. * @param world the matrix to bind
  41024. */
  41025. bindOnlyWorldMatrix(world: Matrix): void;
  41026. /**
  41027. * Binds the given normal matrix to the active effect
  41028. *
  41029. * @param normalMatrix the matrix to bind
  41030. */
  41031. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41032. bind(world: Matrix, mesh?: Mesh): void;
  41033. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41034. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41035. }
  41036. }
  41037. declare module "babylonjs/Materials/materialFlags" {
  41038. /**
  41039. * This groups all the flags used to control the materials channel.
  41040. */
  41041. export class MaterialFlags {
  41042. private static _DiffuseTextureEnabled;
  41043. /**
  41044. * Are diffuse textures enabled in the application.
  41045. */
  41046. static DiffuseTextureEnabled: boolean;
  41047. private static _AmbientTextureEnabled;
  41048. /**
  41049. * Are ambient textures enabled in the application.
  41050. */
  41051. static AmbientTextureEnabled: boolean;
  41052. private static _OpacityTextureEnabled;
  41053. /**
  41054. * Are opacity textures enabled in the application.
  41055. */
  41056. static OpacityTextureEnabled: boolean;
  41057. private static _ReflectionTextureEnabled;
  41058. /**
  41059. * Are reflection textures enabled in the application.
  41060. */
  41061. static ReflectionTextureEnabled: boolean;
  41062. private static _EmissiveTextureEnabled;
  41063. /**
  41064. * Are emissive textures enabled in the application.
  41065. */
  41066. static EmissiveTextureEnabled: boolean;
  41067. private static _SpecularTextureEnabled;
  41068. /**
  41069. * Are specular textures enabled in the application.
  41070. */
  41071. static SpecularTextureEnabled: boolean;
  41072. private static _BumpTextureEnabled;
  41073. /**
  41074. * Are bump textures enabled in the application.
  41075. */
  41076. static BumpTextureEnabled: boolean;
  41077. private static _LightmapTextureEnabled;
  41078. /**
  41079. * Are lightmap textures enabled in the application.
  41080. */
  41081. static LightmapTextureEnabled: boolean;
  41082. private static _RefractionTextureEnabled;
  41083. /**
  41084. * Are refraction textures enabled in the application.
  41085. */
  41086. static RefractionTextureEnabled: boolean;
  41087. private static _ColorGradingTextureEnabled;
  41088. /**
  41089. * Are color grading textures enabled in the application.
  41090. */
  41091. static ColorGradingTextureEnabled: boolean;
  41092. private static _FresnelEnabled;
  41093. /**
  41094. * Are fresnels enabled in the application.
  41095. */
  41096. static FresnelEnabled: boolean;
  41097. private static _ClearCoatTextureEnabled;
  41098. /**
  41099. * Are clear coat textures enabled in the application.
  41100. */
  41101. static ClearCoatTextureEnabled: boolean;
  41102. private static _ClearCoatBumpTextureEnabled;
  41103. /**
  41104. * Are clear coat bump textures enabled in the application.
  41105. */
  41106. static ClearCoatBumpTextureEnabled: boolean;
  41107. private static _ClearCoatTintTextureEnabled;
  41108. /**
  41109. * Are clear coat tint textures enabled in the application.
  41110. */
  41111. static ClearCoatTintTextureEnabled: boolean;
  41112. private static _SheenTextureEnabled;
  41113. /**
  41114. * Are sheen textures enabled in the application.
  41115. */
  41116. static SheenTextureEnabled: boolean;
  41117. private static _AnisotropicTextureEnabled;
  41118. /**
  41119. * Are anisotropic textures enabled in the application.
  41120. */
  41121. static AnisotropicTextureEnabled: boolean;
  41122. private static _ThicknessTextureEnabled;
  41123. /**
  41124. * Are thickness textures enabled in the application.
  41125. */
  41126. static ThicknessTextureEnabled: boolean;
  41127. }
  41128. }
  41129. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41130. /** @hidden */
  41131. export var defaultFragmentDeclaration: {
  41132. name: string;
  41133. shader: string;
  41134. };
  41135. }
  41136. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41137. /** @hidden */
  41138. export var defaultUboDeclaration: {
  41139. name: string;
  41140. shader: string;
  41141. };
  41142. }
  41143. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41144. /** @hidden */
  41145. export var lightFragmentDeclaration: {
  41146. name: string;
  41147. shader: string;
  41148. };
  41149. }
  41150. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41151. /** @hidden */
  41152. export var lightUboDeclaration: {
  41153. name: string;
  41154. shader: string;
  41155. };
  41156. }
  41157. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41158. /** @hidden */
  41159. export var lightsFragmentFunctions: {
  41160. name: string;
  41161. shader: string;
  41162. };
  41163. }
  41164. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41165. /** @hidden */
  41166. export var shadowsFragmentFunctions: {
  41167. name: string;
  41168. shader: string;
  41169. };
  41170. }
  41171. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41172. /** @hidden */
  41173. export var fresnelFunction: {
  41174. name: string;
  41175. shader: string;
  41176. };
  41177. }
  41178. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41179. /** @hidden */
  41180. export var reflectionFunction: {
  41181. name: string;
  41182. shader: string;
  41183. };
  41184. }
  41185. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41186. /** @hidden */
  41187. export var bumpFragmentFunctions: {
  41188. name: string;
  41189. shader: string;
  41190. };
  41191. }
  41192. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41193. /** @hidden */
  41194. export var logDepthDeclaration: {
  41195. name: string;
  41196. shader: string;
  41197. };
  41198. }
  41199. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41200. /** @hidden */
  41201. export var bumpFragment: {
  41202. name: string;
  41203. shader: string;
  41204. };
  41205. }
  41206. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41207. /** @hidden */
  41208. export var depthPrePass: {
  41209. name: string;
  41210. shader: string;
  41211. };
  41212. }
  41213. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41214. /** @hidden */
  41215. export var lightFragment: {
  41216. name: string;
  41217. shader: string;
  41218. };
  41219. }
  41220. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41221. /** @hidden */
  41222. export var logDepthFragment: {
  41223. name: string;
  41224. shader: string;
  41225. };
  41226. }
  41227. declare module "babylonjs/Shaders/default.fragment" {
  41228. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41229. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41231. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41232. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41233. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41234. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41235. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41236. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41237. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41238. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41239. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41240. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41241. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41242. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41243. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41244. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41245. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41246. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41247. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41248. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41249. /** @hidden */
  41250. export var defaultPixelShader: {
  41251. name: string;
  41252. shader: string;
  41253. };
  41254. }
  41255. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41256. /** @hidden */
  41257. export var defaultVertexDeclaration: {
  41258. name: string;
  41259. shader: string;
  41260. };
  41261. }
  41262. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41263. /** @hidden */
  41264. export var bumpVertexDeclaration: {
  41265. name: string;
  41266. shader: string;
  41267. };
  41268. }
  41269. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41270. /** @hidden */
  41271. export var bumpVertex: {
  41272. name: string;
  41273. shader: string;
  41274. };
  41275. }
  41276. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41277. /** @hidden */
  41278. export var fogVertex: {
  41279. name: string;
  41280. shader: string;
  41281. };
  41282. }
  41283. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41284. /** @hidden */
  41285. export var shadowsVertex: {
  41286. name: string;
  41287. shader: string;
  41288. };
  41289. }
  41290. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41291. /** @hidden */
  41292. export var pointCloudVertex: {
  41293. name: string;
  41294. shader: string;
  41295. };
  41296. }
  41297. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41298. /** @hidden */
  41299. export var logDepthVertex: {
  41300. name: string;
  41301. shader: string;
  41302. };
  41303. }
  41304. declare module "babylonjs/Shaders/default.vertex" {
  41305. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41306. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41307. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41308. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41310. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41311. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41312. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41313. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41314. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41315. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41316. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41317. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41319. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41320. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41321. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41323. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41324. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41325. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41326. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41327. /** @hidden */
  41328. export var defaultVertexShader: {
  41329. name: string;
  41330. shader: string;
  41331. };
  41332. }
  41333. declare module "babylonjs/Materials/standardMaterial" {
  41334. import { SmartArray } from "babylonjs/Misc/smartArray";
  41335. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41336. import { Nullable } from "babylonjs/types";
  41337. import { Scene } from "babylonjs/scene";
  41338. import { Matrix } from "babylonjs/Maths/math.vector";
  41339. import { Color3 } from "babylonjs/Maths/math.color";
  41340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41342. import { Mesh } from "babylonjs/Meshes/mesh";
  41343. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41344. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41345. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41346. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41347. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41350. import "babylonjs/Shaders/default.fragment";
  41351. import "babylonjs/Shaders/default.vertex";
  41352. /** @hidden */
  41353. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41354. MAINUV1: boolean;
  41355. MAINUV2: boolean;
  41356. DIFFUSE: boolean;
  41357. DIFFUSEDIRECTUV: number;
  41358. AMBIENT: boolean;
  41359. AMBIENTDIRECTUV: number;
  41360. OPACITY: boolean;
  41361. OPACITYDIRECTUV: number;
  41362. OPACITYRGB: boolean;
  41363. REFLECTION: boolean;
  41364. EMISSIVE: boolean;
  41365. EMISSIVEDIRECTUV: number;
  41366. SPECULAR: boolean;
  41367. SPECULARDIRECTUV: number;
  41368. BUMP: boolean;
  41369. BUMPDIRECTUV: number;
  41370. PARALLAX: boolean;
  41371. PARALLAXOCCLUSION: boolean;
  41372. SPECULAROVERALPHA: boolean;
  41373. CLIPPLANE: boolean;
  41374. CLIPPLANE2: boolean;
  41375. CLIPPLANE3: boolean;
  41376. CLIPPLANE4: boolean;
  41377. ALPHATEST: boolean;
  41378. DEPTHPREPASS: boolean;
  41379. ALPHAFROMDIFFUSE: boolean;
  41380. POINTSIZE: boolean;
  41381. FOG: boolean;
  41382. SPECULARTERM: boolean;
  41383. DIFFUSEFRESNEL: boolean;
  41384. OPACITYFRESNEL: boolean;
  41385. REFLECTIONFRESNEL: boolean;
  41386. REFRACTIONFRESNEL: boolean;
  41387. EMISSIVEFRESNEL: boolean;
  41388. FRESNEL: boolean;
  41389. NORMAL: boolean;
  41390. UV1: boolean;
  41391. UV2: boolean;
  41392. VERTEXCOLOR: boolean;
  41393. VERTEXALPHA: boolean;
  41394. NUM_BONE_INFLUENCERS: number;
  41395. BonesPerMesh: number;
  41396. BONETEXTURE: boolean;
  41397. INSTANCES: boolean;
  41398. GLOSSINESS: boolean;
  41399. ROUGHNESS: boolean;
  41400. EMISSIVEASILLUMINATION: boolean;
  41401. LINKEMISSIVEWITHDIFFUSE: boolean;
  41402. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41403. LIGHTMAP: boolean;
  41404. LIGHTMAPDIRECTUV: number;
  41405. OBJECTSPACE_NORMALMAP: boolean;
  41406. USELIGHTMAPASSHADOWMAP: boolean;
  41407. REFLECTIONMAP_3D: boolean;
  41408. REFLECTIONMAP_SPHERICAL: boolean;
  41409. REFLECTIONMAP_PLANAR: boolean;
  41410. REFLECTIONMAP_CUBIC: boolean;
  41411. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41412. REFLECTIONMAP_PROJECTION: boolean;
  41413. REFLECTIONMAP_SKYBOX: boolean;
  41414. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41415. REFLECTIONMAP_EXPLICIT: boolean;
  41416. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41417. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41418. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41419. INVERTCUBICMAP: boolean;
  41420. LOGARITHMICDEPTH: boolean;
  41421. REFRACTION: boolean;
  41422. REFRACTIONMAP_3D: boolean;
  41423. REFLECTIONOVERALPHA: boolean;
  41424. TWOSIDEDLIGHTING: boolean;
  41425. SHADOWFLOAT: boolean;
  41426. MORPHTARGETS: boolean;
  41427. MORPHTARGETS_NORMAL: boolean;
  41428. MORPHTARGETS_TANGENT: boolean;
  41429. MORPHTARGETS_UV: boolean;
  41430. NUM_MORPH_INFLUENCERS: number;
  41431. NONUNIFORMSCALING: boolean;
  41432. PREMULTIPLYALPHA: boolean;
  41433. IMAGEPROCESSING: boolean;
  41434. VIGNETTE: boolean;
  41435. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41436. VIGNETTEBLENDMODEOPAQUE: boolean;
  41437. TONEMAPPING: boolean;
  41438. TONEMAPPING_ACES: boolean;
  41439. CONTRAST: boolean;
  41440. COLORCURVES: boolean;
  41441. COLORGRADING: boolean;
  41442. COLORGRADING3D: boolean;
  41443. SAMPLER3DGREENDEPTH: boolean;
  41444. SAMPLER3DBGRMAP: boolean;
  41445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41446. MULTIVIEW: boolean;
  41447. /**
  41448. * If the reflection texture on this material is in linear color space
  41449. * @hidden
  41450. */
  41451. IS_REFLECTION_LINEAR: boolean;
  41452. /**
  41453. * If the refraction texture on this material is in linear color space
  41454. * @hidden
  41455. */
  41456. IS_REFRACTION_LINEAR: boolean;
  41457. EXPOSURE: boolean;
  41458. constructor();
  41459. setReflectionMode(modeToEnable: string): void;
  41460. }
  41461. /**
  41462. * This is the default material used in Babylon. It is the best trade off between quality
  41463. * and performances.
  41464. * @see http://doc.babylonjs.com/babylon101/materials
  41465. */
  41466. export class StandardMaterial extends PushMaterial {
  41467. private _diffuseTexture;
  41468. /**
  41469. * The basic texture of the material as viewed under a light.
  41470. */
  41471. diffuseTexture: Nullable<BaseTexture>;
  41472. private _ambientTexture;
  41473. /**
  41474. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41475. */
  41476. ambientTexture: Nullable<BaseTexture>;
  41477. private _opacityTexture;
  41478. /**
  41479. * Define the transparency of the material from a texture.
  41480. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41481. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41482. */
  41483. opacityTexture: Nullable<BaseTexture>;
  41484. private _reflectionTexture;
  41485. /**
  41486. * Define the texture used to display the reflection.
  41487. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41488. */
  41489. reflectionTexture: Nullable<BaseTexture>;
  41490. private _emissiveTexture;
  41491. /**
  41492. * Define texture of the material as if self lit.
  41493. * This will be mixed in the final result even in the absence of light.
  41494. */
  41495. emissiveTexture: Nullable<BaseTexture>;
  41496. private _specularTexture;
  41497. /**
  41498. * Define how the color and intensity of the highlight given by the light in the material.
  41499. */
  41500. specularTexture: Nullable<BaseTexture>;
  41501. private _bumpTexture;
  41502. /**
  41503. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41504. * 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.
  41505. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41506. */
  41507. bumpTexture: Nullable<BaseTexture>;
  41508. private _lightmapTexture;
  41509. /**
  41510. * Complex lighting can be computationally expensive to compute at runtime.
  41511. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41512. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41513. */
  41514. lightmapTexture: Nullable<BaseTexture>;
  41515. private _refractionTexture;
  41516. /**
  41517. * Define the texture used to display the refraction.
  41518. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41519. */
  41520. refractionTexture: Nullable<BaseTexture>;
  41521. /**
  41522. * The color of the material lit by the environmental background lighting.
  41523. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41524. */
  41525. ambientColor: Color3;
  41526. /**
  41527. * The basic color of the material as viewed under a light.
  41528. */
  41529. diffuseColor: Color3;
  41530. /**
  41531. * Define how the color and intensity of the highlight given by the light in the material.
  41532. */
  41533. specularColor: Color3;
  41534. /**
  41535. * Define the color of the material as if self lit.
  41536. * This will be mixed in the final result even in the absence of light.
  41537. */
  41538. emissiveColor: Color3;
  41539. /**
  41540. * Defines how sharp are the highlights in the material.
  41541. * The bigger the value the sharper giving a more glossy feeling to the result.
  41542. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41543. */
  41544. specularPower: number;
  41545. private _useAlphaFromDiffuseTexture;
  41546. /**
  41547. * Does the transparency come from the diffuse texture alpha channel.
  41548. */
  41549. useAlphaFromDiffuseTexture: boolean;
  41550. private _useEmissiveAsIllumination;
  41551. /**
  41552. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41553. */
  41554. useEmissiveAsIllumination: boolean;
  41555. private _linkEmissiveWithDiffuse;
  41556. /**
  41557. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41558. * the emissive level when the final color is close to one.
  41559. */
  41560. linkEmissiveWithDiffuse: boolean;
  41561. private _useSpecularOverAlpha;
  41562. /**
  41563. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41564. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41565. */
  41566. useSpecularOverAlpha: boolean;
  41567. private _useReflectionOverAlpha;
  41568. /**
  41569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41571. */
  41572. useReflectionOverAlpha: boolean;
  41573. private _disableLighting;
  41574. /**
  41575. * Does lights from the scene impacts this material.
  41576. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41577. */
  41578. disableLighting: boolean;
  41579. private _useObjectSpaceNormalMap;
  41580. /**
  41581. * Allows using an object space normal map (instead of tangent space).
  41582. */
  41583. useObjectSpaceNormalMap: boolean;
  41584. private _useParallax;
  41585. /**
  41586. * Is parallax enabled or not.
  41587. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41588. */
  41589. useParallax: boolean;
  41590. private _useParallaxOcclusion;
  41591. /**
  41592. * Is parallax occlusion enabled or not.
  41593. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41594. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41595. */
  41596. useParallaxOcclusion: boolean;
  41597. /**
  41598. * 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.
  41599. */
  41600. parallaxScaleBias: number;
  41601. private _roughness;
  41602. /**
  41603. * Helps to define how blurry the reflections should appears in the material.
  41604. */
  41605. roughness: number;
  41606. /**
  41607. * In case of refraction, define the value of the index of refraction.
  41608. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41609. */
  41610. indexOfRefraction: number;
  41611. /**
  41612. * Invert the refraction texture alongside the y axis.
  41613. * It can be useful with procedural textures or probe for instance.
  41614. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41615. */
  41616. invertRefractionY: boolean;
  41617. /**
  41618. * Defines the alpha limits in alpha test mode.
  41619. */
  41620. alphaCutOff: number;
  41621. private _useLightmapAsShadowmap;
  41622. /**
  41623. * In case of light mapping, define whether the map contains light or shadow informations.
  41624. */
  41625. useLightmapAsShadowmap: boolean;
  41626. private _diffuseFresnelParameters;
  41627. /**
  41628. * Define the diffuse fresnel parameters of the material.
  41629. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41630. */
  41631. diffuseFresnelParameters: FresnelParameters;
  41632. private _opacityFresnelParameters;
  41633. /**
  41634. * Define the opacity fresnel parameters of the material.
  41635. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41636. */
  41637. opacityFresnelParameters: FresnelParameters;
  41638. private _reflectionFresnelParameters;
  41639. /**
  41640. * Define the reflection fresnel parameters of the material.
  41641. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41642. */
  41643. reflectionFresnelParameters: FresnelParameters;
  41644. private _refractionFresnelParameters;
  41645. /**
  41646. * Define the refraction fresnel parameters of the material.
  41647. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41648. */
  41649. refractionFresnelParameters: FresnelParameters;
  41650. private _emissiveFresnelParameters;
  41651. /**
  41652. * Define the emissive fresnel parameters of the material.
  41653. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41654. */
  41655. emissiveFresnelParameters: FresnelParameters;
  41656. private _useReflectionFresnelFromSpecular;
  41657. /**
  41658. * If true automatically deducts the fresnels values from the material specularity.
  41659. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41660. */
  41661. useReflectionFresnelFromSpecular: boolean;
  41662. private _useGlossinessFromSpecularMapAlpha;
  41663. /**
  41664. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41665. */
  41666. useGlossinessFromSpecularMapAlpha: boolean;
  41667. private _maxSimultaneousLights;
  41668. /**
  41669. * Defines the maximum number of lights that can be used in the material
  41670. */
  41671. maxSimultaneousLights: number;
  41672. private _invertNormalMapX;
  41673. /**
  41674. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41675. */
  41676. invertNormalMapX: boolean;
  41677. private _invertNormalMapY;
  41678. /**
  41679. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41680. */
  41681. invertNormalMapY: boolean;
  41682. private _twoSidedLighting;
  41683. /**
  41684. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41685. */
  41686. twoSidedLighting: boolean;
  41687. /**
  41688. * Default configuration related to image processing available in the standard Material.
  41689. */
  41690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41691. /**
  41692. * Gets the image processing configuration used either in this material.
  41693. */
  41694. /**
  41695. * Sets the Default image processing configuration used either in the this material.
  41696. *
  41697. * If sets to null, the scene one is in use.
  41698. */
  41699. imageProcessingConfiguration: ImageProcessingConfiguration;
  41700. /**
  41701. * Keep track of the image processing observer to allow dispose and replace.
  41702. */
  41703. private _imageProcessingObserver;
  41704. /**
  41705. * Attaches a new image processing configuration to the Standard Material.
  41706. * @param configuration
  41707. */
  41708. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41709. /**
  41710. * Gets wether the color curves effect is enabled.
  41711. */
  41712. /**
  41713. * Sets wether the color curves effect is enabled.
  41714. */
  41715. cameraColorCurvesEnabled: boolean;
  41716. /**
  41717. * Gets wether the color grading effect is enabled.
  41718. */
  41719. /**
  41720. * Gets wether the color grading effect is enabled.
  41721. */
  41722. cameraColorGradingEnabled: boolean;
  41723. /**
  41724. * Gets wether tonemapping is enabled or not.
  41725. */
  41726. /**
  41727. * Sets wether tonemapping is enabled or not
  41728. */
  41729. cameraToneMappingEnabled: boolean;
  41730. /**
  41731. * The camera exposure used on this material.
  41732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41733. * This corresponds to a photographic exposure.
  41734. */
  41735. /**
  41736. * The camera exposure used on this material.
  41737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41738. * This corresponds to a photographic exposure.
  41739. */
  41740. cameraExposure: number;
  41741. /**
  41742. * Gets The camera contrast used on this material.
  41743. */
  41744. /**
  41745. * Sets The camera contrast used on this material.
  41746. */
  41747. cameraContrast: number;
  41748. /**
  41749. * Gets the Color Grading 2D Lookup Texture.
  41750. */
  41751. /**
  41752. * Sets the Color Grading 2D Lookup Texture.
  41753. */
  41754. cameraColorGradingTexture: Nullable<BaseTexture>;
  41755. /**
  41756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41758. * 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;
  41759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41760. */
  41761. /**
  41762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41764. * 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;
  41765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41766. */
  41767. cameraColorCurves: Nullable<ColorCurves>;
  41768. /**
  41769. * Custom callback helping to override the default shader used in the material.
  41770. */
  41771. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41772. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41773. protected _worldViewProjectionMatrix: Matrix;
  41774. protected _globalAmbientColor: Color3;
  41775. protected _useLogarithmicDepth: boolean;
  41776. protected _rebuildInParallel: boolean;
  41777. /**
  41778. * Instantiates a new standard material.
  41779. * This is the default material used in Babylon. It is the best trade off between quality
  41780. * and performances.
  41781. * @see http://doc.babylonjs.com/babylon101/materials
  41782. * @param name Define the name of the material in the scene
  41783. * @param scene Define the scene the material belong to
  41784. */
  41785. constructor(name: string, scene: Scene);
  41786. /**
  41787. * Gets a boolean indicating that current material needs to register RTT
  41788. */
  41789. readonly hasRenderTargetTextures: boolean;
  41790. /**
  41791. * Gets the current class name of the material e.g. "StandardMaterial"
  41792. * Mainly use in serialization.
  41793. * @returns the class name
  41794. */
  41795. getClassName(): string;
  41796. /**
  41797. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41798. * You can try switching to logarithmic depth.
  41799. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41800. */
  41801. useLogarithmicDepth: boolean;
  41802. /**
  41803. * Specifies if the material will require alpha blending
  41804. * @returns a boolean specifying if alpha blending is needed
  41805. */
  41806. needAlphaBlending(): boolean;
  41807. /**
  41808. * Specifies if this material should be rendered in alpha test mode
  41809. * @returns a boolean specifying if an alpha test is needed.
  41810. */
  41811. needAlphaTesting(): boolean;
  41812. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41813. /**
  41814. * Get the texture used for alpha test purpose.
  41815. * @returns the diffuse texture in case of the standard material.
  41816. */
  41817. getAlphaTestTexture(): Nullable<BaseTexture>;
  41818. /**
  41819. * Get if the submesh is ready to be used and all its information available.
  41820. * Child classes can use it to update shaders
  41821. * @param mesh defines the mesh to check
  41822. * @param subMesh defines which submesh to check
  41823. * @param useInstances specifies that instances should be used
  41824. * @returns a boolean indicating that the submesh is ready or not
  41825. */
  41826. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41827. /**
  41828. * Builds the material UBO layouts.
  41829. * Used internally during the effect preparation.
  41830. */
  41831. buildUniformLayout(): void;
  41832. /**
  41833. * Unbinds the material from the mesh
  41834. */
  41835. unbind(): void;
  41836. /**
  41837. * Binds the submesh to this material by preparing the effect and shader to draw
  41838. * @param world defines the world transformation matrix
  41839. * @param mesh defines the mesh containing the submesh
  41840. * @param subMesh defines the submesh to bind the material to
  41841. */
  41842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41843. /**
  41844. * Get the list of animatables in the material.
  41845. * @returns the list of animatables object used in the material
  41846. */
  41847. getAnimatables(): IAnimatable[];
  41848. /**
  41849. * Gets the active textures from the material
  41850. * @returns an array of textures
  41851. */
  41852. getActiveTextures(): BaseTexture[];
  41853. /**
  41854. * Specifies if the material uses a texture
  41855. * @param texture defines the texture to check against the material
  41856. * @returns a boolean specifying if the material uses the texture
  41857. */
  41858. hasTexture(texture: BaseTexture): boolean;
  41859. /**
  41860. * Disposes the material
  41861. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41862. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41863. */
  41864. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41865. /**
  41866. * Makes a duplicate of the material, and gives it a new name
  41867. * @param name defines the new name for the duplicated material
  41868. * @returns the cloned material
  41869. */
  41870. clone(name: string): StandardMaterial;
  41871. /**
  41872. * Serializes this material in a JSON representation
  41873. * @returns the serialized material object
  41874. */
  41875. serialize(): any;
  41876. /**
  41877. * Creates a standard material from parsed material data
  41878. * @param source defines the JSON representation of the material
  41879. * @param scene defines the hosting scene
  41880. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41881. * @returns a new standard material
  41882. */
  41883. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41884. /**
  41885. * Are diffuse textures enabled in the application.
  41886. */
  41887. static DiffuseTextureEnabled: boolean;
  41888. /**
  41889. * Are ambient textures enabled in the application.
  41890. */
  41891. static AmbientTextureEnabled: boolean;
  41892. /**
  41893. * Are opacity textures enabled in the application.
  41894. */
  41895. static OpacityTextureEnabled: boolean;
  41896. /**
  41897. * Are reflection textures enabled in the application.
  41898. */
  41899. static ReflectionTextureEnabled: boolean;
  41900. /**
  41901. * Are emissive textures enabled in the application.
  41902. */
  41903. static EmissiveTextureEnabled: boolean;
  41904. /**
  41905. * Are specular textures enabled in the application.
  41906. */
  41907. static SpecularTextureEnabled: boolean;
  41908. /**
  41909. * Are bump textures enabled in the application.
  41910. */
  41911. static BumpTextureEnabled: boolean;
  41912. /**
  41913. * Are lightmap textures enabled in the application.
  41914. */
  41915. static LightmapTextureEnabled: boolean;
  41916. /**
  41917. * Are refraction textures enabled in the application.
  41918. */
  41919. static RefractionTextureEnabled: boolean;
  41920. /**
  41921. * Are color grading textures enabled in the application.
  41922. */
  41923. static ColorGradingTextureEnabled: boolean;
  41924. /**
  41925. * Are fresnels enabled in the application.
  41926. */
  41927. static FresnelEnabled: boolean;
  41928. }
  41929. }
  41930. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41931. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41932. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41933. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41934. /** @hidden */
  41935. export var imageProcessingPixelShader: {
  41936. name: string;
  41937. shader: string;
  41938. };
  41939. }
  41940. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41941. import { Nullable } from "babylonjs/types";
  41942. import { Color4 } from "babylonjs/Maths/math.color";
  41943. import { Camera } from "babylonjs/Cameras/camera";
  41944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41945. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41946. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41947. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41948. import { Engine } from "babylonjs/Engines/engine";
  41949. import "babylonjs/Shaders/imageProcessing.fragment";
  41950. import "babylonjs/Shaders/postprocess.vertex";
  41951. /**
  41952. * ImageProcessingPostProcess
  41953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41954. */
  41955. export class ImageProcessingPostProcess extends PostProcess {
  41956. /**
  41957. * Default configuration related to image processing available in the PBR Material.
  41958. */
  41959. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41960. /**
  41961. * Gets the image processing configuration used either in this material.
  41962. */
  41963. /**
  41964. * Sets the Default image processing configuration used either in the this material.
  41965. *
  41966. * If sets to null, the scene one is in use.
  41967. */
  41968. imageProcessingConfiguration: ImageProcessingConfiguration;
  41969. /**
  41970. * Keep track of the image processing observer to allow dispose and replace.
  41971. */
  41972. private _imageProcessingObserver;
  41973. /**
  41974. * Attaches a new image processing configuration to the PBR Material.
  41975. * @param configuration
  41976. */
  41977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41978. /**
  41979. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41980. */
  41981. /**
  41982. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41983. */
  41984. colorCurves: Nullable<ColorCurves>;
  41985. /**
  41986. * Gets wether the color curves effect is enabled.
  41987. */
  41988. /**
  41989. * Sets wether the color curves effect is enabled.
  41990. */
  41991. colorCurvesEnabled: boolean;
  41992. /**
  41993. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41994. */
  41995. /**
  41996. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41997. */
  41998. colorGradingTexture: Nullable<BaseTexture>;
  41999. /**
  42000. * Gets wether the color grading effect is enabled.
  42001. */
  42002. /**
  42003. * Gets wether the color grading effect is enabled.
  42004. */
  42005. colorGradingEnabled: boolean;
  42006. /**
  42007. * Gets exposure used in the effect.
  42008. */
  42009. /**
  42010. * Sets exposure used in the effect.
  42011. */
  42012. exposure: number;
  42013. /**
  42014. * Gets wether tonemapping is enabled or not.
  42015. */
  42016. /**
  42017. * Sets wether tonemapping is enabled or not
  42018. */
  42019. toneMappingEnabled: boolean;
  42020. /**
  42021. * Gets the type of tone mapping effect.
  42022. */
  42023. /**
  42024. * Sets the type of tone mapping effect.
  42025. */
  42026. toneMappingType: number;
  42027. /**
  42028. * Gets contrast used in the effect.
  42029. */
  42030. /**
  42031. * Sets contrast used in the effect.
  42032. */
  42033. contrast: number;
  42034. /**
  42035. * Gets Vignette stretch size.
  42036. */
  42037. /**
  42038. * Sets Vignette stretch size.
  42039. */
  42040. vignetteStretch: number;
  42041. /**
  42042. * Gets Vignette centre X Offset.
  42043. */
  42044. /**
  42045. * Sets Vignette centre X Offset.
  42046. */
  42047. vignetteCentreX: number;
  42048. /**
  42049. * Gets Vignette centre Y Offset.
  42050. */
  42051. /**
  42052. * Sets Vignette centre Y Offset.
  42053. */
  42054. vignetteCentreY: number;
  42055. /**
  42056. * Gets Vignette weight or intensity of the vignette effect.
  42057. */
  42058. /**
  42059. * Sets Vignette weight or intensity of the vignette effect.
  42060. */
  42061. vignetteWeight: number;
  42062. /**
  42063. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42064. * if vignetteEnabled is set to true.
  42065. */
  42066. /**
  42067. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42068. * if vignetteEnabled is set to true.
  42069. */
  42070. vignetteColor: Color4;
  42071. /**
  42072. * Gets Camera field of view used by the Vignette effect.
  42073. */
  42074. /**
  42075. * Sets Camera field of view used by the Vignette effect.
  42076. */
  42077. vignetteCameraFov: number;
  42078. /**
  42079. * Gets the vignette blend mode allowing different kind of effect.
  42080. */
  42081. /**
  42082. * Sets the vignette blend mode allowing different kind of effect.
  42083. */
  42084. vignetteBlendMode: number;
  42085. /**
  42086. * Gets wether the vignette effect is enabled.
  42087. */
  42088. /**
  42089. * Sets wether the vignette effect is enabled.
  42090. */
  42091. vignetteEnabled: boolean;
  42092. private _fromLinearSpace;
  42093. /**
  42094. * Gets wether the input of the processing is in Gamma or Linear Space.
  42095. */
  42096. /**
  42097. * Sets wether the input of the processing is in Gamma or Linear Space.
  42098. */
  42099. fromLinearSpace: boolean;
  42100. /**
  42101. * Defines cache preventing GC.
  42102. */
  42103. private _defines;
  42104. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42105. /**
  42106. * "ImageProcessingPostProcess"
  42107. * @returns "ImageProcessingPostProcess"
  42108. */
  42109. getClassName(): string;
  42110. protected _updateParameters(): void;
  42111. dispose(camera?: Camera): void;
  42112. }
  42113. }
  42114. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42115. import { Scene } from "babylonjs/scene";
  42116. import { Color3 } from "babylonjs/Maths/math.color";
  42117. import { Mesh } from "babylonjs/Meshes/mesh";
  42118. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42119. import { Nullable } from "babylonjs/types";
  42120. /**
  42121. * Class containing static functions to help procedurally build meshes
  42122. */
  42123. export class GroundBuilder {
  42124. /**
  42125. * Creates a ground mesh
  42126. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42127. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42129. * @param name defines the name of the mesh
  42130. * @param options defines the options used to create the mesh
  42131. * @param scene defines the hosting scene
  42132. * @returns the ground mesh
  42133. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42134. */
  42135. static CreateGround(name: string, options: {
  42136. width?: number;
  42137. height?: number;
  42138. subdivisions?: number;
  42139. subdivisionsX?: number;
  42140. subdivisionsY?: number;
  42141. updatable?: boolean;
  42142. }, scene: any): Mesh;
  42143. /**
  42144. * Creates a tiled ground mesh
  42145. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42146. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42147. * * 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
  42148. * * 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
  42149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42150. * @param name defines the name of the mesh
  42151. * @param options defines the options used to create the mesh
  42152. * @param scene defines the hosting scene
  42153. * @returns the tiled ground mesh
  42154. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42155. */
  42156. static CreateTiledGround(name: string, options: {
  42157. xmin: number;
  42158. zmin: number;
  42159. xmax: number;
  42160. zmax: number;
  42161. subdivisions?: {
  42162. w: number;
  42163. h: number;
  42164. };
  42165. precision?: {
  42166. w: number;
  42167. h: number;
  42168. };
  42169. updatable?: boolean;
  42170. }, scene?: Nullable<Scene>): Mesh;
  42171. /**
  42172. * Creates a ground mesh from a height map
  42173. * * The parameter `url` sets the URL of the height map image resource.
  42174. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42175. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42176. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42177. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42178. * * 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.
  42179. * * 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).
  42180. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42182. * @param name defines the name of the mesh
  42183. * @param url defines the url to the height map
  42184. * @param options defines the options used to create the mesh
  42185. * @param scene defines the hosting scene
  42186. * @returns the ground mesh
  42187. * @see https://doc.babylonjs.com/babylon101/height_map
  42188. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42189. */
  42190. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42191. width?: number;
  42192. height?: number;
  42193. subdivisions?: number;
  42194. minHeight?: number;
  42195. maxHeight?: number;
  42196. colorFilter?: Color3;
  42197. alphaFilter?: number;
  42198. updatable?: boolean;
  42199. onReady?: (mesh: GroundMesh) => void;
  42200. }, scene?: Nullable<Scene>): GroundMesh;
  42201. }
  42202. }
  42203. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42204. import { Vector4 } from "babylonjs/Maths/math.vector";
  42205. import { Mesh } from "babylonjs/Meshes/mesh";
  42206. /**
  42207. * Class containing static functions to help procedurally build meshes
  42208. */
  42209. export class TorusBuilder {
  42210. /**
  42211. * Creates a torus mesh
  42212. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42213. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42214. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42218. * @param name defines the name of the mesh
  42219. * @param options defines the options used to create the mesh
  42220. * @param scene defines the hosting scene
  42221. * @returns the torus mesh
  42222. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42223. */
  42224. static CreateTorus(name: string, options: {
  42225. diameter?: number;
  42226. thickness?: number;
  42227. tessellation?: number;
  42228. updatable?: boolean;
  42229. sideOrientation?: number;
  42230. frontUVs?: Vector4;
  42231. backUVs?: Vector4;
  42232. }, scene: any): Mesh;
  42233. }
  42234. }
  42235. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42236. import { Vector4 } from "babylonjs/Maths/math.vector";
  42237. import { Color4 } from "babylonjs/Maths/math.color";
  42238. import { Mesh } from "babylonjs/Meshes/mesh";
  42239. /**
  42240. * Class containing static functions to help procedurally build meshes
  42241. */
  42242. export class CylinderBuilder {
  42243. /**
  42244. * Creates a cylinder or a cone mesh
  42245. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42246. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42247. * * 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.
  42248. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42249. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42250. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42251. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42252. * * 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).
  42253. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42254. * * 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).
  42255. * * 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
  42256. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42257. * * 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
  42258. * * 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.
  42259. * * If `enclose` is false, a ring surface is one element.
  42260. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42261. * * 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
  42262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42265. * @param name defines the name of the mesh
  42266. * @param options defines the options used to create the mesh
  42267. * @param scene defines the hosting scene
  42268. * @returns the cylinder mesh
  42269. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42270. */
  42271. static CreateCylinder(name: string, options: {
  42272. height?: number;
  42273. diameterTop?: number;
  42274. diameterBottom?: number;
  42275. diameter?: number;
  42276. tessellation?: number;
  42277. subdivisions?: number;
  42278. arc?: number;
  42279. faceColors?: Color4[];
  42280. faceUV?: Vector4[];
  42281. updatable?: boolean;
  42282. hasRings?: boolean;
  42283. enclose?: boolean;
  42284. cap?: number;
  42285. sideOrientation?: number;
  42286. frontUVs?: Vector4;
  42287. backUVs?: Vector4;
  42288. }, scene: any): Mesh;
  42289. }
  42290. }
  42291. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42292. import { Observable } from "babylonjs/Misc/observable";
  42293. import { Nullable } from "babylonjs/types";
  42294. import { Camera } from "babylonjs/Cameras/camera";
  42295. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42296. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42297. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42298. import { Scene } from "babylonjs/scene";
  42299. import { Vector3 } from "babylonjs/Maths/math.vector";
  42300. import { Color3 } from "babylonjs/Maths/math.color";
  42301. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42303. import { Mesh } from "babylonjs/Meshes/mesh";
  42304. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42305. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42306. import "babylonjs/Meshes/Builders/groundBuilder";
  42307. import "babylonjs/Meshes/Builders/torusBuilder";
  42308. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42309. import "babylonjs/Gamepads/gamepadSceneComponent";
  42310. import "babylonjs/Animations/animatable";
  42311. /**
  42312. * Options to modify the vr teleportation behavior.
  42313. */
  42314. export interface VRTeleportationOptions {
  42315. /**
  42316. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42317. */
  42318. floorMeshName?: string;
  42319. /**
  42320. * A list of meshes to be used as the teleportation floor. (default: empty)
  42321. */
  42322. floorMeshes?: Mesh[];
  42323. }
  42324. /**
  42325. * Options to modify the vr experience helper's behavior.
  42326. */
  42327. export interface VRExperienceHelperOptions extends WebVROptions {
  42328. /**
  42329. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42330. */
  42331. createDeviceOrientationCamera?: boolean;
  42332. /**
  42333. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42334. */
  42335. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42336. /**
  42337. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42338. */
  42339. laserToggle?: boolean;
  42340. /**
  42341. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42342. */
  42343. floorMeshes?: Mesh[];
  42344. /**
  42345. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42346. */
  42347. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42348. }
  42349. /**
  42350. * Event containing information after VR has been entered
  42351. */
  42352. export class OnAfterEnteringVRObservableEvent {
  42353. /**
  42354. * If entering vr was successful
  42355. */
  42356. success: boolean;
  42357. }
  42358. /**
  42359. * Helps to quickly add VR support to an existing scene.
  42360. * See http://doc.babylonjs.com/how_to/webvr_helper
  42361. */
  42362. export class VRExperienceHelper {
  42363. /** Options to modify the vr experience helper's behavior. */
  42364. webVROptions: VRExperienceHelperOptions;
  42365. private _scene;
  42366. private _position;
  42367. private _btnVR;
  42368. private _btnVRDisplayed;
  42369. private _webVRsupported;
  42370. private _webVRready;
  42371. private _webVRrequesting;
  42372. private _webVRpresenting;
  42373. private _hasEnteredVR;
  42374. private _fullscreenVRpresenting;
  42375. private _canvas;
  42376. private _webVRCamera;
  42377. private _vrDeviceOrientationCamera;
  42378. private _deviceOrientationCamera;
  42379. private _existingCamera;
  42380. private _onKeyDown;
  42381. private _onVrDisplayPresentChange;
  42382. private _onVRDisplayChanged;
  42383. private _onVRRequestPresentStart;
  42384. private _onVRRequestPresentComplete;
  42385. /**
  42386. * 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)
  42387. */
  42388. enableGazeEvenWhenNoPointerLock: boolean;
  42389. /**
  42390. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42391. */
  42392. exitVROnDoubleTap: boolean;
  42393. /**
  42394. * Observable raised right before entering VR.
  42395. */
  42396. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42397. /**
  42398. * Observable raised when entering VR has completed.
  42399. */
  42400. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42401. /**
  42402. * Observable raised when exiting VR.
  42403. */
  42404. onExitingVRObservable: Observable<VRExperienceHelper>;
  42405. /**
  42406. * Observable raised when controller mesh is loaded.
  42407. */
  42408. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42409. /** Return this.onEnteringVRObservable
  42410. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42411. */
  42412. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42413. /** Return this.onExitingVRObservable
  42414. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42415. */
  42416. readonly onExitingVR: Observable<VRExperienceHelper>;
  42417. /** Return this.onControllerMeshLoadedObservable
  42418. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42419. */
  42420. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42421. private _rayLength;
  42422. private _useCustomVRButton;
  42423. private _teleportationRequested;
  42424. private _teleportActive;
  42425. private _floorMeshName;
  42426. private _floorMeshesCollection;
  42427. private _rotationAllowed;
  42428. private _teleportBackwardsVector;
  42429. private _teleportationTarget;
  42430. private _isDefaultTeleportationTarget;
  42431. private _postProcessMove;
  42432. private _teleportationFillColor;
  42433. private _teleportationBorderColor;
  42434. private _rotationAngle;
  42435. private _haloCenter;
  42436. private _cameraGazer;
  42437. private _padSensibilityUp;
  42438. private _padSensibilityDown;
  42439. private _leftController;
  42440. private _rightController;
  42441. /**
  42442. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42443. */
  42444. onNewMeshSelected: Observable<AbstractMesh>;
  42445. /**
  42446. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42447. * This observable will provide the mesh and the controller used to select the mesh
  42448. */
  42449. onMeshSelectedWithController: Observable<{
  42450. mesh: AbstractMesh;
  42451. controller: WebVRController;
  42452. }>;
  42453. /**
  42454. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42455. */
  42456. onNewMeshPicked: Observable<PickingInfo>;
  42457. private _circleEase;
  42458. /**
  42459. * Observable raised before camera teleportation
  42460. */
  42461. onBeforeCameraTeleport: Observable<Vector3>;
  42462. /**
  42463. * Observable raised after camera teleportation
  42464. */
  42465. onAfterCameraTeleport: Observable<Vector3>;
  42466. /**
  42467. * Observable raised when current selected mesh gets unselected
  42468. */
  42469. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42470. private _raySelectionPredicate;
  42471. /**
  42472. * To be optionaly changed by user to define custom ray selection
  42473. */
  42474. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42475. /**
  42476. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42477. */
  42478. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42479. /**
  42480. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42481. */
  42482. teleportationEnabled: boolean;
  42483. private _defaultHeight;
  42484. private _teleportationInitialized;
  42485. private _interactionsEnabled;
  42486. private _interactionsRequested;
  42487. private _displayGaze;
  42488. private _displayLaserPointer;
  42489. /**
  42490. * The mesh used to display where the user is going to teleport.
  42491. */
  42492. /**
  42493. * Sets the mesh to be used to display where the user is going to teleport.
  42494. */
  42495. teleportationTarget: Mesh;
  42496. /**
  42497. * 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
  42498. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42499. * See http://doc.babylonjs.com/resources/baking_transformations
  42500. */
  42501. gazeTrackerMesh: Mesh;
  42502. /**
  42503. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42504. */
  42505. updateGazeTrackerScale: boolean;
  42506. /**
  42507. * If the gaze trackers color should be updated when selecting meshes
  42508. */
  42509. updateGazeTrackerColor: boolean;
  42510. /**
  42511. * If the controller laser color should be updated when selecting meshes
  42512. */
  42513. updateControllerLaserColor: boolean;
  42514. /**
  42515. * The gaze tracking mesh corresponding to the left controller
  42516. */
  42517. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42518. /**
  42519. * The gaze tracking mesh corresponding to the right controller
  42520. */
  42521. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42522. /**
  42523. * If the ray of the gaze should be displayed.
  42524. */
  42525. /**
  42526. * Sets if the ray of the gaze should be displayed.
  42527. */
  42528. displayGaze: boolean;
  42529. /**
  42530. * If the ray of the LaserPointer should be displayed.
  42531. */
  42532. /**
  42533. * Sets if the ray of the LaserPointer should be displayed.
  42534. */
  42535. displayLaserPointer: boolean;
  42536. /**
  42537. * The deviceOrientationCamera used as the camera when not in VR.
  42538. */
  42539. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42540. /**
  42541. * Based on the current WebVR support, returns the current VR camera used.
  42542. */
  42543. readonly currentVRCamera: Nullable<Camera>;
  42544. /**
  42545. * The webVRCamera which is used when in VR.
  42546. */
  42547. readonly webVRCamera: WebVRFreeCamera;
  42548. /**
  42549. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42550. */
  42551. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42552. /**
  42553. * The html button that is used to trigger entering into VR.
  42554. */
  42555. readonly vrButton: Nullable<HTMLButtonElement>;
  42556. private readonly _teleportationRequestInitiated;
  42557. /**
  42558. * Defines wether or not Pointer lock should be requested when switching to
  42559. * full screen.
  42560. */
  42561. requestPointerLockOnFullScreen: boolean;
  42562. /**
  42563. * Instantiates a VRExperienceHelper.
  42564. * Helps to quickly add VR support to an existing scene.
  42565. * @param scene The scene the VRExperienceHelper belongs to.
  42566. * @param webVROptions Options to modify the vr experience helper's behavior.
  42567. */
  42568. constructor(scene: Scene,
  42569. /** Options to modify the vr experience helper's behavior. */
  42570. webVROptions?: VRExperienceHelperOptions);
  42571. private _onDefaultMeshLoaded;
  42572. private _onResize;
  42573. private _onFullscreenChange;
  42574. /**
  42575. * Gets a value indicating if we are currently in VR mode.
  42576. */
  42577. readonly isInVRMode: boolean;
  42578. private onVrDisplayPresentChange;
  42579. private onVRDisplayChanged;
  42580. private moveButtonToBottomRight;
  42581. private displayVRButton;
  42582. private updateButtonVisibility;
  42583. private _cachedAngularSensibility;
  42584. /**
  42585. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42586. * Otherwise, will use the fullscreen API.
  42587. */
  42588. enterVR(): void;
  42589. /**
  42590. * Attempt to exit VR, or fullscreen.
  42591. */
  42592. exitVR(): void;
  42593. /**
  42594. * The position of the vr experience helper.
  42595. */
  42596. /**
  42597. * Sets the position of the vr experience helper.
  42598. */
  42599. position: Vector3;
  42600. /**
  42601. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42602. */
  42603. enableInteractions(): void;
  42604. private readonly _noControllerIsActive;
  42605. private beforeRender;
  42606. private _isTeleportationFloor;
  42607. /**
  42608. * Adds a floor mesh to be used for teleportation.
  42609. * @param floorMesh the mesh to be used for teleportation.
  42610. */
  42611. addFloorMesh(floorMesh: Mesh): void;
  42612. /**
  42613. * Removes a floor mesh from being used for teleportation.
  42614. * @param floorMesh the mesh to be removed.
  42615. */
  42616. removeFloorMesh(floorMesh: Mesh): void;
  42617. /**
  42618. * Enables interactions and teleportation using the VR controllers and gaze.
  42619. * @param vrTeleportationOptions options to modify teleportation behavior.
  42620. */
  42621. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42622. private _onNewGamepadConnected;
  42623. private _tryEnableInteractionOnController;
  42624. private _onNewGamepadDisconnected;
  42625. private _enableInteractionOnController;
  42626. private _checkTeleportWithRay;
  42627. private _checkRotate;
  42628. private _checkTeleportBackwards;
  42629. private _enableTeleportationOnController;
  42630. private _createTeleportationCircles;
  42631. private _displayTeleportationTarget;
  42632. private _hideTeleportationTarget;
  42633. private _rotateCamera;
  42634. private _moveTeleportationSelectorTo;
  42635. private _workingVector;
  42636. private _workingQuaternion;
  42637. private _workingMatrix;
  42638. /**
  42639. * Teleports the users feet to the desired location
  42640. * @param location The location where the user's feet should be placed
  42641. */
  42642. teleportCamera(location: Vector3): void;
  42643. private _convertNormalToDirectionOfRay;
  42644. private _castRayAndSelectObject;
  42645. private _notifySelectedMeshUnselected;
  42646. /**
  42647. * Sets the color of the laser ray from the vr controllers.
  42648. * @param color new color for the ray.
  42649. */
  42650. changeLaserColor(color: Color3): void;
  42651. /**
  42652. * Sets the color of the ray from the vr headsets gaze.
  42653. * @param color new color for the ray.
  42654. */
  42655. changeGazeColor(color: Color3): void;
  42656. /**
  42657. * Exits VR and disposes of the vr experience helper
  42658. */
  42659. dispose(): void;
  42660. /**
  42661. * Gets the name of the VRExperienceHelper class
  42662. * @returns "VRExperienceHelper"
  42663. */
  42664. getClassName(): string;
  42665. }
  42666. }
  42667. declare module "babylonjs/Cameras/VR/index" {
  42668. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42669. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42670. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42671. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42672. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42673. export * from "babylonjs/Cameras/VR/webVRCamera";
  42674. }
  42675. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42676. import { Observable } from "babylonjs/Misc/observable";
  42677. import { Nullable } from "babylonjs/types";
  42678. import { IDisposable, Scene } from "babylonjs/scene";
  42679. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42680. /**
  42681. * Manages an XRSession to work with Babylon's engine
  42682. * @see https://doc.babylonjs.com/how_to/webxr
  42683. */
  42684. export class WebXRSessionManager implements IDisposable {
  42685. private scene;
  42686. /**
  42687. * Fires every time a new xrFrame arrives which can be used to update the camera
  42688. */
  42689. onXRFrameObservable: Observable<any>;
  42690. /**
  42691. * Fires when the xr session is ended either by the device or manually done
  42692. */
  42693. onXRSessionEnded: Observable<any>;
  42694. /**
  42695. * Underlying xr session
  42696. */
  42697. session: XRSession;
  42698. /**
  42699. * Type of reference space used when creating the session
  42700. */
  42701. referenceSpace: XRReferenceSpace;
  42702. /** @hidden */
  42703. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42704. /**
  42705. * Current XR frame
  42706. */
  42707. currentFrame: Nullable<XRFrame>;
  42708. private _xrNavigator;
  42709. private baseLayer;
  42710. /**
  42711. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42712. * @param scene The scene which the session should be created for
  42713. */
  42714. constructor(scene: Scene);
  42715. /**
  42716. * Initializes the manager
  42717. * After initialization enterXR can be called to start an XR session
  42718. * @returns Promise which resolves after it is initialized
  42719. */
  42720. initializeAsync(): Promise<void>;
  42721. /**
  42722. * Initializes an xr session
  42723. * @param xrSessionMode mode to initialize
  42724. * @returns a promise which will resolve once the session has been initialized
  42725. */
  42726. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42727. /**
  42728. * Sets the reference space on the xr session
  42729. * @param referenceSpace space to set
  42730. * @returns a promise that will resolve once the reference space has been set
  42731. */
  42732. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42733. /**
  42734. * Updates the render state of the session
  42735. * @param state state to set
  42736. * @returns a promise that resolves once the render state has been updated
  42737. */
  42738. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42739. /**
  42740. * Starts rendering to the xr layer
  42741. * @returns a promise that will resolve once rendering has started
  42742. */
  42743. startRenderingToXRAsync(): Promise<void>;
  42744. /**
  42745. * Stops the xrSession and restores the renderloop
  42746. * @returns Promise which resolves after it exits XR
  42747. */
  42748. exitXRAsync(): Promise<unknown>;
  42749. /**
  42750. * Checks if a session would be supported for the creation options specified
  42751. * @param sessionMode session mode to check if supported eg. immersive-vr
  42752. * @returns true if supported
  42753. */
  42754. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42755. /**
  42756. * @hidden
  42757. * Converts the render layer of xrSession to a render target
  42758. * @param session session to create render target for
  42759. * @param scene scene the new render target should be created for
  42760. */
  42761. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42762. /**
  42763. * Disposes of the session manager
  42764. */
  42765. dispose(): void;
  42766. }
  42767. }
  42768. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42769. import { Scene } from "babylonjs/scene";
  42770. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42771. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42772. /**
  42773. * WebXR Camera which holds the views for the xrSession
  42774. * @see https://doc.babylonjs.com/how_to/webxr
  42775. */
  42776. export class WebXRCamera extends FreeCamera {
  42777. private static _TmpMatrix;
  42778. /**
  42779. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42780. * @param name the name of the camera
  42781. * @param scene the scene to add the camera to
  42782. */
  42783. constructor(name: string, scene: Scene);
  42784. private _updateNumberOfRigCameras;
  42785. /** @hidden */
  42786. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42787. /**
  42788. * Updates the cameras position from the current pose information of the XR session
  42789. * @param xrSessionManager the session containing pose information
  42790. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42791. */
  42792. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42793. }
  42794. }
  42795. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42796. import { Nullable } from "babylonjs/types";
  42797. import { IDisposable } from "babylonjs/scene";
  42798. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42799. /**
  42800. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42801. */
  42802. export class WebXRManagedOutputCanvas implements IDisposable {
  42803. private helper;
  42804. private _canvas;
  42805. /**
  42806. * xrpresent context of the canvas which can be used to display/mirror xr content
  42807. */
  42808. canvasContext: WebGLRenderingContext;
  42809. /**
  42810. * xr layer for the canvas
  42811. */
  42812. xrLayer: Nullable<XRWebGLLayer>;
  42813. /**
  42814. * Initializes the xr layer for the session
  42815. * @param xrSession xr session
  42816. * @returns a promise that will resolve once the XR Layer has been created
  42817. */
  42818. initializeXRLayerAsync(xrSession: any): any;
  42819. /**
  42820. * Initializes the canvas to be added/removed upon entering/exiting xr
  42821. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42822. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42823. */
  42824. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42825. /**
  42826. * Disposes of the object
  42827. */
  42828. dispose(): void;
  42829. private _setManagedOutputCanvas;
  42830. private _addCanvas;
  42831. private _removeCanvas;
  42832. }
  42833. }
  42834. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42835. import { Observable } from "babylonjs/Misc/observable";
  42836. import { IDisposable, Scene } from "babylonjs/scene";
  42837. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42839. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42840. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42841. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42842. /**
  42843. * States of the webXR experience
  42844. */
  42845. export enum WebXRState {
  42846. /**
  42847. * Transitioning to being in XR mode
  42848. */
  42849. ENTERING_XR = 0,
  42850. /**
  42851. * Transitioning to non XR mode
  42852. */
  42853. EXITING_XR = 1,
  42854. /**
  42855. * In XR mode and presenting
  42856. */
  42857. IN_XR = 2,
  42858. /**
  42859. * Not entered XR mode
  42860. */
  42861. NOT_IN_XR = 3
  42862. }
  42863. /**
  42864. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42865. * @see https://doc.babylonjs.com/how_to/webxr
  42866. */
  42867. export class WebXRExperienceHelper implements IDisposable {
  42868. private scene;
  42869. /**
  42870. * 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
  42871. */
  42872. container: AbstractMesh;
  42873. /**
  42874. * Camera used to render xr content
  42875. */
  42876. camera: WebXRCamera;
  42877. /**
  42878. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42879. */
  42880. state: WebXRState;
  42881. private _setState;
  42882. private static _TmpVector;
  42883. /**
  42884. * Fires when the state of the experience helper has changed
  42885. */
  42886. onStateChangedObservable: Observable<WebXRState>;
  42887. /** Session manager used to keep track of xr session */
  42888. sessionManager: WebXRSessionManager;
  42889. private _nonVRCamera;
  42890. private _originalSceneAutoClear;
  42891. private _supported;
  42892. /**
  42893. * Creates the experience helper
  42894. * @param scene the scene to attach the experience helper to
  42895. * @returns a promise for the experience helper
  42896. */
  42897. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42898. /**
  42899. * Creates a WebXRExperienceHelper
  42900. * @param scene The scene the helper should be created in
  42901. */
  42902. private constructor();
  42903. /**
  42904. * Exits XR mode and returns the scene to its original state
  42905. * @returns promise that resolves after xr mode has exited
  42906. */
  42907. exitXRAsync(): Promise<unknown>;
  42908. /**
  42909. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42910. * @param sessionCreationOptions options for the XR session
  42911. * @param referenceSpaceType frame of reference of the XR session
  42912. * @param outputCanvas the output canvas that will be used to enter XR mode
  42913. * @returns promise that resolves after xr mode has entered
  42914. */
  42915. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42916. /**
  42917. * Updates the global position of the camera by moving the camera's container
  42918. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42919. * @param position The desired global position of the camera
  42920. */
  42921. setPositionOfCameraUsingContainer(position: Vector3): void;
  42922. /**
  42923. * Rotates the xr camera by rotating the camera's container around the camera's position
  42924. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42925. * @param rotation the desired quaternion rotation to apply to the camera
  42926. */
  42927. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42928. /**
  42929. * Disposes of the experience helper
  42930. */
  42931. dispose(): void;
  42932. }
  42933. }
  42934. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42935. import { Nullable } from "babylonjs/types";
  42936. import { Observable } from "babylonjs/Misc/observable";
  42937. import { IDisposable, Scene } from "babylonjs/scene";
  42938. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42939. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42940. /**
  42941. * Button which can be used to enter a different mode of XR
  42942. */
  42943. export class WebXREnterExitUIButton {
  42944. /** button element */
  42945. element: HTMLElement;
  42946. /** XR initialization options for the button */
  42947. sessionMode: XRSessionMode;
  42948. /** Reference space type */
  42949. referenceSpaceType: XRReferenceSpaceType;
  42950. /**
  42951. * Creates a WebXREnterExitUIButton
  42952. * @param element button element
  42953. * @param sessionMode XR initialization session mode
  42954. * @param referenceSpaceType the type of reference space to be used
  42955. */
  42956. constructor(
  42957. /** button element */
  42958. element: HTMLElement,
  42959. /** XR initialization options for the button */
  42960. sessionMode: XRSessionMode,
  42961. /** Reference space type */
  42962. referenceSpaceType: XRReferenceSpaceType);
  42963. /**
  42964. * Overwritable function which can be used to update the button's visuals when the state changes
  42965. * @param activeButton the current active button in the UI
  42966. */
  42967. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42968. }
  42969. /**
  42970. * Options to create the webXR UI
  42971. */
  42972. export class WebXREnterExitUIOptions {
  42973. /**
  42974. * Context to enter xr with
  42975. */
  42976. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42977. /**
  42978. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42979. */
  42980. customButtons?: Array<WebXREnterExitUIButton>;
  42981. }
  42982. /**
  42983. * UI to allow the user to enter/exit XR mode
  42984. */
  42985. export class WebXREnterExitUI implements IDisposable {
  42986. private scene;
  42987. private _overlay;
  42988. private _buttons;
  42989. private _activeButton;
  42990. /**
  42991. * Fired every time the active button is changed.
  42992. *
  42993. * When xr is entered via a button that launches xr that button will be the callback parameter
  42994. *
  42995. * When exiting xr the callback parameter will be null)
  42996. */
  42997. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42998. /**
  42999. * Creates UI to allow the user to enter/exit XR mode
  43000. * @param scene the scene to add the ui to
  43001. * @param helper the xr experience helper to enter/exit xr with
  43002. * @param options options to configure the UI
  43003. * @returns the created ui
  43004. */
  43005. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43006. private constructor();
  43007. private _updateButtons;
  43008. /**
  43009. * Disposes of the object
  43010. */
  43011. dispose(): void;
  43012. }
  43013. }
  43014. declare module "babylonjs/Cameras/XR/webXRController" {
  43015. import { Nullable } from "babylonjs/types";
  43016. import { Observable } from "babylonjs/Misc/observable";
  43017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43018. import { Ray } from "babylonjs/Culling/ray";
  43019. import { Scene } from "babylonjs/scene";
  43020. /**
  43021. * Represents an XR input
  43022. */
  43023. export class WebXRController {
  43024. private scene;
  43025. /** The underlying input source for the controller */
  43026. inputSource: XRInputSource;
  43027. private parentContainer;
  43028. /**
  43029. * 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
  43030. */
  43031. grip?: AbstractMesh;
  43032. /**
  43033. * Pointer which can be used to select objects or attach a visible laser to
  43034. */
  43035. pointer: AbstractMesh;
  43036. /**
  43037. * Event that fires when the controller is removed/disposed
  43038. */
  43039. onDisposeObservable: Observable<{}>;
  43040. private _tmpMatrix;
  43041. private _tmpQuaternion;
  43042. private _tmpVector;
  43043. /**
  43044. * Creates the controller
  43045. * @see https://doc.babylonjs.com/how_to/webxr
  43046. * @param scene the scene which the controller should be associated to
  43047. * @param inputSource the underlying input source for the controller
  43048. * @param parentContainer parent that the controller meshes should be children of
  43049. */
  43050. constructor(scene: Scene,
  43051. /** The underlying input source for the controller */
  43052. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43053. /**
  43054. * Updates the controller pose based on the given XRFrame
  43055. * @param xrFrame xr frame to update the pose with
  43056. * @param referenceSpace reference space to use
  43057. */
  43058. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43059. /**
  43060. * Gets a world space ray coming from the controller
  43061. * @param result the resulting ray
  43062. */
  43063. getWorldPointerRayToRef(result: Ray): void;
  43064. /**
  43065. * Disposes of the object
  43066. */
  43067. dispose(): void;
  43068. }
  43069. }
  43070. declare module "babylonjs/Cameras/XR/webXRInput" {
  43071. import { Observable } from "babylonjs/Misc/observable";
  43072. import { IDisposable } from "babylonjs/scene";
  43073. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43074. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43075. /**
  43076. * XR input used to track XR inputs such as controllers/rays
  43077. */
  43078. export class WebXRInput implements IDisposable {
  43079. /**
  43080. * Base experience the input listens to
  43081. */
  43082. baseExperience: WebXRExperienceHelper;
  43083. /**
  43084. * XR controllers being tracked
  43085. */
  43086. controllers: Array<WebXRController>;
  43087. private _frameObserver;
  43088. private _stateObserver;
  43089. /**
  43090. * Event when a controller has been connected/added
  43091. */
  43092. onControllerAddedObservable: Observable<WebXRController>;
  43093. /**
  43094. * Event when a controller has been removed/disconnected
  43095. */
  43096. onControllerRemovedObservable: Observable<WebXRController>;
  43097. /**
  43098. * Initializes the WebXRInput
  43099. * @param baseExperience experience helper which the input should be created for
  43100. */
  43101. constructor(
  43102. /**
  43103. * Base experience the input listens to
  43104. */
  43105. baseExperience: WebXRExperienceHelper);
  43106. private _onInputSourcesChange;
  43107. private _addAndRemoveControllers;
  43108. /**
  43109. * Disposes of the object
  43110. */
  43111. dispose(): void;
  43112. }
  43113. }
  43114. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43116. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43117. /**
  43118. * Enables teleportation
  43119. */
  43120. export class WebXRControllerTeleportation {
  43121. private _teleportationFillColor;
  43122. private _teleportationBorderColor;
  43123. private _tmpRay;
  43124. private _tmpVector;
  43125. /**
  43126. * Creates a WebXRControllerTeleportation
  43127. * @param input input manager to add teleportation to
  43128. * @param floorMeshes floormeshes which can be teleported to
  43129. */
  43130. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43131. }
  43132. }
  43133. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43134. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43135. /**
  43136. * Handles pointer input automatically for the pointer of XR controllers
  43137. */
  43138. export class WebXRControllerPointerSelection {
  43139. private static _idCounter;
  43140. private _tmpRay;
  43141. /**
  43142. * Creates a WebXRControllerPointerSelection
  43143. * @param input input manager to setup pointer selection
  43144. */
  43145. constructor(input: WebXRInput);
  43146. private _convertNormalToDirectionOfRay;
  43147. private _updatePointerDistance;
  43148. }
  43149. }
  43150. declare module "babylonjs/Loading/sceneLoader" {
  43151. import { Observable } from "babylonjs/Misc/observable";
  43152. import { Nullable } from "babylonjs/types";
  43153. import { Scene } from "babylonjs/scene";
  43154. import { Engine } from "babylonjs/Engines/engine";
  43155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43156. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43157. import { AssetContainer } from "babylonjs/assetContainer";
  43158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43159. import { Skeleton } from "babylonjs/Bones/skeleton";
  43160. /**
  43161. * Class used to represent data loading progression
  43162. */
  43163. export class SceneLoaderProgressEvent {
  43164. /** defines if data length to load can be evaluated */
  43165. readonly lengthComputable: boolean;
  43166. /** defines the loaded data length */
  43167. readonly loaded: number;
  43168. /** defines the data length to load */
  43169. readonly total: number;
  43170. /**
  43171. * Create a new progress event
  43172. * @param lengthComputable defines if data length to load can be evaluated
  43173. * @param loaded defines the loaded data length
  43174. * @param total defines the data length to load
  43175. */
  43176. constructor(
  43177. /** defines if data length to load can be evaluated */
  43178. lengthComputable: boolean,
  43179. /** defines the loaded data length */
  43180. loaded: number,
  43181. /** defines the data length to load */
  43182. total: number);
  43183. /**
  43184. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43185. * @param event defines the source event
  43186. * @returns a new SceneLoaderProgressEvent
  43187. */
  43188. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43189. }
  43190. /**
  43191. * Interface used by SceneLoader plugins to define supported file extensions
  43192. */
  43193. export interface ISceneLoaderPluginExtensions {
  43194. /**
  43195. * Defines the list of supported extensions
  43196. */
  43197. [extension: string]: {
  43198. isBinary: boolean;
  43199. };
  43200. }
  43201. /**
  43202. * Interface used by SceneLoader plugin factory
  43203. */
  43204. export interface ISceneLoaderPluginFactory {
  43205. /**
  43206. * Defines the name of the factory
  43207. */
  43208. name: string;
  43209. /**
  43210. * Function called to create a new plugin
  43211. * @return the new plugin
  43212. */
  43213. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43214. /**
  43215. * Boolean indicating if the plugin can direct load specific data
  43216. */
  43217. canDirectLoad?: (data: string) => boolean;
  43218. }
  43219. /**
  43220. * Interface used to define a SceneLoader plugin
  43221. */
  43222. export interface ISceneLoaderPlugin {
  43223. /**
  43224. * The friendly name of this plugin.
  43225. */
  43226. name: string;
  43227. /**
  43228. * The file extensions supported by this plugin.
  43229. */
  43230. extensions: string | ISceneLoaderPluginExtensions;
  43231. /**
  43232. * Import meshes into a scene.
  43233. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43234. * @param scene The scene to import into
  43235. * @param data The data to import
  43236. * @param rootUrl The root url for scene and resources
  43237. * @param meshes The meshes array to import into
  43238. * @param particleSystems The particle systems array to import into
  43239. * @param skeletons The skeletons array to import into
  43240. * @param onError The callback when import fails
  43241. * @returns True if successful or false otherwise
  43242. */
  43243. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43244. /**
  43245. * Load into a scene.
  43246. * @param scene The scene to load into
  43247. * @param data The data to import
  43248. * @param rootUrl The root url for scene and resources
  43249. * @param onError The callback when import fails
  43250. * @returns true if successful or false otherwise
  43251. */
  43252. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43253. /**
  43254. * The callback that returns true if the data can be directly loaded.
  43255. */
  43256. canDirectLoad?: (data: string) => boolean;
  43257. /**
  43258. * The callback that allows custom handling of the root url based on the response url.
  43259. */
  43260. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43261. /**
  43262. * Load into an asset container.
  43263. * @param scene The scene to load into
  43264. * @param data The data to import
  43265. * @param rootUrl The root url for scene and resources
  43266. * @param onError The callback when import fails
  43267. * @returns The loaded asset container
  43268. */
  43269. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43270. }
  43271. /**
  43272. * Interface used to define an async SceneLoader plugin
  43273. */
  43274. export interface ISceneLoaderPluginAsync {
  43275. /**
  43276. * The friendly name of this plugin.
  43277. */
  43278. name: string;
  43279. /**
  43280. * The file extensions supported by this plugin.
  43281. */
  43282. extensions: string | ISceneLoaderPluginExtensions;
  43283. /**
  43284. * Import meshes into a scene.
  43285. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43286. * @param scene The scene to import into
  43287. * @param data The data to import
  43288. * @param rootUrl The root url for scene and resources
  43289. * @param onProgress The callback when the load progresses
  43290. * @param fileName Defines the name of the file to load
  43291. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43292. */
  43293. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43294. meshes: AbstractMesh[];
  43295. particleSystems: IParticleSystem[];
  43296. skeletons: Skeleton[];
  43297. animationGroups: AnimationGroup[];
  43298. }>;
  43299. /**
  43300. * Load into a scene.
  43301. * @param scene The scene to load into
  43302. * @param data The data to import
  43303. * @param rootUrl The root url for scene and resources
  43304. * @param onProgress The callback when the load progresses
  43305. * @param fileName Defines the name of the file to load
  43306. * @returns Nothing
  43307. */
  43308. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43309. /**
  43310. * The callback that returns true if the data can be directly loaded.
  43311. */
  43312. canDirectLoad?: (data: string) => boolean;
  43313. /**
  43314. * The callback that allows custom handling of the root url based on the response url.
  43315. */
  43316. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43317. /**
  43318. * Load into an asset container.
  43319. * @param scene The scene to load into
  43320. * @param data The data to import
  43321. * @param rootUrl The root url for scene and resources
  43322. * @param onProgress The callback when the load progresses
  43323. * @param fileName Defines the name of the file to load
  43324. * @returns The loaded asset container
  43325. */
  43326. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43327. }
  43328. /**
  43329. * Class used to load scene from various file formats using registered plugins
  43330. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43331. */
  43332. export class SceneLoader {
  43333. /**
  43334. * No logging while loading
  43335. */
  43336. static readonly NO_LOGGING: number;
  43337. /**
  43338. * Minimal logging while loading
  43339. */
  43340. static readonly MINIMAL_LOGGING: number;
  43341. /**
  43342. * Summary logging while loading
  43343. */
  43344. static readonly SUMMARY_LOGGING: number;
  43345. /**
  43346. * Detailled logging while loading
  43347. */
  43348. static readonly DETAILED_LOGGING: number;
  43349. /**
  43350. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43351. */
  43352. static ForceFullSceneLoadingForIncremental: boolean;
  43353. /**
  43354. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43355. */
  43356. static ShowLoadingScreen: boolean;
  43357. /**
  43358. * Defines the current logging level (while loading the scene)
  43359. * @ignorenaming
  43360. */
  43361. static loggingLevel: number;
  43362. /**
  43363. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43364. */
  43365. static CleanBoneMatrixWeights: boolean;
  43366. /**
  43367. * Event raised when a plugin is used to load a scene
  43368. */
  43369. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43370. private static _registeredPlugins;
  43371. private static _getDefaultPlugin;
  43372. private static _getPluginForExtension;
  43373. private static _getPluginForDirectLoad;
  43374. private static _getPluginForFilename;
  43375. private static _getDirectLoad;
  43376. private static _loadData;
  43377. private static _getFileInfo;
  43378. /**
  43379. * Gets a plugin that can load the given extension
  43380. * @param extension defines the extension to load
  43381. * @returns a plugin or null if none works
  43382. */
  43383. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43384. /**
  43385. * Gets a boolean indicating that the given extension can be loaded
  43386. * @param extension defines the extension to load
  43387. * @returns true if the extension is supported
  43388. */
  43389. static IsPluginForExtensionAvailable(extension: string): boolean;
  43390. /**
  43391. * Adds a new plugin to the list of registered plugins
  43392. * @param plugin defines the plugin to add
  43393. */
  43394. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43395. /**
  43396. * Import meshes into a scene
  43397. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43398. * @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)
  43399. * @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)
  43400. * @param scene the instance of BABYLON.Scene to append to
  43401. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43402. * @param onProgress a callback with a progress event for each file being loaded
  43403. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43404. * @param pluginExtension the extension used to determine the plugin
  43405. * @returns The loaded plugin
  43406. */
  43407. 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>;
  43408. /**
  43409. * Import meshes into a scene
  43410. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43411. * @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)
  43412. * @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)
  43413. * @param scene the instance of BABYLON.Scene to append to
  43414. * @param onProgress a callback with a progress event for each file being loaded
  43415. * @param pluginExtension the extension used to determine the plugin
  43416. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43417. */
  43418. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43419. meshes: AbstractMesh[];
  43420. particleSystems: IParticleSystem[];
  43421. skeletons: Skeleton[];
  43422. animationGroups: AnimationGroup[];
  43423. }>;
  43424. /**
  43425. * Load a scene
  43426. * @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)
  43427. * @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)
  43428. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43429. * @param onSuccess a callback with the scene when import succeeds
  43430. * @param onProgress a callback with a progress event for each file being loaded
  43431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43432. * @param pluginExtension the extension used to determine the plugin
  43433. * @returns The loaded plugin
  43434. */
  43435. 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>;
  43436. /**
  43437. * Load a scene
  43438. * @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)
  43439. * @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)
  43440. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43441. * @param onProgress a callback with a progress event for each file being loaded
  43442. * @param pluginExtension the extension used to determine the plugin
  43443. * @returns The loaded scene
  43444. */
  43445. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43446. /**
  43447. * Append a scene
  43448. * @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)
  43449. * @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)
  43450. * @param scene is the instance of BABYLON.Scene to append to
  43451. * @param onSuccess a callback with the scene when import succeeds
  43452. * @param onProgress a callback with a progress event for each file being loaded
  43453. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43454. * @param pluginExtension the extension used to determine the plugin
  43455. * @returns The loaded plugin
  43456. */
  43457. 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>;
  43458. /**
  43459. * Append a scene
  43460. * @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)
  43461. * @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)
  43462. * @param scene is the instance of BABYLON.Scene to append to
  43463. * @param onProgress a callback with a progress event for each file being loaded
  43464. * @param pluginExtension the extension used to determine the plugin
  43465. * @returns The given scene
  43466. */
  43467. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43468. /**
  43469. * Load a scene into an asset container
  43470. * @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)
  43471. * @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)
  43472. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43473. * @param onSuccess a callback with the scene when import succeeds
  43474. * @param onProgress a callback with a progress event for each file being loaded
  43475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43476. * @param pluginExtension the extension used to determine the plugin
  43477. * @returns The loaded plugin
  43478. */
  43479. 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>;
  43480. /**
  43481. * Load a scene into an asset container
  43482. * @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)
  43483. * @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)
  43484. * @param scene is the instance of Scene to append to
  43485. * @param onProgress a callback with a progress event for each file being loaded
  43486. * @param pluginExtension the extension used to determine the plugin
  43487. * @returns The loaded asset container
  43488. */
  43489. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43490. }
  43491. }
  43492. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43493. import { Scene } from "babylonjs/scene";
  43494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43495. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43496. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43497. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43498. /**
  43499. * Generic Controller
  43500. */
  43501. export class GenericController extends WebVRController {
  43502. /**
  43503. * Base Url for the controller model.
  43504. */
  43505. static readonly MODEL_BASE_URL: string;
  43506. /**
  43507. * File name for the controller model.
  43508. */
  43509. static readonly MODEL_FILENAME: string;
  43510. /**
  43511. * Creates a new GenericController from a gamepad
  43512. * @param vrGamepad the gamepad that the controller should be created from
  43513. */
  43514. constructor(vrGamepad: any);
  43515. /**
  43516. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43517. * @param scene scene in which to add meshes
  43518. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43519. */
  43520. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43521. /**
  43522. * Called once for each button that changed state since the last frame
  43523. * @param buttonIdx Which button index changed
  43524. * @param state New state of the button
  43525. * @param changes Which properties on the state changed since last frame
  43526. */
  43527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43528. }
  43529. }
  43530. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43531. import { Observable } from "babylonjs/Misc/observable";
  43532. import { Scene } from "babylonjs/scene";
  43533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43534. import { Ray } from "babylonjs/Culling/ray";
  43535. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43536. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43537. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43538. /**
  43539. * Defines the WindowsMotionController object that the state of the windows motion controller
  43540. */
  43541. export class WindowsMotionController extends WebVRController {
  43542. /**
  43543. * The base url used to load the left and right controller models
  43544. */
  43545. static MODEL_BASE_URL: string;
  43546. /**
  43547. * The name of the left controller model file
  43548. */
  43549. static MODEL_LEFT_FILENAME: string;
  43550. /**
  43551. * The name of the right controller model file
  43552. */
  43553. static MODEL_RIGHT_FILENAME: string;
  43554. /**
  43555. * The controller name prefix for this controller type
  43556. */
  43557. static readonly GAMEPAD_ID_PREFIX: string;
  43558. /**
  43559. * The controller id pattern for this controller type
  43560. */
  43561. private static readonly GAMEPAD_ID_PATTERN;
  43562. private _loadedMeshInfo;
  43563. private readonly _mapping;
  43564. /**
  43565. * Fired when the trackpad on this controller is clicked
  43566. */
  43567. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43568. /**
  43569. * Fired when the trackpad on this controller is modified
  43570. */
  43571. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43572. /**
  43573. * The current x and y values of this controller's trackpad
  43574. */
  43575. trackpad: StickValues;
  43576. /**
  43577. * Creates a new WindowsMotionController from a gamepad
  43578. * @param vrGamepad the gamepad that the controller should be created from
  43579. */
  43580. constructor(vrGamepad: any);
  43581. /**
  43582. * Fired when the trigger on this controller is modified
  43583. */
  43584. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43585. /**
  43586. * Fired when the menu button on this controller is modified
  43587. */
  43588. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43589. /**
  43590. * Fired when the grip button on this controller is modified
  43591. */
  43592. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43593. /**
  43594. * Fired when the thumbstick button on this controller is modified
  43595. */
  43596. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43597. /**
  43598. * Fired when the touchpad button on this controller is modified
  43599. */
  43600. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43601. /**
  43602. * Fired when the touchpad values on this controller are modified
  43603. */
  43604. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43605. private _updateTrackpad;
  43606. /**
  43607. * Called once per frame by the engine.
  43608. */
  43609. update(): void;
  43610. /**
  43611. * Called once for each button that changed state since the last frame
  43612. * @param buttonIdx Which button index changed
  43613. * @param state New state of the button
  43614. * @param changes Which properties on the state changed since last frame
  43615. */
  43616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43617. /**
  43618. * Moves the buttons on the controller mesh based on their current state
  43619. * @param buttonName the name of the button to move
  43620. * @param buttonValue the value of the button which determines the buttons new position
  43621. */
  43622. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43623. /**
  43624. * Moves the axis on the controller mesh based on its current state
  43625. * @param axis the index of the axis
  43626. * @param axisValue the value of the axis which determines the meshes new position
  43627. * @hidden
  43628. */
  43629. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43630. /**
  43631. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43632. * @param scene scene in which to add meshes
  43633. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43634. */
  43635. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43636. /**
  43637. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43638. * can be transformed by button presses and axes values, based on this._mapping.
  43639. *
  43640. * @param scene scene in which the meshes exist
  43641. * @param meshes list of meshes that make up the controller model to process
  43642. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43643. */
  43644. private processModel;
  43645. private createMeshInfo;
  43646. /**
  43647. * Gets the ray of the controller in the direction the controller is pointing
  43648. * @param length the length the resulting ray should be
  43649. * @returns a ray in the direction the controller is pointing
  43650. */
  43651. getForwardRay(length?: number): Ray;
  43652. /**
  43653. * Disposes of the controller
  43654. */
  43655. dispose(): void;
  43656. }
  43657. }
  43658. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43659. import { Observable } from "babylonjs/Misc/observable";
  43660. import { Scene } from "babylonjs/scene";
  43661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43662. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43663. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43664. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43665. /**
  43666. * Oculus Touch Controller
  43667. */
  43668. export class OculusTouchController extends WebVRController {
  43669. /**
  43670. * Base Url for the controller model.
  43671. */
  43672. static MODEL_BASE_URL: string;
  43673. /**
  43674. * File name for the left controller model.
  43675. */
  43676. static MODEL_LEFT_FILENAME: string;
  43677. /**
  43678. * File name for the right controller model.
  43679. */
  43680. static MODEL_RIGHT_FILENAME: string;
  43681. /**
  43682. * Base Url for the Quest controller model.
  43683. */
  43684. static QUEST_MODEL_BASE_URL: string;
  43685. /**
  43686. * @hidden
  43687. * If the controllers are running on a device that needs the updated Quest controller models
  43688. */
  43689. static _IsQuest: boolean;
  43690. /**
  43691. * Fired when the secondary trigger on this controller is modified
  43692. */
  43693. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43694. /**
  43695. * Fired when the thumb rest on this controller is modified
  43696. */
  43697. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43698. /**
  43699. * Creates a new OculusTouchController from a gamepad
  43700. * @param vrGamepad the gamepad that the controller should be created from
  43701. */
  43702. constructor(vrGamepad: any);
  43703. /**
  43704. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43705. * @param scene scene in which to add meshes
  43706. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43707. */
  43708. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43709. /**
  43710. * Fired when the A button on this controller is modified
  43711. */
  43712. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43713. /**
  43714. * Fired when the B button on this controller is modified
  43715. */
  43716. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43717. /**
  43718. * Fired when the X button on this controller is modified
  43719. */
  43720. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the Y button on this controller is modified
  43723. */
  43724. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43725. /**
  43726. * Called once for each button that changed state since the last frame
  43727. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43728. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43729. * 2) secondary trigger (same)
  43730. * 3) A (right) X (left), touch, pressed = value
  43731. * 4) B / Y
  43732. * 5) thumb rest
  43733. * @param buttonIdx Which button index changed
  43734. * @param state New state of the button
  43735. * @param changes Which properties on the state changed since last frame
  43736. */
  43737. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43738. }
  43739. }
  43740. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43741. import { Scene } from "babylonjs/scene";
  43742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43743. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43744. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43745. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43746. import { Observable } from "babylonjs/Misc/observable";
  43747. /**
  43748. * Vive Controller
  43749. */
  43750. export class ViveController extends WebVRController {
  43751. /**
  43752. * Base Url for the controller model.
  43753. */
  43754. static MODEL_BASE_URL: string;
  43755. /**
  43756. * File name for the controller model.
  43757. */
  43758. static MODEL_FILENAME: string;
  43759. /**
  43760. * Creates a new ViveController from a gamepad
  43761. * @param vrGamepad the gamepad that the controller should be created from
  43762. */
  43763. constructor(vrGamepad: any);
  43764. /**
  43765. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43766. * @param scene scene in which to add meshes
  43767. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43768. */
  43769. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43770. /**
  43771. * Fired when the left button on this controller is modified
  43772. */
  43773. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43774. /**
  43775. * Fired when the right button on this controller is modified
  43776. */
  43777. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43778. /**
  43779. * Fired when the menu button on this controller is modified
  43780. */
  43781. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43782. /**
  43783. * Called once for each button that changed state since the last frame
  43784. * Vive mapping:
  43785. * 0: touchpad
  43786. * 1: trigger
  43787. * 2: left AND right buttons
  43788. * 3: menu button
  43789. * @param buttonIdx Which button index changed
  43790. * @param state New state of the button
  43791. * @param changes Which properties on the state changed since last frame
  43792. */
  43793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43794. }
  43795. }
  43796. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43797. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43798. /**
  43799. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43800. */
  43801. export class WebXRControllerModelLoader {
  43802. /**
  43803. * Creates the WebXRControllerModelLoader
  43804. * @param input xr input that creates the controllers
  43805. */
  43806. constructor(input: WebXRInput);
  43807. }
  43808. }
  43809. declare module "babylonjs/Cameras/XR/index" {
  43810. export * from "babylonjs/Cameras/XR/webXRCamera";
  43811. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43812. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43813. export * from "babylonjs/Cameras/XR/webXRInput";
  43814. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43815. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43816. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43817. export * from "babylonjs/Cameras/XR/webXRController";
  43818. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43819. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43820. }
  43821. declare module "babylonjs/Cameras/RigModes/index" {
  43822. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43823. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43824. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43825. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43826. }
  43827. declare module "babylonjs/Cameras/index" {
  43828. export * from "babylonjs/Cameras/Inputs/index";
  43829. export * from "babylonjs/Cameras/cameraInputsManager";
  43830. export * from "babylonjs/Cameras/camera";
  43831. export * from "babylonjs/Cameras/targetCamera";
  43832. export * from "babylonjs/Cameras/freeCamera";
  43833. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43834. export * from "babylonjs/Cameras/touchCamera";
  43835. export * from "babylonjs/Cameras/arcRotateCamera";
  43836. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43837. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43838. export * from "babylonjs/Cameras/flyCamera";
  43839. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43840. export * from "babylonjs/Cameras/followCamera";
  43841. export * from "babylonjs/Cameras/followCameraInputsManager";
  43842. export * from "babylonjs/Cameras/gamepadCamera";
  43843. export * from "babylonjs/Cameras/Stereoscopic/index";
  43844. export * from "babylonjs/Cameras/universalCamera";
  43845. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43846. export * from "babylonjs/Cameras/VR/index";
  43847. export * from "babylonjs/Cameras/XR/index";
  43848. export * from "babylonjs/Cameras/RigModes/index";
  43849. }
  43850. declare module "babylonjs/Collisions/index" {
  43851. export * from "babylonjs/Collisions/collider";
  43852. export * from "babylonjs/Collisions/collisionCoordinator";
  43853. export * from "babylonjs/Collisions/pickingInfo";
  43854. export * from "babylonjs/Collisions/intersectionInfo";
  43855. export * from "babylonjs/Collisions/meshCollisionData";
  43856. }
  43857. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43858. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43859. import { Vector3 } from "babylonjs/Maths/math.vector";
  43860. import { Ray } from "babylonjs/Culling/ray";
  43861. import { Plane } from "babylonjs/Maths/math.plane";
  43862. /**
  43863. * Contains an array of blocks representing the octree
  43864. */
  43865. export interface IOctreeContainer<T> {
  43866. /**
  43867. * Blocks within the octree
  43868. */
  43869. blocks: Array<OctreeBlock<T>>;
  43870. }
  43871. /**
  43872. * Class used to store a cell in an octree
  43873. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43874. */
  43875. export class OctreeBlock<T> {
  43876. /**
  43877. * Gets the content of the current block
  43878. */
  43879. entries: T[];
  43880. /**
  43881. * Gets the list of block children
  43882. */
  43883. blocks: Array<OctreeBlock<T>>;
  43884. private _depth;
  43885. private _maxDepth;
  43886. private _capacity;
  43887. private _minPoint;
  43888. private _maxPoint;
  43889. private _boundingVectors;
  43890. private _creationFunc;
  43891. /**
  43892. * Creates a new block
  43893. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43894. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43895. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43896. * @param depth defines the current depth of this block in the octree
  43897. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43898. * @param creationFunc defines a callback to call when an element is added to the block
  43899. */
  43900. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43901. /**
  43902. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43903. */
  43904. readonly capacity: number;
  43905. /**
  43906. * Gets the minimum vector (in world space) of the block's bounding box
  43907. */
  43908. readonly minPoint: Vector3;
  43909. /**
  43910. * Gets the maximum vector (in world space) of the block's bounding box
  43911. */
  43912. readonly maxPoint: Vector3;
  43913. /**
  43914. * Add a new element to this block
  43915. * @param entry defines the element to add
  43916. */
  43917. addEntry(entry: T): void;
  43918. /**
  43919. * Remove an element from this block
  43920. * @param entry defines the element to remove
  43921. */
  43922. removeEntry(entry: T): void;
  43923. /**
  43924. * Add an array of elements to this block
  43925. * @param entries defines the array of elements to add
  43926. */
  43927. addEntries(entries: T[]): void;
  43928. /**
  43929. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43930. * @param frustumPlanes defines the frustum planes to test
  43931. * @param selection defines the array to store current content if selection is positive
  43932. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43933. */
  43934. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43935. /**
  43936. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43937. * @param sphereCenter defines the bounding sphere center
  43938. * @param sphereRadius defines the bounding sphere radius
  43939. * @param selection defines the array to store current content if selection is positive
  43940. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43941. */
  43942. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43943. /**
  43944. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43945. * @param ray defines the ray to test with
  43946. * @param selection defines the array to store current content if selection is positive
  43947. */
  43948. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43949. /**
  43950. * Subdivide the content into child blocks (this block will then be empty)
  43951. */
  43952. createInnerBlocks(): void;
  43953. /**
  43954. * @hidden
  43955. */
  43956. 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;
  43957. }
  43958. }
  43959. declare module "babylonjs/Culling/Octrees/octree" {
  43960. import { SmartArray } from "babylonjs/Misc/smartArray";
  43961. import { Vector3 } from "babylonjs/Maths/math.vector";
  43962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43964. import { Ray } from "babylonjs/Culling/ray";
  43965. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43966. import { Plane } from "babylonjs/Maths/math.plane";
  43967. /**
  43968. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43969. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43970. */
  43971. export class Octree<T> {
  43972. /** 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.) */
  43973. maxDepth: number;
  43974. /**
  43975. * Blocks within the octree containing objects
  43976. */
  43977. blocks: Array<OctreeBlock<T>>;
  43978. /**
  43979. * Content stored in the octree
  43980. */
  43981. dynamicContent: T[];
  43982. private _maxBlockCapacity;
  43983. private _selectionContent;
  43984. private _creationFunc;
  43985. /**
  43986. * Creates a octree
  43987. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43988. * @param creationFunc function to be used to instatiate the octree
  43989. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43990. * @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.)
  43991. */
  43992. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43993. /** 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.) */
  43994. maxDepth?: number);
  43995. /**
  43996. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43997. * @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);
  43998. * @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);
  43999. * @param entries meshes to be added to the octree blocks
  44000. */
  44001. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44002. /**
  44003. * Adds a mesh to the octree
  44004. * @param entry Mesh to add to the octree
  44005. */
  44006. addMesh(entry: T): void;
  44007. /**
  44008. * Remove an element from the octree
  44009. * @param entry defines the element to remove
  44010. */
  44011. removeMesh(entry: T): void;
  44012. /**
  44013. * Selects an array of meshes within the frustum
  44014. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44015. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44016. * @returns array of meshes within the frustum
  44017. */
  44018. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44019. /**
  44020. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44021. * @param sphereCenter defines the bounding sphere center
  44022. * @param sphereRadius defines the bounding sphere radius
  44023. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44024. * @returns an array of objects that intersect the sphere
  44025. */
  44026. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44027. /**
  44028. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44029. * @param ray defines the ray to test with
  44030. * @returns array of intersected objects
  44031. */
  44032. intersectsRay(ray: Ray): SmartArray<T>;
  44033. /**
  44034. * Adds a mesh into the octree block if it intersects the block
  44035. */
  44036. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44037. /**
  44038. * Adds a submesh into the octree block if it intersects the block
  44039. */
  44040. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44041. }
  44042. }
  44043. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44044. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44045. import { Scene } from "babylonjs/scene";
  44046. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44048. import { Ray } from "babylonjs/Culling/ray";
  44049. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44050. import { Collider } from "babylonjs/Collisions/collider";
  44051. module "babylonjs/scene" {
  44052. interface Scene {
  44053. /**
  44054. * @hidden
  44055. * Backing Filed
  44056. */
  44057. _selectionOctree: Octree<AbstractMesh>;
  44058. /**
  44059. * Gets the octree used to boost mesh selection (picking)
  44060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44061. */
  44062. selectionOctree: Octree<AbstractMesh>;
  44063. /**
  44064. * Creates or updates the octree used to boost selection (picking)
  44065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44066. * @param maxCapacity defines the maximum capacity per leaf
  44067. * @param maxDepth defines the maximum depth of the octree
  44068. * @returns an octree of AbstractMesh
  44069. */
  44070. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44071. }
  44072. }
  44073. module "babylonjs/Meshes/abstractMesh" {
  44074. interface AbstractMesh {
  44075. /**
  44076. * @hidden
  44077. * Backing Field
  44078. */
  44079. _submeshesOctree: Octree<SubMesh>;
  44080. /**
  44081. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44082. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44083. * @param maxCapacity defines the maximum size of each block (64 by default)
  44084. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44085. * @returns the new octree
  44086. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44088. */
  44089. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44090. }
  44091. }
  44092. /**
  44093. * Defines the octree scene component responsible to manage any octrees
  44094. * in a given scene.
  44095. */
  44096. export class OctreeSceneComponent {
  44097. /**
  44098. * The component name help to identify the component in the list of scene components.
  44099. */
  44100. readonly name: string;
  44101. /**
  44102. * The scene the component belongs to.
  44103. */
  44104. scene: Scene;
  44105. /**
  44106. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44107. */
  44108. readonly checksIsEnabled: boolean;
  44109. /**
  44110. * Creates a new instance of the component for the given scene
  44111. * @param scene Defines the scene to register the component in
  44112. */
  44113. constructor(scene: Scene);
  44114. /**
  44115. * Registers the component in a given scene
  44116. */
  44117. register(): void;
  44118. /**
  44119. * Return the list of active meshes
  44120. * @returns the list of active meshes
  44121. */
  44122. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44123. /**
  44124. * Return the list of active sub meshes
  44125. * @param mesh The mesh to get the candidates sub meshes from
  44126. * @returns the list of active sub meshes
  44127. */
  44128. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44129. private _tempRay;
  44130. /**
  44131. * Return the list of sub meshes intersecting with a given local ray
  44132. * @param mesh defines the mesh to find the submesh for
  44133. * @param localRay defines the ray in local space
  44134. * @returns the list of intersecting sub meshes
  44135. */
  44136. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44137. /**
  44138. * Return the list of sub meshes colliding with a collider
  44139. * @param mesh defines the mesh to find the submesh for
  44140. * @param collider defines the collider to evaluate the collision against
  44141. * @returns the list of colliding sub meshes
  44142. */
  44143. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44144. /**
  44145. * Rebuilds the elements related to this component in case of
  44146. * context lost for instance.
  44147. */
  44148. rebuild(): void;
  44149. /**
  44150. * Disposes the component and the associated ressources.
  44151. */
  44152. dispose(): void;
  44153. }
  44154. }
  44155. declare module "babylonjs/Culling/Octrees/index" {
  44156. export * from "babylonjs/Culling/Octrees/octree";
  44157. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44158. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44159. }
  44160. declare module "babylonjs/Culling/index" {
  44161. export * from "babylonjs/Culling/boundingBox";
  44162. export * from "babylonjs/Culling/boundingInfo";
  44163. export * from "babylonjs/Culling/boundingSphere";
  44164. export * from "babylonjs/Culling/Octrees/index";
  44165. export * from "babylonjs/Culling/ray";
  44166. }
  44167. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44168. import { IDisposable, Scene } from "babylonjs/scene";
  44169. import { Nullable } from "babylonjs/types";
  44170. import { Observable } from "babylonjs/Misc/observable";
  44171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44172. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44173. import { Camera } from "babylonjs/Cameras/camera";
  44174. /**
  44175. * Renders a layer on top of an existing scene
  44176. */
  44177. export class UtilityLayerRenderer implements IDisposable {
  44178. /** the original scene that will be rendered on top of */
  44179. originalScene: Scene;
  44180. private _pointerCaptures;
  44181. private _lastPointerEvents;
  44182. private static _DefaultUtilityLayer;
  44183. private static _DefaultKeepDepthUtilityLayer;
  44184. private _sharedGizmoLight;
  44185. private _renderCamera;
  44186. /**
  44187. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44188. * @returns the camera that is used when rendering the utility layer
  44189. */
  44190. getRenderCamera(): Nullable<Camera>;
  44191. /**
  44192. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44193. * @param cam the camera that should be used when rendering the utility layer
  44194. */
  44195. setRenderCamera(cam: Nullable<Camera>): void;
  44196. /**
  44197. * @hidden
  44198. * Light which used by gizmos to get light shading
  44199. */
  44200. _getSharedGizmoLight(): HemisphericLight;
  44201. /**
  44202. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44203. */
  44204. pickUtilitySceneFirst: boolean;
  44205. /**
  44206. * 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)
  44207. */
  44208. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44209. /**
  44210. * 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)
  44211. */
  44212. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44213. /**
  44214. * The scene that is rendered on top of the original scene
  44215. */
  44216. utilityLayerScene: Scene;
  44217. /**
  44218. * If the utility layer should automatically be rendered on top of existing scene
  44219. */
  44220. shouldRender: boolean;
  44221. /**
  44222. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44223. */
  44224. onlyCheckPointerDownEvents: boolean;
  44225. /**
  44226. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44227. */
  44228. processAllEvents: boolean;
  44229. /**
  44230. * Observable raised when the pointer move from the utility layer scene to the main scene
  44231. */
  44232. onPointerOutObservable: Observable<number>;
  44233. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44234. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44235. private _afterRenderObserver;
  44236. private _sceneDisposeObserver;
  44237. private _originalPointerObserver;
  44238. /**
  44239. * Instantiates a UtilityLayerRenderer
  44240. * @param originalScene the original scene that will be rendered on top of
  44241. * @param handleEvents boolean indicating if the utility layer should handle events
  44242. */
  44243. constructor(
  44244. /** the original scene that will be rendered on top of */
  44245. originalScene: Scene, handleEvents?: boolean);
  44246. private _notifyObservers;
  44247. /**
  44248. * Renders the utility layers scene on top of the original scene
  44249. */
  44250. render(): void;
  44251. /**
  44252. * Disposes of the renderer
  44253. */
  44254. dispose(): void;
  44255. private _updateCamera;
  44256. }
  44257. }
  44258. declare module "babylonjs/Gizmos/gizmo" {
  44259. import { Nullable } from "babylonjs/types";
  44260. import { IDisposable } from "babylonjs/scene";
  44261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44262. import { Mesh } from "babylonjs/Meshes/mesh";
  44263. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44264. /**
  44265. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44266. */
  44267. export class Gizmo implements IDisposable {
  44268. /** The utility layer the gizmo will be added to */
  44269. gizmoLayer: UtilityLayerRenderer;
  44270. /**
  44271. * The root mesh of the gizmo
  44272. */
  44273. _rootMesh: Mesh;
  44274. private _attachedMesh;
  44275. /**
  44276. * Ratio for the scale of the gizmo (Default: 1)
  44277. */
  44278. scaleRatio: number;
  44279. /**
  44280. * If a custom mesh has been set (Default: false)
  44281. */
  44282. protected _customMeshSet: boolean;
  44283. /**
  44284. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44285. * * When set, interactions will be enabled
  44286. */
  44287. attachedMesh: Nullable<AbstractMesh>;
  44288. /**
  44289. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44290. * @param mesh The mesh to replace the default mesh of the gizmo
  44291. */
  44292. setCustomMesh(mesh: Mesh): void;
  44293. /**
  44294. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44295. */
  44296. updateGizmoRotationToMatchAttachedMesh: boolean;
  44297. /**
  44298. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44299. */
  44300. updateGizmoPositionToMatchAttachedMesh: boolean;
  44301. /**
  44302. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44303. */
  44304. updateScale: boolean;
  44305. protected _interactionsEnabled: boolean;
  44306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44307. private _beforeRenderObserver;
  44308. private _tempVector;
  44309. /**
  44310. * Creates a gizmo
  44311. * @param gizmoLayer The utility layer the gizmo will be added to
  44312. */
  44313. constructor(
  44314. /** The utility layer the gizmo will be added to */
  44315. gizmoLayer?: UtilityLayerRenderer);
  44316. /**
  44317. * Updates the gizmo to match the attached mesh's position/rotation
  44318. */
  44319. protected _update(): void;
  44320. /**
  44321. * Disposes of the gizmo
  44322. */
  44323. dispose(): void;
  44324. }
  44325. }
  44326. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44327. import { Observable } from "babylonjs/Misc/observable";
  44328. import { Nullable } from "babylonjs/types";
  44329. import { Vector3 } from "babylonjs/Maths/math.vector";
  44330. import { Color3 } from "babylonjs/Maths/math.color";
  44331. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44333. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44334. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44335. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44336. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44337. import { Scene } from "babylonjs/scene";
  44338. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44339. /**
  44340. * Single plane drag gizmo
  44341. */
  44342. export class PlaneDragGizmo extends Gizmo {
  44343. /**
  44344. * Drag behavior responsible for the gizmos dragging interactions
  44345. */
  44346. dragBehavior: PointerDragBehavior;
  44347. private _pointerObserver;
  44348. /**
  44349. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44350. */
  44351. snapDistance: number;
  44352. /**
  44353. * Event that fires each time the gizmo snaps to a new location.
  44354. * * snapDistance is the the change in distance
  44355. */
  44356. onSnapObservable: Observable<{
  44357. snapDistance: number;
  44358. }>;
  44359. private _plane;
  44360. private _coloredMaterial;
  44361. private _hoverMaterial;
  44362. private _isEnabled;
  44363. private _parent;
  44364. /** @hidden */
  44365. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44366. /** @hidden */
  44367. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44368. /**
  44369. * Creates a PlaneDragGizmo
  44370. * @param gizmoLayer The utility layer the gizmo will be added to
  44371. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44372. * @param color The color of the gizmo
  44373. */
  44374. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44375. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44376. /**
  44377. * If the gizmo is enabled
  44378. */
  44379. isEnabled: boolean;
  44380. /**
  44381. * Disposes of the gizmo
  44382. */
  44383. dispose(): void;
  44384. }
  44385. }
  44386. declare module "babylonjs/Gizmos/positionGizmo" {
  44387. import { Observable } from "babylonjs/Misc/observable";
  44388. import { Nullable } from "babylonjs/types";
  44389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44390. import { Mesh } from "babylonjs/Meshes/mesh";
  44391. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44392. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44393. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44394. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44395. /**
  44396. * Gizmo that enables dragging a mesh along 3 axis
  44397. */
  44398. export class PositionGizmo extends Gizmo {
  44399. /**
  44400. * Internal gizmo used for interactions on the x axis
  44401. */
  44402. xGizmo: AxisDragGizmo;
  44403. /**
  44404. * Internal gizmo used for interactions on the y axis
  44405. */
  44406. yGizmo: AxisDragGizmo;
  44407. /**
  44408. * Internal gizmo used for interactions on the z axis
  44409. */
  44410. zGizmo: AxisDragGizmo;
  44411. /**
  44412. * Internal gizmo used for interactions on the yz plane
  44413. */
  44414. xPlaneGizmo: PlaneDragGizmo;
  44415. /**
  44416. * Internal gizmo used for interactions on the xz plane
  44417. */
  44418. yPlaneGizmo: PlaneDragGizmo;
  44419. /**
  44420. * Internal gizmo used for interactions on the xy plane
  44421. */
  44422. zPlaneGizmo: PlaneDragGizmo;
  44423. /**
  44424. * private variables
  44425. */
  44426. private _meshAttached;
  44427. private _updateGizmoRotationToMatchAttachedMesh;
  44428. private _snapDistance;
  44429. private _scaleRatio;
  44430. /** Fires an event when any of it's sub gizmos are dragged */
  44431. onDragStartObservable: Observable<unknown>;
  44432. /** Fires an event when any of it's sub gizmos are released from dragging */
  44433. onDragEndObservable: Observable<unknown>;
  44434. /**
  44435. * If set to true, planar drag is enabled
  44436. */
  44437. private _planarGizmoEnabled;
  44438. attachedMesh: Nullable<AbstractMesh>;
  44439. /**
  44440. * Creates a PositionGizmo
  44441. * @param gizmoLayer The utility layer the gizmo will be added to
  44442. */
  44443. constructor(gizmoLayer?: UtilityLayerRenderer);
  44444. /**
  44445. * If the planar drag gizmo is enabled
  44446. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44447. */
  44448. planarGizmoEnabled: boolean;
  44449. updateGizmoRotationToMatchAttachedMesh: boolean;
  44450. /**
  44451. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44452. */
  44453. snapDistance: number;
  44454. /**
  44455. * Ratio for the scale of the gizmo (Default: 1)
  44456. */
  44457. scaleRatio: number;
  44458. /**
  44459. * Disposes of the gizmo
  44460. */
  44461. dispose(): void;
  44462. /**
  44463. * CustomMeshes are not supported by this gizmo
  44464. * @param mesh The mesh to replace the default mesh of the gizmo
  44465. */
  44466. setCustomMesh(mesh: Mesh): void;
  44467. }
  44468. }
  44469. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44470. import { Observable } from "babylonjs/Misc/observable";
  44471. import { Nullable } from "babylonjs/types";
  44472. import { Vector3 } from "babylonjs/Maths/math.vector";
  44473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44475. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44476. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44477. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44478. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44479. import { Scene } from "babylonjs/scene";
  44480. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44481. import { Color3 } from "babylonjs/Maths/math.color";
  44482. /**
  44483. * Single axis drag gizmo
  44484. */
  44485. export class AxisDragGizmo extends Gizmo {
  44486. /**
  44487. * Drag behavior responsible for the gizmos dragging interactions
  44488. */
  44489. dragBehavior: PointerDragBehavior;
  44490. private _pointerObserver;
  44491. /**
  44492. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44493. */
  44494. snapDistance: number;
  44495. /**
  44496. * Event that fires each time the gizmo snaps to a new location.
  44497. * * snapDistance is the the change in distance
  44498. */
  44499. onSnapObservable: Observable<{
  44500. snapDistance: number;
  44501. }>;
  44502. private _isEnabled;
  44503. private _parent;
  44504. private _arrow;
  44505. private _coloredMaterial;
  44506. private _hoverMaterial;
  44507. /** @hidden */
  44508. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44509. /** @hidden */
  44510. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44511. /**
  44512. * Creates an AxisDragGizmo
  44513. * @param gizmoLayer The utility layer the gizmo will be added to
  44514. * @param dragAxis The axis which the gizmo will be able to drag on
  44515. * @param color The color of the gizmo
  44516. */
  44517. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44518. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44519. /**
  44520. * If the gizmo is enabled
  44521. */
  44522. isEnabled: boolean;
  44523. /**
  44524. * Disposes of the gizmo
  44525. */
  44526. dispose(): void;
  44527. }
  44528. }
  44529. declare module "babylonjs/Debug/axesViewer" {
  44530. import { Vector3 } from "babylonjs/Maths/math.vector";
  44531. import { Nullable } from "babylonjs/types";
  44532. import { Scene } from "babylonjs/scene";
  44533. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44534. /**
  44535. * The Axes viewer will show 3 axes in a specific point in space
  44536. */
  44537. export class AxesViewer {
  44538. private _xAxis;
  44539. private _yAxis;
  44540. private _zAxis;
  44541. private _scaleLinesFactor;
  44542. private _instanced;
  44543. /**
  44544. * Gets the hosting scene
  44545. */
  44546. scene: Scene;
  44547. /**
  44548. * Gets or sets a number used to scale line length
  44549. */
  44550. scaleLines: number;
  44551. /** Gets the node hierarchy used to render x-axis */
  44552. readonly xAxis: TransformNode;
  44553. /** Gets the node hierarchy used to render y-axis */
  44554. readonly yAxis: TransformNode;
  44555. /** Gets the node hierarchy used to render z-axis */
  44556. readonly zAxis: TransformNode;
  44557. /**
  44558. * Creates a new AxesViewer
  44559. * @param scene defines the hosting scene
  44560. * @param scaleLines defines a number used to scale line length (1 by default)
  44561. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44562. * @param xAxis defines the node hierarchy used to render the x-axis
  44563. * @param yAxis defines the node hierarchy used to render the y-axis
  44564. * @param zAxis defines the node hierarchy used to render the z-axis
  44565. */
  44566. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44567. /**
  44568. * Force the viewer to update
  44569. * @param position defines the position of the viewer
  44570. * @param xaxis defines the x axis of the viewer
  44571. * @param yaxis defines the y axis of the viewer
  44572. * @param zaxis defines the z axis of the viewer
  44573. */
  44574. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44575. /**
  44576. * Creates an instance of this axes viewer.
  44577. * @returns a new axes viewer with instanced meshes
  44578. */
  44579. createInstance(): AxesViewer;
  44580. /** Releases resources */
  44581. dispose(): void;
  44582. private static _SetRenderingGroupId;
  44583. }
  44584. }
  44585. declare module "babylonjs/Debug/boneAxesViewer" {
  44586. import { Nullable } from "babylonjs/types";
  44587. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44588. import { Vector3 } from "babylonjs/Maths/math.vector";
  44589. import { Mesh } from "babylonjs/Meshes/mesh";
  44590. import { Bone } from "babylonjs/Bones/bone";
  44591. import { Scene } from "babylonjs/scene";
  44592. /**
  44593. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44594. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44595. */
  44596. export class BoneAxesViewer extends AxesViewer {
  44597. /**
  44598. * Gets or sets the target mesh where to display the axes viewer
  44599. */
  44600. mesh: Nullable<Mesh>;
  44601. /**
  44602. * Gets or sets the target bone where to display the axes viewer
  44603. */
  44604. bone: Nullable<Bone>;
  44605. /** Gets current position */
  44606. pos: Vector3;
  44607. /** Gets direction of X axis */
  44608. xaxis: Vector3;
  44609. /** Gets direction of Y axis */
  44610. yaxis: Vector3;
  44611. /** Gets direction of Z axis */
  44612. zaxis: Vector3;
  44613. /**
  44614. * Creates a new BoneAxesViewer
  44615. * @param scene defines the hosting scene
  44616. * @param bone defines the target bone
  44617. * @param mesh defines the target mesh
  44618. * @param scaleLines defines a scaling factor for line length (1 by default)
  44619. */
  44620. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44621. /**
  44622. * Force the viewer to update
  44623. */
  44624. update(): void;
  44625. /** Releases resources */
  44626. dispose(): void;
  44627. }
  44628. }
  44629. declare module "babylonjs/Debug/debugLayer" {
  44630. import { Scene } from "babylonjs/scene";
  44631. /**
  44632. * Interface used to define scene explorer extensibility option
  44633. */
  44634. export interface IExplorerExtensibilityOption {
  44635. /**
  44636. * Define the option label
  44637. */
  44638. label: string;
  44639. /**
  44640. * Defines the action to execute on click
  44641. */
  44642. action: (entity: any) => void;
  44643. }
  44644. /**
  44645. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44646. */
  44647. export interface IExplorerExtensibilityGroup {
  44648. /**
  44649. * Defines a predicate to test if a given type mut be extended
  44650. */
  44651. predicate: (entity: any) => boolean;
  44652. /**
  44653. * Gets the list of options added to a type
  44654. */
  44655. entries: IExplorerExtensibilityOption[];
  44656. }
  44657. /**
  44658. * Interface used to define the options to use to create the Inspector
  44659. */
  44660. export interface IInspectorOptions {
  44661. /**
  44662. * Display in overlay mode (default: false)
  44663. */
  44664. overlay?: boolean;
  44665. /**
  44666. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44667. */
  44668. globalRoot?: HTMLElement;
  44669. /**
  44670. * Display the Scene explorer
  44671. */
  44672. showExplorer?: boolean;
  44673. /**
  44674. * Display the property inspector
  44675. */
  44676. showInspector?: boolean;
  44677. /**
  44678. * Display in embed mode (both panes on the right)
  44679. */
  44680. embedMode?: boolean;
  44681. /**
  44682. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44683. */
  44684. handleResize?: boolean;
  44685. /**
  44686. * Allow the panes to popup (default: true)
  44687. */
  44688. enablePopup?: boolean;
  44689. /**
  44690. * Allow the panes to be closed by users (default: true)
  44691. */
  44692. enableClose?: boolean;
  44693. /**
  44694. * Optional list of extensibility entries
  44695. */
  44696. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44697. /**
  44698. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44699. */
  44700. inspectorURL?: string;
  44701. }
  44702. module "babylonjs/scene" {
  44703. interface Scene {
  44704. /**
  44705. * @hidden
  44706. * Backing field
  44707. */
  44708. _debugLayer: DebugLayer;
  44709. /**
  44710. * Gets the debug layer (aka Inspector) associated with the scene
  44711. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44712. */
  44713. debugLayer: DebugLayer;
  44714. }
  44715. }
  44716. /**
  44717. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44718. * what is happening in your scene
  44719. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44720. */
  44721. export class DebugLayer {
  44722. /**
  44723. * Define the url to get the inspector script from.
  44724. * By default it uses the babylonjs CDN.
  44725. * @ignoreNaming
  44726. */
  44727. static InspectorURL: string;
  44728. private _scene;
  44729. private BJSINSPECTOR;
  44730. private _onPropertyChangedObservable?;
  44731. /**
  44732. * Observable triggered when a property is changed through the inspector.
  44733. */
  44734. readonly onPropertyChangedObservable: any;
  44735. /**
  44736. * Instantiates a new debug layer.
  44737. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44738. * what is happening in your scene
  44739. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44740. * @param scene Defines the scene to inspect
  44741. */
  44742. constructor(scene: Scene);
  44743. /** Creates the inspector window. */
  44744. private _createInspector;
  44745. /**
  44746. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44747. * @param entity defines the entity to select
  44748. * @param lineContainerTitle defines the specific block to highlight
  44749. */
  44750. select(entity: any, lineContainerTitle?: string): void;
  44751. /** Get the inspector from bundle or global */
  44752. private _getGlobalInspector;
  44753. /**
  44754. * Get if the inspector is visible or not.
  44755. * @returns true if visible otherwise, false
  44756. */
  44757. isVisible(): boolean;
  44758. /**
  44759. * Hide the inspector and close its window.
  44760. */
  44761. hide(): void;
  44762. /**
  44763. * Launch the debugLayer.
  44764. * @param config Define the configuration of the inspector
  44765. * @return a promise fulfilled when the debug layer is visible
  44766. */
  44767. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44768. }
  44769. }
  44770. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44771. import { Nullable } from "babylonjs/types";
  44772. import { Scene } from "babylonjs/scene";
  44773. import { Vector4 } from "babylonjs/Maths/math.vector";
  44774. import { Color4 } from "babylonjs/Maths/math.color";
  44775. import { Mesh } from "babylonjs/Meshes/mesh";
  44776. /**
  44777. * Class containing static functions to help procedurally build meshes
  44778. */
  44779. export class BoxBuilder {
  44780. /**
  44781. * Creates a box mesh
  44782. * * The parameter `size` sets the size (float) of each box side (default 1)
  44783. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44784. * * 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)
  44785. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44789. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44790. * @param name defines the name of the mesh
  44791. * @param options defines the options used to create the mesh
  44792. * @param scene defines the hosting scene
  44793. * @returns the box mesh
  44794. */
  44795. static CreateBox(name: string, options: {
  44796. size?: number;
  44797. width?: number;
  44798. height?: number;
  44799. depth?: number;
  44800. faceUV?: Vector4[];
  44801. faceColors?: Color4[];
  44802. sideOrientation?: number;
  44803. frontUVs?: Vector4;
  44804. backUVs?: Vector4;
  44805. wrap?: boolean;
  44806. topBaseAt?: number;
  44807. bottomBaseAt?: number;
  44808. updatable?: boolean;
  44809. }, scene?: Nullable<Scene>): Mesh;
  44810. }
  44811. }
  44812. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44813. import { Vector4 } from "babylonjs/Maths/math.vector";
  44814. import { Mesh } from "babylonjs/Meshes/mesh";
  44815. import { Scene } from "babylonjs/scene";
  44816. import { Nullable } from "babylonjs/types";
  44817. /**
  44818. * Class containing static functions to help procedurally build meshes
  44819. */
  44820. export class SphereBuilder {
  44821. /**
  44822. * Creates a sphere mesh
  44823. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44824. * * 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`)
  44825. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44826. * * 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
  44827. * * 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)
  44828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44831. * @param name defines the name of the mesh
  44832. * @param options defines the options used to create the mesh
  44833. * @param scene defines the hosting scene
  44834. * @returns the sphere mesh
  44835. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44836. */
  44837. static CreateSphere(name: string, options: {
  44838. segments?: number;
  44839. diameter?: number;
  44840. diameterX?: number;
  44841. diameterY?: number;
  44842. diameterZ?: number;
  44843. arc?: number;
  44844. slice?: number;
  44845. sideOrientation?: number;
  44846. frontUVs?: Vector4;
  44847. backUVs?: Vector4;
  44848. updatable?: boolean;
  44849. }, scene?: Nullable<Scene>): Mesh;
  44850. }
  44851. }
  44852. declare module "babylonjs/Debug/physicsViewer" {
  44853. import { Nullable } from "babylonjs/types";
  44854. import { Scene } from "babylonjs/scene";
  44855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44856. import { Mesh } from "babylonjs/Meshes/mesh";
  44857. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44858. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44859. /**
  44860. * Used to show the physics impostor around the specific mesh
  44861. */
  44862. export class PhysicsViewer {
  44863. /** @hidden */
  44864. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44865. /** @hidden */
  44866. protected _meshes: Array<Nullable<AbstractMesh>>;
  44867. /** @hidden */
  44868. protected _scene: Nullable<Scene>;
  44869. /** @hidden */
  44870. protected _numMeshes: number;
  44871. /** @hidden */
  44872. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44873. private _renderFunction;
  44874. private _utilityLayer;
  44875. private _debugBoxMesh;
  44876. private _debugSphereMesh;
  44877. private _debugCylinderMesh;
  44878. private _debugMaterial;
  44879. private _debugMeshMeshes;
  44880. /**
  44881. * Creates a new PhysicsViewer
  44882. * @param scene defines the hosting scene
  44883. */
  44884. constructor(scene: Scene);
  44885. /** @hidden */
  44886. protected _updateDebugMeshes(): void;
  44887. /**
  44888. * Renders a specified physic impostor
  44889. * @param impostor defines the impostor to render
  44890. * @param targetMesh defines the mesh represented by the impostor
  44891. * @returns the new debug mesh used to render the impostor
  44892. */
  44893. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44894. /**
  44895. * Hides a specified physic impostor
  44896. * @param impostor defines the impostor to hide
  44897. */
  44898. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44899. private _getDebugMaterial;
  44900. private _getDebugBoxMesh;
  44901. private _getDebugSphereMesh;
  44902. private _getDebugCylinderMesh;
  44903. private _getDebugMeshMesh;
  44904. private _getDebugMesh;
  44905. /** Releases all resources */
  44906. dispose(): void;
  44907. }
  44908. }
  44909. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44910. import { Vector3 } from "babylonjs/Maths/math.vector";
  44911. import { Color4 } from "babylonjs/Maths/math.color";
  44912. import { Nullable } from "babylonjs/types";
  44913. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44914. import { Scene } from "babylonjs/scene";
  44915. /**
  44916. * Class containing static functions to help procedurally build meshes
  44917. */
  44918. export class LinesBuilder {
  44919. /**
  44920. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44921. * * 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
  44922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44923. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44924. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44925. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44926. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44927. * * 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
  44928. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44931. * @param name defines the name of the new line system
  44932. * @param options defines the options used to create the line system
  44933. * @param scene defines the hosting scene
  44934. * @returns a new line system mesh
  44935. */
  44936. static CreateLineSystem(name: string, options: {
  44937. lines: Vector3[][];
  44938. updatable?: boolean;
  44939. instance?: Nullable<LinesMesh>;
  44940. colors?: Nullable<Color4[][]>;
  44941. useVertexAlpha?: boolean;
  44942. }, scene: Nullable<Scene>): LinesMesh;
  44943. /**
  44944. * Creates a line mesh
  44945. * 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
  44946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44947. * * The parameter `points` is an array successive Vector3
  44948. * * 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
  44949. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44950. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44951. * * When updating an instance, remember that only point positions can change, not the number of points
  44952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44954. * @param name defines the name of the new line system
  44955. * @param options defines the options used to create the line system
  44956. * @param scene defines the hosting scene
  44957. * @returns a new line mesh
  44958. */
  44959. static CreateLines(name: string, options: {
  44960. points: Vector3[];
  44961. updatable?: boolean;
  44962. instance?: Nullable<LinesMesh>;
  44963. colors?: Color4[];
  44964. useVertexAlpha?: boolean;
  44965. }, scene?: Nullable<Scene>): LinesMesh;
  44966. /**
  44967. * Creates a dashed line mesh
  44968. * * 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
  44969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44970. * * The parameter `points` is an array successive Vector3
  44971. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44972. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44973. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44974. * * 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
  44975. * * When updating an instance, remember that only point positions can change, not the number of points
  44976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44977. * @param name defines the name of the mesh
  44978. * @param options defines the options used to create the mesh
  44979. * @param scene defines the hosting scene
  44980. * @returns the dashed line mesh
  44981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44982. */
  44983. static CreateDashedLines(name: string, options: {
  44984. points: Vector3[];
  44985. dashSize?: number;
  44986. gapSize?: number;
  44987. dashNb?: number;
  44988. updatable?: boolean;
  44989. instance?: LinesMesh;
  44990. }, scene?: Nullable<Scene>): LinesMesh;
  44991. }
  44992. }
  44993. declare module "babylonjs/Debug/rayHelper" {
  44994. import { Nullable } from "babylonjs/types";
  44995. import { Ray } from "babylonjs/Culling/ray";
  44996. import { Vector3 } from "babylonjs/Maths/math.vector";
  44997. import { Color3 } from "babylonjs/Maths/math.color";
  44998. import { Scene } from "babylonjs/scene";
  44999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45000. import "babylonjs/Meshes/Builders/linesBuilder";
  45001. /**
  45002. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45003. * in order to better appreciate the issue one might have.
  45004. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45005. */
  45006. export class RayHelper {
  45007. /**
  45008. * Defines the ray we are currently tryin to visualize.
  45009. */
  45010. ray: Nullable<Ray>;
  45011. private _renderPoints;
  45012. private _renderLine;
  45013. private _renderFunction;
  45014. private _scene;
  45015. private _updateToMeshFunction;
  45016. private _attachedToMesh;
  45017. private _meshSpaceDirection;
  45018. private _meshSpaceOrigin;
  45019. /**
  45020. * Helper function to create a colored helper in a scene in one line.
  45021. * @param ray Defines the ray we are currently tryin to visualize
  45022. * @param scene Defines the scene the ray is used in
  45023. * @param color Defines the color we want to see the ray in
  45024. * @returns The newly created ray helper.
  45025. */
  45026. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45027. /**
  45028. * Instantiate a new ray helper.
  45029. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45030. * in order to better appreciate the issue one might have.
  45031. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45032. * @param ray Defines the ray we are currently tryin to visualize
  45033. */
  45034. constructor(ray: Ray);
  45035. /**
  45036. * Shows the ray we are willing to debug.
  45037. * @param scene Defines the scene the ray needs to be rendered in
  45038. * @param color Defines the color the ray needs to be rendered in
  45039. */
  45040. show(scene: Scene, color?: Color3): void;
  45041. /**
  45042. * Hides the ray we are debugging.
  45043. */
  45044. hide(): void;
  45045. private _render;
  45046. /**
  45047. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45048. * @param mesh Defines the mesh we want the helper attached to
  45049. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45050. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45051. * @param length Defines the length of the ray
  45052. */
  45053. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45054. /**
  45055. * Detach the ray helper from the mesh it has previously been attached to.
  45056. */
  45057. detachFromMesh(): void;
  45058. private _updateToMesh;
  45059. /**
  45060. * Dispose the helper and release its associated resources.
  45061. */
  45062. dispose(): void;
  45063. }
  45064. }
  45065. declare module "babylonjs/Debug/skeletonViewer" {
  45066. import { Color3 } from "babylonjs/Maths/math.color";
  45067. import { Scene } from "babylonjs/scene";
  45068. import { Nullable } from "babylonjs/types";
  45069. import { Skeleton } from "babylonjs/Bones/skeleton";
  45070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45071. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45072. /**
  45073. * Class used to render a debug view of a given skeleton
  45074. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45075. */
  45076. export class SkeletonViewer {
  45077. /** defines the skeleton to render */
  45078. skeleton: Skeleton;
  45079. /** defines the mesh attached to the skeleton */
  45080. mesh: AbstractMesh;
  45081. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45082. autoUpdateBonesMatrices: boolean;
  45083. /** defines the rendering group id to use with the viewer */
  45084. renderingGroupId: number;
  45085. /** Gets or sets the color used to render the skeleton */
  45086. color: Color3;
  45087. private _scene;
  45088. private _debugLines;
  45089. private _debugMesh;
  45090. private _isEnabled;
  45091. private _renderFunction;
  45092. private _utilityLayer;
  45093. /**
  45094. * Returns the mesh used to render the bones
  45095. */
  45096. readonly debugMesh: Nullable<LinesMesh>;
  45097. /**
  45098. * Creates a new SkeletonViewer
  45099. * @param skeleton defines the skeleton to render
  45100. * @param mesh defines the mesh attached to the skeleton
  45101. * @param scene defines the hosting scene
  45102. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45103. * @param renderingGroupId defines the rendering group id to use with the viewer
  45104. */
  45105. constructor(
  45106. /** defines the skeleton to render */
  45107. skeleton: Skeleton,
  45108. /** defines the mesh attached to the skeleton */
  45109. mesh: AbstractMesh, scene: Scene,
  45110. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45111. autoUpdateBonesMatrices?: boolean,
  45112. /** defines the rendering group id to use with the viewer */
  45113. renderingGroupId?: number);
  45114. /** Gets or sets a boolean indicating if the viewer is enabled */
  45115. isEnabled: boolean;
  45116. private _getBonePosition;
  45117. private _getLinesForBonesWithLength;
  45118. private _getLinesForBonesNoLength;
  45119. /** Update the viewer to sync with current skeleton state */
  45120. update(): void;
  45121. /** Release associated resources */
  45122. dispose(): void;
  45123. }
  45124. }
  45125. declare module "babylonjs/Debug/index" {
  45126. export * from "babylonjs/Debug/axesViewer";
  45127. export * from "babylonjs/Debug/boneAxesViewer";
  45128. export * from "babylonjs/Debug/debugLayer";
  45129. export * from "babylonjs/Debug/physicsViewer";
  45130. export * from "babylonjs/Debug/rayHelper";
  45131. export * from "babylonjs/Debug/skeletonViewer";
  45132. }
  45133. declare module "babylonjs/Engines/nullEngine" {
  45134. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45135. import { Scene } from "babylonjs/scene";
  45136. import { Engine } from "babylonjs/Engines/engine";
  45137. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45138. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45139. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45140. import { Effect } from "babylonjs/Materials/effect";
  45141. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45142. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45143. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45144. /**
  45145. * Options to create the null engine
  45146. */
  45147. export class NullEngineOptions {
  45148. /**
  45149. * Render width (Default: 512)
  45150. */
  45151. renderWidth: number;
  45152. /**
  45153. * Render height (Default: 256)
  45154. */
  45155. renderHeight: number;
  45156. /**
  45157. * Texture size (Default: 512)
  45158. */
  45159. textureSize: number;
  45160. /**
  45161. * If delta time between frames should be constant
  45162. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45163. */
  45164. deterministicLockstep: boolean;
  45165. /**
  45166. * Maximum about of steps between frames (Default: 4)
  45167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45168. */
  45169. lockstepMaxSteps: number;
  45170. }
  45171. /**
  45172. * The null engine class provides support for headless version of babylon.js.
  45173. * This can be used in server side scenario or for testing purposes
  45174. */
  45175. export class NullEngine extends Engine {
  45176. private _options;
  45177. /**
  45178. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45179. */
  45180. isDeterministicLockStep(): boolean;
  45181. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45182. getLockstepMaxSteps(): number;
  45183. /**
  45184. * Sets hardware scaling, used to save performance if needed
  45185. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45186. */
  45187. getHardwareScalingLevel(): number;
  45188. constructor(options?: NullEngineOptions);
  45189. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45190. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45191. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45192. getRenderWidth(useScreen?: boolean): number;
  45193. getRenderHeight(useScreen?: boolean): number;
  45194. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45195. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45196. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45197. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45198. bindSamplers(effect: Effect): void;
  45199. enableEffect(effect: Effect): void;
  45200. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45201. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45202. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45203. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45204. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45205. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45206. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45207. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45208. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45209. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45210. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45211. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45212. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45213. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45214. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45215. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45216. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45217. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45218. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45219. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45220. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45221. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45222. bindBuffers(vertexBuffers: {
  45223. [key: string]: VertexBuffer;
  45224. }, indexBuffer: DataBuffer, effect: Effect): void;
  45225. wipeCaches(bruteForce?: boolean): void;
  45226. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45227. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45228. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45229. /** @hidden */
  45230. _createTexture(): WebGLTexture;
  45231. /** @hidden */
  45232. _releaseTexture(texture: InternalTexture): void;
  45233. 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;
  45234. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45235. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45236. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45237. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45238. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45239. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45240. areAllEffectsReady(): boolean;
  45241. /**
  45242. * @hidden
  45243. * Get the current error code of the webGL context
  45244. * @returns the error code
  45245. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45246. */
  45247. getError(): number;
  45248. /** @hidden */
  45249. _getUnpackAlignement(): number;
  45250. /** @hidden */
  45251. _unpackFlipY(value: boolean): void;
  45252. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45253. /**
  45254. * Updates a dynamic vertex buffer.
  45255. * @param vertexBuffer the vertex buffer to update
  45256. * @param data the data used to update the vertex buffer
  45257. * @param byteOffset the byte offset of the data (optional)
  45258. * @param byteLength the byte length of the data (optional)
  45259. */
  45260. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45261. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45262. /** @hidden */
  45263. _bindTexture(channel: number, texture: InternalTexture): void;
  45264. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45265. releaseEffects(): void;
  45266. displayLoadingUI(): void;
  45267. hideLoadingUI(): void;
  45268. /** @hidden */
  45269. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45270. /** @hidden */
  45271. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45272. /** @hidden */
  45273. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45274. /** @hidden */
  45275. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45276. }
  45277. }
  45278. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45279. import { Nullable, int } from "babylonjs/types";
  45280. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45281. /** @hidden */
  45282. export class _OcclusionDataStorage {
  45283. /** @hidden */
  45284. occlusionInternalRetryCounter: number;
  45285. /** @hidden */
  45286. isOcclusionQueryInProgress: boolean;
  45287. /** @hidden */
  45288. isOccluded: boolean;
  45289. /** @hidden */
  45290. occlusionRetryCount: number;
  45291. /** @hidden */
  45292. occlusionType: number;
  45293. /** @hidden */
  45294. occlusionQueryAlgorithmType: number;
  45295. }
  45296. module "babylonjs/Engines/engine" {
  45297. interface Engine {
  45298. /**
  45299. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45300. * @return the new query
  45301. */
  45302. createQuery(): WebGLQuery;
  45303. /**
  45304. * Delete and release a webGL query
  45305. * @param query defines the query to delete
  45306. * @return the current engine
  45307. */
  45308. deleteQuery(query: WebGLQuery): Engine;
  45309. /**
  45310. * Check if a given query has resolved and got its value
  45311. * @param query defines the query to check
  45312. * @returns true if the query got its value
  45313. */
  45314. isQueryResultAvailable(query: WebGLQuery): boolean;
  45315. /**
  45316. * Gets the value of a given query
  45317. * @param query defines the query to check
  45318. * @returns the value of the query
  45319. */
  45320. getQueryResult(query: WebGLQuery): number;
  45321. /**
  45322. * Initiates an occlusion query
  45323. * @param algorithmType defines the algorithm to use
  45324. * @param query defines the query to use
  45325. * @returns the current engine
  45326. * @see http://doc.babylonjs.com/features/occlusionquery
  45327. */
  45328. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45329. /**
  45330. * Ends an occlusion query
  45331. * @see http://doc.babylonjs.com/features/occlusionquery
  45332. * @param algorithmType defines the algorithm to use
  45333. * @returns the current engine
  45334. */
  45335. endOcclusionQuery(algorithmType: number): Engine;
  45336. /**
  45337. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45338. * Please note that only one query can be issued at a time
  45339. * @returns a time token used to track the time span
  45340. */
  45341. startTimeQuery(): Nullable<_TimeToken>;
  45342. /**
  45343. * Ends a time query
  45344. * @param token defines the token used to measure the time span
  45345. * @returns the time spent (in ns)
  45346. */
  45347. endTimeQuery(token: _TimeToken): int;
  45348. /** @hidden */
  45349. _currentNonTimestampToken: Nullable<_TimeToken>;
  45350. /** @hidden */
  45351. _createTimeQuery(): WebGLQuery;
  45352. /** @hidden */
  45353. _deleteTimeQuery(query: WebGLQuery): void;
  45354. /** @hidden */
  45355. _getGlAlgorithmType(algorithmType: number): number;
  45356. /** @hidden */
  45357. _getTimeQueryResult(query: WebGLQuery): any;
  45358. /** @hidden */
  45359. _getTimeQueryAvailability(query: WebGLQuery): any;
  45360. }
  45361. }
  45362. module "babylonjs/Meshes/abstractMesh" {
  45363. interface AbstractMesh {
  45364. /**
  45365. * Backing filed
  45366. * @hidden
  45367. */
  45368. __occlusionDataStorage: _OcclusionDataStorage;
  45369. /**
  45370. * Access property
  45371. * @hidden
  45372. */
  45373. _occlusionDataStorage: _OcclusionDataStorage;
  45374. /**
  45375. * 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.
  45376. * The default value is -1 which means don't break the query and wait till the result
  45377. * @see http://doc.babylonjs.com/features/occlusionquery
  45378. */
  45379. occlusionRetryCount: number;
  45380. /**
  45381. * 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:
  45382. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45383. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45384. * * 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.
  45385. * @see http://doc.babylonjs.com/features/occlusionquery
  45386. */
  45387. occlusionType: number;
  45388. /**
  45389. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45390. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45391. * * 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.
  45392. * @see http://doc.babylonjs.com/features/occlusionquery
  45393. */
  45394. occlusionQueryAlgorithmType: number;
  45395. /**
  45396. * 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
  45397. * @see http://doc.babylonjs.com/features/occlusionquery
  45398. */
  45399. isOccluded: boolean;
  45400. /**
  45401. * Flag to check the progress status of the query
  45402. * @see http://doc.babylonjs.com/features/occlusionquery
  45403. */
  45404. isOcclusionQueryInProgress: boolean;
  45405. }
  45406. }
  45407. }
  45408. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45409. import { Nullable } from "babylonjs/types";
  45410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45411. /** @hidden */
  45412. export var _forceTransformFeedbackToBundle: boolean;
  45413. module "babylonjs/Engines/engine" {
  45414. interface Engine {
  45415. /**
  45416. * Creates a webGL transform feedback object
  45417. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45418. * @returns the webGL transform feedback object
  45419. */
  45420. createTransformFeedback(): WebGLTransformFeedback;
  45421. /**
  45422. * Delete a webGL transform feedback object
  45423. * @param value defines the webGL transform feedback object to delete
  45424. */
  45425. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45426. /**
  45427. * Bind a webGL transform feedback object to the webgl context
  45428. * @param value defines the webGL transform feedback object to bind
  45429. */
  45430. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45431. /**
  45432. * Begins a transform feedback operation
  45433. * @param usePoints defines if points or triangles must be used
  45434. */
  45435. beginTransformFeedback(usePoints: boolean): void;
  45436. /**
  45437. * Ends a transform feedback operation
  45438. */
  45439. endTransformFeedback(): void;
  45440. /**
  45441. * Specify the varyings to use with transform feedback
  45442. * @param program defines the associated webGL program
  45443. * @param value defines the list of strings representing the varying names
  45444. */
  45445. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45446. /**
  45447. * Bind a webGL buffer for a transform feedback operation
  45448. * @param value defines the webGL buffer to bind
  45449. */
  45450. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45451. }
  45452. }
  45453. }
  45454. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45455. import { Scene } from "babylonjs/scene";
  45456. import { Engine } from "babylonjs/Engines/engine";
  45457. import { Texture } from "babylonjs/Materials/Textures/texture";
  45458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45459. import "babylonjs/Engines/Extensions/engine.multiRender";
  45460. /**
  45461. * Creation options of the multi render target texture.
  45462. */
  45463. export interface IMultiRenderTargetOptions {
  45464. /**
  45465. * Define if the texture needs to create mip maps after render.
  45466. */
  45467. generateMipMaps?: boolean;
  45468. /**
  45469. * Define the types of all the draw buffers we want to create
  45470. */
  45471. types?: number[];
  45472. /**
  45473. * Define the sampling modes of all the draw buffers we want to create
  45474. */
  45475. samplingModes?: number[];
  45476. /**
  45477. * Define if a depth buffer is required
  45478. */
  45479. generateDepthBuffer?: boolean;
  45480. /**
  45481. * Define if a stencil buffer is required
  45482. */
  45483. generateStencilBuffer?: boolean;
  45484. /**
  45485. * Define if a depth texture is required instead of a depth buffer
  45486. */
  45487. generateDepthTexture?: boolean;
  45488. /**
  45489. * Define the number of desired draw buffers
  45490. */
  45491. textureCount?: number;
  45492. /**
  45493. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45494. */
  45495. doNotChangeAspectRatio?: boolean;
  45496. /**
  45497. * Define the default type of the buffers we are creating
  45498. */
  45499. defaultType?: number;
  45500. }
  45501. /**
  45502. * A multi render target, like a render target provides the ability to render to a texture.
  45503. * Unlike the render target, it can render to several draw buffers in one draw.
  45504. * This is specially interesting in deferred rendering or for any effects requiring more than
  45505. * just one color from a single pass.
  45506. */
  45507. export class MultiRenderTarget extends RenderTargetTexture {
  45508. private _internalTextures;
  45509. private _textures;
  45510. private _multiRenderTargetOptions;
  45511. /**
  45512. * Get if draw buffers are currently supported by the used hardware and browser.
  45513. */
  45514. readonly isSupported: boolean;
  45515. /**
  45516. * Get the list of textures generated by the multi render target.
  45517. */
  45518. readonly textures: Texture[];
  45519. /**
  45520. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45521. */
  45522. readonly depthTexture: Texture;
  45523. /**
  45524. * Set the wrapping mode on U of all the textures we are rendering to.
  45525. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45526. */
  45527. wrapU: number;
  45528. /**
  45529. * Set the wrapping mode on V of all the textures we are rendering to.
  45530. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45531. */
  45532. wrapV: number;
  45533. /**
  45534. * Instantiate a new multi render target texture.
  45535. * A multi render target, like a render target provides the ability to render to a texture.
  45536. * Unlike the render target, it can render to several draw buffers in one draw.
  45537. * This is specially interesting in deferred rendering or for any effects requiring more than
  45538. * just one color from a single pass.
  45539. * @param name Define the name of the texture
  45540. * @param size Define the size of the buffers to render to
  45541. * @param count Define the number of target we are rendering into
  45542. * @param scene Define the scene the texture belongs to
  45543. * @param options Define the options used to create the multi render target
  45544. */
  45545. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45546. /** @hidden */
  45547. _rebuild(): void;
  45548. private _createInternalTextures;
  45549. private _createTextures;
  45550. /**
  45551. * Define the number of samples used if MSAA is enabled.
  45552. */
  45553. samples: number;
  45554. /**
  45555. * Resize all the textures in the multi render target.
  45556. * Be carrefull as it will recreate all the data in the new texture.
  45557. * @param size Define the new size
  45558. */
  45559. resize(size: any): void;
  45560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45561. /**
  45562. * Dispose the render targets and their associated resources
  45563. */
  45564. dispose(): void;
  45565. /**
  45566. * Release all the underlying texture used as draw buffers.
  45567. */
  45568. releaseInternalTextures(): void;
  45569. }
  45570. }
  45571. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45573. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45574. import { Nullable } from "babylonjs/types";
  45575. module "babylonjs/Engines/engine" {
  45576. interface Engine {
  45577. /**
  45578. * Unbind a list of render target textures from the webGL context
  45579. * This is used only when drawBuffer extension or webGL2 are active
  45580. * @param textures defines the render target textures to unbind
  45581. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45582. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45583. */
  45584. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45585. /**
  45586. * Create a multi render target texture
  45587. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45588. * @param size defines the size of the texture
  45589. * @param options defines the creation options
  45590. * @returns the cube texture as an InternalTexture
  45591. */
  45592. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45593. /**
  45594. * Update the sample count for a given multiple render target texture
  45595. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45596. * @param textures defines the textures to update
  45597. * @param samples defines the sample count to set
  45598. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45599. */
  45600. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45601. }
  45602. }
  45603. }
  45604. declare module "babylonjs/Engines/Extensions/index" {
  45605. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45606. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45607. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45608. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45609. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45610. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45611. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45612. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45613. }
  45614. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45616. /** @hidden */
  45617. export var rgbdEncodePixelShader: {
  45618. name: string;
  45619. shader: string;
  45620. };
  45621. }
  45622. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45623. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45624. /** @hidden */
  45625. export var rgbdDecodePixelShader: {
  45626. name: string;
  45627. shader: string;
  45628. };
  45629. }
  45630. declare module "babylonjs/Misc/environmentTextureTools" {
  45631. import { Nullable } from "babylonjs/types";
  45632. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45633. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45634. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45635. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45636. import "babylonjs/Shaders/rgbdEncode.fragment";
  45637. import "babylonjs/Shaders/rgbdDecode.fragment";
  45638. /**
  45639. * Raw texture data and descriptor sufficient for WebGL texture upload
  45640. */
  45641. export interface EnvironmentTextureInfo {
  45642. /**
  45643. * Version of the environment map
  45644. */
  45645. version: number;
  45646. /**
  45647. * Width of image
  45648. */
  45649. width: number;
  45650. /**
  45651. * Irradiance information stored in the file.
  45652. */
  45653. irradiance: any;
  45654. /**
  45655. * Specular information stored in the file.
  45656. */
  45657. specular: any;
  45658. }
  45659. /**
  45660. * Defines One Image in the file. It requires only the position in the file
  45661. * as well as the length.
  45662. */
  45663. interface BufferImageData {
  45664. /**
  45665. * Length of the image data.
  45666. */
  45667. length: number;
  45668. /**
  45669. * Position of the data from the null terminator delimiting the end of the JSON.
  45670. */
  45671. position: number;
  45672. }
  45673. /**
  45674. * Defines the specular data enclosed in the file.
  45675. * This corresponds to the version 1 of the data.
  45676. */
  45677. export interface EnvironmentTextureSpecularInfoV1 {
  45678. /**
  45679. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45680. */
  45681. specularDataPosition?: number;
  45682. /**
  45683. * This contains all the images data needed to reconstruct the cubemap.
  45684. */
  45685. mipmaps: Array<BufferImageData>;
  45686. /**
  45687. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45688. */
  45689. lodGenerationScale: number;
  45690. }
  45691. /**
  45692. * Sets of helpers addressing the serialization and deserialization of environment texture
  45693. * stored in a BabylonJS env file.
  45694. * Those files are usually stored as .env files.
  45695. */
  45696. export class EnvironmentTextureTools {
  45697. /**
  45698. * Magic number identifying the env file.
  45699. */
  45700. private static _MagicBytes;
  45701. /**
  45702. * Gets the environment info from an env file.
  45703. * @param data The array buffer containing the .env bytes.
  45704. * @returns the environment file info (the json header) if successfully parsed.
  45705. */
  45706. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45707. /**
  45708. * Creates an environment texture from a loaded cube texture.
  45709. * @param texture defines the cube texture to convert in env file
  45710. * @return a promise containing the environment data if succesfull.
  45711. */
  45712. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45713. /**
  45714. * Creates a JSON representation of the spherical data.
  45715. * @param texture defines the texture containing the polynomials
  45716. * @return the JSON representation of the spherical info
  45717. */
  45718. private static _CreateEnvTextureIrradiance;
  45719. /**
  45720. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45721. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45722. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45723. * @return the views described by info providing access to the underlying buffer
  45724. */
  45725. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45726. /**
  45727. * Uploads the texture info contained in the env file to the GPU.
  45728. * @param texture defines the internal texture to upload to
  45729. * @param arrayBuffer defines the buffer cotaining the data to load
  45730. * @param info defines the texture info retrieved through the GetEnvInfo method
  45731. * @returns a promise
  45732. */
  45733. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45734. /**
  45735. * Uploads the levels of image data to the GPU.
  45736. * @param texture defines the internal texture to upload to
  45737. * @param imageData defines the array buffer views of image data [mipmap][face]
  45738. * @returns a promise
  45739. */
  45740. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45741. /**
  45742. * Uploads spherical polynomials information to the texture.
  45743. * @param texture defines the texture we are trying to upload the information to
  45744. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45745. */
  45746. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45747. /** @hidden */
  45748. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45749. }
  45750. }
  45751. declare module "babylonjs/Maths/math.vertexFormat" {
  45752. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45753. /**
  45754. * Contains position and normal vectors for a vertex
  45755. */
  45756. export class PositionNormalVertex {
  45757. /** the position of the vertex (defaut: 0,0,0) */
  45758. position: Vector3;
  45759. /** the normal of the vertex (defaut: 0,1,0) */
  45760. normal: Vector3;
  45761. /**
  45762. * Creates a PositionNormalVertex
  45763. * @param position the position of the vertex (defaut: 0,0,0)
  45764. * @param normal the normal of the vertex (defaut: 0,1,0)
  45765. */
  45766. constructor(
  45767. /** the position of the vertex (defaut: 0,0,0) */
  45768. position?: Vector3,
  45769. /** the normal of the vertex (defaut: 0,1,0) */
  45770. normal?: Vector3);
  45771. /**
  45772. * Clones the PositionNormalVertex
  45773. * @returns the cloned PositionNormalVertex
  45774. */
  45775. clone(): PositionNormalVertex;
  45776. }
  45777. /**
  45778. * Contains position, normal and uv vectors for a vertex
  45779. */
  45780. export class PositionNormalTextureVertex {
  45781. /** the position of the vertex (defaut: 0,0,0) */
  45782. position: Vector3;
  45783. /** the normal of the vertex (defaut: 0,1,0) */
  45784. normal: Vector3;
  45785. /** the uv of the vertex (default: 0,0) */
  45786. uv: Vector2;
  45787. /**
  45788. * Creates a PositionNormalTextureVertex
  45789. * @param position the position of the vertex (defaut: 0,0,0)
  45790. * @param normal the normal of the vertex (defaut: 0,1,0)
  45791. * @param uv the uv of the vertex (default: 0,0)
  45792. */
  45793. constructor(
  45794. /** the position of the vertex (defaut: 0,0,0) */
  45795. position?: Vector3,
  45796. /** the normal of the vertex (defaut: 0,1,0) */
  45797. normal?: Vector3,
  45798. /** the uv of the vertex (default: 0,0) */
  45799. uv?: Vector2);
  45800. /**
  45801. * Clones the PositionNormalTextureVertex
  45802. * @returns the cloned PositionNormalTextureVertex
  45803. */
  45804. clone(): PositionNormalTextureVertex;
  45805. }
  45806. }
  45807. declare module "babylonjs/Maths/math" {
  45808. export * from "babylonjs/Maths/math.axis";
  45809. export * from "babylonjs/Maths/math.color";
  45810. export * from "babylonjs/Maths/math.constants";
  45811. export * from "babylonjs/Maths/math.frustum";
  45812. export * from "babylonjs/Maths/math.path";
  45813. export * from "babylonjs/Maths/math.plane";
  45814. export * from "babylonjs/Maths/math.size";
  45815. export * from "babylonjs/Maths/math.vector";
  45816. export * from "babylonjs/Maths/math.vertexFormat";
  45817. export * from "babylonjs/Maths/math.viewport";
  45818. }
  45819. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45820. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45821. /** @hidden */
  45822. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45823. private _genericAttributeLocation;
  45824. private _varyingLocationCount;
  45825. private _varyingLocationMap;
  45826. private _replacements;
  45827. private _textureCount;
  45828. private _uniforms;
  45829. lineProcessor(line: string): string;
  45830. attributeProcessor(attribute: string): string;
  45831. varyingProcessor(varying: string, isFragment: boolean): string;
  45832. uniformProcessor(uniform: string): string;
  45833. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45834. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45835. }
  45836. }
  45837. declare module "babylonjs/Engines/nativeEngine" {
  45838. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45839. import { Engine } from "babylonjs/Engines/engine";
  45840. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45841. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45843. import { Effect } from "babylonjs/Materials/effect";
  45844. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45845. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45846. import { Scene } from "babylonjs/scene";
  45847. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45848. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45849. /**
  45850. * Container for accessors for natively-stored mesh data buffers.
  45851. */
  45852. class NativeDataBuffer extends DataBuffer {
  45853. /**
  45854. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45855. */
  45856. nativeIndexBuffer?: any;
  45857. /**
  45858. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45859. */
  45860. nativeVertexBuffer?: any;
  45861. }
  45862. /** @hidden */
  45863. export class NativeEngine extends Engine {
  45864. private readonly _native;
  45865. getHardwareScalingLevel(): number;
  45866. constructor();
  45867. /**
  45868. * Can be used to override the current requestAnimationFrame requester.
  45869. * @hidden
  45870. */
  45871. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45872. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45873. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45874. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45875. recordVertexArrayObject(vertexBuffers: {
  45876. [key: string]: VertexBuffer;
  45877. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45878. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45879. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45880. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45881. /**
  45882. * Draw a list of indexed primitives
  45883. * @param fillMode defines the primitive to use
  45884. * @param indexStart defines the starting index
  45885. * @param indexCount defines the number of index to draw
  45886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45887. */
  45888. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45889. /**
  45890. * Draw a list of unindexed primitives
  45891. * @param fillMode defines the primitive to use
  45892. * @param verticesStart defines the index of first vertex to draw
  45893. * @param verticesCount defines the count of vertices to draw
  45894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45895. */
  45896. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45897. createPipelineContext(): IPipelineContext;
  45898. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45899. /** @hidden */
  45900. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45901. /** @hidden */
  45902. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45903. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45904. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45905. protected _setProgram(program: WebGLProgram): void;
  45906. _releaseEffect(effect: Effect): void;
  45907. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45908. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45909. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45910. bindSamplers(effect: Effect): void;
  45911. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45912. getRenderWidth(useScreen?: boolean): number;
  45913. getRenderHeight(useScreen?: boolean): number;
  45914. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45915. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45916. /**
  45917. * Set the z offset to apply to current rendering
  45918. * @param value defines the offset to apply
  45919. */
  45920. setZOffset(value: number): void;
  45921. /**
  45922. * Gets the current value of the zOffset
  45923. * @returns the current zOffset state
  45924. */
  45925. getZOffset(): number;
  45926. /**
  45927. * Enable or disable depth buffering
  45928. * @param enable defines the state to set
  45929. */
  45930. setDepthBuffer(enable: boolean): void;
  45931. /**
  45932. * Gets a boolean indicating if depth writing is enabled
  45933. * @returns the current depth writing state
  45934. */
  45935. getDepthWrite(): boolean;
  45936. /**
  45937. * Enable or disable depth writing
  45938. * @param enable defines the state to set
  45939. */
  45940. setDepthWrite(enable: boolean): void;
  45941. /**
  45942. * Enable or disable color writing
  45943. * @param enable defines the state to set
  45944. */
  45945. setColorWrite(enable: boolean): void;
  45946. /**
  45947. * Gets a boolean indicating if color writing is enabled
  45948. * @returns the current color writing state
  45949. */
  45950. getColorWrite(): boolean;
  45951. /**
  45952. * Sets alpha constants used by some alpha blending modes
  45953. * @param r defines the red component
  45954. * @param g defines the green component
  45955. * @param b defines the blue component
  45956. * @param a defines the alpha component
  45957. */
  45958. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45959. /**
  45960. * Sets the current alpha mode
  45961. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45962. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45963. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45964. */
  45965. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45966. /**
  45967. * Gets the current alpha mode
  45968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45969. * @returns the current alpha mode
  45970. */
  45971. getAlphaMode(): number;
  45972. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45973. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45974. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45975. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45976. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45977. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45978. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45979. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45980. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45981. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45982. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45983. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45984. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45985. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45986. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45987. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45988. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45989. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45990. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45991. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45992. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45993. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45994. wipeCaches(bruteForce?: boolean): void;
  45995. _createTexture(): WebGLTexture;
  45996. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45997. /**
  45998. * Usually called from BABYLON.Texture.ts.
  45999. * Passed information to create a WebGLTexture
  46000. * @param urlArg defines a value which contains one of the following:
  46001. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46002. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46003. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46004. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46005. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46006. * @param scene needed for loading to the correct scene
  46007. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46008. * @param onLoad optional callback to be called upon successful completion
  46009. * @param onError optional callback to be called upon failure
  46010. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46011. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46012. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46013. * @param forcedExtension defines the extension to use to pick the right loader
  46014. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46015. */
  46016. 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;
  46017. /**
  46018. * Creates a cube texture
  46019. * @param rootUrl defines the url where the files to load is located
  46020. * @param scene defines the current scene
  46021. * @param files defines the list of files to load (1 per face)
  46022. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46023. * @param onLoad defines an optional callback raised when the texture is loaded
  46024. * @param onError defines an optional callback raised if there is an issue to load the texture
  46025. * @param format defines the format of the data
  46026. * @param forcedExtension defines the extension to use to pick the right loader
  46027. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46028. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46029. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46030. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46031. * @returns the cube texture as an InternalTexture
  46032. */
  46033. 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;
  46034. private _getSamplingFilter;
  46035. private static _GetNativeTextureFormat;
  46036. createRenderTargetTexture(size: number | {
  46037. width: number;
  46038. height: number;
  46039. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46040. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46041. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46042. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46043. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46044. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46045. /**
  46046. * Updates a dynamic vertex buffer.
  46047. * @param vertexBuffer the vertex buffer to update
  46048. * @param data the data used to update the vertex buffer
  46049. * @param byteOffset the byte offset of the data (optional)
  46050. * @param byteLength the byte length of the data (optional)
  46051. */
  46052. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46053. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46054. private _updateAnisotropicLevel;
  46055. private _getAddressMode;
  46056. /** @hidden */
  46057. _bindTexture(channel: number, texture: InternalTexture): void;
  46058. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46059. releaseEffects(): void;
  46060. /** @hidden */
  46061. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46062. /** @hidden */
  46063. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46064. /** @hidden */
  46065. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46066. /** @hidden */
  46067. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46068. }
  46069. }
  46070. declare module "babylonjs/Engines/index" {
  46071. export * from "babylonjs/Engines/constants";
  46072. export * from "babylonjs/Engines/engine";
  46073. export * from "babylonjs/Engines/engineStore";
  46074. export * from "babylonjs/Engines/nullEngine";
  46075. export * from "babylonjs/Engines/Extensions/index";
  46076. export * from "babylonjs/Engines/IPipelineContext";
  46077. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46078. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46079. export * from "babylonjs/Engines/nativeEngine";
  46080. }
  46081. declare module "babylonjs/Events/clipboardEvents" {
  46082. /**
  46083. * Gather the list of clipboard event types as constants.
  46084. */
  46085. export class ClipboardEventTypes {
  46086. /**
  46087. * The clipboard event is fired when a copy command is active (pressed).
  46088. */
  46089. static readonly COPY: number;
  46090. /**
  46091. * The clipboard event is fired when a cut command is active (pressed).
  46092. */
  46093. static readonly CUT: number;
  46094. /**
  46095. * The clipboard event is fired when a paste command is active (pressed).
  46096. */
  46097. static readonly PASTE: number;
  46098. }
  46099. /**
  46100. * This class is used to store clipboard related info for the onClipboardObservable event.
  46101. */
  46102. export class ClipboardInfo {
  46103. /**
  46104. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46105. */
  46106. type: number;
  46107. /**
  46108. * Defines the related dom event
  46109. */
  46110. event: ClipboardEvent;
  46111. /**
  46112. *Creates an instance of ClipboardInfo.
  46113. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46114. * @param event Defines the related dom event
  46115. */
  46116. constructor(
  46117. /**
  46118. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46119. */
  46120. type: number,
  46121. /**
  46122. * Defines the related dom event
  46123. */
  46124. event: ClipboardEvent);
  46125. /**
  46126. * Get the clipboard event's type from the keycode.
  46127. * @param keyCode Defines the keyCode for the current keyboard event.
  46128. * @return {number}
  46129. */
  46130. static GetTypeFromCharacter(keyCode: number): number;
  46131. }
  46132. }
  46133. declare module "babylonjs/Events/index" {
  46134. export * from "babylonjs/Events/keyboardEvents";
  46135. export * from "babylonjs/Events/pointerEvents";
  46136. export * from "babylonjs/Events/clipboardEvents";
  46137. }
  46138. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46139. import { Scene } from "babylonjs/scene";
  46140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46141. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46142. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46143. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46144. /**
  46145. * Google Daydream controller
  46146. */
  46147. export class DaydreamController extends WebVRController {
  46148. /**
  46149. * Base Url for the controller model.
  46150. */
  46151. static MODEL_BASE_URL: string;
  46152. /**
  46153. * File name for the controller model.
  46154. */
  46155. static MODEL_FILENAME: string;
  46156. /**
  46157. * Gamepad Id prefix used to identify Daydream Controller.
  46158. */
  46159. static readonly GAMEPAD_ID_PREFIX: string;
  46160. /**
  46161. * Creates a new DaydreamController from a gamepad
  46162. * @param vrGamepad the gamepad that the controller should be created from
  46163. */
  46164. constructor(vrGamepad: any);
  46165. /**
  46166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46167. * @param scene scene in which to add meshes
  46168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46169. */
  46170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46171. /**
  46172. * Called once for each button that changed state since the last frame
  46173. * @param buttonIdx Which button index changed
  46174. * @param state New state of the button
  46175. * @param changes Which properties on the state changed since last frame
  46176. */
  46177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46178. }
  46179. }
  46180. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46181. import { Scene } from "babylonjs/scene";
  46182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46183. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46184. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46185. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46186. /**
  46187. * Gear VR Controller
  46188. */
  46189. export class GearVRController extends WebVRController {
  46190. /**
  46191. * Base Url for the controller model.
  46192. */
  46193. static MODEL_BASE_URL: string;
  46194. /**
  46195. * File name for the controller model.
  46196. */
  46197. static MODEL_FILENAME: string;
  46198. /**
  46199. * Gamepad Id prefix used to identify this controller.
  46200. */
  46201. static readonly GAMEPAD_ID_PREFIX: string;
  46202. private readonly _buttonIndexToObservableNameMap;
  46203. /**
  46204. * Creates a new GearVRController from a gamepad
  46205. * @param vrGamepad the gamepad that the controller should be created from
  46206. */
  46207. constructor(vrGamepad: any);
  46208. /**
  46209. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46210. * @param scene scene in which to add meshes
  46211. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46212. */
  46213. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46214. /**
  46215. * Called once for each button that changed state since the last frame
  46216. * @param buttonIdx Which button index changed
  46217. * @param state New state of the button
  46218. * @param changes Which properties on the state changed since last frame
  46219. */
  46220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46221. }
  46222. }
  46223. declare module "babylonjs/Gamepads/Controllers/index" {
  46224. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46225. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46226. export * from "babylonjs/Gamepads/Controllers/genericController";
  46227. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46228. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46229. export * from "babylonjs/Gamepads/Controllers/viveController";
  46230. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46231. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46232. }
  46233. declare module "babylonjs/Gamepads/index" {
  46234. export * from "babylonjs/Gamepads/Controllers/index";
  46235. export * from "babylonjs/Gamepads/gamepad";
  46236. export * from "babylonjs/Gamepads/gamepadManager";
  46237. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46238. export * from "babylonjs/Gamepads/xboxGamepad";
  46239. export * from "babylonjs/Gamepads/dualShockGamepad";
  46240. }
  46241. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46242. import { Scene } from "babylonjs/scene";
  46243. import { Vector4 } from "babylonjs/Maths/math.vector";
  46244. import { Color4 } from "babylonjs/Maths/math.color";
  46245. import { Mesh } from "babylonjs/Meshes/mesh";
  46246. import { Nullable } from "babylonjs/types";
  46247. /**
  46248. * Class containing static functions to help procedurally build meshes
  46249. */
  46250. export class PolyhedronBuilder {
  46251. /**
  46252. * Creates a polyhedron mesh
  46253. * * 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
  46254. * * The parameter `size` (positive float, default 1) sets the polygon size
  46255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46256. * * 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`
  46257. * * 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
  46258. * * 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)`)
  46259. * * 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
  46260. * * 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
  46261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46264. * @param name defines the name of the mesh
  46265. * @param options defines the options used to create the mesh
  46266. * @param scene defines the hosting scene
  46267. * @returns the polyhedron mesh
  46268. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46269. */
  46270. static CreatePolyhedron(name: string, options: {
  46271. type?: number;
  46272. size?: number;
  46273. sizeX?: number;
  46274. sizeY?: number;
  46275. sizeZ?: number;
  46276. custom?: any;
  46277. faceUV?: Vector4[];
  46278. faceColors?: Color4[];
  46279. flat?: boolean;
  46280. updatable?: boolean;
  46281. sideOrientation?: number;
  46282. frontUVs?: Vector4;
  46283. backUVs?: Vector4;
  46284. }, scene?: Nullable<Scene>): Mesh;
  46285. }
  46286. }
  46287. declare module "babylonjs/Gizmos/scaleGizmo" {
  46288. import { Observable } from "babylonjs/Misc/observable";
  46289. import { Nullable } from "babylonjs/types";
  46290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46291. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46292. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46293. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46294. /**
  46295. * Gizmo that enables scaling a mesh along 3 axis
  46296. */
  46297. export class ScaleGizmo extends Gizmo {
  46298. /**
  46299. * Internal gizmo used for interactions on the x axis
  46300. */
  46301. xGizmo: AxisScaleGizmo;
  46302. /**
  46303. * Internal gizmo used for interactions on the y axis
  46304. */
  46305. yGizmo: AxisScaleGizmo;
  46306. /**
  46307. * Internal gizmo used for interactions on the z axis
  46308. */
  46309. zGizmo: AxisScaleGizmo;
  46310. /**
  46311. * Internal gizmo used to scale all axis equally
  46312. */
  46313. uniformScaleGizmo: AxisScaleGizmo;
  46314. private _meshAttached;
  46315. private _updateGizmoRotationToMatchAttachedMesh;
  46316. private _snapDistance;
  46317. private _scaleRatio;
  46318. private _uniformScalingMesh;
  46319. private _octahedron;
  46320. /** Fires an event when any of it's sub gizmos are dragged */
  46321. onDragStartObservable: Observable<unknown>;
  46322. /** Fires an event when any of it's sub gizmos are released from dragging */
  46323. onDragEndObservable: Observable<unknown>;
  46324. attachedMesh: Nullable<AbstractMesh>;
  46325. /**
  46326. * Creates a ScaleGizmo
  46327. * @param gizmoLayer The utility layer the gizmo will be added to
  46328. */
  46329. constructor(gizmoLayer?: UtilityLayerRenderer);
  46330. updateGizmoRotationToMatchAttachedMesh: boolean;
  46331. /**
  46332. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46333. */
  46334. snapDistance: number;
  46335. /**
  46336. * Ratio for the scale of the gizmo (Default: 1)
  46337. */
  46338. scaleRatio: number;
  46339. /**
  46340. * Disposes of the gizmo
  46341. */
  46342. dispose(): void;
  46343. }
  46344. }
  46345. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46346. import { Observable } from "babylonjs/Misc/observable";
  46347. import { Nullable } from "babylonjs/types";
  46348. import { Vector3 } from "babylonjs/Maths/math.vector";
  46349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46350. import { Mesh } from "babylonjs/Meshes/mesh";
  46351. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46352. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46353. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46354. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46355. import { Color3 } from "babylonjs/Maths/math.color";
  46356. /**
  46357. * Single axis scale gizmo
  46358. */
  46359. export class AxisScaleGizmo extends Gizmo {
  46360. /**
  46361. * Drag behavior responsible for the gizmos dragging interactions
  46362. */
  46363. dragBehavior: PointerDragBehavior;
  46364. private _pointerObserver;
  46365. /**
  46366. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46367. */
  46368. snapDistance: number;
  46369. /**
  46370. * Event that fires each time the gizmo snaps to a new location.
  46371. * * snapDistance is the the change in distance
  46372. */
  46373. onSnapObservable: Observable<{
  46374. snapDistance: number;
  46375. }>;
  46376. /**
  46377. * If the scaling operation should be done on all axis (default: false)
  46378. */
  46379. uniformScaling: boolean;
  46380. private _isEnabled;
  46381. private _parent;
  46382. private _arrow;
  46383. private _coloredMaterial;
  46384. private _hoverMaterial;
  46385. /**
  46386. * Creates an AxisScaleGizmo
  46387. * @param gizmoLayer The utility layer the gizmo will be added to
  46388. * @param dragAxis The axis which the gizmo will be able to scale on
  46389. * @param color The color of the gizmo
  46390. */
  46391. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46392. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46393. /**
  46394. * If the gizmo is enabled
  46395. */
  46396. isEnabled: boolean;
  46397. /**
  46398. * Disposes of the gizmo
  46399. */
  46400. dispose(): void;
  46401. /**
  46402. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46403. * @param mesh The mesh to replace the default mesh of the gizmo
  46404. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46405. */
  46406. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46407. }
  46408. }
  46409. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46410. import { Observable } from "babylonjs/Misc/observable";
  46411. import { Nullable } from "babylonjs/types";
  46412. import { Vector3 } from "babylonjs/Maths/math.vector";
  46413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46414. import { Mesh } from "babylonjs/Meshes/mesh";
  46415. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46416. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46417. import { Color3 } from "babylonjs/Maths/math.color";
  46418. import "babylonjs/Meshes/Builders/boxBuilder";
  46419. /**
  46420. * Bounding box gizmo
  46421. */
  46422. export class BoundingBoxGizmo extends Gizmo {
  46423. private _lineBoundingBox;
  46424. private _rotateSpheresParent;
  46425. private _scaleBoxesParent;
  46426. private _boundingDimensions;
  46427. private _renderObserver;
  46428. private _pointerObserver;
  46429. private _scaleDragSpeed;
  46430. private _tmpQuaternion;
  46431. private _tmpVector;
  46432. private _tmpRotationMatrix;
  46433. /**
  46434. * 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)
  46435. */
  46436. ignoreChildren: boolean;
  46437. /**
  46438. * 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)
  46439. */
  46440. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46441. /**
  46442. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46443. */
  46444. rotationSphereSize: number;
  46445. /**
  46446. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46447. */
  46448. scaleBoxSize: number;
  46449. /**
  46450. * 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)
  46451. */
  46452. fixedDragMeshScreenSize: boolean;
  46453. /**
  46454. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46455. */
  46456. fixedDragMeshScreenSizeDistanceFactor: number;
  46457. /**
  46458. * Fired when a rotation sphere or scale box is dragged
  46459. */
  46460. onDragStartObservable: Observable<{}>;
  46461. /**
  46462. * Fired when a scale box is dragged
  46463. */
  46464. onScaleBoxDragObservable: Observable<{}>;
  46465. /**
  46466. * Fired when a scale box drag is ended
  46467. */
  46468. onScaleBoxDragEndObservable: Observable<{}>;
  46469. /**
  46470. * Fired when a rotation sphere is dragged
  46471. */
  46472. onRotationSphereDragObservable: Observable<{}>;
  46473. /**
  46474. * Fired when a rotation sphere drag is ended
  46475. */
  46476. onRotationSphereDragEndObservable: Observable<{}>;
  46477. /**
  46478. * 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)
  46479. */
  46480. scalePivot: Nullable<Vector3>;
  46481. /**
  46482. * Mesh used as a pivot to rotate the attached mesh
  46483. */
  46484. private _anchorMesh;
  46485. private _existingMeshScale;
  46486. private _dragMesh;
  46487. private pointerDragBehavior;
  46488. private coloredMaterial;
  46489. private hoverColoredMaterial;
  46490. /**
  46491. * Sets the color of the bounding box gizmo
  46492. * @param color the color to set
  46493. */
  46494. setColor(color: Color3): void;
  46495. /**
  46496. * Creates an BoundingBoxGizmo
  46497. * @param gizmoLayer The utility layer the gizmo will be added to
  46498. * @param color The color of the gizmo
  46499. */
  46500. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46501. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46502. private _selectNode;
  46503. /**
  46504. * Updates the bounding box information for the Gizmo
  46505. */
  46506. updateBoundingBox(): void;
  46507. private _updateRotationSpheres;
  46508. private _updateScaleBoxes;
  46509. /**
  46510. * Enables rotation on the specified axis and disables rotation on the others
  46511. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46512. */
  46513. setEnabledRotationAxis(axis: string): void;
  46514. /**
  46515. * Enables/disables scaling
  46516. * @param enable if scaling should be enabled
  46517. */
  46518. setEnabledScaling(enable: boolean): void;
  46519. private _updateDummy;
  46520. /**
  46521. * Enables a pointer drag behavior on the bounding box of the gizmo
  46522. */
  46523. enableDragBehavior(): void;
  46524. /**
  46525. * Disposes of the gizmo
  46526. */
  46527. dispose(): void;
  46528. /**
  46529. * 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)
  46530. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46531. * @returns the bounding box mesh with the passed in mesh as a child
  46532. */
  46533. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46534. /**
  46535. * CustomMeshes are not supported by this gizmo
  46536. * @param mesh The mesh to replace the default mesh of the gizmo
  46537. */
  46538. setCustomMesh(mesh: Mesh): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46542. import { Observable } from "babylonjs/Misc/observable";
  46543. import { Nullable } from "babylonjs/types";
  46544. import { Vector3 } from "babylonjs/Maths/math.vector";
  46545. import { Color3 } from "babylonjs/Maths/math.color";
  46546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46547. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46549. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46550. import "babylonjs/Meshes/Builders/linesBuilder";
  46551. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46552. /**
  46553. * Single plane rotation gizmo
  46554. */
  46555. export class PlaneRotationGizmo extends Gizmo {
  46556. /**
  46557. * Drag behavior responsible for the gizmos dragging interactions
  46558. */
  46559. dragBehavior: PointerDragBehavior;
  46560. private _pointerObserver;
  46561. /**
  46562. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46563. */
  46564. snapDistance: number;
  46565. /**
  46566. * Event that fires each time the gizmo snaps to a new location.
  46567. * * snapDistance is the the change in distance
  46568. */
  46569. onSnapObservable: Observable<{
  46570. snapDistance: number;
  46571. }>;
  46572. private _isEnabled;
  46573. private _parent;
  46574. /**
  46575. * Creates a PlaneRotationGizmo
  46576. * @param gizmoLayer The utility layer the gizmo will be added to
  46577. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46578. * @param color The color of the gizmo
  46579. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46580. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46581. */
  46582. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46583. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46584. /**
  46585. * If the gizmo is enabled
  46586. */
  46587. isEnabled: boolean;
  46588. /**
  46589. * Disposes of the gizmo
  46590. */
  46591. dispose(): void;
  46592. }
  46593. }
  46594. declare module "babylonjs/Gizmos/rotationGizmo" {
  46595. import { Observable } from "babylonjs/Misc/observable";
  46596. import { Nullable } from "babylonjs/types";
  46597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46598. import { Mesh } from "babylonjs/Meshes/mesh";
  46599. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46600. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46601. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46602. /**
  46603. * Gizmo that enables rotating a mesh along 3 axis
  46604. */
  46605. export class RotationGizmo extends Gizmo {
  46606. /**
  46607. * Internal gizmo used for interactions on the x axis
  46608. */
  46609. xGizmo: PlaneRotationGizmo;
  46610. /**
  46611. * Internal gizmo used for interactions on the y axis
  46612. */
  46613. yGizmo: PlaneRotationGizmo;
  46614. /**
  46615. * Internal gizmo used for interactions on the z axis
  46616. */
  46617. zGizmo: PlaneRotationGizmo;
  46618. /** Fires an event when any of it's sub gizmos are dragged */
  46619. onDragStartObservable: Observable<unknown>;
  46620. /** Fires an event when any of it's sub gizmos are released from dragging */
  46621. onDragEndObservable: Observable<unknown>;
  46622. private _meshAttached;
  46623. attachedMesh: Nullable<AbstractMesh>;
  46624. /**
  46625. * Creates a RotationGizmo
  46626. * @param gizmoLayer The utility layer the gizmo will be added to
  46627. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46628. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46629. */
  46630. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46631. updateGizmoRotationToMatchAttachedMesh: boolean;
  46632. /**
  46633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46634. */
  46635. snapDistance: number;
  46636. /**
  46637. * Ratio for the scale of the gizmo (Default: 1)
  46638. */
  46639. scaleRatio: number;
  46640. /**
  46641. * Disposes of the gizmo
  46642. */
  46643. dispose(): void;
  46644. /**
  46645. * CustomMeshes are not supported by this gizmo
  46646. * @param mesh The mesh to replace the default mesh of the gizmo
  46647. */
  46648. setCustomMesh(mesh: Mesh): void;
  46649. }
  46650. }
  46651. declare module "babylonjs/Gizmos/gizmoManager" {
  46652. import { Observable } from "babylonjs/Misc/observable";
  46653. import { Nullable } from "babylonjs/types";
  46654. import { Scene, IDisposable } from "babylonjs/scene";
  46655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46656. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46657. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46658. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46659. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46660. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46661. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46662. /**
  46663. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46664. */
  46665. export class GizmoManager implements IDisposable {
  46666. private scene;
  46667. /**
  46668. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46669. */
  46670. gizmos: {
  46671. positionGizmo: Nullable<PositionGizmo>;
  46672. rotationGizmo: Nullable<RotationGizmo>;
  46673. scaleGizmo: Nullable<ScaleGizmo>;
  46674. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46675. };
  46676. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46677. clearGizmoOnEmptyPointerEvent: boolean;
  46678. /** Fires an event when the manager is attached to a mesh */
  46679. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46680. private _gizmosEnabled;
  46681. private _pointerObserver;
  46682. private _attachedMesh;
  46683. private _boundingBoxColor;
  46684. private _defaultUtilityLayer;
  46685. private _defaultKeepDepthUtilityLayer;
  46686. /**
  46687. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46688. */
  46689. boundingBoxDragBehavior: SixDofDragBehavior;
  46690. /**
  46691. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46692. */
  46693. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46694. /**
  46695. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46696. */
  46697. usePointerToAttachGizmos: boolean;
  46698. /**
  46699. * Utility layer that the bounding box gizmo belongs to
  46700. */
  46701. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46702. /**
  46703. * Utility layer that all gizmos besides bounding box belong to
  46704. */
  46705. readonly utilityLayer: UtilityLayerRenderer;
  46706. /**
  46707. * Instatiates a gizmo manager
  46708. * @param scene the scene to overlay the gizmos on top of
  46709. */
  46710. constructor(scene: Scene);
  46711. /**
  46712. * Attaches a set of gizmos to the specified mesh
  46713. * @param mesh The mesh the gizmo's should be attached to
  46714. */
  46715. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46716. /**
  46717. * If the position gizmo is enabled
  46718. */
  46719. positionGizmoEnabled: boolean;
  46720. /**
  46721. * If the rotation gizmo is enabled
  46722. */
  46723. rotationGizmoEnabled: boolean;
  46724. /**
  46725. * If the scale gizmo is enabled
  46726. */
  46727. scaleGizmoEnabled: boolean;
  46728. /**
  46729. * If the boundingBox gizmo is enabled
  46730. */
  46731. boundingBoxGizmoEnabled: boolean;
  46732. /**
  46733. * Disposes of the gizmo manager
  46734. */
  46735. dispose(): void;
  46736. }
  46737. }
  46738. declare module "babylonjs/Lights/directionalLight" {
  46739. import { Camera } from "babylonjs/Cameras/camera";
  46740. import { Scene } from "babylonjs/scene";
  46741. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46743. import { Light } from "babylonjs/Lights/light";
  46744. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46745. import { Effect } from "babylonjs/Materials/effect";
  46746. /**
  46747. * A directional light is defined by a direction (what a surprise!).
  46748. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46749. * 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.
  46750. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46751. */
  46752. export class DirectionalLight extends ShadowLight {
  46753. private _shadowFrustumSize;
  46754. /**
  46755. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46756. */
  46757. /**
  46758. * Specifies a fix frustum size for the shadow generation.
  46759. */
  46760. shadowFrustumSize: number;
  46761. private _shadowOrthoScale;
  46762. /**
  46763. * Gets the shadow projection scale against the optimal computed one.
  46764. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46765. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46766. */
  46767. /**
  46768. * Sets the shadow projection scale against the optimal computed one.
  46769. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46770. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46771. */
  46772. shadowOrthoScale: number;
  46773. /**
  46774. * Automatically compute the projection matrix to best fit (including all the casters)
  46775. * on each frame.
  46776. */
  46777. autoUpdateExtends: boolean;
  46778. private _orthoLeft;
  46779. private _orthoRight;
  46780. private _orthoTop;
  46781. private _orthoBottom;
  46782. /**
  46783. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46784. * The directional light is emitted from everywhere in the given direction.
  46785. * It can cast shadows.
  46786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46787. * @param name The friendly name of the light
  46788. * @param direction The direction of the light
  46789. * @param scene The scene the light belongs to
  46790. */
  46791. constructor(name: string, direction: Vector3, scene: Scene);
  46792. /**
  46793. * Returns the string "DirectionalLight".
  46794. * @return The class name
  46795. */
  46796. getClassName(): string;
  46797. /**
  46798. * Returns the integer 1.
  46799. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46800. */
  46801. getTypeID(): number;
  46802. /**
  46803. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46804. * Returns the DirectionalLight Shadow projection matrix.
  46805. */
  46806. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46807. /**
  46808. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46809. * Returns the DirectionalLight Shadow projection matrix.
  46810. */
  46811. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46812. /**
  46813. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46814. * Returns the DirectionalLight Shadow projection matrix.
  46815. */
  46816. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46817. protected _buildUniformLayout(): void;
  46818. /**
  46819. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46820. * @param effect The effect to update
  46821. * @param lightIndex The index of the light in the effect to update
  46822. * @returns The directional light
  46823. */
  46824. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46825. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46826. /**
  46827. * Gets the minZ used for shadow according to both the scene and the light.
  46828. *
  46829. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46830. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46831. * @param activeCamera The camera we are returning the min for
  46832. * @returns the depth min z
  46833. */
  46834. getDepthMinZ(activeCamera: Camera): number;
  46835. /**
  46836. * Gets the maxZ used for shadow according to both the scene and the light.
  46837. *
  46838. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46839. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46840. * @param activeCamera The camera we are returning the max for
  46841. * @returns the depth max z
  46842. */
  46843. getDepthMaxZ(activeCamera: Camera): number;
  46844. /**
  46845. * Prepares the list of defines specific to the light type.
  46846. * @param defines the list of defines
  46847. * @param lightIndex defines the index of the light for the effect
  46848. */
  46849. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46850. }
  46851. }
  46852. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46853. import { Mesh } from "babylonjs/Meshes/mesh";
  46854. /**
  46855. * Class containing static functions to help procedurally build meshes
  46856. */
  46857. export class HemisphereBuilder {
  46858. /**
  46859. * Creates a hemisphere mesh
  46860. * @param name defines the name of the mesh
  46861. * @param options defines the options used to create the mesh
  46862. * @param scene defines the hosting scene
  46863. * @returns the hemisphere mesh
  46864. */
  46865. static CreateHemisphere(name: string, options: {
  46866. segments?: number;
  46867. diameter?: number;
  46868. sideOrientation?: number;
  46869. }, scene: any): Mesh;
  46870. }
  46871. }
  46872. declare module "babylonjs/Lights/spotLight" {
  46873. import { Nullable } from "babylonjs/types";
  46874. import { Scene } from "babylonjs/scene";
  46875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46877. import { Effect } from "babylonjs/Materials/effect";
  46878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46879. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46880. /**
  46881. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46882. * These values define a cone of light starting from the position, emitting toward the direction.
  46883. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46884. * and the exponent defines the speed of the decay of the light with distance (reach).
  46885. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46886. */
  46887. export class SpotLight extends ShadowLight {
  46888. private _angle;
  46889. private _innerAngle;
  46890. private _cosHalfAngle;
  46891. private _lightAngleScale;
  46892. private _lightAngleOffset;
  46893. /**
  46894. * Gets the cone angle of the spot light in Radians.
  46895. */
  46896. /**
  46897. * Sets the cone angle of the spot light in Radians.
  46898. */
  46899. angle: number;
  46900. /**
  46901. * Only used in gltf falloff mode, this defines the angle where
  46902. * the directional falloff will start before cutting at angle which could be seen
  46903. * as outer angle.
  46904. */
  46905. /**
  46906. * Only used in gltf falloff mode, this defines the angle where
  46907. * the directional falloff will start before cutting at angle which could be seen
  46908. * as outer angle.
  46909. */
  46910. innerAngle: number;
  46911. private _shadowAngleScale;
  46912. /**
  46913. * Allows scaling the angle of the light for shadow generation only.
  46914. */
  46915. /**
  46916. * Allows scaling the angle of the light for shadow generation only.
  46917. */
  46918. shadowAngleScale: number;
  46919. /**
  46920. * The light decay speed with the distance from the emission spot.
  46921. */
  46922. exponent: number;
  46923. private _projectionTextureMatrix;
  46924. /**
  46925. * Allows reading the projecton texture
  46926. */
  46927. readonly projectionTextureMatrix: Matrix;
  46928. protected _projectionTextureLightNear: number;
  46929. /**
  46930. * Gets the near clip of the Spotlight for texture projection.
  46931. */
  46932. /**
  46933. * Sets the near clip of the Spotlight for texture projection.
  46934. */
  46935. projectionTextureLightNear: number;
  46936. protected _projectionTextureLightFar: number;
  46937. /**
  46938. * Gets the far clip of the Spotlight for texture projection.
  46939. */
  46940. /**
  46941. * Sets the far clip of the Spotlight for texture projection.
  46942. */
  46943. projectionTextureLightFar: number;
  46944. protected _projectionTextureUpDirection: Vector3;
  46945. /**
  46946. * Gets the Up vector of the Spotlight for texture projection.
  46947. */
  46948. /**
  46949. * Sets the Up vector of the Spotlight for texture projection.
  46950. */
  46951. projectionTextureUpDirection: Vector3;
  46952. private _projectionTexture;
  46953. /**
  46954. * Gets the projection texture of the light.
  46955. */
  46956. /**
  46957. * Sets the projection texture of the light.
  46958. */
  46959. projectionTexture: Nullable<BaseTexture>;
  46960. private _projectionTextureViewLightDirty;
  46961. private _projectionTextureProjectionLightDirty;
  46962. private _projectionTextureDirty;
  46963. private _projectionTextureViewTargetVector;
  46964. private _projectionTextureViewLightMatrix;
  46965. private _projectionTextureProjectionLightMatrix;
  46966. private _projectionTextureScalingMatrix;
  46967. /**
  46968. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46969. * It can cast shadows.
  46970. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46971. * @param name The light friendly name
  46972. * @param position The position of the spot light in the scene
  46973. * @param direction The direction of the light in the scene
  46974. * @param angle The cone angle of the light in Radians
  46975. * @param exponent The light decay speed with the distance from the emission spot
  46976. * @param scene The scene the lights belongs to
  46977. */
  46978. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46979. /**
  46980. * Returns the string "SpotLight".
  46981. * @returns the class name
  46982. */
  46983. getClassName(): string;
  46984. /**
  46985. * Returns the integer 2.
  46986. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46987. */
  46988. getTypeID(): number;
  46989. /**
  46990. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46991. */
  46992. protected _setDirection(value: Vector3): void;
  46993. /**
  46994. * Overrides the position setter to recompute the projection texture view light Matrix.
  46995. */
  46996. protected _setPosition(value: Vector3): void;
  46997. /**
  46998. * 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.
  46999. * Returns the SpotLight.
  47000. */
  47001. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47002. protected _computeProjectionTextureViewLightMatrix(): void;
  47003. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47004. /**
  47005. * Main function for light texture projection matrix computing.
  47006. */
  47007. protected _computeProjectionTextureMatrix(): void;
  47008. protected _buildUniformLayout(): void;
  47009. private _computeAngleValues;
  47010. /**
  47011. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47012. * @param effect The effect to update
  47013. * @param lightIndex The index of the light in the effect to update
  47014. * @returns The spot light
  47015. */
  47016. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47017. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47018. /**
  47019. * Disposes the light and the associated resources.
  47020. */
  47021. dispose(): void;
  47022. /**
  47023. * Prepares the list of defines specific to the light type.
  47024. * @param defines the list of defines
  47025. * @param lightIndex defines the index of the light for the effect
  47026. */
  47027. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47028. }
  47029. }
  47030. declare module "babylonjs/Gizmos/lightGizmo" {
  47031. import { Nullable } from "babylonjs/types";
  47032. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47033. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47034. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47035. import { Light } from "babylonjs/Lights/light";
  47036. /**
  47037. * Gizmo that enables viewing a light
  47038. */
  47039. export class LightGizmo extends Gizmo {
  47040. private _lightMesh;
  47041. private _material;
  47042. private cachedPosition;
  47043. private cachedForward;
  47044. /**
  47045. * Creates a LightGizmo
  47046. * @param gizmoLayer The utility layer the gizmo will be added to
  47047. */
  47048. constructor(gizmoLayer?: UtilityLayerRenderer);
  47049. private _light;
  47050. /**
  47051. * The light that the gizmo is attached to
  47052. */
  47053. light: Nullable<Light>;
  47054. /**
  47055. * Gets the material used to render the light gizmo
  47056. */
  47057. readonly material: StandardMaterial;
  47058. /**
  47059. * @hidden
  47060. * Updates the gizmo to match the attached mesh's position/rotation
  47061. */
  47062. protected _update(): void;
  47063. private static _Scale;
  47064. /**
  47065. * Creates the lines for a light mesh
  47066. */
  47067. private static _createLightLines;
  47068. /**
  47069. * Disposes of the light gizmo
  47070. */
  47071. dispose(): void;
  47072. private static _CreateHemisphericLightMesh;
  47073. private static _CreatePointLightMesh;
  47074. private static _CreateSpotLightMesh;
  47075. private static _CreateDirectionalLightMesh;
  47076. }
  47077. }
  47078. declare module "babylonjs/Gizmos/index" {
  47079. export * from "babylonjs/Gizmos/axisDragGizmo";
  47080. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47081. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47082. export * from "babylonjs/Gizmos/gizmo";
  47083. export * from "babylonjs/Gizmos/gizmoManager";
  47084. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47085. export * from "babylonjs/Gizmos/positionGizmo";
  47086. export * from "babylonjs/Gizmos/rotationGizmo";
  47087. export * from "babylonjs/Gizmos/scaleGizmo";
  47088. export * from "babylonjs/Gizmos/lightGizmo";
  47089. export * from "babylonjs/Gizmos/planeDragGizmo";
  47090. }
  47091. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47092. /** @hidden */
  47093. export var backgroundFragmentDeclaration: {
  47094. name: string;
  47095. shader: string;
  47096. };
  47097. }
  47098. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47099. /** @hidden */
  47100. export var backgroundUboDeclaration: {
  47101. name: string;
  47102. shader: string;
  47103. };
  47104. }
  47105. declare module "babylonjs/Shaders/background.fragment" {
  47106. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47107. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47108. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47109. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47110. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47111. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47112. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47113. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47114. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47115. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47116. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47117. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47118. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47119. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47120. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47121. /** @hidden */
  47122. export var backgroundPixelShader: {
  47123. name: string;
  47124. shader: string;
  47125. };
  47126. }
  47127. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47128. /** @hidden */
  47129. export var backgroundVertexDeclaration: {
  47130. name: string;
  47131. shader: string;
  47132. };
  47133. }
  47134. declare module "babylonjs/Shaders/background.vertex" {
  47135. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47136. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47137. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47138. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47139. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47140. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47141. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47142. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47143. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47144. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47145. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47146. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47147. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47148. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47149. /** @hidden */
  47150. export var backgroundVertexShader: {
  47151. name: string;
  47152. shader: string;
  47153. };
  47154. }
  47155. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47156. import { Nullable, int, float } from "babylonjs/types";
  47157. import { Scene } from "babylonjs/scene";
  47158. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47161. import { Mesh } from "babylonjs/Meshes/mesh";
  47162. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47163. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47164. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47166. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47167. import { Color3 } from "babylonjs/Maths/math.color";
  47168. import "babylonjs/Shaders/background.fragment";
  47169. import "babylonjs/Shaders/background.vertex";
  47170. /**
  47171. * Background material used to create an efficient environement around your scene.
  47172. */
  47173. export class BackgroundMaterial extends PushMaterial {
  47174. /**
  47175. * Standard reflectance value at parallel view angle.
  47176. */
  47177. static StandardReflectance0: number;
  47178. /**
  47179. * Standard reflectance value at grazing angle.
  47180. */
  47181. static StandardReflectance90: number;
  47182. protected _primaryColor: Color3;
  47183. /**
  47184. * Key light Color (multiply against the environement texture)
  47185. */
  47186. primaryColor: Color3;
  47187. protected __perceptualColor: Nullable<Color3>;
  47188. /**
  47189. * Experimental Internal Use Only.
  47190. *
  47191. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47192. * This acts as a helper to set the primary color to a more "human friendly" value.
  47193. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47194. * output color as close as possible from the chosen value.
  47195. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47196. * part of lighting setup.)
  47197. */
  47198. _perceptualColor: Nullable<Color3>;
  47199. protected _primaryColorShadowLevel: float;
  47200. /**
  47201. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47202. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47203. */
  47204. primaryColorShadowLevel: float;
  47205. protected _primaryColorHighlightLevel: float;
  47206. /**
  47207. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47208. * The primary color is used at the level chosen to define what the white area would look.
  47209. */
  47210. primaryColorHighlightLevel: float;
  47211. protected _reflectionTexture: Nullable<BaseTexture>;
  47212. /**
  47213. * Reflection Texture used in the material.
  47214. * Should be author in a specific way for the best result (refer to the documentation).
  47215. */
  47216. reflectionTexture: Nullable<BaseTexture>;
  47217. protected _reflectionBlur: float;
  47218. /**
  47219. * Reflection Texture level of blur.
  47220. *
  47221. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47222. * texture twice.
  47223. */
  47224. reflectionBlur: float;
  47225. protected _diffuseTexture: Nullable<BaseTexture>;
  47226. /**
  47227. * Diffuse Texture used in the material.
  47228. * Should be author in a specific way for the best result (refer to the documentation).
  47229. */
  47230. diffuseTexture: Nullable<BaseTexture>;
  47231. protected _shadowLights: Nullable<IShadowLight[]>;
  47232. /**
  47233. * Specify the list of lights casting shadow on the material.
  47234. * All scene shadow lights will be included if null.
  47235. */
  47236. shadowLights: Nullable<IShadowLight[]>;
  47237. protected _shadowLevel: float;
  47238. /**
  47239. * Helps adjusting the shadow to a softer level if required.
  47240. * 0 means black shadows and 1 means no shadows.
  47241. */
  47242. shadowLevel: float;
  47243. protected _sceneCenter: Vector3;
  47244. /**
  47245. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47246. * It is usually zero but might be interesting to modify according to your setup.
  47247. */
  47248. sceneCenter: Vector3;
  47249. protected _opacityFresnel: boolean;
  47250. /**
  47251. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47252. * This helps ensuring a nice transition when the camera goes under the ground.
  47253. */
  47254. opacityFresnel: boolean;
  47255. protected _reflectionFresnel: boolean;
  47256. /**
  47257. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47258. * This helps adding a mirror texture on the ground.
  47259. */
  47260. reflectionFresnel: boolean;
  47261. protected _reflectionFalloffDistance: number;
  47262. /**
  47263. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47264. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47265. */
  47266. reflectionFalloffDistance: number;
  47267. protected _reflectionAmount: number;
  47268. /**
  47269. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47270. */
  47271. reflectionAmount: number;
  47272. protected _reflectionReflectance0: number;
  47273. /**
  47274. * This specifies the weight of the reflection at grazing angle.
  47275. */
  47276. reflectionReflectance0: number;
  47277. protected _reflectionReflectance90: number;
  47278. /**
  47279. * This specifies the weight of the reflection at a perpendicular point of view.
  47280. */
  47281. reflectionReflectance90: number;
  47282. /**
  47283. * Sets the reflection reflectance fresnel values according to the default standard
  47284. * empirically know to work well :-)
  47285. */
  47286. reflectionStandardFresnelWeight: number;
  47287. protected _useRGBColor: boolean;
  47288. /**
  47289. * Helps to directly use the maps channels instead of their level.
  47290. */
  47291. useRGBColor: boolean;
  47292. protected _enableNoise: boolean;
  47293. /**
  47294. * This helps reducing the banding effect that could occur on the background.
  47295. */
  47296. enableNoise: boolean;
  47297. /**
  47298. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47299. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47300. * Recommended to be keep at 1.0 except for special cases.
  47301. */
  47302. fovMultiplier: number;
  47303. private _fovMultiplier;
  47304. /**
  47305. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47306. */
  47307. useEquirectangularFOV: boolean;
  47308. private _maxSimultaneousLights;
  47309. /**
  47310. * Number of Simultaneous lights allowed on the material.
  47311. */
  47312. maxSimultaneousLights: int;
  47313. /**
  47314. * Default configuration related to image processing available in the Background Material.
  47315. */
  47316. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47317. /**
  47318. * Keep track of the image processing observer to allow dispose and replace.
  47319. */
  47320. private _imageProcessingObserver;
  47321. /**
  47322. * Attaches a new image processing configuration to the PBR Material.
  47323. * @param configuration (if null the scene configuration will be use)
  47324. */
  47325. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47326. /**
  47327. * Gets the image processing configuration used either in this material.
  47328. */
  47329. /**
  47330. * Sets the Default image processing configuration used either in the this material.
  47331. *
  47332. * If sets to null, the scene one is in use.
  47333. */
  47334. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47335. /**
  47336. * Gets wether the color curves effect is enabled.
  47337. */
  47338. /**
  47339. * Sets wether the color curves effect is enabled.
  47340. */
  47341. cameraColorCurvesEnabled: boolean;
  47342. /**
  47343. * Gets wether the color grading effect is enabled.
  47344. */
  47345. /**
  47346. * Gets wether the color grading effect is enabled.
  47347. */
  47348. cameraColorGradingEnabled: boolean;
  47349. /**
  47350. * Gets wether tonemapping is enabled or not.
  47351. */
  47352. /**
  47353. * Sets wether tonemapping is enabled or not
  47354. */
  47355. cameraToneMappingEnabled: boolean;
  47356. /**
  47357. * The camera exposure used on this material.
  47358. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47359. * This corresponds to a photographic exposure.
  47360. */
  47361. /**
  47362. * The camera exposure used on this material.
  47363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47364. * This corresponds to a photographic exposure.
  47365. */
  47366. cameraExposure: float;
  47367. /**
  47368. * Gets The camera contrast used on this material.
  47369. */
  47370. /**
  47371. * Sets The camera contrast used on this material.
  47372. */
  47373. cameraContrast: float;
  47374. /**
  47375. * Gets the Color Grading 2D Lookup Texture.
  47376. */
  47377. /**
  47378. * Sets the Color Grading 2D Lookup Texture.
  47379. */
  47380. cameraColorGradingTexture: Nullable<BaseTexture>;
  47381. /**
  47382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47384. * 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;
  47385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47386. */
  47387. /**
  47388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47390. * 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;
  47391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47392. */
  47393. cameraColorCurves: Nullable<ColorCurves>;
  47394. /**
  47395. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47396. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47397. */
  47398. switchToBGR: boolean;
  47399. private _renderTargets;
  47400. private _reflectionControls;
  47401. private _white;
  47402. private _primaryShadowColor;
  47403. private _primaryHighlightColor;
  47404. /**
  47405. * Instantiates a Background Material in the given scene
  47406. * @param name The friendly name of the material
  47407. * @param scene The scene to add the material to
  47408. */
  47409. constructor(name: string, scene: Scene);
  47410. /**
  47411. * Gets a boolean indicating that current material needs to register RTT
  47412. */
  47413. readonly hasRenderTargetTextures: boolean;
  47414. /**
  47415. * The entire material has been created in order to prevent overdraw.
  47416. * @returns false
  47417. */
  47418. needAlphaTesting(): boolean;
  47419. /**
  47420. * The entire material has been created in order to prevent overdraw.
  47421. * @returns true if blending is enable
  47422. */
  47423. needAlphaBlending(): boolean;
  47424. /**
  47425. * Checks wether the material is ready to be rendered for a given mesh.
  47426. * @param mesh The mesh to render
  47427. * @param subMesh The submesh to check against
  47428. * @param useInstances Specify wether or not the material is used with instances
  47429. * @returns true if all the dependencies are ready (Textures, Effects...)
  47430. */
  47431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47432. /**
  47433. * Compute the primary color according to the chosen perceptual color.
  47434. */
  47435. private _computePrimaryColorFromPerceptualColor;
  47436. /**
  47437. * Compute the highlights and shadow colors according to their chosen levels.
  47438. */
  47439. private _computePrimaryColors;
  47440. /**
  47441. * Build the uniform buffer used in the material.
  47442. */
  47443. buildUniformLayout(): void;
  47444. /**
  47445. * Unbind the material.
  47446. */
  47447. unbind(): void;
  47448. /**
  47449. * Bind only the world matrix to the material.
  47450. * @param world The world matrix to bind.
  47451. */
  47452. bindOnlyWorldMatrix(world: Matrix): void;
  47453. /**
  47454. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47455. * @param world The world matrix to bind.
  47456. * @param subMesh The submesh to bind for.
  47457. */
  47458. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47459. /**
  47460. * Checks to see if a texture is used in the material.
  47461. * @param texture - Base texture to use.
  47462. * @returns - Boolean specifying if a texture is used in the material.
  47463. */
  47464. hasTexture(texture: BaseTexture): boolean;
  47465. /**
  47466. * Dispose the material.
  47467. * @param forceDisposeEffect Force disposal of the associated effect.
  47468. * @param forceDisposeTextures Force disposal of the associated textures.
  47469. */
  47470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47471. /**
  47472. * Clones the material.
  47473. * @param name The cloned name.
  47474. * @returns The cloned material.
  47475. */
  47476. clone(name: string): BackgroundMaterial;
  47477. /**
  47478. * Serializes the current material to its JSON representation.
  47479. * @returns The JSON representation.
  47480. */
  47481. serialize(): any;
  47482. /**
  47483. * Gets the class name of the material
  47484. * @returns "BackgroundMaterial"
  47485. */
  47486. getClassName(): string;
  47487. /**
  47488. * Parse a JSON input to create back a background material.
  47489. * @param source The JSON data to parse
  47490. * @param scene The scene to create the parsed material in
  47491. * @param rootUrl The root url of the assets the material depends upon
  47492. * @returns the instantiated BackgroundMaterial.
  47493. */
  47494. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47495. }
  47496. }
  47497. declare module "babylonjs/Helpers/environmentHelper" {
  47498. import { Observable } from "babylonjs/Misc/observable";
  47499. import { Nullable } from "babylonjs/types";
  47500. import { Scene } from "babylonjs/scene";
  47501. import { Vector3 } from "babylonjs/Maths/math.vector";
  47502. import { Color3 } from "babylonjs/Maths/math.color";
  47503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47504. import { Mesh } from "babylonjs/Meshes/mesh";
  47505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47506. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47507. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47508. import "babylonjs/Meshes/Builders/planeBuilder";
  47509. import "babylonjs/Meshes/Builders/boxBuilder";
  47510. /**
  47511. * Represents the different options available during the creation of
  47512. * a Environment helper.
  47513. *
  47514. * This can control the default ground, skybox and image processing setup of your scene.
  47515. */
  47516. export interface IEnvironmentHelperOptions {
  47517. /**
  47518. * Specifies wether or not to create a ground.
  47519. * True by default.
  47520. */
  47521. createGround: boolean;
  47522. /**
  47523. * Specifies the ground size.
  47524. * 15 by default.
  47525. */
  47526. groundSize: number;
  47527. /**
  47528. * The texture used on the ground for the main color.
  47529. * Comes from the BabylonJS CDN by default.
  47530. *
  47531. * Remarks: Can be either a texture or a url.
  47532. */
  47533. groundTexture: string | BaseTexture;
  47534. /**
  47535. * The color mixed in the ground texture by default.
  47536. * BabylonJS clearColor by default.
  47537. */
  47538. groundColor: Color3;
  47539. /**
  47540. * Specifies the ground opacity.
  47541. * 1 by default.
  47542. */
  47543. groundOpacity: number;
  47544. /**
  47545. * Enables the ground to receive shadows.
  47546. * True by default.
  47547. */
  47548. enableGroundShadow: boolean;
  47549. /**
  47550. * Helps preventing the shadow to be fully black on the ground.
  47551. * 0.5 by default.
  47552. */
  47553. groundShadowLevel: number;
  47554. /**
  47555. * Creates a mirror texture attach to the ground.
  47556. * false by default.
  47557. */
  47558. enableGroundMirror: boolean;
  47559. /**
  47560. * Specifies the ground mirror size ratio.
  47561. * 0.3 by default as the default kernel is 64.
  47562. */
  47563. groundMirrorSizeRatio: number;
  47564. /**
  47565. * Specifies the ground mirror blur kernel size.
  47566. * 64 by default.
  47567. */
  47568. groundMirrorBlurKernel: number;
  47569. /**
  47570. * Specifies the ground mirror visibility amount.
  47571. * 1 by default
  47572. */
  47573. groundMirrorAmount: number;
  47574. /**
  47575. * Specifies the ground mirror reflectance weight.
  47576. * This uses the standard weight of the background material to setup the fresnel effect
  47577. * of the mirror.
  47578. * 1 by default.
  47579. */
  47580. groundMirrorFresnelWeight: number;
  47581. /**
  47582. * Specifies the ground mirror Falloff distance.
  47583. * This can helps reducing the size of the reflection.
  47584. * 0 by Default.
  47585. */
  47586. groundMirrorFallOffDistance: number;
  47587. /**
  47588. * Specifies the ground mirror texture type.
  47589. * Unsigned Int by Default.
  47590. */
  47591. groundMirrorTextureType: number;
  47592. /**
  47593. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47594. * the shown objects.
  47595. */
  47596. groundYBias: number;
  47597. /**
  47598. * Specifies wether or not to create a skybox.
  47599. * True by default.
  47600. */
  47601. createSkybox: boolean;
  47602. /**
  47603. * Specifies the skybox size.
  47604. * 20 by default.
  47605. */
  47606. skyboxSize: number;
  47607. /**
  47608. * The texture used on the skybox for the main color.
  47609. * Comes from the BabylonJS CDN by default.
  47610. *
  47611. * Remarks: Can be either a texture or a url.
  47612. */
  47613. skyboxTexture: string | BaseTexture;
  47614. /**
  47615. * The color mixed in the skybox texture by default.
  47616. * BabylonJS clearColor by default.
  47617. */
  47618. skyboxColor: Color3;
  47619. /**
  47620. * The background rotation around the Y axis of the scene.
  47621. * This helps aligning the key lights of your scene with the background.
  47622. * 0 by default.
  47623. */
  47624. backgroundYRotation: number;
  47625. /**
  47626. * Compute automatically the size of the elements to best fit with the scene.
  47627. */
  47628. sizeAuto: boolean;
  47629. /**
  47630. * Default position of the rootMesh if autoSize is not true.
  47631. */
  47632. rootPosition: Vector3;
  47633. /**
  47634. * Sets up the image processing in the scene.
  47635. * true by default.
  47636. */
  47637. setupImageProcessing: boolean;
  47638. /**
  47639. * The texture used as your environment texture in the scene.
  47640. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47641. *
  47642. * Remarks: Can be either a texture or a url.
  47643. */
  47644. environmentTexture: string | BaseTexture;
  47645. /**
  47646. * The value of the exposure to apply to the scene.
  47647. * 0.6 by default if setupImageProcessing is true.
  47648. */
  47649. cameraExposure: number;
  47650. /**
  47651. * The value of the contrast to apply to the scene.
  47652. * 1.6 by default if setupImageProcessing is true.
  47653. */
  47654. cameraContrast: number;
  47655. /**
  47656. * Specifies wether or not tonemapping should be enabled in the scene.
  47657. * true by default if setupImageProcessing is true.
  47658. */
  47659. toneMappingEnabled: boolean;
  47660. }
  47661. /**
  47662. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47663. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47664. * It also helps with the default setup of your imageProcessing configuration.
  47665. */
  47666. export class EnvironmentHelper {
  47667. /**
  47668. * Default ground texture URL.
  47669. */
  47670. private static _groundTextureCDNUrl;
  47671. /**
  47672. * Default skybox texture URL.
  47673. */
  47674. private static _skyboxTextureCDNUrl;
  47675. /**
  47676. * Default environment texture URL.
  47677. */
  47678. private static _environmentTextureCDNUrl;
  47679. /**
  47680. * Creates the default options for the helper.
  47681. */
  47682. private static _getDefaultOptions;
  47683. private _rootMesh;
  47684. /**
  47685. * Gets the root mesh created by the helper.
  47686. */
  47687. readonly rootMesh: Mesh;
  47688. private _skybox;
  47689. /**
  47690. * Gets the skybox created by the helper.
  47691. */
  47692. readonly skybox: Nullable<Mesh>;
  47693. private _skyboxTexture;
  47694. /**
  47695. * Gets the skybox texture created by the helper.
  47696. */
  47697. readonly skyboxTexture: Nullable<BaseTexture>;
  47698. private _skyboxMaterial;
  47699. /**
  47700. * Gets the skybox material created by the helper.
  47701. */
  47702. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47703. private _ground;
  47704. /**
  47705. * Gets the ground mesh created by the helper.
  47706. */
  47707. readonly ground: Nullable<Mesh>;
  47708. private _groundTexture;
  47709. /**
  47710. * Gets the ground texture created by the helper.
  47711. */
  47712. readonly groundTexture: Nullable<BaseTexture>;
  47713. private _groundMirror;
  47714. /**
  47715. * Gets the ground mirror created by the helper.
  47716. */
  47717. readonly groundMirror: Nullable<MirrorTexture>;
  47718. /**
  47719. * Gets the ground mirror render list to helps pushing the meshes
  47720. * you wish in the ground reflection.
  47721. */
  47722. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47723. private _groundMaterial;
  47724. /**
  47725. * Gets the ground material created by the helper.
  47726. */
  47727. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47728. /**
  47729. * Stores the creation options.
  47730. */
  47731. private readonly _scene;
  47732. private _options;
  47733. /**
  47734. * This observable will be notified with any error during the creation of the environment,
  47735. * mainly texture creation errors.
  47736. */
  47737. onErrorObservable: Observable<{
  47738. message?: string;
  47739. exception?: any;
  47740. }>;
  47741. /**
  47742. * constructor
  47743. * @param options Defines the options we want to customize the helper
  47744. * @param scene The scene to add the material to
  47745. */
  47746. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47747. /**
  47748. * Updates the background according to the new options
  47749. * @param options
  47750. */
  47751. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47752. /**
  47753. * Sets the primary color of all the available elements.
  47754. * @param color the main color to affect to the ground and the background
  47755. */
  47756. setMainColor(color: Color3): void;
  47757. /**
  47758. * Setup the image processing according to the specified options.
  47759. */
  47760. private _setupImageProcessing;
  47761. /**
  47762. * Setup the environment texture according to the specified options.
  47763. */
  47764. private _setupEnvironmentTexture;
  47765. /**
  47766. * Setup the background according to the specified options.
  47767. */
  47768. private _setupBackground;
  47769. /**
  47770. * Get the scene sizes according to the setup.
  47771. */
  47772. private _getSceneSize;
  47773. /**
  47774. * Setup the ground according to the specified options.
  47775. */
  47776. private _setupGround;
  47777. /**
  47778. * Setup the ground material according to the specified options.
  47779. */
  47780. private _setupGroundMaterial;
  47781. /**
  47782. * Setup the ground diffuse texture according to the specified options.
  47783. */
  47784. private _setupGroundDiffuseTexture;
  47785. /**
  47786. * Setup the ground mirror texture according to the specified options.
  47787. */
  47788. private _setupGroundMirrorTexture;
  47789. /**
  47790. * Setup the ground to receive the mirror texture.
  47791. */
  47792. private _setupMirrorInGroundMaterial;
  47793. /**
  47794. * Setup the skybox according to the specified options.
  47795. */
  47796. private _setupSkybox;
  47797. /**
  47798. * Setup the skybox material according to the specified options.
  47799. */
  47800. private _setupSkyboxMaterial;
  47801. /**
  47802. * Setup the skybox reflection texture according to the specified options.
  47803. */
  47804. private _setupSkyboxReflectionTexture;
  47805. private _errorHandler;
  47806. /**
  47807. * Dispose all the elements created by the Helper.
  47808. */
  47809. dispose(): void;
  47810. }
  47811. }
  47812. declare module "babylonjs/Helpers/photoDome" {
  47813. import { Observable } from "babylonjs/Misc/observable";
  47814. import { Nullable } from "babylonjs/types";
  47815. import { Scene } from "babylonjs/scene";
  47816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47817. import { Mesh } from "babylonjs/Meshes/mesh";
  47818. import { Texture } from "babylonjs/Materials/Textures/texture";
  47819. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47820. import "babylonjs/Meshes/Builders/sphereBuilder";
  47821. /**
  47822. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47823. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47824. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47825. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47826. */
  47827. export class PhotoDome extends TransformNode {
  47828. /**
  47829. * Define the image as a Monoscopic panoramic 360 image.
  47830. */
  47831. static readonly MODE_MONOSCOPIC: number;
  47832. /**
  47833. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47834. */
  47835. static readonly MODE_TOPBOTTOM: number;
  47836. /**
  47837. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47838. */
  47839. static readonly MODE_SIDEBYSIDE: number;
  47840. private _useDirectMapping;
  47841. /**
  47842. * The texture being displayed on the sphere
  47843. */
  47844. protected _photoTexture: Texture;
  47845. /**
  47846. * Gets or sets the texture being displayed on the sphere
  47847. */
  47848. photoTexture: Texture;
  47849. /**
  47850. * Observable raised when an error occured while loading the 360 image
  47851. */
  47852. onLoadErrorObservable: Observable<string>;
  47853. /**
  47854. * The skybox material
  47855. */
  47856. protected _material: BackgroundMaterial;
  47857. /**
  47858. * The surface used for the skybox
  47859. */
  47860. protected _mesh: Mesh;
  47861. /**
  47862. * Gets the mesh used for the skybox.
  47863. */
  47864. readonly mesh: Mesh;
  47865. /**
  47866. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47867. * Also see the options.resolution property.
  47868. */
  47869. fovMultiplier: number;
  47870. private _imageMode;
  47871. /**
  47872. * Gets or set the current video mode for the video. It can be:
  47873. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47874. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47875. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47876. */
  47877. imageMode: number;
  47878. /**
  47879. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47880. * @param name Element's name, child elements will append suffixes for their own names.
  47881. * @param urlsOfPhoto defines the url of the photo to display
  47882. * @param options defines an object containing optional or exposed sub element properties
  47883. * @param onError defines a callback called when an error occured while loading the texture
  47884. */
  47885. constructor(name: string, urlOfPhoto: string, options: {
  47886. resolution?: number;
  47887. size?: number;
  47888. useDirectMapping?: boolean;
  47889. faceForward?: boolean;
  47890. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47891. private _onBeforeCameraRenderObserver;
  47892. private _changeImageMode;
  47893. /**
  47894. * Releases resources associated with this node.
  47895. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47896. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47897. */
  47898. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47899. }
  47900. }
  47901. declare module "babylonjs/Misc/rgbdTextureTools" {
  47902. import "babylonjs/Shaders/rgbdDecode.fragment";
  47903. import { Texture } from "babylonjs/Materials/Textures/texture";
  47904. /**
  47905. * Class used to host RGBD texture specific utilities
  47906. */
  47907. export class RGBDTextureTools {
  47908. /**
  47909. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47910. * @param texture the texture to expand.
  47911. */
  47912. static ExpandRGBDTexture(texture: Texture): void;
  47913. }
  47914. }
  47915. declare module "babylonjs/Misc/brdfTextureTools" {
  47916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47917. import { Scene } from "babylonjs/scene";
  47918. /**
  47919. * Class used to host texture specific utilities
  47920. */
  47921. export class BRDFTextureTools {
  47922. /**
  47923. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47924. * @param scene defines the hosting scene
  47925. * @returns the environment BRDF texture
  47926. */
  47927. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47928. private static _environmentBRDFBase64Texture;
  47929. }
  47930. }
  47931. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47932. import { Nullable } from "babylonjs/types";
  47933. import { Color3 } from "babylonjs/Maths/math.color";
  47934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47935. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47936. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47937. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47938. import { Engine } from "babylonjs/Engines/engine";
  47939. import { Scene } from "babylonjs/scene";
  47940. /**
  47941. * @hidden
  47942. */
  47943. export interface IMaterialClearCoatDefines {
  47944. CLEARCOAT: boolean;
  47945. CLEARCOAT_DEFAULTIOR: boolean;
  47946. CLEARCOAT_TEXTURE: boolean;
  47947. CLEARCOAT_TEXTUREDIRECTUV: number;
  47948. CLEARCOAT_BUMP: boolean;
  47949. CLEARCOAT_BUMPDIRECTUV: number;
  47950. CLEARCOAT_TINT: boolean;
  47951. CLEARCOAT_TINT_TEXTURE: boolean;
  47952. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47953. /** @hidden */
  47954. _areTexturesDirty: boolean;
  47955. }
  47956. /**
  47957. * Define the code related to the clear coat parameters of the pbr material.
  47958. */
  47959. export class PBRClearCoatConfiguration {
  47960. /**
  47961. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47962. * The default fits with a polyurethane material.
  47963. */
  47964. private static readonly _DefaultIndexOfRefraction;
  47965. private _isEnabled;
  47966. /**
  47967. * Defines if the clear coat is enabled in the material.
  47968. */
  47969. isEnabled: boolean;
  47970. /**
  47971. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47972. */
  47973. intensity: number;
  47974. /**
  47975. * Defines the clear coat layer roughness.
  47976. */
  47977. roughness: number;
  47978. private _indexOfRefraction;
  47979. /**
  47980. * Defines the index of refraction of the clear coat.
  47981. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47982. * The default fits with a polyurethane material.
  47983. * Changing the default value is more performance intensive.
  47984. */
  47985. indexOfRefraction: number;
  47986. private _texture;
  47987. /**
  47988. * Stores the clear coat values in a texture.
  47989. */
  47990. texture: Nullable<BaseTexture>;
  47991. private _bumpTexture;
  47992. /**
  47993. * Define the clear coat specific bump texture.
  47994. */
  47995. bumpTexture: Nullable<BaseTexture>;
  47996. private _isTintEnabled;
  47997. /**
  47998. * Defines if the clear coat tint is enabled in the material.
  47999. */
  48000. isTintEnabled: boolean;
  48001. /**
  48002. * Defines the clear coat tint of the material.
  48003. * This is only use if tint is enabled
  48004. */
  48005. tintColor: Color3;
  48006. /**
  48007. * Defines the distance at which the tint color should be found in the
  48008. * clear coat media.
  48009. * This is only use if tint is enabled
  48010. */
  48011. tintColorAtDistance: number;
  48012. /**
  48013. * Defines the clear coat layer thickness.
  48014. * This is only use if tint is enabled
  48015. */
  48016. tintThickness: number;
  48017. private _tintTexture;
  48018. /**
  48019. * Stores the clear tint values in a texture.
  48020. * rgb is tint
  48021. * a is a thickness factor
  48022. */
  48023. tintTexture: Nullable<BaseTexture>;
  48024. /** @hidden */
  48025. private _internalMarkAllSubMeshesAsTexturesDirty;
  48026. /** @hidden */
  48027. _markAllSubMeshesAsTexturesDirty(): void;
  48028. /**
  48029. * Instantiate a new istance of clear coat configuration.
  48030. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48031. */
  48032. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48033. /**
  48034. * Gets wehter the submesh is ready to be used or not.
  48035. * @param defines the list of "defines" to update.
  48036. * @param scene defines the scene the material belongs to.
  48037. * @param engine defines the engine the material belongs to.
  48038. * @param disableBumpMap defines wether the material disables bump or not.
  48039. * @returns - boolean indicating that the submesh is ready or not.
  48040. */
  48041. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48042. /**
  48043. * Checks to see if a texture is used in the material.
  48044. * @param defines the list of "defines" to update.
  48045. * @param scene defines the scene to the material belongs to.
  48046. */
  48047. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48048. /**
  48049. * Binds the material data.
  48050. * @param uniformBuffer defines the Uniform buffer to fill in.
  48051. * @param scene defines the scene the material belongs to.
  48052. * @param engine defines the engine the material belongs to.
  48053. * @param disableBumpMap defines wether the material disables bump or not.
  48054. * @param isFrozen defines wether the material is frozen or not.
  48055. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48056. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48057. */
  48058. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48059. /**
  48060. * Checks to see if a texture is used in the material.
  48061. * @param texture - Base texture to use.
  48062. * @returns - Boolean specifying if a texture is used in the material.
  48063. */
  48064. hasTexture(texture: BaseTexture): boolean;
  48065. /**
  48066. * Returns an array of the actively used textures.
  48067. * @param activeTextures Array of BaseTextures
  48068. */
  48069. getActiveTextures(activeTextures: BaseTexture[]): void;
  48070. /**
  48071. * Returns the animatable textures.
  48072. * @param animatables Array of animatable textures.
  48073. */
  48074. getAnimatables(animatables: IAnimatable[]): void;
  48075. /**
  48076. * Disposes the resources of the material.
  48077. * @param forceDisposeTextures - Forces the disposal of all textures.
  48078. */
  48079. dispose(forceDisposeTextures?: boolean): void;
  48080. /**
  48081. * Get the current class name of the texture useful for serialization or dynamic coding.
  48082. * @returns "PBRClearCoatConfiguration"
  48083. */
  48084. getClassName(): string;
  48085. /**
  48086. * Add fallbacks to the effect fallbacks list.
  48087. * @param defines defines the Base texture to use.
  48088. * @param fallbacks defines the current fallback list.
  48089. * @param currentRank defines the current fallback rank.
  48090. * @returns the new fallback rank.
  48091. */
  48092. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48093. /**
  48094. * Add the required uniforms to the current list.
  48095. * @param uniforms defines the current uniform list.
  48096. */
  48097. static AddUniforms(uniforms: string[]): void;
  48098. /**
  48099. * Add the required samplers to the current list.
  48100. * @param samplers defines the current sampler list.
  48101. */
  48102. static AddSamplers(samplers: string[]): void;
  48103. /**
  48104. * Add the required uniforms to the current buffer.
  48105. * @param uniformBuffer defines the current uniform buffer.
  48106. */
  48107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48108. /**
  48109. * Makes a duplicate of the current configuration into another one.
  48110. * @param clearCoatConfiguration define the config where to copy the info
  48111. */
  48112. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48113. /**
  48114. * Serializes this clear coat configuration.
  48115. * @returns - An object with the serialized config.
  48116. */
  48117. serialize(): any;
  48118. /**
  48119. * Parses a anisotropy Configuration from a serialized object.
  48120. * @param source - Serialized object.
  48121. * @param scene Defines the scene we are parsing for
  48122. * @param rootUrl Defines the rootUrl to load from
  48123. */
  48124. parse(source: any, scene: Scene, rootUrl: string): void;
  48125. }
  48126. }
  48127. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48128. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48129. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48131. import { Vector2 } from "babylonjs/Maths/math.vector";
  48132. import { Scene } from "babylonjs/scene";
  48133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48134. import { Nullable } from "babylonjs/types";
  48135. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48136. /**
  48137. * @hidden
  48138. */
  48139. export interface IMaterialAnisotropicDefines {
  48140. ANISOTROPIC: boolean;
  48141. ANISOTROPIC_TEXTURE: boolean;
  48142. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48143. MAINUV1: boolean;
  48144. _areTexturesDirty: boolean;
  48145. _needUVs: boolean;
  48146. }
  48147. /**
  48148. * Define the code related to the anisotropic parameters of the pbr material.
  48149. */
  48150. export class PBRAnisotropicConfiguration {
  48151. private _isEnabled;
  48152. /**
  48153. * Defines if the anisotropy is enabled in the material.
  48154. */
  48155. isEnabled: boolean;
  48156. /**
  48157. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48158. */
  48159. intensity: number;
  48160. /**
  48161. * Defines if the effect is along the tangents, bitangents or in between.
  48162. * By default, the effect is "strectching" the highlights along the tangents.
  48163. */
  48164. direction: Vector2;
  48165. private _texture;
  48166. /**
  48167. * Stores the anisotropy values in a texture.
  48168. * rg is direction (like normal from -1 to 1)
  48169. * b is a intensity
  48170. */
  48171. texture: Nullable<BaseTexture>;
  48172. /** @hidden */
  48173. private _internalMarkAllSubMeshesAsTexturesDirty;
  48174. /** @hidden */
  48175. _markAllSubMeshesAsTexturesDirty(): void;
  48176. /**
  48177. * Instantiate a new istance of anisotropy configuration.
  48178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48179. */
  48180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48181. /**
  48182. * Specifies that the submesh is ready to be used.
  48183. * @param defines the list of "defines" to update.
  48184. * @param scene defines the scene the material belongs to.
  48185. * @returns - boolean indicating that the submesh is ready or not.
  48186. */
  48187. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48188. /**
  48189. * Checks to see if a texture is used in the material.
  48190. * @param defines the list of "defines" to update.
  48191. * @param mesh the mesh we are preparing the defines for.
  48192. * @param scene defines the scene the material belongs to.
  48193. */
  48194. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48195. /**
  48196. * Binds the material data.
  48197. * @param uniformBuffer defines the Uniform buffer to fill in.
  48198. * @param scene defines the scene the material belongs to.
  48199. * @param isFrozen defines wether the material is frozen or not.
  48200. */
  48201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48202. /**
  48203. * Checks to see if a texture is used in the material.
  48204. * @param texture - Base texture to use.
  48205. * @returns - Boolean specifying if a texture is used in the material.
  48206. */
  48207. hasTexture(texture: BaseTexture): boolean;
  48208. /**
  48209. * Returns an array of the actively used textures.
  48210. * @param activeTextures Array of BaseTextures
  48211. */
  48212. getActiveTextures(activeTextures: BaseTexture[]): void;
  48213. /**
  48214. * Returns the animatable textures.
  48215. * @param animatables Array of animatable textures.
  48216. */
  48217. getAnimatables(animatables: IAnimatable[]): void;
  48218. /**
  48219. * Disposes the resources of the material.
  48220. * @param forceDisposeTextures - Forces the disposal of all textures.
  48221. */
  48222. dispose(forceDisposeTextures?: boolean): void;
  48223. /**
  48224. * Get the current class name of the texture useful for serialization or dynamic coding.
  48225. * @returns "PBRAnisotropicConfiguration"
  48226. */
  48227. getClassName(): string;
  48228. /**
  48229. * Add fallbacks to the effect fallbacks list.
  48230. * @param defines defines the Base texture to use.
  48231. * @param fallbacks defines the current fallback list.
  48232. * @param currentRank defines the current fallback rank.
  48233. * @returns the new fallback rank.
  48234. */
  48235. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48236. /**
  48237. * Add the required uniforms to the current list.
  48238. * @param uniforms defines the current uniform list.
  48239. */
  48240. static AddUniforms(uniforms: string[]): void;
  48241. /**
  48242. * Add the required uniforms to the current buffer.
  48243. * @param uniformBuffer defines the current uniform buffer.
  48244. */
  48245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48246. /**
  48247. * Add the required samplers to the current list.
  48248. * @param samplers defines the current sampler list.
  48249. */
  48250. static AddSamplers(samplers: string[]): void;
  48251. /**
  48252. * Makes a duplicate of the current configuration into another one.
  48253. * @param anisotropicConfiguration define the config where to copy the info
  48254. */
  48255. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48256. /**
  48257. * Serializes this anisotropy configuration.
  48258. * @returns - An object with the serialized config.
  48259. */
  48260. serialize(): any;
  48261. /**
  48262. * Parses a anisotropy Configuration from a serialized object.
  48263. * @param source - Serialized object.
  48264. * @param scene Defines the scene we are parsing for
  48265. * @param rootUrl Defines the rootUrl to load from
  48266. */
  48267. parse(source: any, scene: Scene, rootUrl: string): void;
  48268. }
  48269. }
  48270. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48271. import { Scene } from "babylonjs/scene";
  48272. /**
  48273. * @hidden
  48274. */
  48275. export interface IMaterialBRDFDefines {
  48276. BRDF_V_HEIGHT_CORRELATED: boolean;
  48277. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48278. SPHERICAL_HARMONICS: boolean;
  48279. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48280. /** @hidden */
  48281. _areMiscDirty: boolean;
  48282. }
  48283. /**
  48284. * Define the code related to the BRDF parameters of the pbr material.
  48285. */
  48286. export class PBRBRDFConfiguration {
  48287. /**
  48288. * Default value used for the energy conservation.
  48289. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48290. */
  48291. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48292. /**
  48293. * Default value used for the Smith Visibility Height Correlated mode.
  48294. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48295. */
  48296. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48297. /**
  48298. * Default value used for the IBL diffuse part.
  48299. * This can help switching back to the polynomials mode globally which is a tiny bit
  48300. * less GPU intensive at the drawback of a lower quality.
  48301. */
  48302. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48303. /**
  48304. * Default value used for activating energy conservation for the specular workflow.
  48305. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48306. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48307. */
  48308. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48309. private _useEnergyConservation;
  48310. /**
  48311. * Defines if the material uses energy conservation.
  48312. */
  48313. useEnergyConservation: boolean;
  48314. private _useSmithVisibilityHeightCorrelated;
  48315. /**
  48316. * LEGACY Mode set to false
  48317. * Defines if the material uses height smith correlated visibility term.
  48318. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48319. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48320. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48321. * Not relying on height correlated will also disable energy conservation.
  48322. */
  48323. useSmithVisibilityHeightCorrelated: boolean;
  48324. private _useSphericalHarmonics;
  48325. /**
  48326. * LEGACY Mode set to false
  48327. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48328. * diffuse part of the IBL.
  48329. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48330. * to the ground truth.
  48331. */
  48332. useSphericalHarmonics: boolean;
  48333. private _useSpecularGlossinessInputEnergyConservation;
  48334. /**
  48335. * Defines if the material uses energy conservation, when the specular workflow is active.
  48336. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48337. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48338. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48339. */
  48340. useSpecularGlossinessInputEnergyConservation: boolean;
  48341. /** @hidden */
  48342. private _internalMarkAllSubMeshesAsMiscDirty;
  48343. /** @hidden */
  48344. _markAllSubMeshesAsMiscDirty(): void;
  48345. /**
  48346. * Instantiate a new istance of clear coat configuration.
  48347. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48348. */
  48349. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48350. /**
  48351. * Checks to see if a texture is used in the material.
  48352. * @param defines the list of "defines" to update.
  48353. */
  48354. prepareDefines(defines: IMaterialBRDFDefines): void;
  48355. /**
  48356. * Get the current class name of the texture useful for serialization or dynamic coding.
  48357. * @returns "PBRClearCoatConfiguration"
  48358. */
  48359. getClassName(): string;
  48360. /**
  48361. * Makes a duplicate of the current configuration into another one.
  48362. * @param brdfConfiguration define the config where to copy the info
  48363. */
  48364. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48365. /**
  48366. * Serializes this BRDF configuration.
  48367. * @returns - An object with the serialized config.
  48368. */
  48369. serialize(): any;
  48370. /**
  48371. * Parses a anisotropy Configuration from a serialized object.
  48372. * @param source - Serialized object.
  48373. * @param scene Defines the scene we are parsing for
  48374. * @param rootUrl Defines the rootUrl to load from
  48375. */
  48376. parse(source: any, scene: Scene, rootUrl: string): void;
  48377. }
  48378. }
  48379. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48380. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48382. import { Color3 } from "babylonjs/Maths/math.color";
  48383. import { Scene } from "babylonjs/scene";
  48384. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48385. import { Nullable } from "babylonjs/types";
  48386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48387. /**
  48388. * @hidden
  48389. */
  48390. export interface IMaterialSheenDefines {
  48391. SHEEN: boolean;
  48392. SHEEN_TEXTURE: boolean;
  48393. SHEEN_TEXTUREDIRECTUV: number;
  48394. SHEEN_LINKWITHALBEDO: boolean;
  48395. /** @hidden */
  48396. _areTexturesDirty: boolean;
  48397. }
  48398. /**
  48399. * Define the code related to the Sheen parameters of the pbr material.
  48400. */
  48401. export class PBRSheenConfiguration {
  48402. private _isEnabled;
  48403. /**
  48404. * Defines if the material uses sheen.
  48405. */
  48406. isEnabled: boolean;
  48407. private _linkSheenWithAlbedo;
  48408. /**
  48409. * Defines if the sheen is linked to the sheen color.
  48410. */
  48411. linkSheenWithAlbedo: boolean;
  48412. /**
  48413. * Defines the sheen intensity.
  48414. */
  48415. intensity: number;
  48416. /**
  48417. * Defines the sheen color.
  48418. */
  48419. color: Color3;
  48420. private _texture;
  48421. /**
  48422. * Stores the sheen tint values in a texture.
  48423. * rgb is tint
  48424. * a is a intensity
  48425. */
  48426. texture: Nullable<BaseTexture>;
  48427. /** @hidden */
  48428. private _internalMarkAllSubMeshesAsTexturesDirty;
  48429. /** @hidden */
  48430. _markAllSubMeshesAsTexturesDirty(): void;
  48431. /**
  48432. * Instantiate a new istance of clear coat configuration.
  48433. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48434. */
  48435. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48436. /**
  48437. * Specifies that the submesh is ready to be used.
  48438. * @param defines the list of "defines" to update.
  48439. * @param scene defines the scene the material belongs to.
  48440. * @returns - boolean indicating that the submesh is ready or not.
  48441. */
  48442. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48443. /**
  48444. * Checks to see if a texture is used in the material.
  48445. * @param defines the list of "defines" to update.
  48446. * @param scene defines the scene the material belongs to.
  48447. */
  48448. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48449. /**
  48450. * Binds the material data.
  48451. * @param uniformBuffer defines the Uniform buffer to fill in.
  48452. * @param scene defines the scene the material belongs to.
  48453. * @param isFrozen defines wether the material is frozen or not.
  48454. */
  48455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48456. /**
  48457. * Checks to see if a texture is used in the material.
  48458. * @param texture - Base texture to use.
  48459. * @returns - Boolean specifying if a texture is used in the material.
  48460. */
  48461. hasTexture(texture: BaseTexture): boolean;
  48462. /**
  48463. * Returns an array of the actively used textures.
  48464. * @param activeTextures Array of BaseTextures
  48465. */
  48466. getActiveTextures(activeTextures: BaseTexture[]): void;
  48467. /**
  48468. * Returns the animatable textures.
  48469. * @param animatables Array of animatable textures.
  48470. */
  48471. getAnimatables(animatables: IAnimatable[]): void;
  48472. /**
  48473. * Disposes the resources of the material.
  48474. * @param forceDisposeTextures - Forces the disposal of all textures.
  48475. */
  48476. dispose(forceDisposeTextures?: boolean): void;
  48477. /**
  48478. * Get the current class name of the texture useful for serialization or dynamic coding.
  48479. * @returns "PBRSheenConfiguration"
  48480. */
  48481. getClassName(): string;
  48482. /**
  48483. * Add fallbacks to the effect fallbacks list.
  48484. * @param defines defines the Base texture to use.
  48485. * @param fallbacks defines the current fallback list.
  48486. * @param currentRank defines the current fallback rank.
  48487. * @returns the new fallback rank.
  48488. */
  48489. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48490. /**
  48491. * Add the required uniforms to the current list.
  48492. * @param uniforms defines the current uniform list.
  48493. */
  48494. static AddUniforms(uniforms: string[]): void;
  48495. /**
  48496. * Add the required uniforms to the current buffer.
  48497. * @param uniformBuffer defines the current uniform buffer.
  48498. */
  48499. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48500. /**
  48501. * Add the required samplers to the current list.
  48502. * @param samplers defines the current sampler list.
  48503. */
  48504. static AddSamplers(samplers: string[]): void;
  48505. /**
  48506. * Makes a duplicate of the current configuration into another one.
  48507. * @param sheenConfiguration define the config where to copy the info
  48508. */
  48509. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48510. /**
  48511. * Serializes this BRDF configuration.
  48512. * @returns - An object with the serialized config.
  48513. */
  48514. serialize(): any;
  48515. /**
  48516. * Parses a anisotropy Configuration from a serialized object.
  48517. * @param source - Serialized object.
  48518. * @param scene Defines the scene we are parsing for
  48519. * @param rootUrl Defines the rootUrl to load from
  48520. */
  48521. parse(source: any, scene: Scene, rootUrl: string): void;
  48522. }
  48523. }
  48524. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48525. import { Nullable } from "babylonjs/types";
  48526. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48527. import { Color3 } from "babylonjs/Maths/math.color";
  48528. import { SmartArray } from "babylonjs/Misc/smartArray";
  48529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48531. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48532. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48533. import { Engine } from "babylonjs/Engines/engine";
  48534. import { Scene } from "babylonjs/scene";
  48535. /**
  48536. * @hidden
  48537. */
  48538. export interface IMaterialSubSurfaceDefines {
  48539. SUBSURFACE: boolean;
  48540. SS_REFRACTION: boolean;
  48541. SS_TRANSLUCENCY: boolean;
  48542. SS_SCATERRING: boolean;
  48543. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48544. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48545. SS_REFRACTIONMAP_3D: boolean;
  48546. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48547. SS_LODINREFRACTIONALPHA: boolean;
  48548. SS_GAMMAREFRACTION: boolean;
  48549. SS_RGBDREFRACTION: boolean;
  48550. SS_LINEARSPECULARREFRACTION: boolean;
  48551. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48552. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48553. /** @hidden */
  48554. _areTexturesDirty: boolean;
  48555. }
  48556. /**
  48557. * Define the code related to the sub surface parameters of the pbr material.
  48558. */
  48559. export class PBRSubSurfaceConfiguration {
  48560. private _isRefractionEnabled;
  48561. /**
  48562. * Defines if the refraction is enabled in the material.
  48563. */
  48564. isRefractionEnabled: boolean;
  48565. private _isTranslucencyEnabled;
  48566. /**
  48567. * Defines if the translucency is enabled in the material.
  48568. */
  48569. isTranslucencyEnabled: boolean;
  48570. private _isScatteringEnabled;
  48571. /**
  48572. * Defines the refraction intensity of the material.
  48573. * The refraction when enabled replaces the Diffuse part of the material.
  48574. * The intensity helps transitionning between diffuse and refraction.
  48575. */
  48576. refractionIntensity: number;
  48577. /**
  48578. * Defines the translucency intensity of the material.
  48579. * When translucency has been enabled, this defines how much of the "translucency"
  48580. * is addded to the diffuse part of the material.
  48581. */
  48582. translucencyIntensity: number;
  48583. /**
  48584. * Defines the scattering intensity of the material.
  48585. * When scattering has been enabled, this defines how much of the "scattered light"
  48586. * is addded to the diffuse part of the material.
  48587. */
  48588. scatteringIntensity: number;
  48589. private _thicknessTexture;
  48590. /**
  48591. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48592. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48593. * 0 would mean minimumThickness
  48594. * 1 would mean maximumThickness
  48595. * The other channels might be use as a mask to vary the different effects intensity.
  48596. */
  48597. thicknessTexture: Nullable<BaseTexture>;
  48598. private _refractionTexture;
  48599. /**
  48600. * Defines the texture to use for refraction.
  48601. */
  48602. refractionTexture: Nullable<BaseTexture>;
  48603. private _indexOfRefraction;
  48604. /**
  48605. * Defines the index of refraction used in the material.
  48606. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48607. */
  48608. indexOfRefraction: number;
  48609. private _invertRefractionY;
  48610. /**
  48611. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48612. */
  48613. invertRefractionY: boolean;
  48614. private _linkRefractionWithTransparency;
  48615. /**
  48616. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48617. * Materials half opaque for instance using refraction could benefit from this control.
  48618. */
  48619. linkRefractionWithTransparency: boolean;
  48620. /**
  48621. * Defines the minimum thickness stored in the thickness map.
  48622. * If no thickness map is defined, this value will be used to simulate thickness.
  48623. */
  48624. minimumThickness: number;
  48625. /**
  48626. * Defines the maximum thickness stored in the thickness map.
  48627. */
  48628. maximumThickness: number;
  48629. /**
  48630. * Defines the volume tint of the material.
  48631. * This is used for both translucency and scattering.
  48632. */
  48633. tintColor: Color3;
  48634. /**
  48635. * Defines the distance at which the tint color should be found in the media.
  48636. * This is used for refraction only.
  48637. */
  48638. tintColorAtDistance: number;
  48639. /**
  48640. * Defines how far each channel transmit through the media.
  48641. * It is defined as a color to simplify it selection.
  48642. */
  48643. diffusionDistance: Color3;
  48644. private _useMaskFromThicknessTexture;
  48645. /**
  48646. * Stores the intensity of the different subsurface effects in the thickness texture.
  48647. * * the green channel is the translucency intensity.
  48648. * * the blue channel is the scattering intensity.
  48649. * * the alpha channel is the refraction intensity.
  48650. */
  48651. useMaskFromThicknessTexture: boolean;
  48652. /** @hidden */
  48653. private _internalMarkAllSubMeshesAsTexturesDirty;
  48654. /** @hidden */
  48655. _markAllSubMeshesAsTexturesDirty(): void;
  48656. /**
  48657. * Instantiate a new istance of sub surface configuration.
  48658. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48659. */
  48660. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48661. /**
  48662. * Gets wehter the submesh is ready to be used or not.
  48663. * @param defines the list of "defines" to update.
  48664. * @param scene defines the scene the material belongs to.
  48665. * @returns - boolean indicating that the submesh is ready or not.
  48666. */
  48667. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48668. /**
  48669. * Checks to see if a texture is used in the material.
  48670. * @param defines the list of "defines" to update.
  48671. * @param scene defines the scene to the material belongs to.
  48672. */
  48673. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48674. /**
  48675. * Binds the material data.
  48676. * @param uniformBuffer defines the Uniform buffer to fill in.
  48677. * @param scene defines the scene the material belongs to.
  48678. * @param engine defines the engine the material belongs to.
  48679. * @param isFrozen defines wether the material is frozen or not.
  48680. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48681. */
  48682. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48683. /**
  48684. * Unbinds the material from the mesh.
  48685. * @param activeEffect defines the effect that should be unbound from.
  48686. * @returns true if unbound, otherwise false
  48687. */
  48688. unbind(activeEffect: Effect): boolean;
  48689. /**
  48690. * Returns the texture used for refraction or null if none is used.
  48691. * @param scene defines the scene the material belongs to.
  48692. * @returns - Refraction texture if present. If no refraction texture and refraction
  48693. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48694. */
  48695. private _getRefractionTexture;
  48696. /**
  48697. * Returns true if alpha blending should be disabled.
  48698. */
  48699. readonly disableAlphaBlending: boolean;
  48700. /**
  48701. * Fills the list of render target textures.
  48702. * @param renderTargets the list of render targets to update
  48703. */
  48704. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48705. /**
  48706. * Checks to see if a texture is used in the material.
  48707. * @param texture - Base texture to use.
  48708. * @returns - Boolean specifying if a texture is used in the material.
  48709. */
  48710. hasTexture(texture: BaseTexture): boolean;
  48711. /**
  48712. * Gets a boolean indicating that current material needs to register RTT
  48713. * @returns true if this uses a render target otherwise false.
  48714. */
  48715. hasRenderTargetTextures(): boolean;
  48716. /**
  48717. * Returns an array of the actively used textures.
  48718. * @param activeTextures Array of BaseTextures
  48719. */
  48720. getActiveTextures(activeTextures: BaseTexture[]): void;
  48721. /**
  48722. * Returns the animatable textures.
  48723. * @param animatables Array of animatable textures.
  48724. */
  48725. getAnimatables(animatables: IAnimatable[]): void;
  48726. /**
  48727. * Disposes the resources of the material.
  48728. * @param forceDisposeTextures - Forces the disposal of all textures.
  48729. */
  48730. dispose(forceDisposeTextures?: boolean): void;
  48731. /**
  48732. * Get the current class name of the texture useful for serialization or dynamic coding.
  48733. * @returns "PBRSubSurfaceConfiguration"
  48734. */
  48735. getClassName(): string;
  48736. /**
  48737. * Add fallbacks to the effect fallbacks list.
  48738. * @param defines defines the Base texture to use.
  48739. * @param fallbacks defines the current fallback list.
  48740. * @param currentRank defines the current fallback rank.
  48741. * @returns the new fallback rank.
  48742. */
  48743. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48744. /**
  48745. * Add the required uniforms to the current list.
  48746. * @param uniforms defines the current uniform list.
  48747. */
  48748. static AddUniforms(uniforms: string[]): void;
  48749. /**
  48750. * Add the required samplers to the current list.
  48751. * @param samplers defines the current sampler list.
  48752. */
  48753. static AddSamplers(samplers: string[]): void;
  48754. /**
  48755. * Add the required uniforms to the current buffer.
  48756. * @param uniformBuffer defines the current uniform buffer.
  48757. */
  48758. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48759. /**
  48760. * Makes a duplicate of the current configuration into another one.
  48761. * @param configuration define the config where to copy the info
  48762. */
  48763. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48764. /**
  48765. * Serializes this Sub Surface configuration.
  48766. * @returns - An object with the serialized config.
  48767. */
  48768. serialize(): any;
  48769. /**
  48770. * Parses a anisotropy Configuration from a serialized object.
  48771. * @param source - Serialized object.
  48772. * @param scene Defines the scene we are parsing for
  48773. * @param rootUrl Defines the rootUrl to load from
  48774. */
  48775. parse(source: any, scene: Scene, rootUrl: string): void;
  48776. }
  48777. }
  48778. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48779. /** @hidden */
  48780. export var pbrFragmentDeclaration: {
  48781. name: string;
  48782. shader: string;
  48783. };
  48784. }
  48785. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48786. /** @hidden */
  48787. export var pbrUboDeclaration: {
  48788. name: string;
  48789. shader: string;
  48790. };
  48791. }
  48792. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48793. /** @hidden */
  48794. export var pbrFragmentExtraDeclaration: {
  48795. name: string;
  48796. shader: string;
  48797. };
  48798. }
  48799. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48800. /** @hidden */
  48801. export var pbrFragmentSamplersDeclaration: {
  48802. name: string;
  48803. shader: string;
  48804. };
  48805. }
  48806. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48807. /** @hidden */
  48808. export var pbrHelperFunctions: {
  48809. name: string;
  48810. shader: string;
  48811. };
  48812. }
  48813. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48814. /** @hidden */
  48815. export var harmonicsFunctions: {
  48816. name: string;
  48817. shader: string;
  48818. };
  48819. }
  48820. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48821. /** @hidden */
  48822. export var pbrDirectLightingSetupFunctions: {
  48823. name: string;
  48824. shader: string;
  48825. };
  48826. }
  48827. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48828. /** @hidden */
  48829. export var pbrDirectLightingFalloffFunctions: {
  48830. name: string;
  48831. shader: string;
  48832. };
  48833. }
  48834. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48835. /** @hidden */
  48836. export var pbrBRDFFunctions: {
  48837. name: string;
  48838. shader: string;
  48839. };
  48840. }
  48841. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48842. /** @hidden */
  48843. export var pbrDirectLightingFunctions: {
  48844. name: string;
  48845. shader: string;
  48846. };
  48847. }
  48848. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48849. /** @hidden */
  48850. export var pbrIBLFunctions: {
  48851. name: string;
  48852. shader: string;
  48853. };
  48854. }
  48855. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48856. /** @hidden */
  48857. export var pbrDebug: {
  48858. name: string;
  48859. shader: string;
  48860. };
  48861. }
  48862. declare module "babylonjs/Shaders/pbr.fragment" {
  48863. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48868. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48869. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48870. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48871. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48872. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48874. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48875. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48876. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48877. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48878. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48879. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48880. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48881. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48882. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48883. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48884. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48885. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48886. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48887. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48888. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48889. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48890. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48891. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48892. /** @hidden */
  48893. export var pbrPixelShader: {
  48894. name: string;
  48895. shader: string;
  48896. };
  48897. }
  48898. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48899. /** @hidden */
  48900. export var pbrVertexDeclaration: {
  48901. name: string;
  48902. shader: string;
  48903. };
  48904. }
  48905. declare module "babylonjs/Shaders/pbr.vertex" {
  48906. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48907. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48908. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48909. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48910. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48911. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48912. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48913. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48914. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48915. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48916. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48919. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48921. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48922. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48923. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48924. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48925. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48926. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48927. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48928. /** @hidden */
  48929. export var pbrVertexShader: {
  48930. name: string;
  48931. shader: string;
  48932. };
  48933. }
  48934. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48935. import { Nullable } from "babylonjs/types";
  48936. import { Scene } from "babylonjs/scene";
  48937. import { Matrix } from "babylonjs/Maths/math.vector";
  48938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48940. import { Mesh } from "babylonjs/Meshes/mesh";
  48941. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48942. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48943. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48944. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48945. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48946. import { Color3 } from "babylonjs/Maths/math.color";
  48947. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48948. import { Material } from "babylonjs/Materials/material";
  48949. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48950. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48952. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48953. import "babylonjs/Shaders/pbr.fragment";
  48954. import "babylonjs/Shaders/pbr.vertex";
  48955. /**
  48956. * Manages the defines for the PBR Material.
  48957. * @hidden
  48958. */
  48959. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48960. PBR: boolean;
  48961. MAINUV1: boolean;
  48962. MAINUV2: boolean;
  48963. UV1: boolean;
  48964. UV2: boolean;
  48965. ALBEDO: boolean;
  48966. ALBEDODIRECTUV: number;
  48967. VERTEXCOLOR: boolean;
  48968. AMBIENT: boolean;
  48969. AMBIENTDIRECTUV: number;
  48970. AMBIENTINGRAYSCALE: boolean;
  48971. OPACITY: boolean;
  48972. VERTEXALPHA: boolean;
  48973. OPACITYDIRECTUV: number;
  48974. OPACITYRGB: boolean;
  48975. ALPHATEST: boolean;
  48976. DEPTHPREPASS: boolean;
  48977. ALPHABLEND: boolean;
  48978. ALPHAFROMALBEDO: boolean;
  48979. ALPHATESTVALUE: string;
  48980. SPECULAROVERALPHA: boolean;
  48981. RADIANCEOVERALPHA: boolean;
  48982. ALPHAFRESNEL: boolean;
  48983. LINEARALPHAFRESNEL: boolean;
  48984. PREMULTIPLYALPHA: boolean;
  48985. EMISSIVE: boolean;
  48986. EMISSIVEDIRECTUV: number;
  48987. REFLECTIVITY: boolean;
  48988. REFLECTIVITYDIRECTUV: number;
  48989. SPECULARTERM: boolean;
  48990. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48991. MICROSURFACEAUTOMATIC: boolean;
  48992. LODBASEDMICROSFURACE: boolean;
  48993. MICROSURFACEMAP: boolean;
  48994. MICROSURFACEMAPDIRECTUV: number;
  48995. METALLICWORKFLOW: boolean;
  48996. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48997. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48998. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48999. AOSTOREINMETALMAPRED: boolean;
  49000. ENVIRONMENTBRDF: boolean;
  49001. ENVIRONMENTBRDF_RGBD: boolean;
  49002. NORMAL: boolean;
  49003. TANGENT: boolean;
  49004. BUMP: boolean;
  49005. BUMPDIRECTUV: number;
  49006. OBJECTSPACE_NORMALMAP: boolean;
  49007. PARALLAX: boolean;
  49008. PARALLAXOCCLUSION: boolean;
  49009. NORMALXYSCALE: boolean;
  49010. LIGHTMAP: boolean;
  49011. LIGHTMAPDIRECTUV: number;
  49012. USELIGHTMAPASSHADOWMAP: boolean;
  49013. GAMMALIGHTMAP: boolean;
  49014. RGBDLIGHTMAP: boolean;
  49015. REFLECTION: boolean;
  49016. REFLECTIONMAP_3D: boolean;
  49017. REFLECTIONMAP_SPHERICAL: boolean;
  49018. REFLECTIONMAP_PLANAR: boolean;
  49019. REFLECTIONMAP_CUBIC: boolean;
  49020. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49021. REFLECTIONMAP_PROJECTION: boolean;
  49022. REFLECTIONMAP_SKYBOX: boolean;
  49023. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49024. REFLECTIONMAP_EXPLICIT: boolean;
  49025. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49026. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49027. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49028. INVERTCUBICMAP: boolean;
  49029. USESPHERICALFROMREFLECTIONMAP: boolean;
  49030. USEIRRADIANCEMAP: boolean;
  49031. SPHERICAL_HARMONICS: boolean;
  49032. USESPHERICALINVERTEX: boolean;
  49033. REFLECTIONMAP_OPPOSITEZ: boolean;
  49034. LODINREFLECTIONALPHA: boolean;
  49035. GAMMAREFLECTION: boolean;
  49036. RGBDREFLECTION: boolean;
  49037. LINEARSPECULARREFLECTION: boolean;
  49038. RADIANCEOCCLUSION: boolean;
  49039. HORIZONOCCLUSION: boolean;
  49040. INSTANCES: boolean;
  49041. NUM_BONE_INFLUENCERS: number;
  49042. BonesPerMesh: number;
  49043. BONETEXTURE: boolean;
  49044. NONUNIFORMSCALING: boolean;
  49045. MORPHTARGETS: boolean;
  49046. MORPHTARGETS_NORMAL: boolean;
  49047. MORPHTARGETS_TANGENT: boolean;
  49048. MORPHTARGETS_UV: boolean;
  49049. NUM_MORPH_INFLUENCERS: number;
  49050. IMAGEPROCESSING: boolean;
  49051. VIGNETTE: boolean;
  49052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49053. VIGNETTEBLENDMODEOPAQUE: boolean;
  49054. TONEMAPPING: boolean;
  49055. TONEMAPPING_ACES: boolean;
  49056. CONTRAST: boolean;
  49057. COLORCURVES: boolean;
  49058. COLORGRADING: boolean;
  49059. COLORGRADING3D: boolean;
  49060. SAMPLER3DGREENDEPTH: boolean;
  49061. SAMPLER3DBGRMAP: boolean;
  49062. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49063. EXPOSURE: boolean;
  49064. MULTIVIEW: boolean;
  49065. USEPHYSICALLIGHTFALLOFF: boolean;
  49066. USEGLTFLIGHTFALLOFF: boolean;
  49067. TWOSIDEDLIGHTING: boolean;
  49068. SHADOWFLOAT: boolean;
  49069. CLIPPLANE: boolean;
  49070. CLIPPLANE2: boolean;
  49071. CLIPPLANE3: boolean;
  49072. CLIPPLANE4: boolean;
  49073. POINTSIZE: boolean;
  49074. FOG: boolean;
  49075. LOGARITHMICDEPTH: boolean;
  49076. FORCENORMALFORWARD: boolean;
  49077. SPECULARAA: boolean;
  49078. CLEARCOAT: boolean;
  49079. CLEARCOAT_DEFAULTIOR: boolean;
  49080. CLEARCOAT_TEXTURE: boolean;
  49081. CLEARCOAT_TEXTUREDIRECTUV: number;
  49082. CLEARCOAT_BUMP: boolean;
  49083. CLEARCOAT_BUMPDIRECTUV: number;
  49084. CLEARCOAT_TINT: boolean;
  49085. CLEARCOAT_TINT_TEXTURE: boolean;
  49086. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49087. ANISOTROPIC: boolean;
  49088. ANISOTROPIC_TEXTURE: boolean;
  49089. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49090. BRDF_V_HEIGHT_CORRELATED: boolean;
  49091. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49092. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49093. SHEEN: boolean;
  49094. SHEEN_TEXTURE: boolean;
  49095. SHEEN_TEXTUREDIRECTUV: number;
  49096. SHEEN_LINKWITHALBEDO: boolean;
  49097. SUBSURFACE: boolean;
  49098. SS_REFRACTION: boolean;
  49099. SS_TRANSLUCENCY: boolean;
  49100. SS_SCATERRING: boolean;
  49101. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49102. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49103. SS_REFRACTIONMAP_3D: boolean;
  49104. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49105. SS_LODINREFRACTIONALPHA: boolean;
  49106. SS_GAMMAREFRACTION: boolean;
  49107. SS_RGBDREFRACTION: boolean;
  49108. SS_LINEARSPECULARREFRACTION: boolean;
  49109. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49110. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49111. UNLIT: boolean;
  49112. DEBUGMODE: number;
  49113. /**
  49114. * Initializes the PBR Material defines.
  49115. */
  49116. constructor();
  49117. /**
  49118. * Resets the PBR Material defines.
  49119. */
  49120. reset(): void;
  49121. }
  49122. /**
  49123. * The Physically based material base class of BJS.
  49124. *
  49125. * This offers the main features of a standard PBR material.
  49126. * For more information, please refer to the documentation :
  49127. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49128. */
  49129. export abstract class PBRBaseMaterial extends PushMaterial {
  49130. /**
  49131. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49132. */
  49133. static readonly PBRMATERIAL_OPAQUE: number;
  49134. /**
  49135. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49136. */
  49137. static readonly PBRMATERIAL_ALPHATEST: number;
  49138. /**
  49139. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49140. */
  49141. static readonly PBRMATERIAL_ALPHABLEND: number;
  49142. /**
  49143. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49144. * They are also discarded below the alpha cutoff threshold to improve performances.
  49145. */
  49146. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49147. /**
  49148. * Defines the default value of how much AO map is occluding the analytical lights
  49149. * (point spot...).
  49150. */
  49151. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49152. /**
  49153. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49154. */
  49155. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49156. /**
  49157. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49158. * to enhance interoperability with other engines.
  49159. */
  49160. static readonly LIGHTFALLOFF_GLTF: number;
  49161. /**
  49162. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49163. * to enhance interoperability with other materials.
  49164. */
  49165. static readonly LIGHTFALLOFF_STANDARD: number;
  49166. /**
  49167. * Intensity of the direct lights e.g. the four lights available in your scene.
  49168. * This impacts both the direct diffuse and specular highlights.
  49169. */
  49170. protected _directIntensity: number;
  49171. /**
  49172. * Intensity of the emissive part of the material.
  49173. * This helps controlling the emissive effect without modifying the emissive color.
  49174. */
  49175. protected _emissiveIntensity: number;
  49176. /**
  49177. * Intensity of the environment e.g. how much the environment will light the object
  49178. * either through harmonics for rough material or through the refelction for shiny ones.
  49179. */
  49180. protected _environmentIntensity: number;
  49181. /**
  49182. * This is a special control allowing the reduction of the specular highlights coming from the
  49183. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49184. */
  49185. protected _specularIntensity: number;
  49186. /**
  49187. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49188. */
  49189. private _lightingInfos;
  49190. /**
  49191. * Debug Control allowing disabling the bump map on this material.
  49192. */
  49193. protected _disableBumpMap: boolean;
  49194. /**
  49195. * AKA Diffuse Texture in standard nomenclature.
  49196. */
  49197. protected _albedoTexture: Nullable<BaseTexture>;
  49198. /**
  49199. * AKA Occlusion Texture in other nomenclature.
  49200. */
  49201. protected _ambientTexture: Nullable<BaseTexture>;
  49202. /**
  49203. * AKA Occlusion Texture Intensity in other nomenclature.
  49204. */
  49205. protected _ambientTextureStrength: number;
  49206. /**
  49207. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49208. * 1 means it completely occludes it
  49209. * 0 mean it has no impact
  49210. */
  49211. protected _ambientTextureImpactOnAnalyticalLights: number;
  49212. /**
  49213. * Stores the alpha values in a texture.
  49214. */
  49215. protected _opacityTexture: Nullable<BaseTexture>;
  49216. /**
  49217. * Stores the reflection values in a texture.
  49218. */
  49219. protected _reflectionTexture: Nullable<BaseTexture>;
  49220. /**
  49221. * Stores the emissive values in a texture.
  49222. */
  49223. protected _emissiveTexture: Nullable<BaseTexture>;
  49224. /**
  49225. * AKA Specular texture in other nomenclature.
  49226. */
  49227. protected _reflectivityTexture: Nullable<BaseTexture>;
  49228. /**
  49229. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49230. */
  49231. protected _metallicTexture: Nullable<BaseTexture>;
  49232. /**
  49233. * Specifies the metallic scalar of the metallic/roughness workflow.
  49234. * Can also be used to scale the metalness values of the metallic texture.
  49235. */
  49236. protected _metallic: Nullable<number>;
  49237. /**
  49238. * Specifies the roughness scalar of the metallic/roughness workflow.
  49239. * Can also be used to scale the roughness values of the metallic texture.
  49240. */
  49241. protected _roughness: Nullable<number>;
  49242. /**
  49243. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49244. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49245. */
  49246. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49247. /**
  49248. * Stores surface normal data used to displace a mesh in a texture.
  49249. */
  49250. protected _bumpTexture: Nullable<BaseTexture>;
  49251. /**
  49252. * Stores the pre-calculated light information of a mesh in a texture.
  49253. */
  49254. protected _lightmapTexture: Nullable<BaseTexture>;
  49255. /**
  49256. * The color of a material in ambient lighting.
  49257. */
  49258. protected _ambientColor: Color3;
  49259. /**
  49260. * AKA Diffuse Color in other nomenclature.
  49261. */
  49262. protected _albedoColor: Color3;
  49263. /**
  49264. * AKA Specular Color in other nomenclature.
  49265. */
  49266. protected _reflectivityColor: Color3;
  49267. /**
  49268. * The color applied when light is reflected from a material.
  49269. */
  49270. protected _reflectionColor: Color3;
  49271. /**
  49272. * The color applied when light is emitted from a material.
  49273. */
  49274. protected _emissiveColor: Color3;
  49275. /**
  49276. * AKA Glossiness in other nomenclature.
  49277. */
  49278. protected _microSurface: number;
  49279. /**
  49280. * Specifies that the material will use the light map as a show map.
  49281. */
  49282. protected _useLightmapAsShadowmap: boolean;
  49283. /**
  49284. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49285. * makes the reflect vector face the model (under horizon).
  49286. */
  49287. protected _useHorizonOcclusion: boolean;
  49288. /**
  49289. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49290. * too much the area relying on ambient texture to define their ambient occlusion.
  49291. */
  49292. protected _useRadianceOcclusion: boolean;
  49293. /**
  49294. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49295. */
  49296. protected _useAlphaFromAlbedoTexture: boolean;
  49297. /**
  49298. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49299. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49300. */
  49301. protected _useSpecularOverAlpha: boolean;
  49302. /**
  49303. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49304. */
  49305. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49306. /**
  49307. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49308. */
  49309. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49310. /**
  49311. * Specifies if the metallic texture contains the roughness information in its green channel.
  49312. */
  49313. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49314. /**
  49315. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49316. */
  49317. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49318. /**
  49319. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49320. */
  49321. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49322. /**
  49323. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49324. */
  49325. protected _useAmbientInGrayScale: boolean;
  49326. /**
  49327. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49328. * The material will try to infer what glossiness each pixel should be.
  49329. */
  49330. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49331. /**
  49332. * Defines the falloff type used in this material.
  49333. * It by default is Physical.
  49334. */
  49335. protected _lightFalloff: number;
  49336. /**
  49337. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49338. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49339. */
  49340. protected _useRadianceOverAlpha: boolean;
  49341. /**
  49342. * Allows using an object space normal map (instead of tangent space).
  49343. */
  49344. protected _useObjectSpaceNormalMap: boolean;
  49345. /**
  49346. * Allows using the bump map in parallax mode.
  49347. */
  49348. protected _useParallax: boolean;
  49349. /**
  49350. * Allows using the bump map in parallax occlusion mode.
  49351. */
  49352. protected _useParallaxOcclusion: boolean;
  49353. /**
  49354. * Controls the scale bias of the parallax mode.
  49355. */
  49356. protected _parallaxScaleBias: number;
  49357. /**
  49358. * If sets to true, disables all the lights affecting the material.
  49359. */
  49360. protected _disableLighting: boolean;
  49361. /**
  49362. * Number of Simultaneous lights allowed on the material.
  49363. */
  49364. protected _maxSimultaneousLights: number;
  49365. /**
  49366. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49367. */
  49368. protected _invertNormalMapX: boolean;
  49369. /**
  49370. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49371. */
  49372. protected _invertNormalMapY: boolean;
  49373. /**
  49374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49375. */
  49376. protected _twoSidedLighting: boolean;
  49377. /**
  49378. * Defines the alpha limits in alpha test mode.
  49379. */
  49380. protected _alphaCutOff: number;
  49381. /**
  49382. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49383. */
  49384. protected _forceAlphaTest: boolean;
  49385. /**
  49386. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49387. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49388. */
  49389. protected _useAlphaFresnel: boolean;
  49390. /**
  49391. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49392. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49393. */
  49394. protected _useLinearAlphaFresnel: boolean;
  49395. /**
  49396. * The transparency mode of the material.
  49397. */
  49398. protected _transparencyMode: Nullable<number>;
  49399. /**
  49400. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49401. * from cos thetav and roughness:
  49402. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49403. */
  49404. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49405. /**
  49406. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49407. */
  49408. protected _forceIrradianceInFragment: boolean;
  49409. /**
  49410. * Force normal to face away from face.
  49411. */
  49412. protected _forceNormalForward: boolean;
  49413. /**
  49414. * Enables specular anti aliasing in the PBR shader.
  49415. * It will both interacts on the Geometry for analytical and IBL lighting.
  49416. * It also prefilter the roughness map based on the bump values.
  49417. */
  49418. protected _enableSpecularAntiAliasing: boolean;
  49419. /**
  49420. * Default configuration related to image processing available in the PBR Material.
  49421. */
  49422. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49423. /**
  49424. * Keep track of the image processing observer to allow dispose and replace.
  49425. */
  49426. private _imageProcessingObserver;
  49427. /**
  49428. * Attaches a new image processing configuration to the PBR Material.
  49429. * @param configuration
  49430. */
  49431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49432. /**
  49433. * Stores the available render targets.
  49434. */
  49435. private _renderTargets;
  49436. /**
  49437. * Sets the global ambient color for the material used in lighting calculations.
  49438. */
  49439. private _globalAmbientColor;
  49440. /**
  49441. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49442. */
  49443. private _useLogarithmicDepth;
  49444. /**
  49445. * If set to true, no lighting calculations will be applied.
  49446. */
  49447. private _unlit;
  49448. private _debugMode;
  49449. /**
  49450. * @hidden
  49451. * This is reserved for the inspector.
  49452. * Defines the material debug mode.
  49453. * It helps seeing only some components of the material while troubleshooting.
  49454. */
  49455. debugMode: number;
  49456. /**
  49457. * @hidden
  49458. * This is reserved for the inspector.
  49459. * Specify from where on screen the debug mode should start.
  49460. * The value goes from -1 (full screen) to 1 (not visible)
  49461. * It helps with side by side comparison against the final render
  49462. * This defaults to -1
  49463. */
  49464. private debugLimit;
  49465. /**
  49466. * @hidden
  49467. * This is reserved for the inspector.
  49468. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49469. * You can use the factor to better multiply the final value.
  49470. */
  49471. private debugFactor;
  49472. /**
  49473. * Defines the clear coat layer parameters for the material.
  49474. */
  49475. readonly clearCoat: PBRClearCoatConfiguration;
  49476. /**
  49477. * Defines the anisotropic parameters for the material.
  49478. */
  49479. readonly anisotropy: PBRAnisotropicConfiguration;
  49480. /**
  49481. * Defines the BRDF parameters for the material.
  49482. */
  49483. readonly brdf: PBRBRDFConfiguration;
  49484. /**
  49485. * Defines the Sheen parameters for the material.
  49486. */
  49487. readonly sheen: PBRSheenConfiguration;
  49488. /**
  49489. * Defines the SubSurface parameters for the material.
  49490. */
  49491. readonly subSurface: PBRSubSurfaceConfiguration;
  49492. /**
  49493. * Custom callback helping to override the default shader used in the material.
  49494. */
  49495. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49496. protected _rebuildInParallel: boolean;
  49497. /**
  49498. * Instantiates a new PBRMaterial instance.
  49499. *
  49500. * @param name The material name
  49501. * @param scene The scene the material will be use in.
  49502. */
  49503. constructor(name: string, scene: Scene);
  49504. /**
  49505. * Gets a boolean indicating that current material needs to register RTT
  49506. */
  49507. readonly hasRenderTargetTextures: boolean;
  49508. /**
  49509. * Gets the name of the material class.
  49510. */
  49511. getClassName(): string;
  49512. /**
  49513. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49514. */
  49515. /**
  49516. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49517. */
  49518. useLogarithmicDepth: boolean;
  49519. /**
  49520. * Gets the current transparency mode.
  49521. */
  49522. /**
  49523. * Sets the transparency mode of the material.
  49524. *
  49525. * | Value | Type | Description |
  49526. * | ----- | ----------------------------------- | ----------- |
  49527. * | 0 | OPAQUE | |
  49528. * | 1 | ALPHATEST | |
  49529. * | 2 | ALPHABLEND | |
  49530. * | 3 | ALPHATESTANDBLEND | |
  49531. *
  49532. */
  49533. transparencyMode: Nullable<number>;
  49534. /**
  49535. * Returns true if alpha blending should be disabled.
  49536. */
  49537. private readonly _disableAlphaBlending;
  49538. /**
  49539. * Specifies whether or not this material should be rendered in alpha blend mode.
  49540. */
  49541. needAlphaBlending(): boolean;
  49542. /**
  49543. * Specifies if the mesh will require alpha blending.
  49544. * @param mesh - BJS mesh.
  49545. */
  49546. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49547. /**
  49548. * Specifies whether or not this material should be rendered in alpha test mode.
  49549. */
  49550. needAlphaTesting(): boolean;
  49551. /**
  49552. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49553. */
  49554. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49555. /**
  49556. * Gets the texture used for the alpha test.
  49557. */
  49558. getAlphaTestTexture(): Nullable<BaseTexture>;
  49559. /**
  49560. * Specifies that the submesh is ready to be used.
  49561. * @param mesh - BJS mesh.
  49562. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49563. * @param useInstances - Specifies that instances should be used.
  49564. * @returns - boolean indicating that the submesh is ready or not.
  49565. */
  49566. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49567. /**
  49568. * Specifies if the material uses metallic roughness workflow.
  49569. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49570. */
  49571. isMetallicWorkflow(): boolean;
  49572. private _prepareEffect;
  49573. private _prepareDefines;
  49574. /**
  49575. * Force shader compilation
  49576. */
  49577. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49578. clipPlane: boolean;
  49579. }>): void;
  49580. /**
  49581. * Initializes the uniform buffer layout for the shader.
  49582. */
  49583. buildUniformLayout(): void;
  49584. /**
  49585. * Unbinds the material from the mesh
  49586. */
  49587. unbind(): void;
  49588. /**
  49589. * Binds the submesh data.
  49590. * @param world - The world matrix.
  49591. * @param mesh - The BJS mesh.
  49592. * @param subMesh - A submesh of the BJS mesh.
  49593. */
  49594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49595. /**
  49596. * Returns the animatable textures.
  49597. * @returns - Array of animatable textures.
  49598. */
  49599. getAnimatables(): IAnimatable[];
  49600. /**
  49601. * Returns the texture used for reflections.
  49602. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49603. */
  49604. private _getReflectionTexture;
  49605. /**
  49606. * Returns an array of the actively used textures.
  49607. * @returns - Array of BaseTextures
  49608. */
  49609. getActiveTextures(): BaseTexture[];
  49610. /**
  49611. * Checks to see if a texture is used in the material.
  49612. * @param texture - Base texture to use.
  49613. * @returns - Boolean specifying if a texture is used in the material.
  49614. */
  49615. hasTexture(texture: BaseTexture): boolean;
  49616. /**
  49617. * Disposes the resources of the material.
  49618. * @param forceDisposeEffect - Forces the disposal of effects.
  49619. * @param forceDisposeTextures - Forces the disposal of all textures.
  49620. */
  49621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49622. }
  49623. }
  49624. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49625. import { Nullable } from "babylonjs/types";
  49626. import { Scene } from "babylonjs/scene";
  49627. import { Color3 } from "babylonjs/Maths/math.color";
  49628. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49629. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49631. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49632. /**
  49633. * The Physically based material of BJS.
  49634. *
  49635. * This offers the main features of a standard PBR material.
  49636. * For more information, please refer to the documentation :
  49637. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49638. */
  49639. export class PBRMaterial extends PBRBaseMaterial {
  49640. /**
  49641. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49642. */
  49643. static readonly PBRMATERIAL_OPAQUE: number;
  49644. /**
  49645. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49646. */
  49647. static readonly PBRMATERIAL_ALPHATEST: number;
  49648. /**
  49649. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49650. */
  49651. static readonly PBRMATERIAL_ALPHABLEND: number;
  49652. /**
  49653. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49654. * They are also discarded below the alpha cutoff threshold to improve performances.
  49655. */
  49656. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49657. /**
  49658. * Defines the default value of how much AO map is occluding the analytical lights
  49659. * (point spot...).
  49660. */
  49661. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49662. /**
  49663. * Intensity of the direct lights e.g. the four lights available in your scene.
  49664. * This impacts both the direct diffuse and specular highlights.
  49665. */
  49666. directIntensity: number;
  49667. /**
  49668. * Intensity of the emissive part of the material.
  49669. * This helps controlling the emissive effect without modifying the emissive color.
  49670. */
  49671. emissiveIntensity: number;
  49672. /**
  49673. * Intensity of the environment e.g. how much the environment will light the object
  49674. * either through harmonics for rough material or through the refelction for shiny ones.
  49675. */
  49676. environmentIntensity: number;
  49677. /**
  49678. * This is a special control allowing the reduction of the specular highlights coming from the
  49679. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49680. */
  49681. specularIntensity: number;
  49682. /**
  49683. * Debug Control allowing disabling the bump map on this material.
  49684. */
  49685. disableBumpMap: boolean;
  49686. /**
  49687. * AKA Diffuse Texture in standard nomenclature.
  49688. */
  49689. albedoTexture: BaseTexture;
  49690. /**
  49691. * AKA Occlusion Texture in other nomenclature.
  49692. */
  49693. ambientTexture: BaseTexture;
  49694. /**
  49695. * AKA Occlusion Texture Intensity in other nomenclature.
  49696. */
  49697. ambientTextureStrength: number;
  49698. /**
  49699. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49700. * 1 means it completely occludes it
  49701. * 0 mean it has no impact
  49702. */
  49703. ambientTextureImpactOnAnalyticalLights: number;
  49704. /**
  49705. * Stores the alpha values in a texture.
  49706. */
  49707. opacityTexture: BaseTexture;
  49708. /**
  49709. * Stores the reflection values in a texture.
  49710. */
  49711. reflectionTexture: Nullable<BaseTexture>;
  49712. /**
  49713. * Stores the emissive values in a texture.
  49714. */
  49715. emissiveTexture: BaseTexture;
  49716. /**
  49717. * AKA Specular texture in other nomenclature.
  49718. */
  49719. reflectivityTexture: BaseTexture;
  49720. /**
  49721. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49722. */
  49723. metallicTexture: BaseTexture;
  49724. /**
  49725. * Specifies the metallic scalar of the metallic/roughness workflow.
  49726. * Can also be used to scale the metalness values of the metallic texture.
  49727. */
  49728. metallic: Nullable<number>;
  49729. /**
  49730. * Specifies the roughness scalar of the metallic/roughness workflow.
  49731. * Can also be used to scale the roughness values of the metallic texture.
  49732. */
  49733. roughness: Nullable<number>;
  49734. /**
  49735. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49736. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49737. */
  49738. microSurfaceTexture: BaseTexture;
  49739. /**
  49740. * Stores surface normal data used to displace a mesh in a texture.
  49741. */
  49742. bumpTexture: BaseTexture;
  49743. /**
  49744. * Stores the pre-calculated light information of a mesh in a texture.
  49745. */
  49746. lightmapTexture: BaseTexture;
  49747. /**
  49748. * Stores the refracted light information in a texture.
  49749. */
  49750. refractionTexture: Nullable<BaseTexture>;
  49751. /**
  49752. * The color of a material in ambient lighting.
  49753. */
  49754. ambientColor: Color3;
  49755. /**
  49756. * AKA Diffuse Color in other nomenclature.
  49757. */
  49758. albedoColor: Color3;
  49759. /**
  49760. * AKA Specular Color in other nomenclature.
  49761. */
  49762. reflectivityColor: Color3;
  49763. /**
  49764. * The color reflected from the material.
  49765. */
  49766. reflectionColor: Color3;
  49767. /**
  49768. * The color emitted from the material.
  49769. */
  49770. emissiveColor: Color3;
  49771. /**
  49772. * AKA Glossiness in other nomenclature.
  49773. */
  49774. microSurface: number;
  49775. /**
  49776. * source material index of refraction (IOR)' / 'destination material IOR.
  49777. */
  49778. indexOfRefraction: number;
  49779. /**
  49780. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49781. */
  49782. invertRefractionY: boolean;
  49783. /**
  49784. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49785. * Materials half opaque for instance using refraction could benefit from this control.
  49786. */
  49787. linkRefractionWithTransparency: boolean;
  49788. /**
  49789. * If true, the light map contains occlusion information instead of lighting info.
  49790. */
  49791. useLightmapAsShadowmap: boolean;
  49792. /**
  49793. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49794. */
  49795. useAlphaFromAlbedoTexture: boolean;
  49796. /**
  49797. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49798. */
  49799. forceAlphaTest: boolean;
  49800. /**
  49801. * Defines the alpha limits in alpha test mode.
  49802. */
  49803. alphaCutOff: number;
  49804. /**
  49805. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49806. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49807. */
  49808. useSpecularOverAlpha: boolean;
  49809. /**
  49810. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49811. */
  49812. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49813. /**
  49814. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49815. */
  49816. useRoughnessFromMetallicTextureAlpha: boolean;
  49817. /**
  49818. * Specifies if the metallic texture contains the roughness information in its green channel.
  49819. */
  49820. useRoughnessFromMetallicTextureGreen: boolean;
  49821. /**
  49822. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49823. */
  49824. useMetallnessFromMetallicTextureBlue: boolean;
  49825. /**
  49826. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49827. */
  49828. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49829. /**
  49830. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49831. */
  49832. useAmbientInGrayScale: boolean;
  49833. /**
  49834. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49835. * The material will try to infer what glossiness each pixel should be.
  49836. */
  49837. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49838. /**
  49839. * BJS is using an harcoded light falloff based on a manually sets up range.
  49840. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49841. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49842. */
  49843. /**
  49844. * BJS is using an harcoded light falloff based on a manually sets up range.
  49845. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49846. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49847. */
  49848. usePhysicalLightFalloff: boolean;
  49849. /**
  49850. * In order to support the falloff compatibility with gltf, a special mode has been added
  49851. * to reproduce the gltf light falloff.
  49852. */
  49853. /**
  49854. * In order to support the falloff compatibility with gltf, a special mode has been added
  49855. * to reproduce the gltf light falloff.
  49856. */
  49857. useGLTFLightFalloff: boolean;
  49858. /**
  49859. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49860. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49861. */
  49862. useRadianceOverAlpha: boolean;
  49863. /**
  49864. * Allows using an object space normal map (instead of tangent space).
  49865. */
  49866. useObjectSpaceNormalMap: boolean;
  49867. /**
  49868. * Allows using the bump map in parallax mode.
  49869. */
  49870. useParallax: boolean;
  49871. /**
  49872. * Allows using the bump map in parallax occlusion mode.
  49873. */
  49874. useParallaxOcclusion: boolean;
  49875. /**
  49876. * Controls the scale bias of the parallax mode.
  49877. */
  49878. parallaxScaleBias: number;
  49879. /**
  49880. * If sets to true, disables all the lights affecting the material.
  49881. */
  49882. disableLighting: boolean;
  49883. /**
  49884. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49885. */
  49886. forceIrradianceInFragment: boolean;
  49887. /**
  49888. * Number of Simultaneous lights allowed on the material.
  49889. */
  49890. maxSimultaneousLights: number;
  49891. /**
  49892. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49893. */
  49894. invertNormalMapX: boolean;
  49895. /**
  49896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49897. */
  49898. invertNormalMapY: boolean;
  49899. /**
  49900. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49901. */
  49902. twoSidedLighting: boolean;
  49903. /**
  49904. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49905. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49906. */
  49907. useAlphaFresnel: boolean;
  49908. /**
  49909. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49910. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49911. */
  49912. useLinearAlphaFresnel: boolean;
  49913. /**
  49914. * Let user defines the brdf lookup texture used for IBL.
  49915. * A default 8bit version is embedded but you could point at :
  49916. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49917. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49918. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49919. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49920. */
  49921. environmentBRDFTexture: Nullable<BaseTexture>;
  49922. /**
  49923. * Force normal to face away from face.
  49924. */
  49925. forceNormalForward: boolean;
  49926. /**
  49927. * Enables specular anti aliasing in the PBR shader.
  49928. * It will both interacts on the Geometry for analytical and IBL lighting.
  49929. * It also prefilter the roughness map based on the bump values.
  49930. */
  49931. enableSpecularAntiAliasing: boolean;
  49932. /**
  49933. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49934. * makes the reflect vector face the model (under horizon).
  49935. */
  49936. useHorizonOcclusion: boolean;
  49937. /**
  49938. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49939. * too much the area relying on ambient texture to define their ambient occlusion.
  49940. */
  49941. useRadianceOcclusion: boolean;
  49942. /**
  49943. * If set to true, no lighting calculations will be applied.
  49944. */
  49945. unlit: boolean;
  49946. /**
  49947. * Gets the image processing configuration used either in this material.
  49948. */
  49949. /**
  49950. * Sets the Default image processing configuration used either in the this material.
  49951. *
  49952. * If sets to null, the scene one is in use.
  49953. */
  49954. imageProcessingConfiguration: ImageProcessingConfiguration;
  49955. /**
  49956. * Gets wether the color curves effect is enabled.
  49957. */
  49958. /**
  49959. * Sets wether the color curves effect is enabled.
  49960. */
  49961. cameraColorCurvesEnabled: boolean;
  49962. /**
  49963. * Gets wether the color grading effect is enabled.
  49964. */
  49965. /**
  49966. * Gets wether the color grading effect is enabled.
  49967. */
  49968. cameraColorGradingEnabled: boolean;
  49969. /**
  49970. * Gets wether tonemapping is enabled or not.
  49971. */
  49972. /**
  49973. * Sets wether tonemapping is enabled or not
  49974. */
  49975. cameraToneMappingEnabled: boolean;
  49976. /**
  49977. * The camera exposure used on this material.
  49978. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49979. * This corresponds to a photographic exposure.
  49980. */
  49981. /**
  49982. * The camera exposure used on this material.
  49983. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49984. * This corresponds to a photographic exposure.
  49985. */
  49986. cameraExposure: number;
  49987. /**
  49988. * Gets The camera contrast used on this material.
  49989. */
  49990. /**
  49991. * Sets The camera contrast used on this material.
  49992. */
  49993. cameraContrast: number;
  49994. /**
  49995. * Gets the Color Grading 2D Lookup Texture.
  49996. */
  49997. /**
  49998. * Sets the Color Grading 2D Lookup Texture.
  49999. */
  50000. cameraColorGradingTexture: Nullable<BaseTexture>;
  50001. /**
  50002. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50003. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50004. * 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;
  50005. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50006. */
  50007. /**
  50008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50010. * 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;
  50011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50012. */
  50013. cameraColorCurves: Nullable<ColorCurves>;
  50014. /**
  50015. * Instantiates a new PBRMaterial instance.
  50016. *
  50017. * @param name The material name
  50018. * @param scene The scene the material will be use in.
  50019. */
  50020. constructor(name: string, scene: Scene);
  50021. /**
  50022. * Returns the name of this material class.
  50023. */
  50024. getClassName(): string;
  50025. /**
  50026. * Makes a duplicate of the current material.
  50027. * @param name - name to use for the new material.
  50028. */
  50029. clone(name: string): PBRMaterial;
  50030. /**
  50031. * Serializes this PBR Material.
  50032. * @returns - An object with the serialized material.
  50033. */
  50034. serialize(): any;
  50035. /**
  50036. * Parses a PBR Material from a serialized object.
  50037. * @param source - Serialized object.
  50038. * @param scene - BJS scene instance.
  50039. * @param rootUrl - url for the scene object
  50040. * @returns - PBRMaterial
  50041. */
  50042. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50043. }
  50044. }
  50045. declare module "babylonjs/Misc/dds" {
  50046. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50047. import { Engine } from "babylonjs/Engines/engine";
  50048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50049. import { Nullable } from "babylonjs/types";
  50050. import { Scene } from "babylonjs/scene";
  50051. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50052. /**
  50053. * Direct draw surface info
  50054. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50055. */
  50056. export interface DDSInfo {
  50057. /**
  50058. * Width of the texture
  50059. */
  50060. width: number;
  50061. /**
  50062. * Width of the texture
  50063. */
  50064. height: number;
  50065. /**
  50066. * Number of Mipmaps for the texture
  50067. * @see https://en.wikipedia.org/wiki/Mipmap
  50068. */
  50069. mipmapCount: number;
  50070. /**
  50071. * If the textures format is a known fourCC format
  50072. * @see https://www.fourcc.org/
  50073. */
  50074. isFourCC: boolean;
  50075. /**
  50076. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50077. */
  50078. isRGB: boolean;
  50079. /**
  50080. * If the texture is a lumincance format
  50081. */
  50082. isLuminance: boolean;
  50083. /**
  50084. * If this is a cube texture
  50085. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50086. */
  50087. isCube: boolean;
  50088. /**
  50089. * If the texture is a compressed format eg. FOURCC_DXT1
  50090. */
  50091. isCompressed: boolean;
  50092. /**
  50093. * The dxgiFormat of the texture
  50094. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50095. */
  50096. dxgiFormat: number;
  50097. /**
  50098. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50099. */
  50100. textureType: number;
  50101. /**
  50102. * Sphericle polynomial created for the dds texture
  50103. */
  50104. sphericalPolynomial?: SphericalPolynomial;
  50105. }
  50106. /**
  50107. * Class used to provide DDS decompression tools
  50108. */
  50109. export class DDSTools {
  50110. /**
  50111. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50112. */
  50113. static StoreLODInAlphaChannel: boolean;
  50114. /**
  50115. * Gets DDS information from an array buffer
  50116. * @param arrayBuffer defines the array buffer to read data from
  50117. * @returns the DDS information
  50118. */
  50119. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50120. private static _FloatView;
  50121. private static _Int32View;
  50122. private static _ToHalfFloat;
  50123. private static _FromHalfFloat;
  50124. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50125. private static _GetHalfFloatRGBAArrayBuffer;
  50126. private static _GetFloatRGBAArrayBuffer;
  50127. private static _GetFloatAsUIntRGBAArrayBuffer;
  50128. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50129. private static _GetRGBAArrayBuffer;
  50130. private static _ExtractLongWordOrder;
  50131. private static _GetRGBArrayBuffer;
  50132. private static _GetLuminanceArrayBuffer;
  50133. /**
  50134. * Uploads DDS Levels to a Babylon Texture
  50135. * @hidden
  50136. */
  50137. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50138. }
  50139. module "babylonjs/Engines/engine" {
  50140. interface Engine {
  50141. /**
  50142. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50143. * @param rootUrl defines the url where the file to load is located
  50144. * @param scene defines the current scene
  50145. * @param lodScale defines scale to apply to the mip map selection
  50146. * @param lodOffset defines offset to apply to the mip map selection
  50147. * @param onLoad defines an optional callback raised when the texture is loaded
  50148. * @param onError defines an optional callback raised if there is an issue to load the texture
  50149. * @param format defines the format of the data
  50150. * @param forcedExtension defines the extension to use to pick the right loader
  50151. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50152. * @returns the cube texture as an InternalTexture
  50153. */
  50154. 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;
  50155. }
  50156. }
  50157. }
  50158. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50159. import { Nullable } from "babylonjs/types";
  50160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50161. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50162. /**
  50163. * Implementation of the DDS Texture Loader.
  50164. * @hidden
  50165. */
  50166. export class _DDSTextureLoader implements IInternalTextureLoader {
  50167. /**
  50168. * Defines wether the loader supports cascade loading the different faces.
  50169. */
  50170. readonly supportCascades: boolean;
  50171. /**
  50172. * This returns if the loader support the current file information.
  50173. * @param extension defines the file extension of the file being loaded
  50174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50175. * @param fallback defines the fallback internal texture if any
  50176. * @param isBase64 defines whether the texture is encoded as a base64
  50177. * @param isBuffer defines whether the texture data are stored as a buffer
  50178. * @returns true if the loader can load the specified file
  50179. */
  50180. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50181. /**
  50182. * Transform the url before loading if required.
  50183. * @param rootUrl the url of the texture
  50184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50185. * @returns the transformed texture
  50186. */
  50187. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50188. /**
  50189. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50190. * @param rootUrl the url of the texture
  50191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50192. * @returns the fallback texture
  50193. */
  50194. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50195. /**
  50196. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50197. * @param data contains the texture data
  50198. * @param texture defines the BabylonJS internal texture
  50199. * @param createPolynomials will be true if polynomials have been requested
  50200. * @param onLoad defines the callback to trigger once the texture is ready
  50201. * @param onError defines the callback to trigger in case of error
  50202. */
  50203. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50204. /**
  50205. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50206. * @param data contains the texture data
  50207. * @param texture defines the BabylonJS internal texture
  50208. * @param callback defines the method to call once ready to upload
  50209. */
  50210. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50211. }
  50212. }
  50213. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50214. import { Nullable } from "babylonjs/types";
  50215. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50216. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50217. /**
  50218. * Implementation of the ENV Texture Loader.
  50219. * @hidden
  50220. */
  50221. export class _ENVTextureLoader implements IInternalTextureLoader {
  50222. /**
  50223. * Defines wether the loader supports cascade loading the different faces.
  50224. */
  50225. readonly supportCascades: boolean;
  50226. /**
  50227. * This returns if the loader support the current file information.
  50228. * @param extension defines the file extension of the file being loaded
  50229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50230. * @param fallback defines the fallback internal texture if any
  50231. * @param isBase64 defines whether the texture is encoded as a base64
  50232. * @param isBuffer defines whether the texture data are stored as a buffer
  50233. * @returns true if the loader can load the specified file
  50234. */
  50235. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50236. /**
  50237. * Transform the url before loading if required.
  50238. * @param rootUrl the url of the texture
  50239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50240. * @returns the transformed texture
  50241. */
  50242. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50243. /**
  50244. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50245. * @param rootUrl the url of the texture
  50246. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50247. * @returns the fallback texture
  50248. */
  50249. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50250. /**
  50251. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50252. * @param data contains the texture data
  50253. * @param texture defines the BabylonJS internal texture
  50254. * @param createPolynomials will be true if polynomials have been requested
  50255. * @param onLoad defines the callback to trigger once the texture is ready
  50256. * @param onError defines the callback to trigger in case of error
  50257. */
  50258. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50259. /**
  50260. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50261. * @param data contains the texture data
  50262. * @param texture defines the BabylonJS internal texture
  50263. * @param callback defines the method to call once ready to upload
  50264. */
  50265. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50266. }
  50267. }
  50268. declare module "babylonjs/Misc/khronosTextureContainer" {
  50269. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50270. /**
  50271. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50272. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50273. */
  50274. export class KhronosTextureContainer {
  50275. /** contents of the KTX container file */
  50276. arrayBuffer: any;
  50277. private static HEADER_LEN;
  50278. private static COMPRESSED_2D;
  50279. private static COMPRESSED_3D;
  50280. private static TEX_2D;
  50281. private static TEX_3D;
  50282. /**
  50283. * Gets the openGL type
  50284. */
  50285. glType: number;
  50286. /**
  50287. * Gets the openGL type size
  50288. */
  50289. glTypeSize: number;
  50290. /**
  50291. * Gets the openGL format
  50292. */
  50293. glFormat: number;
  50294. /**
  50295. * Gets the openGL internal format
  50296. */
  50297. glInternalFormat: number;
  50298. /**
  50299. * Gets the base internal format
  50300. */
  50301. glBaseInternalFormat: number;
  50302. /**
  50303. * Gets image width in pixel
  50304. */
  50305. pixelWidth: number;
  50306. /**
  50307. * Gets image height in pixel
  50308. */
  50309. pixelHeight: number;
  50310. /**
  50311. * Gets image depth in pixels
  50312. */
  50313. pixelDepth: number;
  50314. /**
  50315. * Gets the number of array elements
  50316. */
  50317. numberOfArrayElements: number;
  50318. /**
  50319. * Gets the number of faces
  50320. */
  50321. numberOfFaces: number;
  50322. /**
  50323. * Gets the number of mipmap levels
  50324. */
  50325. numberOfMipmapLevels: number;
  50326. /**
  50327. * Gets the bytes of key value data
  50328. */
  50329. bytesOfKeyValueData: number;
  50330. /**
  50331. * Gets the load type
  50332. */
  50333. loadType: number;
  50334. /**
  50335. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50336. */
  50337. isInvalid: boolean;
  50338. /**
  50339. * Creates a new KhronosTextureContainer
  50340. * @param arrayBuffer contents of the KTX container file
  50341. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50342. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50343. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50344. */
  50345. constructor(
  50346. /** contents of the KTX container file */
  50347. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50348. /**
  50349. * Uploads KTX content to a Babylon Texture.
  50350. * It is assumed that the texture has already been created & is currently bound
  50351. * @hidden
  50352. */
  50353. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50354. private _upload2DCompressedLevels;
  50355. }
  50356. }
  50357. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50358. import { Nullable } from "babylonjs/types";
  50359. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50360. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50361. /**
  50362. * Implementation of the KTX Texture Loader.
  50363. * @hidden
  50364. */
  50365. export class _KTXTextureLoader implements IInternalTextureLoader {
  50366. /**
  50367. * Defines wether the loader supports cascade loading the different faces.
  50368. */
  50369. readonly supportCascades: boolean;
  50370. /**
  50371. * This returns if the loader support the current file information.
  50372. * @param extension defines the file extension of the file being loaded
  50373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50374. * @param fallback defines the fallback internal texture if any
  50375. * @param isBase64 defines whether the texture is encoded as a base64
  50376. * @param isBuffer defines whether the texture data are stored as a buffer
  50377. * @returns true if the loader can load the specified file
  50378. */
  50379. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50380. /**
  50381. * Transform the url before loading if required.
  50382. * @param rootUrl the url of the texture
  50383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50384. * @returns the transformed texture
  50385. */
  50386. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50387. /**
  50388. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50389. * @param rootUrl the url of the texture
  50390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50391. * @returns the fallback texture
  50392. */
  50393. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50394. /**
  50395. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50396. * @param data contains the texture data
  50397. * @param texture defines the BabylonJS internal texture
  50398. * @param createPolynomials will be true if polynomials have been requested
  50399. * @param onLoad defines the callback to trigger once the texture is ready
  50400. * @param onError defines the callback to trigger in case of error
  50401. */
  50402. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50403. /**
  50404. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50405. * @param data contains the texture data
  50406. * @param texture defines the BabylonJS internal texture
  50407. * @param callback defines the method to call once ready to upload
  50408. */
  50409. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50410. }
  50411. }
  50412. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50413. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50414. import { Scene } from "babylonjs/scene";
  50415. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50416. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50417. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50418. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50419. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50420. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50422. /**
  50423. * Options for the default xr helper
  50424. */
  50425. export class WebXRDefaultExperienceOptions {
  50426. /**
  50427. * Floor meshes that should be used for teleporting
  50428. */
  50429. floorMeshes: Array<AbstractMesh>;
  50430. }
  50431. /**
  50432. * Default experience which provides a similar setup to the previous webVRExperience
  50433. */
  50434. export class WebXRDefaultExperience {
  50435. /**
  50436. * Base experience
  50437. */
  50438. baseExperience: WebXRExperienceHelper;
  50439. /**
  50440. * Input experience extension
  50441. */
  50442. input: WebXRInput;
  50443. /**
  50444. * Loads the controller models
  50445. */
  50446. controllerModelLoader: WebXRControllerModelLoader;
  50447. /**
  50448. * Enables laser pointer and selection
  50449. */
  50450. pointerSelection: WebXRControllerPointerSelection;
  50451. /**
  50452. * Enables teleportation
  50453. */
  50454. teleportation: WebXRControllerTeleportation;
  50455. /**
  50456. * Enables ui for enetering/exiting xr
  50457. */
  50458. enterExitUI: WebXREnterExitUI;
  50459. /**
  50460. * Default output canvas xr should render to
  50461. */
  50462. outputCanvas: WebXRManagedOutputCanvas;
  50463. /**
  50464. * Creates the default xr experience
  50465. * @param scene scene
  50466. * @param options options for basic configuration
  50467. * @returns resulting WebXRDefaultExperience
  50468. */
  50469. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50470. private constructor();
  50471. /**
  50472. * DIsposes of the experience helper
  50473. */
  50474. dispose(): void;
  50475. }
  50476. }
  50477. declare module "babylonjs/Helpers/sceneHelpers" {
  50478. import { Nullable } from "babylonjs/types";
  50479. import { Mesh } from "babylonjs/Meshes/mesh";
  50480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50481. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50482. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50483. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50484. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50485. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50486. import "babylonjs/Meshes/Builders/boxBuilder";
  50487. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50488. /** @hidden */
  50489. export var _forceSceneHelpersToBundle: boolean;
  50490. module "babylonjs/scene" {
  50491. interface Scene {
  50492. /**
  50493. * Creates a default light for the scene.
  50494. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50495. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50496. */
  50497. createDefaultLight(replace?: boolean): void;
  50498. /**
  50499. * Creates a default camera for the scene.
  50500. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50501. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50502. * @param replace has default false, when true replaces the active camera in the scene
  50503. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50504. */
  50505. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50506. /**
  50507. * Creates a default camera and a default light.
  50508. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50509. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50510. * @param replace has the default false, when true replaces the active camera/light in the scene
  50511. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50512. */
  50513. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50514. /**
  50515. * Creates a new sky box
  50516. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50517. * @param environmentTexture defines the texture to use as environment texture
  50518. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50519. * @param scale defines the overall scale of the skybox
  50520. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50521. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50522. * @returns a new mesh holding the sky box
  50523. */
  50524. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50525. /**
  50526. * Creates a new environment
  50527. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50528. * @param options defines the options you can use to configure the environment
  50529. * @returns the new EnvironmentHelper
  50530. */
  50531. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50532. /**
  50533. * Creates a new VREXperienceHelper
  50534. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50535. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50536. * @returns a new VREXperienceHelper
  50537. */
  50538. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50539. /**
  50540. * Creates a new WebXRDefaultExperience
  50541. * @see http://doc.babylonjs.com/how_to/webxr
  50542. * @param options experience options
  50543. * @returns a promise for a new WebXRDefaultExperience
  50544. */
  50545. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50546. }
  50547. }
  50548. }
  50549. declare module "babylonjs/Helpers/videoDome" {
  50550. import { Scene } from "babylonjs/scene";
  50551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50552. import { Mesh } from "babylonjs/Meshes/mesh";
  50553. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50554. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50555. import "babylonjs/Meshes/Builders/sphereBuilder";
  50556. /**
  50557. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50558. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50559. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50560. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50561. */
  50562. export class VideoDome extends TransformNode {
  50563. /**
  50564. * Define the video source as a Monoscopic panoramic 360 video.
  50565. */
  50566. static readonly MODE_MONOSCOPIC: number;
  50567. /**
  50568. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50569. */
  50570. static readonly MODE_TOPBOTTOM: number;
  50571. /**
  50572. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50573. */
  50574. static readonly MODE_SIDEBYSIDE: number;
  50575. private _halfDome;
  50576. private _useDirectMapping;
  50577. /**
  50578. * The video texture being displayed on the sphere
  50579. */
  50580. protected _videoTexture: VideoTexture;
  50581. /**
  50582. * Gets the video texture being displayed on the sphere
  50583. */
  50584. readonly videoTexture: VideoTexture;
  50585. /**
  50586. * The skybox material
  50587. */
  50588. protected _material: BackgroundMaterial;
  50589. /**
  50590. * The surface used for the skybox
  50591. */
  50592. protected _mesh: Mesh;
  50593. /**
  50594. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50595. */
  50596. private _halfDomeMask;
  50597. /**
  50598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50599. * Also see the options.resolution property.
  50600. */
  50601. fovMultiplier: number;
  50602. private _videoMode;
  50603. /**
  50604. * Gets or set the current video mode for the video. It can be:
  50605. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50606. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50607. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50608. */
  50609. videoMode: number;
  50610. /**
  50611. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50612. *
  50613. */
  50614. /**
  50615. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50616. */
  50617. halfDome: boolean;
  50618. /**
  50619. * Oberserver used in Stereoscopic VR Mode.
  50620. */
  50621. private _onBeforeCameraRenderObserver;
  50622. /**
  50623. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50624. * @param name Element's name, child elements will append suffixes for their own names.
  50625. * @param urlsOrVideo defines the url(s) or the video element to use
  50626. * @param options An object containing optional or exposed sub element properties
  50627. */
  50628. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50629. resolution?: number;
  50630. clickToPlay?: boolean;
  50631. autoPlay?: boolean;
  50632. loop?: boolean;
  50633. size?: number;
  50634. poster?: string;
  50635. faceForward?: boolean;
  50636. useDirectMapping?: boolean;
  50637. halfDomeMode?: boolean;
  50638. }, scene: Scene);
  50639. private _changeVideoMode;
  50640. /**
  50641. * Releases resources associated with this node.
  50642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50644. */
  50645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50646. }
  50647. }
  50648. declare module "babylonjs/Helpers/index" {
  50649. export * from "babylonjs/Helpers/environmentHelper";
  50650. export * from "babylonjs/Helpers/photoDome";
  50651. export * from "babylonjs/Helpers/sceneHelpers";
  50652. export * from "babylonjs/Helpers/videoDome";
  50653. }
  50654. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50655. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50656. import { IDisposable } from "babylonjs/scene";
  50657. import { Engine } from "babylonjs/Engines/engine";
  50658. /**
  50659. * This class can be used to get instrumentation data from a Babylon engine
  50660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50661. */
  50662. export class EngineInstrumentation implements IDisposable {
  50663. /**
  50664. * Define the instrumented engine.
  50665. */
  50666. engine: Engine;
  50667. private _captureGPUFrameTime;
  50668. private _gpuFrameTimeToken;
  50669. private _gpuFrameTime;
  50670. private _captureShaderCompilationTime;
  50671. private _shaderCompilationTime;
  50672. private _onBeginFrameObserver;
  50673. private _onEndFrameObserver;
  50674. private _onBeforeShaderCompilationObserver;
  50675. private _onAfterShaderCompilationObserver;
  50676. /**
  50677. * Gets the perf counter used for GPU frame time
  50678. */
  50679. readonly gpuFrameTimeCounter: PerfCounter;
  50680. /**
  50681. * Gets the GPU frame time capture status
  50682. */
  50683. /**
  50684. * Enable or disable the GPU frame time capture
  50685. */
  50686. captureGPUFrameTime: boolean;
  50687. /**
  50688. * Gets the perf counter used for shader compilation time
  50689. */
  50690. readonly shaderCompilationTimeCounter: PerfCounter;
  50691. /**
  50692. * Gets the shader compilation time capture status
  50693. */
  50694. /**
  50695. * Enable or disable the shader compilation time capture
  50696. */
  50697. captureShaderCompilationTime: boolean;
  50698. /**
  50699. * Instantiates a new engine instrumentation.
  50700. * This class can be used to get instrumentation data from a Babylon engine
  50701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50702. * @param engine Defines the engine to instrument
  50703. */
  50704. constructor(
  50705. /**
  50706. * Define the instrumented engine.
  50707. */
  50708. engine: Engine);
  50709. /**
  50710. * Dispose and release associated resources.
  50711. */
  50712. dispose(): void;
  50713. }
  50714. }
  50715. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50716. import { Scene, IDisposable } from "babylonjs/scene";
  50717. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50718. /**
  50719. * This class can be used to get instrumentation data from a Babylon engine
  50720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50721. */
  50722. export class SceneInstrumentation implements IDisposable {
  50723. /**
  50724. * Defines the scene to instrument
  50725. */
  50726. scene: Scene;
  50727. private _captureActiveMeshesEvaluationTime;
  50728. private _activeMeshesEvaluationTime;
  50729. private _captureRenderTargetsRenderTime;
  50730. private _renderTargetsRenderTime;
  50731. private _captureFrameTime;
  50732. private _frameTime;
  50733. private _captureRenderTime;
  50734. private _renderTime;
  50735. private _captureInterFrameTime;
  50736. private _interFrameTime;
  50737. private _captureParticlesRenderTime;
  50738. private _particlesRenderTime;
  50739. private _captureSpritesRenderTime;
  50740. private _spritesRenderTime;
  50741. private _capturePhysicsTime;
  50742. private _physicsTime;
  50743. private _captureAnimationsTime;
  50744. private _animationsTime;
  50745. private _captureCameraRenderTime;
  50746. private _cameraRenderTime;
  50747. private _onBeforeActiveMeshesEvaluationObserver;
  50748. private _onAfterActiveMeshesEvaluationObserver;
  50749. private _onBeforeRenderTargetsRenderObserver;
  50750. private _onAfterRenderTargetsRenderObserver;
  50751. private _onAfterRenderObserver;
  50752. private _onBeforeDrawPhaseObserver;
  50753. private _onAfterDrawPhaseObserver;
  50754. private _onBeforeAnimationsObserver;
  50755. private _onBeforeParticlesRenderingObserver;
  50756. private _onAfterParticlesRenderingObserver;
  50757. private _onBeforeSpritesRenderingObserver;
  50758. private _onAfterSpritesRenderingObserver;
  50759. private _onBeforePhysicsObserver;
  50760. private _onAfterPhysicsObserver;
  50761. private _onAfterAnimationsObserver;
  50762. private _onBeforeCameraRenderObserver;
  50763. private _onAfterCameraRenderObserver;
  50764. /**
  50765. * Gets the perf counter used for active meshes evaluation time
  50766. */
  50767. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50768. /**
  50769. * Gets the active meshes evaluation time capture status
  50770. */
  50771. /**
  50772. * Enable or disable the active meshes evaluation time capture
  50773. */
  50774. captureActiveMeshesEvaluationTime: boolean;
  50775. /**
  50776. * Gets the perf counter used for render targets render time
  50777. */
  50778. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50779. /**
  50780. * Gets the render targets render time capture status
  50781. */
  50782. /**
  50783. * Enable or disable the render targets render time capture
  50784. */
  50785. captureRenderTargetsRenderTime: boolean;
  50786. /**
  50787. * Gets the perf counter used for particles render time
  50788. */
  50789. readonly particlesRenderTimeCounter: PerfCounter;
  50790. /**
  50791. * Gets the particles render time capture status
  50792. */
  50793. /**
  50794. * Enable or disable the particles render time capture
  50795. */
  50796. captureParticlesRenderTime: boolean;
  50797. /**
  50798. * Gets the perf counter used for sprites render time
  50799. */
  50800. readonly spritesRenderTimeCounter: PerfCounter;
  50801. /**
  50802. * Gets the sprites render time capture status
  50803. */
  50804. /**
  50805. * Enable or disable the sprites render time capture
  50806. */
  50807. captureSpritesRenderTime: boolean;
  50808. /**
  50809. * Gets the perf counter used for physics time
  50810. */
  50811. readonly physicsTimeCounter: PerfCounter;
  50812. /**
  50813. * Gets the physics time capture status
  50814. */
  50815. /**
  50816. * Enable or disable the physics time capture
  50817. */
  50818. capturePhysicsTime: boolean;
  50819. /**
  50820. * Gets the perf counter used for animations time
  50821. */
  50822. readonly animationsTimeCounter: PerfCounter;
  50823. /**
  50824. * Gets the animations time capture status
  50825. */
  50826. /**
  50827. * Enable or disable the animations time capture
  50828. */
  50829. captureAnimationsTime: boolean;
  50830. /**
  50831. * Gets the perf counter used for frame time capture
  50832. */
  50833. readonly frameTimeCounter: PerfCounter;
  50834. /**
  50835. * Gets the frame time capture status
  50836. */
  50837. /**
  50838. * Enable or disable the frame time capture
  50839. */
  50840. captureFrameTime: boolean;
  50841. /**
  50842. * Gets the perf counter used for inter-frames time capture
  50843. */
  50844. readonly interFrameTimeCounter: PerfCounter;
  50845. /**
  50846. * Gets the inter-frames time capture status
  50847. */
  50848. /**
  50849. * Enable or disable the inter-frames time capture
  50850. */
  50851. captureInterFrameTime: boolean;
  50852. /**
  50853. * Gets the perf counter used for render time capture
  50854. */
  50855. readonly renderTimeCounter: PerfCounter;
  50856. /**
  50857. * Gets the render time capture status
  50858. */
  50859. /**
  50860. * Enable or disable the render time capture
  50861. */
  50862. captureRenderTime: boolean;
  50863. /**
  50864. * Gets the perf counter used for camera render time capture
  50865. */
  50866. readonly cameraRenderTimeCounter: PerfCounter;
  50867. /**
  50868. * Gets the camera render time capture status
  50869. */
  50870. /**
  50871. * Enable or disable the camera render time capture
  50872. */
  50873. captureCameraRenderTime: boolean;
  50874. /**
  50875. * Gets the perf counter used for draw calls
  50876. */
  50877. readonly drawCallsCounter: PerfCounter;
  50878. /**
  50879. * Instantiates a new scene instrumentation.
  50880. * This class can be used to get instrumentation data from a Babylon engine
  50881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50882. * @param scene Defines the scene to instrument
  50883. */
  50884. constructor(
  50885. /**
  50886. * Defines the scene to instrument
  50887. */
  50888. scene: Scene);
  50889. /**
  50890. * Dispose and release associated resources.
  50891. */
  50892. dispose(): void;
  50893. }
  50894. }
  50895. declare module "babylonjs/Instrumentation/index" {
  50896. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50897. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50898. export * from "babylonjs/Instrumentation/timeToken";
  50899. }
  50900. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50901. /** @hidden */
  50902. export var glowMapGenerationPixelShader: {
  50903. name: string;
  50904. shader: string;
  50905. };
  50906. }
  50907. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50908. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50909. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50911. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50913. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50914. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50915. /** @hidden */
  50916. export var glowMapGenerationVertexShader: {
  50917. name: string;
  50918. shader: string;
  50919. };
  50920. }
  50921. declare module "babylonjs/Layers/effectLayer" {
  50922. import { Observable } from "babylonjs/Misc/observable";
  50923. import { Nullable } from "babylonjs/types";
  50924. import { Camera } from "babylonjs/Cameras/camera";
  50925. import { Scene } from "babylonjs/scene";
  50926. import { ISize } from "babylonjs/Maths/math.size";
  50927. import { Color4 } from "babylonjs/Maths/math.color";
  50928. import { Engine } from "babylonjs/Engines/engine";
  50929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50931. import { Mesh } from "babylonjs/Meshes/mesh";
  50932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50934. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50935. import { Effect } from "babylonjs/Materials/effect";
  50936. import { Material } from "babylonjs/Materials/material";
  50937. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50938. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50939. /**
  50940. * Effect layer options. This helps customizing the behaviour
  50941. * of the effect layer.
  50942. */
  50943. export interface IEffectLayerOptions {
  50944. /**
  50945. * Multiplication factor apply to the canvas size to compute the render target size
  50946. * used to generated the objects (the smaller the faster).
  50947. */
  50948. mainTextureRatio: number;
  50949. /**
  50950. * Enforces a fixed size texture to ensure effect stability across devices.
  50951. */
  50952. mainTextureFixedSize?: number;
  50953. /**
  50954. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50955. */
  50956. alphaBlendingMode: number;
  50957. /**
  50958. * The camera attached to the layer.
  50959. */
  50960. camera: Nullable<Camera>;
  50961. /**
  50962. * The rendering group to draw the layer in.
  50963. */
  50964. renderingGroupId: number;
  50965. }
  50966. /**
  50967. * The effect layer Helps adding post process effect blended with the main pass.
  50968. *
  50969. * This can be for instance use to generate glow or higlight effects on the scene.
  50970. *
  50971. * The effect layer class can not be used directly and is intented to inherited from to be
  50972. * customized per effects.
  50973. */
  50974. export abstract class EffectLayer {
  50975. private _vertexBuffers;
  50976. private _indexBuffer;
  50977. private _cachedDefines;
  50978. private _effectLayerMapGenerationEffect;
  50979. private _effectLayerOptions;
  50980. private _mergeEffect;
  50981. protected _scene: Scene;
  50982. protected _engine: Engine;
  50983. protected _maxSize: number;
  50984. protected _mainTextureDesiredSize: ISize;
  50985. protected _mainTexture: RenderTargetTexture;
  50986. protected _shouldRender: boolean;
  50987. protected _postProcesses: PostProcess[];
  50988. protected _textures: BaseTexture[];
  50989. protected _emissiveTextureAndColor: {
  50990. texture: Nullable<BaseTexture>;
  50991. color: Color4;
  50992. };
  50993. /**
  50994. * The name of the layer
  50995. */
  50996. name: string;
  50997. /**
  50998. * The clear color of the texture used to generate the glow map.
  50999. */
  51000. neutralColor: Color4;
  51001. /**
  51002. * Specifies wether the highlight layer is enabled or not.
  51003. */
  51004. isEnabled: boolean;
  51005. /**
  51006. * Gets the camera attached to the layer.
  51007. */
  51008. readonly camera: Nullable<Camera>;
  51009. /**
  51010. * Gets the rendering group id the layer should render in.
  51011. */
  51012. renderingGroupId: number;
  51013. /**
  51014. * An event triggered when the effect layer has been disposed.
  51015. */
  51016. onDisposeObservable: Observable<EffectLayer>;
  51017. /**
  51018. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51019. */
  51020. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51021. /**
  51022. * An event triggered when the generated texture is being merged in the scene.
  51023. */
  51024. onBeforeComposeObservable: Observable<EffectLayer>;
  51025. /**
  51026. * An event triggered when the generated texture has been merged in the scene.
  51027. */
  51028. onAfterComposeObservable: Observable<EffectLayer>;
  51029. /**
  51030. * An event triggered when the efffect layer changes its size.
  51031. */
  51032. onSizeChangedObservable: Observable<EffectLayer>;
  51033. /** @hidden */
  51034. static _SceneComponentInitialization: (scene: Scene) => void;
  51035. /**
  51036. * Instantiates a new effect Layer and references it in the scene.
  51037. * @param name The name of the layer
  51038. * @param scene The scene to use the layer in
  51039. */
  51040. constructor(
  51041. /** The Friendly of the effect in the scene */
  51042. name: string, scene: Scene);
  51043. /**
  51044. * Get the effect name of the layer.
  51045. * @return The effect name
  51046. */
  51047. abstract getEffectName(): string;
  51048. /**
  51049. * Checks for the readiness of the element composing the layer.
  51050. * @param subMesh the mesh to check for
  51051. * @param useInstances specify wether or not to use instances to render the mesh
  51052. * @return true if ready otherwise, false
  51053. */
  51054. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51055. /**
  51056. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51057. * @returns true if the effect requires stencil during the main canvas render pass.
  51058. */
  51059. abstract needStencil(): boolean;
  51060. /**
  51061. * Create the merge effect. This is the shader use to blit the information back
  51062. * to the main canvas at the end of the scene rendering.
  51063. * @returns The effect containing the shader used to merge the effect on the main canvas
  51064. */
  51065. protected abstract _createMergeEffect(): Effect;
  51066. /**
  51067. * Creates the render target textures and post processes used in the effect layer.
  51068. */
  51069. protected abstract _createTextureAndPostProcesses(): void;
  51070. /**
  51071. * Implementation specific of rendering the generating effect on the main canvas.
  51072. * @param effect The effect used to render through
  51073. */
  51074. protected abstract _internalRender(effect: Effect): void;
  51075. /**
  51076. * Sets the required values for both the emissive texture and and the main color.
  51077. */
  51078. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51079. /**
  51080. * Free any resources and references associated to a mesh.
  51081. * Internal use
  51082. * @param mesh The mesh to free.
  51083. */
  51084. abstract _disposeMesh(mesh: Mesh): void;
  51085. /**
  51086. * Serializes this layer (Glow or Highlight for example)
  51087. * @returns a serialized layer object
  51088. */
  51089. abstract serialize?(): any;
  51090. /**
  51091. * Initializes the effect layer with the required options.
  51092. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51093. */
  51094. protected _init(options: Partial<IEffectLayerOptions>): void;
  51095. /**
  51096. * Generates the index buffer of the full screen quad blending to the main canvas.
  51097. */
  51098. private _generateIndexBuffer;
  51099. /**
  51100. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51101. */
  51102. private _generateVertexBuffer;
  51103. /**
  51104. * Sets the main texture desired size which is the closest power of two
  51105. * of the engine canvas size.
  51106. */
  51107. private _setMainTextureSize;
  51108. /**
  51109. * Creates the main texture for the effect layer.
  51110. */
  51111. protected _createMainTexture(): void;
  51112. /**
  51113. * Adds specific effects defines.
  51114. * @param defines The defines to add specifics to.
  51115. */
  51116. protected _addCustomEffectDefines(defines: string[]): void;
  51117. /**
  51118. * Checks for the readiness of the element composing the layer.
  51119. * @param subMesh the mesh to check for
  51120. * @param useInstances specify wether or not to use instances to render the mesh
  51121. * @param emissiveTexture the associated emissive texture used to generate the glow
  51122. * @return true if ready otherwise, false
  51123. */
  51124. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51125. /**
  51126. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51127. */
  51128. render(): void;
  51129. /**
  51130. * Determine if a given mesh will be used in the current effect.
  51131. * @param mesh mesh to test
  51132. * @returns true if the mesh will be used
  51133. */
  51134. hasMesh(mesh: AbstractMesh): boolean;
  51135. /**
  51136. * Returns true if the layer contains information to display, otherwise false.
  51137. * @returns true if the glow layer should be rendered
  51138. */
  51139. shouldRender(): boolean;
  51140. /**
  51141. * Returns true if the mesh should render, otherwise false.
  51142. * @param mesh The mesh to render
  51143. * @returns true if it should render otherwise false
  51144. */
  51145. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51146. /**
  51147. * Returns true if the mesh can be rendered, otherwise false.
  51148. * @param mesh The mesh to render
  51149. * @param material The material used on the mesh
  51150. * @returns true if it can be rendered otherwise false
  51151. */
  51152. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51153. /**
  51154. * Returns true if the mesh should render, otherwise false.
  51155. * @param mesh The mesh to render
  51156. * @returns true if it should render otherwise false
  51157. */
  51158. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51159. /**
  51160. * Renders the submesh passed in parameter to the generation map.
  51161. */
  51162. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51163. /**
  51164. * Rebuild the required buffers.
  51165. * @hidden Internal use only.
  51166. */
  51167. _rebuild(): void;
  51168. /**
  51169. * Dispose only the render target textures and post process.
  51170. */
  51171. private _disposeTextureAndPostProcesses;
  51172. /**
  51173. * Dispose the highlight layer and free resources.
  51174. */
  51175. dispose(): void;
  51176. /**
  51177. * Gets the class name of the effect layer
  51178. * @returns the string with the class name of the effect layer
  51179. */
  51180. getClassName(): string;
  51181. /**
  51182. * Creates an effect layer from parsed effect layer data
  51183. * @param parsedEffectLayer defines effect layer data
  51184. * @param scene defines the current scene
  51185. * @param rootUrl defines the root URL containing the effect layer information
  51186. * @returns a parsed effect Layer
  51187. */
  51188. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51189. }
  51190. }
  51191. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51192. import { Scene } from "babylonjs/scene";
  51193. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51194. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51195. import { AbstractScene } from "babylonjs/abstractScene";
  51196. module "babylonjs/abstractScene" {
  51197. interface AbstractScene {
  51198. /**
  51199. * The list of effect layers (highlights/glow) added to the scene
  51200. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51201. * @see http://doc.babylonjs.com/how_to/glow_layer
  51202. */
  51203. effectLayers: Array<EffectLayer>;
  51204. /**
  51205. * Removes the given effect layer from this scene.
  51206. * @param toRemove defines the effect layer to remove
  51207. * @returns the index of the removed effect layer
  51208. */
  51209. removeEffectLayer(toRemove: EffectLayer): number;
  51210. /**
  51211. * Adds the given effect layer to this scene
  51212. * @param newEffectLayer defines the effect layer to add
  51213. */
  51214. addEffectLayer(newEffectLayer: EffectLayer): void;
  51215. }
  51216. }
  51217. /**
  51218. * Defines the layer scene component responsible to manage any effect layers
  51219. * in a given scene.
  51220. */
  51221. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51222. /**
  51223. * The component name helpfull to identify the component in the list of scene components.
  51224. */
  51225. readonly name: string;
  51226. /**
  51227. * The scene the component belongs to.
  51228. */
  51229. scene: Scene;
  51230. private _engine;
  51231. private _renderEffects;
  51232. private _needStencil;
  51233. private _previousStencilState;
  51234. /**
  51235. * Creates a new instance of the component for the given scene
  51236. * @param scene Defines the scene to register the component in
  51237. */
  51238. constructor(scene: Scene);
  51239. /**
  51240. * Registers the component in a given scene
  51241. */
  51242. register(): void;
  51243. /**
  51244. * Rebuilds the elements related to this component in case of
  51245. * context lost for instance.
  51246. */
  51247. rebuild(): void;
  51248. /**
  51249. * Serializes the component data to the specified json object
  51250. * @param serializationObject The object to serialize to
  51251. */
  51252. serialize(serializationObject: any): void;
  51253. /**
  51254. * Adds all the elements from the container to the scene
  51255. * @param container the container holding the elements
  51256. */
  51257. addFromContainer(container: AbstractScene): void;
  51258. /**
  51259. * Removes all the elements in the container from the scene
  51260. * @param container contains the elements to remove
  51261. * @param dispose if the removed element should be disposed (default: false)
  51262. */
  51263. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51264. /**
  51265. * Disposes the component and the associated ressources.
  51266. */
  51267. dispose(): void;
  51268. private _isReadyForMesh;
  51269. private _renderMainTexture;
  51270. private _setStencil;
  51271. private _setStencilBack;
  51272. private _draw;
  51273. private _drawCamera;
  51274. private _drawRenderingGroup;
  51275. }
  51276. }
  51277. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51278. /** @hidden */
  51279. export var glowMapMergePixelShader: {
  51280. name: string;
  51281. shader: string;
  51282. };
  51283. }
  51284. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51285. /** @hidden */
  51286. export var glowMapMergeVertexShader: {
  51287. name: string;
  51288. shader: string;
  51289. };
  51290. }
  51291. declare module "babylonjs/Layers/glowLayer" {
  51292. import { Nullable } from "babylonjs/types";
  51293. import { Camera } from "babylonjs/Cameras/camera";
  51294. import { Scene } from "babylonjs/scene";
  51295. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51297. import { Mesh } from "babylonjs/Meshes/mesh";
  51298. import { Texture } from "babylonjs/Materials/Textures/texture";
  51299. import { Effect } from "babylonjs/Materials/effect";
  51300. import { Material } from "babylonjs/Materials/material";
  51301. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51302. import { Color4 } from "babylonjs/Maths/math.color";
  51303. import "babylonjs/Shaders/glowMapMerge.fragment";
  51304. import "babylonjs/Shaders/glowMapMerge.vertex";
  51305. import "babylonjs/Layers/effectLayerSceneComponent";
  51306. module "babylonjs/abstractScene" {
  51307. interface AbstractScene {
  51308. /**
  51309. * Return a the first highlight layer of the scene with a given name.
  51310. * @param name The name of the highlight layer to look for.
  51311. * @return The highlight layer if found otherwise null.
  51312. */
  51313. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51314. }
  51315. }
  51316. /**
  51317. * Glow layer options. This helps customizing the behaviour
  51318. * of the glow layer.
  51319. */
  51320. export interface IGlowLayerOptions {
  51321. /**
  51322. * Multiplication factor apply to the canvas size to compute the render target size
  51323. * used to generated the glowing objects (the smaller the faster).
  51324. */
  51325. mainTextureRatio: number;
  51326. /**
  51327. * Enforces a fixed size texture to ensure resize independant blur.
  51328. */
  51329. mainTextureFixedSize?: number;
  51330. /**
  51331. * How big is the kernel of the blur texture.
  51332. */
  51333. blurKernelSize: number;
  51334. /**
  51335. * The camera attached to the layer.
  51336. */
  51337. camera: Nullable<Camera>;
  51338. /**
  51339. * Enable MSAA by chosing the number of samples.
  51340. */
  51341. mainTextureSamples?: number;
  51342. /**
  51343. * The rendering group to draw the layer in.
  51344. */
  51345. renderingGroupId: number;
  51346. }
  51347. /**
  51348. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51349. *
  51350. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51351. * glowy meshes to your scene.
  51352. *
  51353. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51354. */
  51355. export class GlowLayer extends EffectLayer {
  51356. /**
  51357. * Effect Name of the layer.
  51358. */
  51359. static readonly EffectName: string;
  51360. /**
  51361. * The default blur kernel size used for the glow.
  51362. */
  51363. static DefaultBlurKernelSize: number;
  51364. /**
  51365. * The default texture size ratio used for the glow.
  51366. */
  51367. static DefaultTextureRatio: number;
  51368. /**
  51369. * Sets the kernel size of the blur.
  51370. */
  51371. /**
  51372. * Gets the kernel size of the blur.
  51373. */
  51374. blurKernelSize: number;
  51375. /**
  51376. * Sets the glow intensity.
  51377. */
  51378. /**
  51379. * Gets the glow intensity.
  51380. */
  51381. intensity: number;
  51382. private _options;
  51383. private _intensity;
  51384. private _horizontalBlurPostprocess1;
  51385. private _verticalBlurPostprocess1;
  51386. private _horizontalBlurPostprocess2;
  51387. private _verticalBlurPostprocess2;
  51388. private _blurTexture1;
  51389. private _blurTexture2;
  51390. private _postProcesses1;
  51391. private _postProcesses2;
  51392. private _includedOnlyMeshes;
  51393. private _excludedMeshes;
  51394. /**
  51395. * Callback used to let the user override the color selection on a per mesh basis
  51396. */
  51397. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51398. /**
  51399. * Callback used to let the user override the texture selection on a per mesh basis
  51400. */
  51401. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51402. /**
  51403. * Instantiates a new glow Layer and references it to the scene.
  51404. * @param name The name of the layer
  51405. * @param scene The scene to use the layer in
  51406. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51407. */
  51408. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51409. /**
  51410. * Get the effect name of the layer.
  51411. * @return The effect name
  51412. */
  51413. getEffectName(): string;
  51414. /**
  51415. * Create the merge effect. This is the shader use to blit the information back
  51416. * to the main canvas at the end of the scene rendering.
  51417. */
  51418. protected _createMergeEffect(): Effect;
  51419. /**
  51420. * Creates the render target textures and post processes used in the glow layer.
  51421. */
  51422. protected _createTextureAndPostProcesses(): void;
  51423. /**
  51424. * Checks for the readiness of the element composing the layer.
  51425. * @param subMesh the mesh to check for
  51426. * @param useInstances specify wether or not to use instances to render the mesh
  51427. * @param emissiveTexture the associated emissive texture used to generate the glow
  51428. * @return true if ready otherwise, false
  51429. */
  51430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51431. /**
  51432. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51433. */
  51434. needStencil(): boolean;
  51435. /**
  51436. * Returns true if the mesh can be rendered, otherwise false.
  51437. * @param mesh The mesh to render
  51438. * @param material The material used on the mesh
  51439. * @returns true if it can be rendered otherwise false
  51440. */
  51441. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51442. /**
  51443. * Implementation specific of rendering the generating effect on the main canvas.
  51444. * @param effect The effect used to render through
  51445. */
  51446. protected _internalRender(effect: Effect): void;
  51447. /**
  51448. * Sets the required values for both the emissive texture and and the main color.
  51449. */
  51450. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51451. /**
  51452. * Returns true if the mesh should render, otherwise false.
  51453. * @param mesh The mesh to render
  51454. * @returns true if it should render otherwise false
  51455. */
  51456. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51457. /**
  51458. * Adds specific effects defines.
  51459. * @param defines The defines to add specifics to.
  51460. */
  51461. protected _addCustomEffectDefines(defines: string[]): void;
  51462. /**
  51463. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51464. * @param mesh The mesh to exclude from the glow layer
  51465. */
  51466. addExcludedMesh(mesh: Mesh): void;
  51467. /**
  51468. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51469. * @param mesh The mesh to remove
  51470. */
  51471. removeExcludedMesh(mesh: Mesh): void;
  51472. /**
  51473. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51474. * @param mesh The mesh to include in the glow layer
  51475. */
  51476. addIncludedOnlyMesh(mesh: Mesh): void;
  51477. /**
  51478. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51479. * @param mesh The mesh to remove
  51480. */
  51481. removeIncludedOnlyMesh(mesh: Mesh): void;
  51482. /**
  51483. * Determine if a given mesh will be used in the glow layer
  51484. * @param mesh The mesh to test
  51485. * @returns true if the mesh will be highlighted by the current glow layer
  51486. */
  51487. hasMesh(mesh: AbstractMesh): boolean;
  51488. /**
  51489. * Free any resources and references associated to a mesh.
  51490. * Internal use
  51491. * @param mesh The mesh to free.
  51492. * @hidden
  51493. */
  51494. _disposeMesh(mesh: Mesh): void;
  51495. /**
  51496. * Gets the class name of the effect layer
  51497. * @returns the string with the class name of the effect layer
  51498. */
  51499. getClassName(): string;
  51500. /**
  51501. * Serializes this glow layer
  51502. * @returns a serialized glow layer object
  51503. */
  51504. serialize(): any;
  51505. /**
  51506. * Creates a Glow Layer from parsed glow layer data
  51507. * @param parsedGlowLayer defines glow layer data
  51508. * @param scene defines the current scene
  51509. * @param rootUrl defines the root URL containing the glow layer information
  51510. * @returns a parsed Glow Layer
  51511. */
  51512. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51513. }
  51514. }
  51515. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51516. /** @hidden */
  51517. export var glowBlurPostProcessPixelShader: {
  51518. name: string;
  51519. shader: string;
  51520. };
  51521. }
  51522. declare module "babylonjs/Layers/highlightLayer" {
  51523. import { Observable } from "babylonjs/Misc/observable";
  51524. import { Nullable } from "babylonjs/types";
  51525. import { Camera } from "babylonjs/Cameras/camera";
  51526. import { Scene } from "babylonjs/scene";
  51527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51529. import { Mesh } from "babylonjs/Meshes/mesh";
  51530. import { Effect } from "babylonjs/Materials/effect";
  51531. import { Material } from "babylonjs/Materials/material";
  51532. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51533. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51534. import "babylonjs/Shaders/glowMapMerge.fragment";
  51535. import "babylonjs/Shaders/glowMapMerge.vertex";
  51536. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51537. module "babylonjs/abstractScene" {
  51538. interface AbstractScene {
  51539. /**
  51540. * Return a the first highlight layer of the scene with a given name.
  51541. * @param name The name of the highlight layer to look for.
  51542. * @return The highlight layer if found otherwise null.
  51543. */
  51544. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51545. }
  51546. }
  51547. /**
  51548. * Highlight layer options. This helps customizing the behaviour
  51549. * of the highlight layer.
  51550. */
  51551. export interface IHighlightLayerOptions {
  51552. /**
  51553. * Multiplication factor apply to the canvas size to compute the render target size
  51554. * used to generated the glowing objects (the smaller the faster).
  51555. */
  51556. mainTextureRatio: number;
  51557. /**
  51558. * Enforces a fixed size texture to ensure resize independant blur.
  51559. */
  51560. mainTextureFixedSize?: number;
  51561. /**
  51562. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51563. * of the picture to blur (the smaller the faster).
  51564. */
  51565. blurTextureSizeRatio: number;
  51566. /**
  51567. * How big in texel of the blur texture is the vertical blur.
  51568. */
  51569. blurVerticalSize: number;
  51570. /**
  51571. * How big in texel of the blur texture is the horizontal blur.
  51572. */
  51573. blurHorizontalSize: number;
  51574. /**
  51575. * Alpha blending mode used to apply the blur. Default is combine.
  51576. */
  51577. alphaBlendingMode: number;
  51578. /**
  51579. * The camera attached to the layer.
  51580. */
  51581. camera: Nullable<Camera>;
  51582. /**
  51583. * Should we display highlight as a solid stroke?
  51584. */
  51585. isStroke?: boolean;
  51586. /**
  51587. * The rendering group to draw the layer in.
  51588. */
  51589. renderingGroupId: number;
  51590. }
  51591. /**
  51592. * The highlight layer Helps adding a glow effect around a mesh.
  51593. *
  51594. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51595. * glowy meshes to your scene.
  51596. *
  51597. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51598. */
  51599. export class HighlightLayer extends EffectLayer {
  51600. name: string;
  51601. /**
  51602. * Effect Name of the highlight layer.
  51603. */
  51604. static readonly EffectName: string;
  51605. /**
  51606. * The neutral color used during the preparation of the glow effect.
  51607. * This is black by default as the blend operation is a blend operation.
  51608. */
  51609. static NeutralColor: Color4;
  51610. /**
  51611. * Stencil value used for glowing meshes.
  51612. */
  51613. static GlowingMeshStencilReference: number;
  51614. /**
  51615. * Stencil value used for the other meshes in the scene.
  51616. */
  51617. static NormalMeshStencilReference: number;
  51618. /**
  51619. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51620. */
  51621. innerGlow: boolean;
  51622. /**
  51623. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51624. */
  51625. outerGlow: boolean;
  51626. /**
  51627. * Specifies the horizontal size of the blur.
  51628. */
  51629. /**
  51630. * Gets the horizontal size of the blur.
  51631. */
  51632. blurHorizontalSize: number;
  51633. /**
  51634. * Specifies the vertical size of the blur.
  51635. */
  51636. /**
  51637. * Gets the vertical size of the blur.
  51638. */
  51639. blurVerticalSize: number;
  51640. /**
  51641. * An event triggered when the highlight layer is being blurred.
  51642. */
  51643. onBeforeBlurObservable: Observable<HighlightLayer>;
  51644. /**
  51645. * An event triggered when the highlight layer has been blurred.
  51646. */
  51647. onAfterBlurObservable: Observable<HighlightLayer>;
  51648. private _instanceGlowingMeshStencilReference;
  51649. private _options;
  51650. private _downSamplePostprocess;
  51651. private _horizontalBlurPostprocess;
  51652. private _verticalBlurPostprocess;
  51653. private _blurTexture;
  51654. private _meshes;
  51655. private _excludedMeshes;
  51656. /**
  51657. * Instantiates a new highlight Layer and references it to the scene..
  51658. * @param name The name of the layer
  51659. * @param scene The scene to use the layer in
  51660. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51661. */
  51662. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51663. /**
  51664. * Get the effect name of the layer.
  51665. * @return The effect name
  51666. */
  51667. getEffectName(): string;
  51668. /**
  51669. * Create the merge effect. This is the shader use to blit the information back
  51670. * to the main canvas at the end of the scene rendering.
  51671. */
  51672. protected _createMergeEffect(): Effect;
  51673. /**
  51674. * Creates the render target textures and post processes used in the highlight layer.
  51675. */
  51676. protected _createTextureAndPostProcesses(): void;
  51677. /**
  51678. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51679. */
  51680. needStencil(): boolean;
  51681. /**
  51682. * Checks for the readiness of the element composing the layer.
  51683. * @param subMesh the mesh to check for
  51684. * @param useInstances specify wether or not to use instances to render the mesh
  51685. * @param emissiveTexture the associated emissive texture used to generate the glow
  51686. * @return true if ready otherwise, false
  51687. */
  51688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51689. /**
  51690. * Implementation specific of rendering the generating effect on the main canvas.
  51691. * @param effect The effect used to render through
  51692. */
  51693. protected _internalRender(effect: Effect): void;
  51694. /**
  51695. * Returns true if the layer contains information to display, otherwise false.
  51696. */
  51697. shouldRender(): boolean;
  51698. /**
  51699. * Returns true if the mesh should render, otherwise false.
  51700. * @param mesh The mesh to render
  51701. * @returns true if it should render otherwise false
  51702. */
  51703. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51704. /**
  51705. * Sets the required values for both the emissive texture and and the main color.
  51706. */
  51707. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51708. /**
  51709. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51710. * @param mesh The mesh to exclude from the highlight layer
  51711. */
  51712. addExcludedMesh(mesh: Mesh): void;
  51713. /**
  51714. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51715. * @param mesh The mesh to highlight
  51716. */
  51717. removeExcludedMesh(mesh: Mesh): void;
  51718. /**
  51719. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51720. * @param mesh mesh to test
  51721. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51722. */
  51723. hasMesh(mesh: AbstractMesh): boolean;
  51724. /**
  51725. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51726. * @param mesh The mesh to highlight
  51727. * @param color The color of the highlight
  51728. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51729. */
  51730. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51731. /**
  51732. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51733. * @param mesh The mesh to highlight
  51734. */
  51735. removeMesh(mesh: Mesh): void;
  51736. /**
  51737. * Force the stencil to the normal expected value for none glowing parts
  51738. */
  51739. private _defaultStencilReference;
  51740. /**
  51741. * Free any resources and references associated to a mesh.
  51742. * Internal use
  51743. * @param mesh The mesh to free.
  51744. * @hidden
  51745. */
  51746. _disposeMesh(mesh: Mesh): void;
  51747. /**
  51748. * Dispose the highlight layer and free resources.
  51749. */
  51750. dispose(): void;
  51751. /**
  51752. * Gets the class name of the effect layer
  51753. * @returns the string with the class name of the effect layer
  51754. */
  51755. getClassName(): string;
  51756. /**
  51757. * Serializes this Highlight layer
  51758. * @returns a serialized Highlight layer object
  51759. */
  51760. serialize(): any;
  51761. /**
  51762. * Creates a Highlight layer from parsed Highlight layer data
  51763. * @param parsedHightlightLayer defines the Highlight layer data
  51764. * @param scene defines the current scene
  51765. * @param rootUrl defines the root URL containing the Highlight layer information
  51766. * @returns a parsed Highlight layer
  51767. */
  51768. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51769. }
  51770. }
  51771. declare module "babylonjs/Layers/layerSceneComponent" {
  51772. import { Scene } from "babylonjs/scene";
  51773. import { ISceneComponent } from "babylonjs/sceneComponent";
  51774. import { Layer } from "babylonjs/Layers/layer";
  51775. import { AbstractScene } from "babylonjs/abstractScene";
  51776. module "babylonjs/abstractScene" {
  51777. interface AbstractScene {
  51778. /**
  51779. * The list of layers (background and foreground) of the scene
  51780. */
  51781. layers: Array<Layer>;
  51782. }
  51783. }
  51784. /**
  51785. * Defines the layer scene component responsible to manage any layers
  51786. * in a given scene.
  51787. */
  51788. export class LayerSceneComponent implements ISceneComponent {
  51789. /**
  51790. * The component name helpfull to identify the component in the list of scene components.
  51791. */
  51792. readonly name: string;
  51793. /**
  51794. * The scene the component belongs to.
  51795. */
  51796. scene: Scene;
  51797. private _engine;
  51798. /**
  51799. * Creates a new instance of the component for the given scene
  51800. * @param scene Defines the scene to register the component in
  51801. */
  51802. constructor(scene: Scene);
  51803. /**
  51804. * Registers the component in a given scene
  51805. */
  51806. register(): void;
  51807. /**
  51808. * Rebuilds the elements related to this component in case of
  51809. * context lost for instance.
  51810. */
  51811. rebuild(): void;
  51812. /**
  51813. * Disposes the component and the associated ressources.
  51814. */
  51815. dispose(): void;
  51816. private _draw;
  51817. private _drawCameraPredicate;
  51818. private _drawCameraBackground;
  51819. private _drawCameraForeground;
  51820. private _drawRenderTargetPredicate;
  51821. private _drawRenderTargetBackground;
  51822. private _drawRenderTargetForeground;
  51823. /**
  51824. * Adds all the elements from the container to the scene
  51825. * @param container the container holding the elements
  51826. */
  51827. addFromContainer(container: AbstractScene): void;
  51828. /**
  51829. * Removes all the elements in the container from the scene
  51830. * @param container contains the elements to remove
  51831. * @param dispose if the removed element should be disposed (default: false)
  51832. */
  51833. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51834. }
  51835. }
  51836. declare module "babylonjs/Shaders/layer.fragment" {
  51837. /** @hidden */
  51838. export var layerPixelShader: {
  51839. name: string;
  51840. shader: string;
  51841. };
  51842. }
  51843. declare module "babylonjs/Shaders/layer.vertex" {
  51844. /** @hidden */
  51845. export var layerVertexShader: {
  51846. name: string;
  51847. shader: string;
  51848. };
  51849. }
  51850. declare module "babylonjs/Layers/layer" {
  51851. import { Observable } from "babylonjs/Misc/observable";
  51852. import { Nullable } from "babylonjs/types";
  51853. import { Scene } from "babylonjs/scene";
  51854. import { Vector2 } from "babylonjs/Maths/math.vector";
  51855. import { Color4 } from "babylonjs/Maths/math.color";
  51856. import { Texture } from "babylonjs/Materials/Textures/texture";
  51857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51858. import "babylonjs/Shaders/layer.fragment";
  51859. import "babylonjs/Shaders/layer.vertex";
  51860. /**
  51861. * This represents a full screen 2d layer.
  51862. * This can be useful to display a picture in the background of your scene for instance.
  51863. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51864. */
  51865. export class Layer {
  51866. /**
  51867. * Define the name of the layer.
  51868. */
  51869. name: string;
  51870. /**
  51871. * Define the texture the layer should display.
  51872. */
  51873. texture: Nullable<Texture>;
  51874. /**
  51875. * Is the layer in background or foreground.
  51876. */
  51877. isBackground: boolean;
  51878. /**
  51879. * Define the color of the layer (instead of texture).
  51880. */
  51881. color: Color4;
  51882. /**
  51883. * Define the scale of the layer in order to zoom in out of the texture.
  51884. */
  51885. scale: Vector2;
  51886. /**
  51887. * Define an offset for the layer in order to shift the texture.
  51888. */
  51889. offset: Vector2;
  51890. /**
  51891. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51892. */
  51893. alphaBlendingMode: number;
  51894. /**
  51895. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51896. * Alpha test will not mix with the background color in case of transparency.
  51897. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51898. */
  51899. alphaTest: boolean;
  51900. /**
  51901. * Define a mask to restrict the layer to only some of the scene cameras.
  51902. */
  51903. layerMask: number;
  51904. /**
  51905. * Define the list of render target the layer is visible into.
  51906. */
  51907. renderTargetTextures: RenderTargetTexture[];
  51908. /**
  51909. * Define if the layer is only used in renderTarget or if it also
  51910. * renders in the main frame buffer of the canvas.
  51911. */
  51912. renderOnlyInRenderTargetTextures: boolean;
  51913. private _scene;
  51914. private _vertexBuffers;
  51915. private _indexBuffer;
  51916. private _effect;
  51917. private _alphaTestEffect;
  51918. /**
  51919. * An event triggered when the layer is disposed.
  51920. */
  51921. onDisposeObservable: Observable<Layer>;
  51922. private _onDisposeObserver;
  51923. /**
  51924. * Back compatibility with callback before the onDisposeObservable existed.
  51925. * The set callback will be triggered when the layer has been disposed.
  51926. */
  51927. onDispose: () => void;
  51928. /**
  51929. * An event triggered before rendering the scene
  51930. */
  51931. onBeforeRenderObservable: Observable<Layer>;
  51932. private _onBeforeRenderObserver;
  51933. /**
  51934. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51935. * The set callback will be triggered just before rendering the layer.
  51936. */
  51937. onBeforeRender: () => void;
  51938. /**
  51939. * An event triggered after rendering the scene
  51940. */
  51941. onAfterRenderObservable: Observable<Layer>;
  51942. private _onAfterRenderObserver;
  51943. /**
  51944. * Back compatibility with callback before the onAfterRenderObservable existed.
  51945. * The set callback will be triggered just after rendering the layer.
  51946. */
  51947. onAfterRender: () => void;
  51948. /**
  51949. * Instantiates a new layer.
  51950. * This represents a full screen 2d layer.
  51951. * This can be useful to display a picture in the background of your scene for instance.
  51952. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51953. * @param name Define the name of the layer in the scene
  51954. * @param imgUrl Define the url of the texture to display in the layer
  51955. * @param scene Define the scene the layer belongs to
  51956. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51957. * @param color Defines a color for the layer
  51958. */
  51959. constructor(
  51960. /**
  51961. * Define the name of the layer.
  51962. */
  51963. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51964. private _createIndexBuffer;
  51965. /** @hidden */
  51966. _rebuild(): void;
  51967. /**
  51968. * Renders the layer in the scene.
  51969. */
  51970. render(): void;
  51971. /**
  51972. * Disposes and releases the associated ressources.
  51973. */
  51974. dispose(): void;
  51975. }
  51976. }
  51977. declare module "babylonjs/Layers/index" {
  51978. export * from "babylonjs/Layers/effectLayer";
  51979. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51980. export * from "babylonjs/Layers/glowLayer";
  51981. export * from "babylonjs/Layers/highlightLayer";
  51982. export * from "babylonjs/Layers/layer";
  51983. export * from "babylonjs/Layers/layerSceneComponent";
  51984. }
  51985. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51986. /** @hidden */
  51987. export var lensFlarePixelShader: {
  51988. name: string;
  51989. shader: string;
  51990. };
  51991. }
  51992. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51993. /** @hidden */
  51994. export var lensFlareVertexShader: {
  51995. name: string;
  51996. shader: string;
  51997. };
  51998. }
  51999. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52000. import { Scene } from "babylonjs/scene";
  52001. import { Vector3 } from "babylonjs/Maths/math.vector";
  52002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52003. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52004. import "babylonjs/Shaders/lensFlare.fragment";
  52005. import "babylonjs/Shaders/lensFlare.vertex";
  52006. import { Viewport } from "babylonjs/Maths/math.viewport";
  52007. /**
  52008. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52009. * It is usually composed of several `lensFlare`.
  52010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52011. */
  52012. export class LensFlareSystem {
  52013. /**
  52014. * Define the name of the lens flare system
  52015. */
  52016. name: string;
  52017. /**
  52018. * List of lens flares used in this system.
  52019. */
  52020. lensFlares: LensFlare[];
  52021. /**
  52022. * Define a limit from the border the lens flare can be visible.
  52023. */
  52024. borderLimit: number;
  52025. /**
  52026. * Define a viewport border we do not want to see the lens flare in.
  52027. */
  52028. viewportBorder: number;
  52029. /**
  52030. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52031. */
  52032. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52033. /**
  52034. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52035. */
  52036. layerMask: number;
  52037. /**
  52038. * Define the id of the lens flare system in the scene.
  52039. * (equal to name by default)
  52040. */
  52041. id: string;
  52042. private _scene;
  52043. private _emitter;
  52044. private _vertexBuffers;
  52045. private _indexBuffer;
  52046. private _effect;
  52047. private _positionX;
  52048. private _positionY;
  52049. private _isEnabled;
  52050. /** @hidden */
  52051. static _SceneComponentInitialization: (scene: Scene) => void;
  52052. /**
  52053. * Instantiates a lens flare system.
  52054. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52055. * It is usually composed of several `lensFlare`.
  52056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52057. * @param name Define the name of the lens flare system in the scene
  52058. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52059. * @param scene Define the scene the lens flare system belongs to
  52060. */
  52061. constructor(
  52062. /**
  52063. * Define the name of the lens flare system
  52064. */
  52065. name: string, emitter: any, scene: Scene);
  52066. /**
  52067. * Define if the lens flare system is enabled.
  52068. */
  52069. isEnabled: boolean;
  52070. /**
  52071. * Get the scene the effects belongs to.
  52072. * @returns the scene holding the lens flare system
  52073. */
  52074. getScene(): Scene;
  52075. /**
  52076. * Get the emitter of the lens flare system.
  52077. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52078. * @returns the emitter of the lens flare system
  52079. */
  52080. getEmitter(): any;
  52081. /**
  52082. * Set the emitter of the lens flare system.
  52083. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52084. * @param newEmitter Define the new emitter of the system
  52085. */
  52086. setEmitter(newEmitter: any): void;
  52087. /**
  52088. * Get the lens flare system emitter position.
  52089. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52090. * @returns the position
  52091. */
  52092. getEmitterPosition(): Vector3;
  52093. /**
  52094. * @hidden
  52095. */
  52096. computeEffectivePosition(globalViewport: Viewport): boolean;
  52097. /** @hidden */
  52098. _isVisible(): boolean;
  52099. /**
  52100. * @hidden
  52101. */
  52102. render(): boolean;
  52103. /**
  52104. * Dispose and release the lens flare with its associated resources.
  52105. */
  52106. dispose(): void;
  52107. /**
  52108. * Parse a lens flare system from a JSON repressentation
  52109. * @param parsedLensFlareSystem Define the JSON to parse
  52110. * @param scene Define the scene the parsed system should be instantiated in
  52111. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52112. * @returns the parsed system
  52113. */
  52114. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52115. /**
  52116. * Serialize the current Lens Flare System into a JSON representation.
  52117. * @returns the serialized JSON
  52118. */
  52119. serialize(): any;
  52120. }
  52121. }
  52122. declare module "babylonjs/LensFlares/lensFlare" {
  52123. import { Nullable } from "babylonjs/types";
  52124. import { Color3 } from "babylonjs/Maths/math.color";
  52125. import { Texture } from "babylonjs/Materials/Textures/texture";
  52126. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52127. /**
  52128. * This represents one of the lens effect in a `lensFlareSystem`.
  52129. * It controls one of the indiviual texture used in the effect.
  52130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52131. */
  52132. export class LensFlare {
  52133. /**
  52134. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52135. */
  52136. size: number;
  52137. /**
  52138. * 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.
  52139. */
  52140. position: number;
  52141. /**
  52142. * Define the lens color.
  52143. */
  52144. color: Color3;
  52145. /**
  52146. * Define the lens texture.
  52147. */
  52148. texture: Nullable<Texture>;
  52149. /**
  52150. * Define the alpha mode to render this particular lens.
  52151. */
  52152. alphaMode: number;
  52153. private _system;
  52154. /**
  52155. * Creates a new Lens Flare.
  52156. * This represents one of the lens effect in a `lensFlareSystem`.
  52157. * It controls one of the indiviual texture used in the effect.
  52158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52159. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52160. * @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.
  52161. * @param color Define the lens color
  52162. * @param imgUrl Define the lens texture url
  52163. * @param system Define the `lensFlareSystem` this flare is part of
  52164. * @returns The newly created Lens Flare
  52165. */
  52166. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52167. /**
  52168. * Instantiates a new Lens Flare.
  52169. * This represents one of the lens effect in a `lensFlareSystem`.
  52170. * It controls one of the indiviual texture used in the effect.
  52171. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52172. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52173. * @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.
  52174. * @param color Define the lens color
  52175. * @param imgUrl Define the lens texture url
  52176. * @param system Define the `lensFlareSystem` this flare is part of
  52177. */
  52178. constructor(
  52179. /**
  52180. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52181. */
  52182. size: number,
  52183. /**
  52184. * 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.
  52185. */
  52186. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52187. /**
  52188. * Dispose and release the lens flare with its associated resources.
  52189. */
  52190. dispose(): void;
  52191. }
  52192. }
  52193. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52194. import { Nullable } from "babylonjs/types";
  52195. import { Scene } from "babylonjs/scene";
  52196. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52197. import { AbstractScene } from "babylonjs/abstractScene";
  52198. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52199. module "babylonjs/abstractScene" {
  52200. interface AbstractScene {
  52201. /**
  52202. * The list of lens flare system added to the scene
  52203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52204. */
  52205. lensFlareSystems: Array<LensFlareSystem>;
  52206. /**
  52207. * Removes the given lens flare system from this scene.
  52208. * @param toRemove The lens flare system to remove
  52209. * @returns The index of the removed lens flare system
  52210. */
  52211. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52212. /**
  52213. * Adds the given lens flare system to this scene
  52214. * @param newLensFlareSystem The lens flare system to add
  52215. */
  52216. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52217. /**
  52218. * Gets a lens flare system using its name
  52219. * @param name defines the name to look for
  52220. * @returns the lens flare system or null if not found
  52221. */
  52222. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52223. /**
  52224. * Gets a lens flare system using its id
  52225. * @param id defines the id to look for
  52226. * @returns the lens flare system or null if not found
  52227. */
  52228. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52229. }
  52230. }
  52231. /**
  52232. * Defines the lens flare scene component responsible to manage any lens flares
  52233. * in a given scene.
  52234. */
  52235. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52236. /**
  52237. * The component name helpfull to identify the component in the list of scene components.
  52238. */
  52239. readonly name: string;
  52240. /**
  52241. * The scene the component belongs to.
  52242. */
  52243. scene: Scene;
  52244. /**
  52245. * Creates a new instance of the component for the given scene
  52246. * @param scene Defines the scene to register the component in
  52247. */
  52248. constructor(scene: Scene);
  52249. /**
  52250. * Registers the component in a given scene
  52251. */
  52252. register(): void;
  52253. /**
  52254. * Rebuilds the elements related to this component in case of
  52255. * context lost for instance.
  52256. */
  52257. rebuild(): void;
  52258. /**
  52259. * Adds all the elements from the container to the scene
  52260. * @param container the container holding the elements
  52261. */
  52262. addFromContainer(container: AbstractScene): void;
  52263. /**
  52264. * Removes all the elements in the container from the scene
  52265. * @param container contains the elements to remove
  52266. * @param dispose if the removed element should be disposed (default: false)
  52267. */
  52268. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52269. /**
  52270. * Serializes the component data to the specified json object
  52271. * @param serializationObject The object to serialize to
  52272. */
  52273. serialize(serializationObject: any): void;
  52274. /**
  52275. * Disposes the component and the associated ressources.
  52276. */
  52277. dispose(): void;
  52278. private _draw;
  52279. }
  52280. }
  52281. declare module "babylonjs/LensFlares/index" {
  52282. export * from "babylonjs/LensFlares/lensFlare";
  52283. export * from "babylonjs/LensFlares/lensFlareSystem";
  52284. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52285. }
  52286. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52287. import { Scene } from "babylonjs/scene";
  52288. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52289. import { AbstractScene } from "babylonjs/abstractScene";
  52290. /**
  52291. * Defines the shadow generator component responsible to manage any shadow generators
  52292. * in a given scene.
  52293. */
  52294. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52295. /**
  52296. * The component name helpfull to identify the component in the list of scene components.
  52297. */
  52298. readonly name: string;
  52299. /**
  52300. * The scene the component belongs to.
  52301. */
  52302. scene: Scene;
  52303. /**
  52304. * Creates a new instance of the component for the given scene
  52305. * @param scene Defines the scene to register the component in
  52306. */
  52307. constructor(scene: Scene);
  52308. /**
  52309. * Registers the component in a given scene
  52310. */
  52311. register(): void;
  52312. /**
  52313. * Rebuilds the elements related to this component in case of
  52314. * context lost for instance.
  52315. */
  52316. rebuild(): void;
  52317. /**
  52318. * Serializes the component data to the specified json object
  52319. * @param serializationObject The object to serialize to
  52320. */
  52321. serialize(serializationObject: any): void;
  52322. /**
  52323. * Adds all the elements from the container to the scene
  52324. * @param container the container holding the elements
  52325. */
  52326. addFromContainer(container: AbstractScene): void;
  52327. /**
  52328. * Removes all the elements in the container from the scene
  52329. * @param container contains the elements to remove
  52330. * @param dispose if the removed element should be disposed (default: false)
  52331. */
  52332. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52333. /**
  52334. * Rebuilds the elements related to this component in case of
  52335. * context lost for instance.
  52336. */
  52337. dispose(): void;
  52338. private _gatherRenderTargets;
  52339. }
  52340. }
  52341. declare module "babylonjs/Lights/Shadows/index" {
  52342. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52343. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52344. }
  52345. declare module "babylonjs/Lights/pointLight" {
  52346. import { Scene } from "babylonjs/scene";
  52347. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52349. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52350. import { Effect } from "babylonjs/Materials/effect";
  52351. /**
  52352. * A point light is a light defined by an unique point in world space.
  52353. * The light is emitted in every direction from this point.
  52354. * A good example of a point light is a standard light bulb.
  52355. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52356. */
  52357. export class PointLight extends ShadowLight {
  52358. private _shadowAngle;
  52359. /**
  52360. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52361. * This specifies what angle the shadow will use to be created.
  52362. *
  52363. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52364. */
  52365. /**
  52366. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52367. * This specifies what angle the shadow will use to be created.
  52368. *
  52369. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52370. */
  52371. shadowAngle: number;
  52372. /**
  52373. * Gets the direction if it has been set.
  52374. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52375. */
  52376. /**
  52377. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52378. */
  52379. direction: Vector3;
  52380. /**
  52381. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52382. * A PointLight emits the light in every direction.
  52383. * It can cast shadows.
  52384. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52385. * ```javascript
  52386. * var pointLight = new PointLight("pl", camera.position, scene);
  52387. * ```
  52388. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52389. * @param name The light friendly name
  52390. * @param position The position of the point light in the scene
  52391. * @param scene The scene the lights belongs to
  52392. */
  52393. constructor(name: string, position: Vector3, scene: Scene);
  52394. /**
  52395. * Returns the string "PointLight"
  52396. * @returns the class name
  52397. */
  52398. getClassName(): string;
  52399. /**
  52400. * Returns the integer 0.
  52401. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52402. */
  52403. getTypeID(): number;
  52404. /**
  52405. * Specifies wether or not the shadowmap should be a cube texture.
  52406. * @returns true if the shadowmap needs to be a cube texture.
  52407. */
  52408. needCube(): boolean;
  52409. /**
  52410. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52411. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52412. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52413. */
  52414. getShadowDirection(faceIndex?: number): Vector3;
  52415. /**
  52416. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52417. * - fov = PI / 2
  52418. * - aspect ratio : 1.0
  52419. * - z-near and far equal to the active camera minZ and maxZ.
  52420. * Returns the PointLight.
  52421. */
  52422. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52423. protected _buildUniformLayout(): void;
  52424. /**
  52425. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52426. * @param effect The effect to update
  52427. * @param lightIndex The index of the light in the effect to update
  52428. * @returns The point light
  52429. */
  52430. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52431. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52432. /**
  52433. * Prepares the list of defines specific to the light type.
  52434. * @param defines the list of defines
  52435. * @param lightIndex defines the index of the light for the effect
  52436. */
  52437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52438. }
  52439. }
  52440. declare module "babylonjs/Lights/index" {
  52441. export * from "babylonjs/Lights/light";
  52442. export * from "babylonjs/Lights/shadowLight";
  52443. export * from "babylonjs/Lights/Shadows/index";
  52444. export * from "babylonjs/Lights/directionalLight";
  52445. export * from "babylonjs/Lights/hemisphericLight";
  52446. export * from "babylonjs/Lights/pointLight";
  52447. export * from "babylonjs/Lights/spotLight";
  52448. }
  52449. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52450. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52451. /**
  52452. * Header information of HDR texture files.
  52453. */
  52454. export interface HDRInfo {
  52455. /**
  52456. * The height of the texture in pixels.
  52457. */
  52458. height: number;
  52459. /**
  52460. * The width of the texture in pixels.
  52461. */
  52462. width: number;
  52463. /**
  52464. * The index of the beginning of the data in the binary file.
  52465. */
  52466. dataPosition: number;
  52467. }
  52468. /**
  52469. * This groups tools to convert HDR texture to native colors array.
  52470. */
  52471. export class HDRTools {
  52472. private static Ldexp;
  52473. private static Rgbe2float;
  52474. private static readStringLine;
  52475. /**
  52476. * Reads header information from an RGBE texture stored in a native array.
  52477. * More information on this format are available here:
  52478. * https://en.wikipedia.org/wiki/RGBE_image_format
  52479. *
  52480. * @param uint8array The binary file stored in native array.
  52481. * @return The header information.
  52482. */
  52483. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52484. /**
  52485. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52486. * This RGBE texture needs to store the information as a panorama.
  52487. *
  52488. * More information on this format are available here:
  52489. * https://en.wikipedia.org/wiki/RGBE_image_format
  52490. *
  52491. * @param buffer The binary file stored in an array buffer.
  52492. * @param size The expected size of the extracted cubemap.
  52493. * @return The Cube Map information.
  52494. */
  52495. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52496. /**
  52497. * Returns the pixels data extracted from an RGBE texture.
  52498. * This pixels will be stored left to right up to down in the R G B order in one array.
  52499. *
  52500. * More information on this format are available here:
  52501. * https://en.wikipedia.org/wiki/RGBE_image_format
  52502. *
  52503. * @param uint8array The binary file stored in an array buffer.
  52504. * @param hdrInfo The header information of the file.
  52505. * @return The pixels data in RGB right to left up to down order.
  52506. */
  52507. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52508. private static RGBE_ReadPixels_RLE;
  52509. }
  52510. }
  52511. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52512. import { Nullable } from "babylonjs/types";
  52513. import { Scene } from "babylonjs/scene";
  52514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52515. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52516. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52517. /**
  52518. * This represents a texture coming from an HDR input.
  52519. *
  52520. * The only supported format is currently panorama picture stored in RGBE format.
  52521. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52522. */
  52523. export class HDRCubeTexture extends BaseTexture {
  52524. private static _facesMapping;
  52525. private _generateHarmonics;
  52526. private _noMipmap;
  52527. private _textureMatrix;
  52528. private _size;
  52529. private _onLoad;
  52530. private _onError;
  52531. /**
  52532. * The texture URL.
  52533. */
  52534. url: string;
  52535. /**
  52536. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52537. */
  52538. coordinatesMode: number;
  52539. protected _isBlocking: boolean;
  52540. /**
  52541. * Sets wether or not the texture is blocking during loading.
  52542. */
  52543. /**
  52544. * Gets wether or not the texture is blocking during loading.
  52545. */
  52546. isBlocking: boolean;
  52547. protected _rotationY: number;
  52548. /**
  52549. * Sets texture matrix rotation angle around Y axis in radians.
  52550. */
  52551. /**
  52552. * Gets texture matrix rotation angle around Y axis radians.
  52553. */
  52554. rotationY: number;
  52555. /**
  52556. * Gets or sets the center of the bounding box associated with the cube texture
  52557. * It must define where the camera used to render the texture was set
  52558. */
  52559. boundingBoxPosition: Vector3;
  52560. private _boundingBoxSize;
  52561. /**
  52562. * Gets or sets the size of the bounding box associated with the cube texture
  52563. * When defined, the cubemap will switch to local mode
  52564. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52565. * @example https://www.babylonjs-playground.com/#RNASML
  52566. */
  52567. boundingBoxSize: Vector3;
  52568. /**
  52569. * Instantiates an HDRTexture from the following parameters.
  52570. *
  52571. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52572. * @param scene The scene the texture will be used in
  52573. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52574. * @param noMipmap Forces to not generate the mipmap if true
  52575. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52576. * @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)
  52577. * @param reserved Reserved flag for internal use.
  52578. */
  52579. 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>);
  52580. /**
  52581. * Get the current class name of the texture useful for serialization or dynamic coding.
  52582. * @returns "HDRCubeTexture"
  52583. */
  52584. getClassName(): string;
  52585. /**
  52586. * Occurs when the file is raw .hdr file.
  52587. */
  52588. private loadTexture;
  52589. clone(): HDRCubeTexture;
  52590. delayLoad(): void;
  52591. /**
  52592. * Get the texture reflection matrix used to rotate/transform the reflection.
  52593. * @returns the reflection matrix
  52594. */
  52595. getReflectionTextureMatrix(): Matrix;
  52596. /**
  52597. * Set the texture reflection matrix used to rotate/transform the reflection.
  52598. * @param value Define the reflection matrix to set
  52599. */
  52600. setReflectionTextureMatrix(value: Matrix): void;
  52601. /**
  52602. * Parses a JSON representation of an HDR Texture in order to create the texture
  52603. * @param parsedTexture Define the JSON representation
  52604. * @param scene Define the scene the texture should be created in
  52605. * @param rootUrl Define the root url in case we need to load relative dependencies
  52606. * @returns the newly created texture after parsing
  52607. */
  52608. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52609. serialize(): any;
  52610. }
  52611. }
  52612. declare module "babylonjs/Physics/physicsEngine" {
  52613. import { Nullable } from "babylonjs/types";
  52614. import { Vector3 } from "babylonjs/Maths/math.vector";
  52615. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52616. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52617. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52618. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52619. /**
  52620. * Class used to control physics engine
  52621. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52622. */
  52623. export class PhysicsEngine implements IPhysicsEngine {
  52624. private _physicsPlugin;
  52625. /**
  52626. * Global value used to control the smallest number supported by the simulation
  52627. */
  52628. static Epsilon: number;
  52629. private _impostors;
  52630. private _joints;
  52631. /**
  52632. * Gets the gravity vector used by the simulation
  52633. */
  52634. gravity: Vector3;
  52635. /**
  52636. * Factory used to create the default physics plugin.
  52637. * @returns The default physics plugin
  52638. */
  52639. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52640. /**
  52641. * Creates a new Physics Engine
  52642. * @param gravity defines the gravity vector used by the simulation
  52643. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52644. */
  52645. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52646. /**
  52647. * Sets the gravity vector used by the simulation
  52648. * @param gravity defines the gravity vector to use
  52649. */
  52650. setGravity(gravity: Vector3): void;
  52651. /**
  52652. * Set the time step of the physics engine.
  52653. * Default is 1/60.
  52654. * To slow it down, enter 1/600 for example.
  52655. * To speed it up, 1/30
  52656. * @param newTimeStep defines the new timestep to apply to this world.
  52657. */
  52658. setTimeStep(newTimeStep?: number): void;
  52659. /**
  52660. * Get the time step of the physics engine.
  52661. * @returns the current time step
  52662. */
  52663. getTimeStep(): number;
  52664. /**
  52665. * Release all resources
  52666. */
  52667. dispose(): void;
  52668. /**
  52669. * Gets the name of the current physics plugin
  52670. * @returns the name of the plugin
  52671. */
  52672. getPhysicsPluginName(): string;
  52673. /**
  52674. * Adding a new impostor for the impostor tracking.
  52675. * This will be done by the impostor itself.
  52676. * @param impostor the impostor to add
  52677. */
  52678. addImpostor(impostor: PhysicsImpostor): void;
  52679. /**
  52680. * Remove an impostor from the engine.
  52681. * This impostor and its mesh will not longer be updated by the physics engine.
  52682. * @param impostor the impostor to remove
  52683. */
  52684. removeImpostor(impostor: PhysicsImpostor): void;
  52685. /**
  52686. * Add a joint to the physics engine
  52687. * @param mainImpostor defines the main impostor to which the joint is added.
  52688. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52689. * @param joint defines the joint that will connect both impostors.
  52690. */
  52691. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52692. /**
  52693. * Removes a joint from the simulation
  52694. * @param mainImpostor defines the impostor used with the joint
  52695. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52696. * @param joint defines the joint to remove
  52697. */
  52698. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52699. /**
  52700. * Called by the scene. No need to call it.
  52701. * @param delta defines the timespam between frames
  52702. */
  52703. _step(delta: number): void;
  52704. /**
  52705. * Gets the current plugin used to run the simulation
  52706. * @returns current plugin
  52707. */
  52708. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52709. /**
  52710. * Gets the list of physic impostors
  52711. * @returns an array of PhysicsImpostor
  52712. */
  52713. getImpostors(): Array<PhysicsImpostor>;
  52714. /**
  52715. * Gets the impostor for a physics enabled object
  52716. * @param object defines the object impersonated by the impostor
  52717. * @returns the PhysicsImpostor or null if not found
  52718. */
  52719. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52720. /**
  52721. * Gets the impostor for a physics body object
  52722. * @param body defines physics body used by the impostor
  52723. * @returns the PhysicsImpostor or null if not found
  52724. */
  52725. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52726. /**
  52727. * Does a raycast in the physics world
  52728. * @param from when should the ray start?
  52729. * @param to when should the ray end?
  52730. * @returns PhysicsRaycastResult
  52731. */
  52732. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52733. }
  52734. }
  52735. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52736. import { Nullable } from "babylonjs/types";
  52737. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52739. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52740. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52741. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52742. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52743. /** @hidden */
  52744. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52745. private _useDeltaForWorldStep;
  52746. world: any;
  52747. name: string;
  52748. private _physicsMaterials;
  52749. private _fixedTimeStep;
  52750. private _cannonRaycastResult;
  52751. private _raycastResult;
  52752. private _physicsBodysToRemoveAfterStep;
  52753. BJSCANNON: any;
  52754. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52755. setGravity(gravity: Vector3): void;
  52756. setTimeStep(timeStep: number): void;
  52757. getTimeStep(): number;
  52758. executeStep(delta: number): void;
  52759. private _removeMarkedPhysicsBodiesFromWorld;
  52760. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52761. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52762. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52763. private _processChildMeshes;
  52764. removePhysicsBody(impostor: PhysicsImpostor): void;
  52765. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52766. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52767. private _addMaterial;
  52768. private _checkWithEpsilon;
  52769. private _createShape;
  52770. private _createHeightmap;
  52771. private _minus90X;
  52772. private _plus90X;
  52773. private _tmpPosition;
  52774. private _tmpDeltaPosition;
  52775. private _tmpUnityRotation;
  52776. private _updatePhysicsBodyTransformation;
  52777. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52778. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52779. isSupported(): boolean;
  52780. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52781. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52782. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52783. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52784. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52785. getBodyMass(impostor: PhysicsImpostor): number;
  52786. getBodyFriction(impostor: PhysicsImpostor): number;
  52787. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52788. getBodyRestitution(impostor: PhysicsImpostor): number;
  52789. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52790. sleepBody(impostor: PhysicsImpostor): void;
  52791. wakeUpBody(impostor: PhysicsImpostor): void;
  52792. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52794. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52795. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52796. getRadius(impostor: PhysicsImpostor): number;
  52797. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52798. dispose(): void;
  52799. private _extendNamespace;
  52800. /**
  52801. * Does a raycast in the physics world
  52802. * @param from when should the ray start?
  52803. * @param to when should the ray end?
  52804. * @returns PhysicsRaycastResult
  52805. */
  52806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52807. }
  52808. }
  52809. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52810. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52811. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52812. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52814. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52815. import { Nullable } from "babylonjs/types";
  52816. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52817. /** @hidden */
  52818. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52819. world: any;
  52820. name: string;
  52821. BJSOIMO: any;
  52822. private _raycastResult;
  52823. constructor(iterations?: number, oimoInjection?: any);
  52824. setGravity(gravity: Vector3): void;
  52825. setTimeStep(timeStep: number): void;
  52826. getTimeStep(): number;
  52827. private _tmpImpostorsArray;
  52828. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52829. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52830. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52831. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52832. private _tmpPositionVector;
  52833. removePhysicsBody(impostor: PhysicsImpostor): void;
  52834. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52835. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52836. isSupported(): boolean;
  52837. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52838. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52839. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52840. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52841. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52842. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52843. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52844. getBodyMass(impostor: PhysicsImpostor): number;
  52845. getBodyFriction(impostor: PhysicsImpostor): number;
  52846. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52847. getBodyRestitution(impostor: PhysicsImpostor): number;
  52848. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52849. sleepBody(impostor: PhysicsImpostor): void;
  52850. wakeUpBody(impostor: PhysicsImpostor): void;
  52851. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52852. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52853. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52854. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52855. getRadius(impostor: PhysicsImpostor): number;
  52856. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52857. dispose(): void;
  52858. /**
  52859. * Does a raycast in the physics world
  52860. * @param from when should the ray start?
  52861. * @param to when should the ray end?
  52862. * @returns PhysicsRaycastResult
  52863. */
  52864. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52865. }
  52866. }
  52867. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52868. import { Nullable } from "babylonjs/types";
  52869. import { Scene } from "babylonjs/scene";
  52870. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52871. import { Color4 } from "babylonjs/Maths/math.color";
  52872. import { Mesh } from "babylonjs/Meshes/mesh";
  52873. /**
  52874. * Class containing static functions to help procedurally build meshes
  52875. */
  52876. export class RibbonBuilder {
  52877. /**
  52878. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52879. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52880. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52881. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52882. * * 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
  52883. * * 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
  52884. * * 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
  52885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52888. * * 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
  52889. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52890. * * 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
  52891. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52893. * @param name defines the name of the mesh
  52894. * @param options defines the options used to create the mesh
  52895. * @param scene defines the hosting scene
  52896. * @returns the ribbon mesh
  52897. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52899. */
  52900. static CreateRibbon(name: string, options: {
  52901. pathArray: Vector3[][];
  52902. closeArray?: boolean;
  52903. closePath?: boolean;
  52904. offset?: number;
  52905. updatable?: boolean;
  52906. sideOrientation?: number;
  52907. frontUVs?: Vector4;
  52908. backUVs?: Vector4;
  52909. instance?: Mesh;
  52910. invertUV?: boolean;
  52911. uvs?: Vector2[];
  52912. colors?: Color4[];
  52913. }, scene?: Nullable<Scene>): Mesh;
  52914. }
  52915. }
  52916. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52917. import { Nullable } from "babylonjs/types";
  52918. import { Scene } from "babylonjs/scene";
  52919. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52920. import { Mesh } from "babylonjs/Meshes/mesh";
  52921. /**
  52922. * Class containing static functions to help procedurally build meshes
  52923. */
  52924. export class ShapeBuilder {
  52925. /**
  52926. * 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.
  52927. * * 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.
  52928. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52929. * * 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.
  52930. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52931. * * 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
  52932. * * 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
  52933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52938. * @param name defines the name of the mesh
  52939. * @param options defines the options used to create the mesh
  52940. * @param scene defines the hosting scene
  52941. * @returns the extruded shape mesh
  52942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52944. */
  52945. static ExtrudeShape(name: string, options: {
  52946. shape: Vector3[];
  52947. path: Vector3[];
  52948. scale?: number;
  52949. rotation?: number;
  52950. cap?: number;
  52951. updatable?: boolean;
  52952. sideOrientation?: number;
  52953. frontUVs?: Vector4;
  52954. backUVs?: Vector4;
  52955. instance?: Mesh;
  52956. invertUV?: boolean;
  52957. }, scene?: Nullable<Scene>): Mesh;
  52958. /**
  52959. * Creates an custom extruded shape mesh.
  52960. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52961. * * 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.
  52962. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52963. * * 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
  52964. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52965. * * 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
  52966. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52967. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52968. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52969. * * 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
  52970. * * 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
  52971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52976. * @param name defines the name of the mesh
  52977. * @param options defines the options used to create the mesh
  52978. * @param scene defines the hosting scene
  52979. * @returns the custom extruded shape mesh
  52980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52983. */
  52984. static ExtrudeShapeCustom(name: string, options: {
  52985. shape: Vector3[];
  52986. path: Vector3[];
  52987. scaleFunction?: any;
  52988. rotationFunction?: any;
  52989. ribbonCloseArray?: boolean;
  52990. ribbonClosePath?: boolean;
  52991. cap?: number;
  52992. updatable?: boolean;
  52993. sideOrientation?: number;
  52994. frontUVs?: Vector4;
  52995. backUVs?: Vector4;
  52996. instance?: Mesh;
  52997. invertUV?: boolean;
  52998. }, scene?: Nullable<Scene>): Mesh;
  52999. private static _ExtrudeShapeGeneric;
  53000. }
  53001. }
  53002. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53003. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53004. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53005. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53006. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53007. import { Nullable } from "babylonjs/types";
  53008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53009. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53010. /**
  53011. * AmmoJS Physics plugin
  53012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53013. * @see https://github.com/kripken/ammo.js/
  53014. */
  53015. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53016. private _useDeltaForWorldStep;
  53017. /**
  53018. * Reference to the Ammo library
  53019. */
  53020. bjsAMMO: any;
  53021. /**
  53022. * Created ammoJS world which physics bodies are added to
  53023. */
  53024. world: any;
  53025. /**
  53026. * Name of the plugin
  53027. */
  53028. name: string;
  53029. private _timeStep;
  53030. private _fixedTimeStep;
  53031. private _maxSteps;
  53032. private _tmpQuaternion;
  53033. private _tmpAmmoTransform;
  53034. private _tmpAmmoQuaternion;
  53035. private _tmpAmmoConcreteContactResultCallback;
  53036. private _collisionConfiguration;
  53037. private _dispatcher;
  53038. private _overlappingPairCache;
  53039. private _solver;
  53040. private _softBodySolver;
  53041. private _tmpAmmoVectorA;
  53042. private _tmpAmmoVectorB;
  53043. private _tmpAmmoVectorC;
  53044. private _tmpAmmoVectorD;
  53045. private _tmpContactCallbackResult;
  53046. private _tmpAmmoVectorRCA;
  53047. private _tmpAmmoVectorRCB;
  53048. private _raycastResult;
  53049. private static readonly DISABLE_COLLISION_FLAG;
  53050. private static readonly KINEMATIC_FLAG;
  53051. private static readonly DISABLE_DEACTIVATION_FLAG;
  53052. /**
  53053. * Initializes the ammoJS plugin
  53054. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53055. * @param ammoInjection can be used to inject your own ammo reference
  53056. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53057. */
  53058. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53059. /**
  53060. * Sets the gravity of the physics world (m/(s^2))
  53061. * @param gravity Gravity to set
  53062. */
  53063. setGravity(gravity: Vector3): void;
  53064. /**
  53065. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53066. * @param timeStep timestep to use in seconds
  53067. */
  53068. setTimeStep(timeStep: number): void;
  53069. /**
  53070. * 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)
  53071. * @param fixedTimeStep fixedTimeStep to use in seconds
  53072. */
  53073. setFixedTimeStep(fixedTimeStep: number): void;
  53074. /**
  53075. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53076. * @param maxSteps the maximum number of steps by the physics engine per frame
  53077. */
  53078. setMaxSteps(maxSteps: number): void;
  53079. /**
  53080. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53081. * @returns the current timestep in seconds
  53082. */
  53083. getTimeStep(): number;
  53084. private _isImpostorInContact;
  53085. private _isImpostorPairInContact;
  53086. private _stepSimulation;
  53087. /**
  53088. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53089. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53090. * After the step the babylon meshes are set to the position of the physics imposters
  53091. * @param delta amount of time to step forward
  53092. * @param impostors array of imposters to update before/after the step
  53093. */
  53094. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53095. /**
  53096. * Update babylon mesh to match physics world object
  53097. * @param impostor imposter to match
  53098. */
  53099. private _afterSoftStep;
  53100. /**
  53101. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53102. * @param impostor imposter to match
  53103. */
  53104. private _ropeStep;
  53105. /**
  53106. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53107. * @param impostor imposter to match
  53108. */
  53109. private _softbodyOrClothStep;
  53110. private _tmpVector;
  53111. private _tmpMatrix;
  53112. /**
  53113. * Applies an impulse on the imposter
  53114. * @param impostor imposter to apply impulse to
  53115. * @param force amount of force to be applied to the imposter
  53116. * @param contactPoint the location to apply the impulse on the imposter
  53117. */
  53118. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53119. /**
  53120. * Applies a force on the imposter
  53121. * @param impostor imposter to apply force
  53122. * @param force amount of force to be applied to the imposter
  53123. * @param contactPoint the location to apply the force on the imposter
  53124. */
  53125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53126. /**
  53127. * Creates a physics body using the plugin
  53128. * @param impostor the imposter to create the physics body on
  53129. */
  53130. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53131. /**
  53132. * Removes the physics body from the imposter and disposes of the body's memory
  53133. * @param impostor imposter to remove the physics body from
  53134. */
  53135. removePhysicsBody(impostor: PhysicsImpostor): void;
  53136. /**
  53137. * Generates a joint
  53138. * @param impostorJoint the imposter joint to create the joint with
  53139. */
  53140. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53141. /**
  53142. * Removes a joint
  53143. * @param impostorJoint the imposter joint to remove the joint from
  53144. */
  53145. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53146. private _addMeshVerts;
  53147. /**
  53148. * Initialise the soft body vertices to match its object's (mesh) vertices
  53149. * Softbody vertices (nodes) are in world space and to match this
  53150. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53151. * @param impostor to create the softbody for
  53152. */
  53153. private _softVertexData;
  53154. /**
  53155. * Create an impostor's soft body
  53156. * @param impostor to create the softbody for
  53157. */
  53158. private _createSoftbody;
  53159. /**
  53160. * Create cloth for an impostor
  53161. * @param impostor to create the softbody for
  53162. */
  53163. private _createCloth;
  53164. /**
  53165. * Create rope for an impostor
  53166. * @param impostor to create the softbody for
  53167. */
  53168. private _createRope;
  53169. private _addHullVerts;
  53170. private _createShape;
  53171. /**
  53172. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53173. * @param impostor imposter containing the physics body and babylon object
  53174. */
  53175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53176. /**
  53177. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53178. * @param impostor imposter containing the physics body and babylon object
  53179. * @param newPosition new position
  53180. * @param newRotation new rotation
  53181. */
  53182. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53183. /**
  53184. * If this plugin is supported
  53185. * @returns true if its supported
  53186. */
  53187. isSupported(): boolean;
  53188. /**
  53189. * Sets the linear velocity of the physics body
  53190. * @param impostor imposter to set the velocity on
  53191. * @param velocity velocity to set
  53192. */
  53193. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53194. /**
  53195. * Sets the angular velocity of the physics body
  53196. * @param impostor imposter to set the velocity on
  53197. * @param velocity velocity to set
  53198. */
  53199. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53200. /**
  53201. * gets the linear velocity
  53202. * @param impostor imposter to get linear velocity from
  53203. * @returns linear velocity
  53204. */
  53205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53206. /**
  53207. * gets the angular velocity
  53208. * @param impostor imposter to get angular velocity from
  53209. * @returns angular velocity
  53210. */
  53211. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53212. /**
  53213. * Sets the mass of physics body
  53214. * @param impostor imposter to set the mass on
  53215. * @param mass mass to set
  53216. */
  53217. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53218. /**
  53219. * Gets the mass of the physics body
  53220. * @param impostor imposter to get the mass from
  53221. * @returns mass
  53222. */
  53223. getBodyMass(impostor: PhysicsImpostor): number;
  53224. /**
  53225. * Gets friction of the impostor
  53226. * @param impostor impostor to get friction from
  53227. * @returns friction value
  53228. */
  53229. getBodyFriction(impostor: PhysicsImpostor): number;
  53230. /**
  53231. * Sets friction of the impostor
  53232. * @param impostor impostor to set friction on
  53233. * @param friction friction value
  53234. */
  53235. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53236. /**
  53237. * Gets restitution of the impostor
  53238. * @param impostor impostor to get restitution from
  53239. * @returns restitution value
  53240. */
  53241. getBodyRestitution(impostor: PhysicsImpostor): number;
  53242. /**
  53243. * Sets resitution of the impostor
  53244. * @param impostor impostor to set resitution on
  53245. * @param restitution resitution value
  53246. */
  53247. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53248. /**
  53249. * Gets pressure inside the impostor
  53250. * @param impostor impostor to get pressure from
  53251. * @returns pressure value
  53252. */
  53253. getBodyPressure(impostor: PhysicsImpostor): number;
  53254. /**
  53255. * Sets pressure inside a soft body impostor
  53256. * Cloth and rope must remain 0 pressure
  53257. * @param impostor impostor to set pressure on
  53258. * @param pressure pressure value
  53259. */
  53260. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53261. /**
  53262. * Gets stiffness of the impostor
  53263. * @param impostor impostor to get stiffness from
  53264. * @returns pressure value
  53265. */
  53266. getBodyStiffness(impostor: PhysicsImpostor): number;
  53267. /**
  53268. * Sets stiffness of the impostor
  53269. * @param impostor impostor to set stiffness on
  53270. * @param stiffness stiffness value from 0 to 1
  53271. */
  53272. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53273. /**
  53274. * Gets velocityIterations of the impostor
  53275. * @param impostor impostor to get velocity iterations from
  53276. * @returns velocityIterations value
  53277. */
  53278. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53279. /**
  53280. * Sets velocityIterations of the impostor
  53281. * @param impostor impostor to set velocity iterations on
  53282. * @param velocityIterations velocityIterations value
  53283. */
  53284. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53285. /**
  53286. * Gets positionIterations of the impostor
  53287. * @param impostor impostor to get position iterations from
  53288. * @returns positionIterations value
  53289. */
  53290. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53291. /**
  53292. * Sets positionIterations of the impostor
  53293. * @param impostor impostor to set position on
  53294. * @param positionIterations positionIterations value
  53295. */
  53296. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53297. /**
  53298. * Append an anchor to a cloth object
  53299. * @param impostor is the cloth impostor to add anchor to
  53300. * @param otherImpostor is the rigid impostor to anchor to
  53301. * @param width ratio across width from 0 to 1
  53302. * @param height ratio up height from 0 to 1
  53303. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53304. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53305. */
  53306. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53307. /**
  53308. * Append an hook to a rope object
  53309. * @param impostor is the rope impostor to add hook to
  53310. * @param otherImpostor is the rigid impostor to hook to
  53311. * @param length ratio along the rope from 0 to 1
  53312. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53313. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53314. */
  53315. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53316. /**
  53317. * Sleeps the physics body and stops it from being active
  53318. * @param impostor impostor to sleep
  53319. */
  53320. sleepBody(impostor: PhysicsImpostor): void;
  53321. /**
  53322. * Activates the physics body
  53323. * @param impostor impostor to activate
  53324. */
  53325. wakeUpBody(impostor: PhysicsImpostor): void;
  53326. /**
  53327. * Updates the distance parameters of the joint
  53328. * @param joint joint to update
  53329. * @param maxDistance maximum distance of the joint
  53330. * @param minDistance minimum distance of the joint
  53331. */
  53332. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53333. /**
  53334. * Sets a motor on the joint
  53335. * @param joint joint to set motor on
  53336. * @param speed speed of the motor
  53337. * @param maxForce maximum force of the motor
  53338. * @param motorIndex index of the motor
  53339. */
  53340. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53341. /**
  53342. * Sets the motors limit
  53343. * @param joint joint to set limit on
  53344. * @param upperLimit upper limit
  53345. * @param lowerLimit lower limit
  53346. */
  53347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53348. /**
  53349. * Syncs the position and rotation of a mesh with the impostor
  53350. * @param mesh mesh to sync
  53351. * @param impostor impostor to update the mesh with
  53352. */
  53353. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53354. /**
  53355. * Gets the radius of the impostor
  53356. * @param impostor impostor to get radius from
  53357. * @returns the radius
  53358. */
  53359. getRadius(impostor: PhysicsImpostor): number;
  53360. /**
  53361. * Gets the box size of the impostor
  53362. * @param impostor impostor to get box size from
  53363. * @param result the resulting box size
  53364. */
  53365. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53366. /**
  53367. * Disposes of the impostor
  53368. */
  53369. dispose(): void;
  53370. /**
  53371. * Does a raycast in the physics world
  53372. * @param from when should the ray start?
  53373. * @param to when should the ray end?
  53374. * @returns PhysicsRaycastResult
  53375. */
  53376. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53377. }
  53378. }
  53379. declare module "babylonjs/Probes/reflectionProbe" {
  53380. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53381. import { Vector3 } from "babylonjs/Maths/math.vector";
  53382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53383. import { Nullable } from "babylonjs/types";
  53384. import { Scene } from "babylonjs/scene";
  53385. module "babylonjs/abstractScene" {
  53386. interface AbstractScene {
  53387. /**
  53388. * The list of reflection probes added to the scene
  53389. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53390. */
  53391. reflectionProbes: Array<ReflectionProbe>;
  53392. /**
  53393. * Removes the given reflection probe from this scene.
  53394. * @param toRemove The reflection probe to remove
  53395. * @returns The index of the removed reflection probe
  53396. */
  53397. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53398. /**
  53399. * Adds the given reflection probe to this scene.
  53400. * @param newReflectionProbe The reflection probe to add
  53401. */
  53402. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53403. }
  53404. }
  53405. /**
  53406. * Class used to generate realtime reflection / refraction cube textures
  53407. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53408. */
  53409. export class ReflectionProbe {
  53410. /** defines the name of the probe */
  53411. name: string;
  53412. private _scene;
  53413. private _renderTargetTexture;
  53414. private _projectionMatrix;
  53415. private _viewMatrix;
  53416. private _target;
  53417. private _add;
  53418. private _attachedMesh;
  53419. private _invertYAxis;
  53420. /** Gets or sets probe position (center of the cube map) */
  53421. position: Vector3;
  53422. /**
  53423. * Creates a new reflection probe
  53424. * @param name defines the name of the probe
  53425. * @param size defines the texture resolution (for each face)
  53426. * @param scene defines the hosting scene
  53427. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53428. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53429. */
  53430. constructor(
  53431. /** defines the name of the probe */
  53432. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53433. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53434. samples: number;
  53435. /** Gets or sets the refresh rate to use (on every frame by default) */
  53436. refreshRate: number;
  53437. /**
  53438. * Gets the hosting scene
  53439. * @returns a Scene
  53440. */
  53441. getScene(): Scene;
  53442. /** Gets the internal CubeTexture used to render to */
  53443. readonly cubeTexture: RenderTargetTexture;
  53444. /** Gets the list of meshes to render */
  53445. readonly renderList: Nullable<AbstractMesh[]>;
  53446. /**
  53447. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53448. * @param mesh defines the mesh to attach to
  53449. */
  53450. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53451. /**
  53452. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53453. * @param renderingGroupId The rendering group id corresponding to its index
  53454. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53455. */
  53456. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53457. /**
  53458. * Clean all associated resources
  53459. */
  53460. dispose(): void;
  53461. /**
  53462. * Converts the reflection probe information to a readable string for debug purpose.
  53463. * @param fullDetails Supports for multiple levels of logging within scene loading
  53464. * @returns the human readable reflection probe info
  53465. */
  53466. toString(fullDetails?: boolean): string;
  53467. /**
  53468. * Get the class name of the relfection probe.
  53469. * @returns "ReflectionProbe"
  53470. */
  53471. getClassName(): string;
  53472. /**
  53473. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53474. * @returns The JSON representation of the texture
  53475. */
  53476. serialize(): any;
  53477. /**
  53478. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53479. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53480. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53481. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53482. * @returns The parsed reflection probe if successful
  53483. */
  53484. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53485. }
  53486. }
  53487. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53488. /** @hidden */
  53489. export var _BabylonLoaderRegistered: boolean;
  53490. }
  53491. declare module "babylonjs/Loading/Plugins/index" {
  53492. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53493. }
  53494. declare module "babylonjs/Loading/index" {
  53495. export * from "babylonjs/Loading/loadingScreen";
  53496. export * from "babylonjs/Loading/Plugins/index";
  53497. export * from "babylonjs/Loading/sceneLoader";
  53498. export * from "babylonjs/Loading/sceneLoaderFlags";
  53499. }
  53500. declare module "babylonjs/Materials/Background/index" {
  53501. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53502. }
  53503. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53504. import { Scene } from "babylonjs/scene";
  53505. import { Color3 } from "babylonjs/Maths/math.color";
  53506. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53508. /**
  53509. * The Physically based simple base material of BJS.
  53510. *
  53511. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53512. * It is used as the base class for both the specGloss and metalRough conventions.
  53513. */
  53514. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53515. /**
  53516. * Number of Simultaneous lights allowed on the material.
  53517. */
  53518. maxSimultaneousLights: number;
  53519. /**
  53520. * If sets to true, disables all the lights affecting the material.
  53521. */
  53522. disableLighting: boolean;
  53523. /**
  53524. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53525. */
  53526. environmentTexture: BaseTexture;
  53527. /**
  53528. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53529. */
  53530. invertNormalMapX: boolean;
  53531. /**
  53532. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53533. */
  53534. invertNormalMapY: boolean;
  53535. /**
  53536. * Normal map used in the model.
  53537. */
  53538. normalTexture: BaseTexture;
  53539. /**
  53540. * Emissivie color used to self-illuminate the model.
  53541. */
  53542. emissiveColor: Color3;
  53543. /**
  53544. * Emissivie texture used to self-illuminate the model.
  53545. */
  53546. emissiveTexture: BaseTexture;
  53547. /**
  53548. * Occlusion Channel Strenght.
  53549. */
  53550. occlusionStrength: number;
  53551. /**
  53552. * Occlusion Texture of the material (adding extra occlusion effects).
  53553. */
  53554. occlusionTexture: BaseTexture;
  53555. /**
  53556. * Defines the alpha limits in alpha test mode.
  53557. */
  53558. alphaCutOff: number;
  53559. /**
  53560. * Gets the current double sided mode.
  53561. */
  53562. /**
  53563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53564. */
  53565. doubleSided: boolean;
  53566. /**
  53567. * Stores the pre-calculated light information of a mesh in a texture.
  53568. */
  53569. lightmapTexture: BaseTexture;
  53570. /**
  53571. * If true, the light map contains occlusion information instead of lighting info.
  53572. */
  53573. useLightmapAsShadowmap: boolean;
  53574. /**
  53575. * Instantiates a new PBRMaterial instance.
  53576. *
  53577. * @param name The material name
  53578. * @param scene The scene the material will be use in.
  53579. */
  53580. constructor(name: string, scene: Scene);
  53581. getClassName(): string;
  53582. }
  53583. }
  53584. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53585. import { Scene } from "babylonjs/scene";
  53586. import { Color3 } from "babylonjs/Maths/math.color";
  53587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53588. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53589. /**
  53590. * The PBR material of BJS following the metal roughness convention.
  53591. *
  53592. * This fits to the PBR convention in the GLTF definition:
  53593. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53594. */
  53595. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53596. /**
  53597. * The base color has two different interpretations depending on the value of metalness.
  53598. * When the material is a metal, the base color is the specific measured reflectance value
  53599. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53600. * of the material.
  53601. */
  53602. baseColor: Color3;
  53603. /**
  53604. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53605. * well as opacity information in the alpha channel.
  53606. */
  53607. baseTexture: BaseTexture;
  53608. /**
  53609. * Specifies the metallic scalar value of the material.
  53610. * Can also be used to scale the metalness values of the metallic texture.
  53611. */
  53612. metallic: number;
  53613. /**
  53614. * Specifies the roughness scalar value of the material.
  53615. * Can also be used to scale the roughness values of the metallic texture.
  53616. */
  53617. roughness: number;
  53618. /**
  53619. * Texture containing both the metallic value in the B channel and the
  53620. * roughness value in the G channel to keep better precision.
  53621. */
  53622. metallicRoughnessTexture: BaseTexture;
  53623. /**
  53624. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53625. *
  53626. * @param name The material name
  53627. * @param scene The scene the material will be use in.
  53628. */
  53629. constructor(name: string, scene: Scene);
  53630. /**
  53631. * Return the currrent class name of the material.
  53632. */
  53633. getClassName(): string;
  53634. /**
  53635. * Makes a duplicate of the current material.
  53636. * @param name - name to use for the new material.
  53637. */
  53638. clone(name: string): PBRMetallicRoughnessMaterial;
  53639. /**
  53640. * Serialize the material to a parsable JSON object.
  53641. */
  53642. serialize(): any;
  53643. /**
  53644. * Parses a JSON object correponding to the serialize function.
  53645. */
  53646. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53647. }
  53648. }
  53649. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53650. import { Scene } from "babylonjs/scene";
  53651. import { Color3 } from "babylonjs/Maths/math.color";
  53652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53653. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53654. /**
  53655. * The PBR material of BJS following the specular glossiness convention.
  53656. *
  53657. * This fits to the PBR convention in the GLTF definition:
  53658. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53659. */
  53660. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53661. /**
  53662. * Specifies the diffuse color of the material.
  53663. */
  53664. diffuseColor: Color3;
  53665. /**
  53666. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53667. * channel.
  53668. */
  53669. diffuseTexture: BaseTexture;
  53670. /**
  53671. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53672. */
  53673. specularColor: Color3;
  53674. /**
  53675. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53676. */
  53677. glossiness: number;
  53678. /**
  53679. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53680. */
  53681. specularGlossinessTexture: BaseTexture;
  53682. /**
  53683. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53684. *
  53685. * @param name The material name
  53686. * @param scene The scene the material will be use in.
  53687. */
  53688. constructor(name: string, scene: Scene);
  53689. /**
  53690. * Return the currrent class name of the material.
  53691. */
  53692. getClassName(): string;
  53693. /**
  53694. * Makes a duplicate of the current material.
  53695. * @param name - name to use for the new material.
  53696. */
  53697. clone(name: string): PBRSpecularGlossinessMaterial;
  53698. /**
  53699. * Serialize the material to a parsable JSON object.
  53700. */
  53701. serialize(): any;
  53702. /**
  53703. * Parses a JSON object correponding to the serialize function.
  53704. */
  53705. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53706. }
  53707. }
  53708. declare module "babylonjs/Materials/PBR/index" {
  53709. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53710. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53711. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53712. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53713. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53714. }
  53715. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53716. import { Nullable } from "babylonjs/types";
  53717. import { Scene } from "babylonjs/scene";
  53718. import { Matrix } from "babylonjs/Maths/math.vector";
  53719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53720. /**
  53721. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53722. * It can help converting any input color in a desired output one. This can then be used to create effects
  53723. * from sepia, black and white to sixties or futuristic rendering...
  53724. *
  53725. * The only supported format is currently 3dl.
  53726. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53727. */
  53728. export class ColorGradingTexture extends BaseTexture {
  53729. /**
  53730. * The current texture matrix. (will always be identity in color grading texture)
  53731. */
  53732. private _textureMatrix;
  53733. /**
  53734. * The texture URL.
  53735. */
  53736. url: string;
  53737. /**
  53738. * Empty line regex stored for GC.
  53739. */
  53740. private static _noneEmptyLineRegex;
  53741. private _engine;
  53742. /**
  53743. * Instantiates a ColorGradingTexture from the following parameters.
  53744. *
  53745. * @param url The location of the color gradind data (currently only supporting 3dl)
  53746. * @param scene The scene the texture will be used in
  53747. */
  53748. constructor(url: string, scene: Scene);
  53749. /**
  53750. * Returns the texture matrix used in most of the material.
  53751. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53752. */
  53753. getTextureMatrix(): Matrix;
  53754. /**
  53755. * Occurs when the file being loaded is a .3dl LUT file.
  53756. */
  53757. private load3dlTexture;
  53758. /**
  53759. * Starts the loading process of the texture.
  53760. */
  53761. private loadTexture;
  53762. /**
  53763. * Clones the color gradind texture.
  53764. */
  53765. clone(): ColorGradingTexture;
  53766. /**
  53767. * Called during delayed load for textures.
  53768. */
  53769. delayLoad(): void;
  53770. /**
  53771. * Parses a color grading texture serialized by Babylon.
  53772. * @param parsedTexture The texture information being parsedTexture
  53773. * @param scene The scene to load the texture in
  53774. * @param rootUrl The root url of the data assets to load
  53775. * @return A color gradind texture
  53776. */
  53777. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53778. /**
  53779. * Serializes the LUT texture to json format.
  53780. */
  53781. serialize(): any;
  53782. }
  53783. }
  53784. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53785. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53786. import { Scene } from "babylonjs/scene";
  53787. import { Nullable } from "babylonjs/types";
  53788. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53789. /**
  53790. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53791. */
  53792. export class EquiRectangularCubeTexture extends BaseTexture {
  53793. /** The six faces of the cube. */
  53794. private static _FacesMapping;
  53795. private _noMipmap;
  53796. private _onLoad;
  53797. private _onError;
  53798. /** The size of the cubemap. */
  53799. private _size;
  53800. /** The buffer of the image. */
  53801. private _buffer;
  53802. /** The width of the input image. */
  53803. private _width;
  53804. /** The height of the input image. */
  53805. private _height;
  53806. /** The URL to the image. */
  53807. url: string;
  53808. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53809. coordinatesMode: number;
  53810. /**
  53811. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53812. * @param url The location of the image
  53813. * @param scene The scene the texture will be used in
  53814. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53815. * @param noMipmap Forces to not generate the mipmap if true
  53816. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53817. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53818. * @param onLoad — defines a callback called when texture is loaded
  53819. * @param onError — defines a callback called if there is an error
  53820. */
  53821. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53822. /**
  53823. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53824. */
  53825. private loadImage;
  53826. /**
  53827. * Convert the image buffer into a cubemap and create a CubeTexture.
  53828. */
  53829. private loadTexture;
  53830. /**
  53831. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53832. * @param buffer The ArrayBuffer that should be converted.
  53833. * @returns The buffer as Float32Array.
  53834. */
  53835. private getFloat32ArrayFromArrayBuffer;
  53836. /**
  53837. * Get the current class name of the texture useful for serialization or dynamic coding.
  53838. * @returns "EquiRectangularCubeTexture"
  53839. */
  53840. getClassName(): string;
  53841. /**
  53842. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53843. * @returns A clone of the current EquiRectangularCubeTexture.
  53844. */
  53845. clone(): EquiRectangularCubeTexture;
  53846. }
  53847. }
  53848. declare module "babylonjs/Misc/tga" {
  53849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53850. /**
  53851. * Based on jsTGALoader - Javascript loader for TGA file
  53852. * By Vincent Thibault
  53853. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53854. */
  53855. export class TGATools {
  53856. private static _TYPE_INDEXED;
  53857. private static _TYPE_RGB;
  53858. private static _TYPE_GREY;
  53859. private static _TYPE_RLE_INDEXED;
  53860. private static _TYPE_RLE_RGB;
  53861. private static _TYPE_RLE_GREY;
  53862. private static _ORIGIN_MASK;
  53863. private static _ORIGIN_SHIFT;
  53864. private static _ORIGIN_BL;
  53865. private static _ORIGIN_BR;
  53866. private static _ORIGIN_UL;
  53867. private static _ORIGIN_UR;
  53868. /**
  53869. * Gets the header of a TGA file
  53870. * @param data defines the TGA data
  53871. * @returns the header
  53872. */
  53873. static GetTGAHeader(data: Uint8Array): any;
  53874. /**
  53875. * Uploads TGA content to a Babylon Texture
  53876. * @hidden
  53877. */
  53878. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53879. /** @hidden */
  53880. 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;
  53881. /** @hidden */
  53882. 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;
  53883. /** @hidden */
  53884. 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;
  53885. /** @hidden */
  53886. 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;
  53887. /** @hidden */
  53888. 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;
  53889. /** @hidden */
  53890. 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;
  53891. }
  53892. }
  53893. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53894. import { Nullable } from "babylonjs/types";
  53895. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53896. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53897. /**
  53898. * Implementation of the TGA Texture Loader.
  53899. * @hidden
  53900. */
  53901. export class _TGATextureLoader implements IInternalTextureLoader {
  53902. /**
  53903. * Defines wether the loader supports cascade loading the different faces.
  53904. */
  53905. readonly supportCascades: boolean;
  53906. /**
  53907. * This returns if the loader support the current file information.
  53908. * @param extension defines the file extension of the file being loaded
  53909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53910. * @param fallback defines the fallback internal texture if any
  53911. * @param isBase64 defines whether the texture is encoded as a base64
  53912. * @param isBuffer defines whether the texture data are stored as a buffer
  53913. * @returns true if the loader can load the specified file
  53914. */
  53915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53916. /**
  53917. * Transform the url before loading if required.
  53918. * @param rootUrl the url of the texture
  53919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53920. * @returns the transformed texture
  53921. */
  53922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53923. /**
  53924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53925. * @param rootUrl the url of the texture
  53926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53927. * @returns the fallback texture
  53928. */
  53929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53930. /**
  53931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53932. * @param data contains the texture data
  53933. * @param texture defines the BabylonJS internal texture
  53934. * @param createPolynomials will be true if polynomials have been requested
  53935. * @param onLoad defines the callback to trigger once the texture is ready
  53936. * @param onError defines the callback to trigger in case of error
  53937. */
  53938. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53939. /**
  53940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53941. * @param data contains the texture data
  53942. * @param texture defines the BabylonJS internal texture
  53943. * @param callback defines the method to call once ready to upload
  53944. */
  53945. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53946. }
  53947. }
  53948. declare module "babylonjs/Misc/basis" {
  53949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53950. /**
  53951. * Info about the .basis files
  53952. */
  53953. class BasisFileInfo {
  53954. /**
  53955. * If the file has alpha
  53956. */
  53957. hasAlpha: boolean;
  53958. /**
  53959. * Info about each image of the basis file
  53960. */
  53961. images: Array<{
  53962. levels: Array<{
  53963. width: number;
  53964. height: number;
  53965. transcodedPixels: ArrayBufferView;
  53966. }>;
  53967. }>;
  53968. }
  53969. /**
  53970. * Result of transcoding a basis file
  53971. */
  53972. class TranscodeResult {
  53973. /**
  53974. * Info about the .basis file
  53975. */
  53976. fileInfo: BasisFileInfo;
  53977. /**
  53978. * Format to use when loading the file
  53979. */
  53980. format: number;
  53981. }
  53982. /**
  53983. * Configuration options for the Basis transcoder
  53984. */
  53985. export class BasisTranscodeConfiguration {
  53986. /**
  53987. * Supported compression formats used to determine the supported output format of the transcoder
  53988. */
  53989. supportedCompressionFormats?: {
  53990. /**
  53991. * etc1 compression format
  53992. */
  53993. etc1?: boolean;
  53994. /**
  53995. * s3tc compression format
  53996. */
  53997. s3tc?: boolean;
  53998. /**
  53999. * pvrtc compression format
  54000. */
  54001. pvrtc?: boolean;
  54002. /**
  54003. * etc2 compression format
  54004. */
  54005. etc2?: boolean;
  54006. };
  54007. /**
  54008. * If mipmap levels should be loaded for transcoded images (Default: true)
  54009. */
  54010. loadMipmapLevels?: boolean;
  54011. /**
  54012. * Index of a single image to load (Default: all images)
  54013. */
  54014. loadSingleImage?: number;
  54015. }
  54016. /**
  54017. * Used to load .Basis files
  54018. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54019. */
  54020. export class BasisTools {
  54021. private static _IgnoreSupportedFormats;
  54022. /**
  54023. * URL to use when loading the basis transcoder
  54024. */
  54025. static JSModuleURL: string;
  54026. /**
  54027. * URL to use when loading the wasm module for the transcoder
  54028. */
  54029. static WasmModuleURL: string;
  54030. /**
  54031. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54032. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54033. * @returns internal format corresponding to the Basis format
  54034. */
  54035. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54036. private static _WorkerPromise;
  54037. private static _Worker;
  54038. private static _actionId;
  54039. private static _CreateWorkerAsync;
  54040. /**
  54041. * Transcodes a loaded image file to compressed pixel data
  54042. * @param imageData image data to transcode
  54043. * @param config configuration options for the transcoding
  54044. * @returns a promise resulting in the transcoded image
  54045. */
  54046. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54047. /**
  54048. * Loads a texture from the transcode result
  54049. * @param texture texture load to
  54050. * @param transcodeResult the result of transcoding the basis file to load from
  54051. */
  54052. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54053. }
  54054. }
  54055. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54056. import { Nullable } from "babylonjs/types";
  54057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54058. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54059. /**
  54060. * Loader for .basis file format
  54061. */
  54062. export class _BasisTextureLoader implements IInternalTextureLoader {
  54063. /**
  54064. * Defines whether the loader supports cascade loading the different faces.
  54065. */
  54066. readonly supportCascades: boolean;
  54067. /**
  54068. * This returns if the loader support the current file information.
  54069. * @param extension defines the file extension of the file being loaded
  54070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54071. * @param fallback defines the fallback internal texture if any
  54072. * @param isBase64 defines whether the texture is encoded as a base64
  54073. * @param isBuffer defines whether the texture data are stored as a buffer
  54074. * @returns true if the loader can load the specified file
  54075. */
  54076. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54077. /**
  54078. * Transform the url before loading if required.
  54079. * @param rootUrl the url of the texture
  54080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54081. * @returns the transformed texture
  54082. */
  54083. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54084. /**
  54085. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54086. * @param rootUrl the url of the texture
  54087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54088. * @returns the fallback texture
  54089. */
  54090. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54091. /**
  54092. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54093. * @param data contains the texture data
  54094. * @param texture defines the BabylonJS internal texture
  54095. * @param createPolynomials will be true if polynomials have been requested
  54096. * @param onLoad defines the callback to trigger once the texture is ready
  54097. * @param onError defines the callback to trigger in case of error
  54098. */
  54099. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54100. /**
  54101. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54102. * @param data contains the texture data
  54103. * @param texture defines the BabylonJS internal texture
  54104. * @param callback defines the method to call once ready to upload
  54105. */
  54106. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54107. }
  54108. }
  54109. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54110. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54111. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54112. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54113. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54114. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54115. }
  54116. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54117. import { Scene } from "babylonjs/scene";
  54118. import { Texture } from "babylonjs/Materials/Textures/texture";
  54119. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54120. /**
  54121. * 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.
  54122. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54123. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54124. */
  54125. export class CustomProceduralTexture extends ProceduralTexture {
  54126. private _animate;
  54127. private _time;
  54128. private _config;
  54129. private _texturePath;
  54130. /**
  54131. * Instantiates a new Custom Procedural Texture.
  54132. * 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.
  54133. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54134. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54135. * @param name Define the name of the texture
  54136. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54137. * @param size Define the size of the texture to create
  54138. * @param scene Define the scene the texture belongs to
  54139. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54140. * @param generateMipMaps Define if the texture should creates mip maps or not
  54141. */
  54142. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54143. private _loadJson;
  54144. /**
  54145. * Is the texture ready to be used ? (rendered at least once)
  54146. * @returns true if ready, otherwise, false.
  54147. */
  54148. isReady(): boolean;
  54149. /**
  54150. * Render the texture to its associated render target.
  54151. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54152. */
  54153. render(useCameraPostProcess?: boolean): void;
  54154. /**
  54155. * Update the list of dependant textures samplers in the shader.
  54156. */
  54157. updateTextures(): void;
  54158. /**
  54159. * Update the uniform values of the procedural texture in the shader.
  54160. */
  54161. updateShaderUniforms(): void;
  54162. /**
  54163. * Define if the texture animates or not.
  54164. */
  54165. animate: boolean;
  54166. }
  54167. }
  54168. declare module "babylonjs/Shaders/noise.fragment" {
  54169. /** @hidden */
  54170. export var noisePixelShader: {
  54171. name: string;
  54172. shader: string;
  54173. };
  54174. }
  54175. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54176. import { Nullable } from "babylonjs/types";
  54177. import { Scene } from "babylonjs/scene";
  54178. import { Texture } from "babylonjs/Materials/Textures/texture";
  54179. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54180. import "babylonjs/Shaders/noise.fragment";
  54181. /**
  54182. * Class used to generate noise procedural textures
  54183. */
  54184. export class NoiseProceduralTexture extends ProceduralTexture {
  54185. private _time;
  54186. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54187. brightness: number;
  54188. /** Defines the number of octaves to process */
  54189. octaves: number;
  54190. /** Defines the level of persistence (0.8 by default) */
  54191. persistence: number;
  54192. /** Gets or sets animation speed factor (default is 1) */
  54193. animationSpeedFactor: number;
  54194. /**
  54195. * Creates a new NoiseProceduralTexture
  54196. * @param name defines the name fo the texture
  54197. * @param size defines the size of the texture (default is 256)
  54198. * @param scene defines the hosting scene
  54199. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54200. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54201. */
  54202. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54203. private _updateShaderUniforms;
  54204. protected _getDefines(): string;
  54205. /** Generate the current state of the procedural texture */
  54206. render(useCameraPostProcess?: boolean): void;
  54207. /**
  54208. * Serializes this noise procedural texture
  54209. * @returns a serialized noise procedural texture object
  54210. */
  54211. serialize(): any;
  54212. /**
  54213. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54214. * @param parsedTexture defines parsed texture data
  54215. * @param scene defines the current scene
  54216. * @param rootUrl defines the root URL containing noise procedural texture information
  54217. * @returns a parsed NoiseProceduralTexture
  54218. */
  54219. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54220. }
  54221. }
  54222. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54223. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54224. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54225. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54226. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54227. }
  54228. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54229. import { Nullable } from "babylonjs/types";
  54230. import { Scene } from "babylonjs/scene";
  54231. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54232. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54233. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54234. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54235. /**
  54236. * Raw cube texture where the raw buffers are passed in
  54237. */
  54238. export class RawCubeTexture extends CubeTexture {
  54239. /**
  54240. * Creates a cube texture where the raw buffers are passed in.
  54241. * @param scene defines the scene the texture is attached to
  54242. * @param data defines the array of data to use to create each face
  54243. * @param size defines the size of the textures
  54244. * @param format defines the format of the data
  54245. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54246. * @param generateMipMaps defines if the engine should generate the mip levels
  54247. * @param invertY defines if data must be stored with Y axis inverted
  54248. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54249. * @param compression defines the compression used (null by default)
  54250. */
  54251. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54252. /**
  54253. * Updates the raw cube texture.
  54254. * @param data defines the data to store
  54255. * @param format defines the data format
  54256. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54257. * @param invertY defines if data must be stored with Y axis inverted
  54258. * @param compression defines the compression used (null by default)
  54259. * @param level defines which level of the texture to update
  54260. */
  54261. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54262. /**
  54263. * Updates a raw cube texture with RGBD encoded data.
  54264. * @param data defines the array of data [mipmap][face] to use to create each face
  54265. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54266. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54267. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54268. * @returns a promsie that resolves when the operation is complete
  54269. */
  54270. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54271. /**
  54272. * Clones the raw cube texture.
  54273. * @return a new cube texture
  54274. */
  54275. clone(): CubeTexture;
  54276. /** @hidden */
  54277. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54278. }
  54279. }
  54280. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54281. import { Scene } from "babylonjs/scene";
  54282. import { Texture } from "babylonjs/Materials/Textures/texture";
  54283. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54284. /**
  54285. * Class used to store 3D textures containing user data
  54286. */
  54287. export class RawTexture3D extends Texture {
  54288. /** Gets or sets the texture format to use */
  54289. format: number;
  54290. private _engine;
  54291. /**
  54292. * Create a new RawTexture3D
  54293. * @param data defines the data of the texture
  54294. * @param width defines the width of the texture
  54295. * @param height defines the height of the texture
  54296. * @param depth defines the depth of the texture
  54297. * @param format defines the texture format to use
  54298. * @param scene defines the hosting scene
  54299. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54300. * @param invertY defines if texture must be stored with Y axis inverted
  54301. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54302. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54303. */
  54304. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54305. /** Gets or sets the texture format to use */
  54306. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54307. /**
  54308. * Update the texture with new data
  54309. * @param data defines the data to store in the texture
  54310. */
  54311. update(data: ArrayBufferView): void;
  54312. }
  54313. }
  54314. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54315. import { Scene } from "babylonjs/scene";
  54316. import { Plane } from "babylonjs/Maths/math.plane";
  54317. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54318. /**
  54319. * Creates a refraction texture used by refraction channel of the standard material.
  54320. * It is like a mirror but to see through a material.
  54321. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54322. */
  54323. export class RefractionTexture extends RenderTargetTexture {
  54324. /**
  54325. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54326. * 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.
  54327. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54328. */
  54329. refractionPlane: Plane;
  54330. /**
  54331. * Define how deep under the surface we should see.
  54332. */
  54333. depth: number;
  54334. /**
  54335. * Creates a refraction texture used by refraction channel of the standard material.
  54336. * It is like a mirror but to see through a material.
  54337. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54338. * @param name Define the texture name
  54339. * @param size Define the size of the underlying texture
  54340. * @param scene Define the scene the refraction belongs to
  54341. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54342. */
  54343. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54344. /**
  54345. * Clone the refraction texture.
  54346. * @returns the cloned texture
  54347. */
  54348. clone(): RefractionTexture;
  54349. /**
  54350. * Serialize the texture to a JSON representation you could use in Parse later on
  54351. * @returns the serialized JSON representation
  54352. */
  54353. serialize(): any;
  54354. }
  54355. }
  54356. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54357. import { Nullable } from "babylonjs/types";
  54358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54359. import { Matrix } from "babylonjs/Maths/math.vector";
  54360. import { Engine } from "babylonjs/Engines/engine";
  54361. import { Scene } from "babylonjs/scene";
  54362. /**
  54363. * Defines the options related to the creation of an HtmlElementTexture
  54364. */
  54365. export interface IHtmlElementTextureOptions {
  54366. /**
  54367. * Defines wether mip maps should be created or not.
  54368. */
  54369. generateMipMaps?: boolean;
  54370. /**
  54371. * Defines the sampling mode of the texture.
  54372. */
  54373. samplingMode?: number;
  54374. /**
  54375. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54376. */
  54377. engine: Nullable<Engine>;
  54378. /**
  54379. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54380. */
  54381. scene: Nullable<Scene>;
  54382. }
  54383. /**
  54384. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54385. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54386. * is automatically managed.
  54387. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54388. * in your application.
  54389. *
  54390. * As the update is not automatic, you need to call them manually.
  54391. */
  54392. export class HtmlElementTexture extends BaseTexture {
  54393. /**
  54394. * The texture URL.
  54395. */
  54396. element: HTMLVideoElement | HTMLCanvasElement;
  54397. private static readonly DefaultOptions;
  54398. private _textureMatrix;
  54399. private _engine;
  54400. private _isVideo;
  54401. private _generateMipMaps;
  54402. private _samplingMode;
  54403. /**
  54404. * Instantiates a HtmlElementTexture from the following parameters.
  54405. *
  54406. * @param name Defines the name of the texture
  54407. * @param element Defines the video or canvas the texture is filled with
  54408. * @param options Defines the other none mandatory texture creation options
  54409. */
  54410. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54411. private _createInternalTexture;
  54412. /**
  54413. * Returns the texture matrix used in most of the material.
  54414. */
  54415. getTextureMatrix(): Matrix;
  54416. /**
  54417. * Updates the content of the texture.
  54418. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54419. */
  54420. update(invertY?: Nullable<boolean>): void;
  54421. }
  54422. }
  54423. declare module "babylonjs/Materials/Textures/index" {
  54424. export * from "babylonjs/Materials/Textures/baseTexture";
  54425. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54426. export * from "babylonjs/Materials/Textures/cubeTexture";
  54427. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54428. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54429. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54430. export * from "babylonjs/Materials/Textures/internalTexture";
  54431. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54432. export * from "babylonjs/Materials/Textures/Loaders/index";
  54433. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54434. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54435. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54436. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54437. export * from "babylonjs/Materials/Textures/rawTexture";
  54438. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54439. export * from "babylonjs/Materials/Textures/refractionTexture";
  54440. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54441. export * from "babylonjs/Materials/Textures/texture";
  54442. export * from "babylonjs/Materials/Textures/videoTexture";
  54443. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54444. }
  54445. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54446. /**
  54447. * Enum used to define the target of a block
  54448. */
  54449. export enum NodeMaterialBlockTargets {
  54450. /** Vertex shader */
  54451. Vertex = 1,
  54452. /** Fragment shader */
  54453. Fragment = 2,
  54454. /** Neutral */
  54455. Neutral = 4,
  54456. /** Vertex and Fragment */
  54457. VertexAndFragment = 3
  54458. }
  54459. }
  54460. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54461. /**
  54462. * Defines the kind of connection point for node based material
  54463. */
  54464. export enum NodeMaterialBlockConnectionPointTypes {
  54465. /** Float */
  54466. Float = 1,
  54467. /** Int */
  54468. Int = 2,
  54469. /** Vector2 */
  54470. Vector2 = 4,
  54471. /** Vector3 */
  54472. Vector3 = 8,
  54473. /** Vector4 */
  54474. Vector4 = 16,
  54475. /** Color3 */
  54476. Color3 = 32,
  54477. /** Color4 */
  54478. Color4 = 64,
  54479. /** Matrix */
  54480. Matrix = 128,
  54481. /** Detect type based on connection */
  54482. AutoDetect = 1024,
  54483. /** Output type that will be defined by input type */
  54484. BasedOnInput = 2048
  54485. }
  54486. }
  54487. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54488. /**
  54489. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54490. */
  54491. export enum NodeMaterialBlockConnectionPointMode {
  54492. /** Value is an uniform */
  54493. Uniform = 0,
  54494. /** Value is a mesh attribute */
  54495. Attribute = 1,
  54496. /** Value is a varying between vertex and fragment shaders */
  54497. Varying = 2,
  54498. /** Mode is undefined */
  54499. Undefined = 3
  54500. }
  54501. }
  54502. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54503. /**
  54504. * Enum used to define system values e.g. values automatically provided by the system
  54505. */
  54506. export enum NodeMaterialSystemValues {
  54507. /** World */
  54508. World = 1,
  54509. /** View */
  54510. View = 2,
  54511. /** Projection */
  54512. Projection = 3,
  54513. /** ViewProjection */
  54514. ViewProjection = 4,
  54515. /** WorldView */
  54516. WorldView = 5,
  54517. /** WorldViewProjection */
  54518. WorldViewProjection = 6,
  54519. /** CameraPosition */
  54520. CameraPosition = 7,
  54521. /** Fog Color */
  54522. FogColor = 8
  54523. }
  54524. }
  54525. declare module "babylonjs/Materials/Node/Enums/index" {
  54526. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54527. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54528. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54529. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54530. }
  54531. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54533. /**
  54534. * Root class for all node material optimizers
  54535. */
  54536. export class NodeMaterialOptimizer {
  54537. /**
  54538. * Function used to optimize a NodeMaterial graph
  54539. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54540. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54541. */
  54542. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54543. }
  54544. }
  54545. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54549. import { Scene } from "babylonjs/scene";
  54550. /**
  54551. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54552. */
  54553. export class TransformBlock extends NodeMaterialBlock {
  54554. /**
  54555. * Defines the value to use to complement W value to transform it to a Vector4
  54556. */
  54557. complementW: number;
  54558. /**
  54559. * Defines the value to use to complement z value to transform it to a Vector4
  54560. */
  54561. complementZ: number;
  54562. /**
  54563. * Creates a new TransformBlock
  54564. * @param name defines the block name
  54565. */
  54566. constructor(name: string);
  54567. /**
  54568. * Gets the current class name
  54569. * @returns the class name
  54570. */
  54571. getClassName(): string;
  54572. /**
  54573. * Gets the vector input
  54574. */
  54575. readonly vector: NodeMaterialConnectionPoint;
  54576. /**
  54577. * Gets the output component
  54578. */
  54579. readonly output: NodeMaterialConnectionPoint;
  54580. /**
  54581. * Gets the matrix transform input
  54582. */
  54583. readonly transform: NodeMaterialConnectionPoint;
  54584. protected _buildBlock(state: NodeMaterialBuildState): this;
  54585. serialize(): any;
  54586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54587. protected _dumpPropertiesCode(): string;
  54588. }
  54589. }
  54590. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54594. /**
  54595. * Block used to output the vertex position
  54596. */
  54597. export class VertexOutputBlock extends NodeMaterialBlock {
  54598. /**
  54599. * Creates a new VertexOutputBlock
  54600. * @param name defines the block name
  54601. */
  54602. constructor(name: string);
  54603. /**
  54604. * Gets the current class name
  54605. * @returns the class name
  54606. */
  54607. getClassName(): string;
  54608. /**
  54609. * Gets the vector input component
  54610. */
  54611. readonly vector: NodeMaterialConnectionPoint;
  54612. protected _buildBlock(state: NodeMaterialBuildState): this;
  54613. }
  54614. }
  54615. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54619. /**
  54620. * Block used to output the final color
  54621. */
  54622. export class FragmentOutputBlock extends NodeMaterialBlock {
  54623. /**
  54624. * Create a new FragmentOutputBlock
  54625. * @param name defines the block name
  54626. */
  54627. constructor(name: string);
  54628. /**
  54629. * Gets the current class name
  54630. * @returns the class name
  54631. */
  54632. getClassName(): string;
  54633. /**
  54634. * Gets the rgba input component
  54635. */
  54636. readonly rgba: NodeMaterialConnectionPoint;
  54637. /**
  54638. * Gets the rgb input component
  54639. */
  54640. readonly rgb: NodeMaterialConnectionPoint;
  54641. /**
  54642. * Gets the a input component
  54643. */
  54644. readonly a: NodeMaterialConnectionPoint;
  54645. protected _buildBlock(state: NodeMaterialBuildState): this;
  54646. }
  54647. }
  54648. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54654. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54655. import { Effect } from "babylonjs/Materials/effect";
  54656. import { Mesh } from "babylonjs/Meshes/mesh";
  54657. import { Nullable } from "babylonjs/types";
  54658. import { Scene } from "babylonjs/scene";
  54659. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54660. /**
  54661. * Block used to read a reflection texture from a sampler
  54662. */
  54663. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54664. private _define3DName;
  54665. private _defineCubicName;
  54666. private _defineExplicitName;
  54667. private _defineProjectionName;
  54668. private _defineLocalCubicName;
  54669. private _defineSphericalName;
  54670. private _definePlanarName;
  54671. private _defineEquirectangularName;
  54672. private _defineMirroredEquirectangularFixedName;
  54673. private _defineEquirectangularFixedName;
  54674. private _defineSkyboxName;
  54675. private _cubeSamplerName;
  54676. private _2DSamplerName;
  54677. private _positionUVWName;
  54678. private _directionWName;
  54679. private _reflectionCoordsName;
  54680. private _reflection2DCoordsName;
  54681. private _reflectionColorName;
  54682. private _reflectionMatrixName;
  54683. /**
  54684. * Gets or sets the texture associated with the node
  54685. */
  54686. texture: Nullable<BaseTexture>;
  54687. /**
  54688. * Create a new TextureBlock
  54689. * @param name defines the block name
  54690. */
  54691. constructor(name: string);
  54692. /**
  54693. * Gets the current class name
  54694. * @returns the class name
  54695. */
  54696. getClassName(): string;
  54697. /**
  54698. * Gets the world position input component
  54699. */
  54700. readonly position: NodeMaterialConnectionPoint;
  54701. /**
  54702. * Gets the world position input component
  54703. */
  54704. readonly worldPosition: NodeMaterialConnectionPoint;
  54705. /**
  54706. * Gets the world normal input component
  54707. */
  54708. readonly worldNormal: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the world input component
  54711. */
  54712. readonly world: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the camera (or eye) position component
  54715. */
  54716. readonly cameraPosition: NodeMaterialConnectionPoint;
  54717. /**
  54718. * Gets the view input component
  54719. */
  54720. readonly view: NodeMaterialConnectionPoint;
  54721. /**
  54722. * Gets the rgb output component
  54723. */
  54724. readonly rgb: NodeMaterialConnectionPoint;
  54725. /**
  54726. * Gets the r output component
  54727. */
  54728. readonly r: NodeMaterialConnectionPoint;
  54729. /**
  54730. * Gets the g output component
  54731. */
  54732. readonly g: NodeMaterialConnectionPoint;
  54733. /**
  54734. * Gets the b output component
  54735. */
  54736. readonly b: NodeMaterialConnectionPoint;
  54737. autoConfigure(material: NodeMaterial): void;
  54738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54739. isReady(): boolean;
  54740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54741. private _injectVertexCode;
  54742. private _writeOutput;
  54743. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54744. serialize(): any;
  54745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54746. }
  54747. }
  54748. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54750. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54751. import { Scene } from "babylonjs/scene";
  54752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54753. import { Matrix } from "babylonjs/Maths/math.vector";
  54754. import { Mesh } from "babylonjs/Meshes/mesh";
  54755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54756. import { Observable } from "babylonjs/Misc/observable";
  54757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54758. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54759. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54760. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54761. import { Nullable } from "babylonjs/types";
  54762. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54763. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54764. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54765. /**
  54766. * Interface used to configure the node material editor
  54767. */
  54768. export interface INodeMaterialEditorOptions {
  54769. /** Define the URl to load node editor script */
  54770. editorURL?: string;
  54771. }
  54772. /** @hidden */
  54773. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54774. /** BONES */
  54775. NUM_BONE_INFLUENCERS: number;
  54776. BonesPerMesh: number;
  54777. BONETEXTURE: boolean;
  54778. /** MORPH TARGETS */
  54779. MORPHTARGETS: boolean;
  54780. MORPHTARGETS_NORMAL: boolean;
  54781. MORPHTARGETS_TANGENT: boolean;
  54782. MORPHTARGETS_UV: boolean;
  54783. NUM_MORPH_INFLUENCERS: number;
  54784. /** IMAGE PROCESSING */
  54785. IMAGEPROCESSING: boolean;
  54786. VIGNETTE: boolean;
  54787. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54788. VIGNETTEBLENDMODEOPAQUE: boolean;
  54789. TONEMAPPING: boolean;
  54790. TONEMAPPING_ACES: boolean;
  54791. CONTRAST: boolean;
  54792. EXPOSURE: boolean;
  54793. COLORCURVES: boolean;
  54794. COLORGRADING: boolean;
  54795. COLORGRADING3D: boolean;
  54796. SAMPLER3DGREENDEPTH: boolean;
  54797. SAMPLER3DBGRMAP: boolean;
  54798. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54799. /** MISC. */
  54800. BUMPDIRECTUV: number;
  54801. constructor();
  54802. setValue(name: string, value: boolean): void;
  54803. }
  54804. /**
  54805. * Class used to configure NodeMaterial
  54806. */
  54807. export interface INodeMaterialOptions {
  54808. /**
  54809. * Defines if blocks should emit comments
  54810. */
  54811. emitComments: boolean;
  54812. }
  54813. /**
  54814. * Class used to create a node based material built by assembling shader blocks
  54815. */
  54816. export class NodeMaterial extends PushMaterial {
  54817. private static _BuildIdGenerator;
  54818. private _options;
  54819. private _vertexCompilationState;
  54820. private _fragmentCompilationState;
  54821. private _sharedData;
  54822. private _buildId;
  54823. private _buildWasSuccessful;
  54824. private _cachedWorldViewMatrix;
  54825. private _cachedWorldViewProjectionMatrix;
  54826. private _optimizers;
  54827. private _animationFrame;
  54828. /** Define the URl to load node editor script */
  54829. static EditorURL: string;
  54830. private BJSNODEMATERIALEDITOR;
  54831. /** Get the inspector from bundle or global */
  54832. private _getGlobalNodeMaterialEditor;
  54833. /**
  54834. * 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)
  54835. */
  54836. ignoreAlpha: boolean;
  54837. /**
  54838. * Defines the maximum number of lights that can be used in the material
  54839. */
  54840. maxSimultaneousLights: number;
  54841. /**
  54842. * Observable raised when the material is built
  54843. */
  54844. onBuildObservable: Observable<NodeMaterial>;
  54845. /**
  54846. * Gets or sets the root nodes of the material vertex shader
  54847. */
  54848. _vertexOutputNodes: NodeMaterialBlock[];
  54849. /**
  54850. * Gets or sets the root nodes of the material fragment (pixel) shader
  54851. */
  54852. _fragmentOutputNodes: NodeMaterialBlock[];
  54853. /** Gets or sets options to control the node material overall behavior */
  54854. options: INodeMaterialOptions;
  54855. /**
  54856. * Default configuration related to image processing available in the standard Material.
  54857. */
  54858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54859. /**
  54860. * Gets the image processing configuration used either in this material.
  54861. */
  54862. /**
  54863. * Sets the Default image processing configuration used either in the this material.
  54864. *
  54865. * If sets to null, the scene one is in use.
  54866. */
  54867. imageProcessingConfiguration: ImageProcessingConfiguration;
  54868. /**
  54869. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54870. */
  54871. attachedBlocks: NodeMaterialBlock[];
  54872. /**
  54873. * Create a new node based material
  54874. * @param name defines the material name
  54875. * @param scene defines the hosting scene
  54876. * @param options defines creation option
  54877. */
  54878. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54879. /**
  54880. * Gets the current class name of the material e.g. "NodeMaterial"
  54881. * @returns the class name
  54882. */
  54883. getClassName(): string;
  54884. /**
  54885. * Keep track of the image processing observer to allow dispose and replace.
  54886. */
  54887. private _imageProcessingObserver;
  54888. /**
  54889. * Attaches a new image processing configuration to the Standard Material.
  54890. * @param configuration
  54891. */
  54892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54893. /**
  54894. * Get a block by its name
  54895. * @param name defines the name of the block to retrieve
  54896. * @returns the required block or null if not found
  54897. */
  54898. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54899. /**
  54900. * Get a block by its name
  54901. * @param predicate defines the predicate used to find the good candidate
  54902. * @returns the required block or null if not found
  54903. */
  54904. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54905. /**
  54906. * Get an input block by its name
  54907. * @param predicate defines the predicate used to find the good candidate
  54908. * @returns the required input block or null if not found
  54909. */
  54910. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54911. /**
  54912. * Gets the list of input blocks attached to this material
  54913. * @returns an array of InputBlocks
  54914. */
  54915. getInputBlocks(): InputBlock[];
  54916. /**
  54917. * Adds a new optimizer to the list of optimizers
  54918. * @param optimizer defines the optimizers to add
  54919. * @returns the current material
  54920. */
  54921. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54922. /**
  54923. * Remove an optimizer from the list of optimizers
  54924. * @param optimizer defines the optimizers to remove
  54925. * @returns the current material
  54926. */
  54927. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54928. /**
  54929. * Add a new block to the list of output nodes
  54930. * @param node defines the node to add
  54931. * @returns the current material
  54932. */
  54933. addOutputNode(node: NodeMaterialBlock): this;
  54934. /**
  54935. * Remove a block from the list of root nodes
  54936. * @param node defines the node to remove
  54937. * @returns the current material
  54938. */
  54939. removeOutputNode(node: NodeMaterialBlock): this;
  54940. private _addVertexOutputNode;
  54941. private _removeVertexOutputNode;
  54942. private _addFragmentOutputNode;
  54943. private _removeFragmentOutputNode;
  54944. /**
  54945. * Specifies if the material will require alpha blending
  54946. * @returns a boolean specifying if alpha blending is needed
  54947. */
  54948. needAlphaBlending(): boolean;
  54949. /**
  54950. * Specifies if this material should be rendered in alpha test mode
  54951. * @returns a boolean specifying if an alpha test is needed.
  54952. */
  54953. needAlphaTesting(): boolean;
  54954. private _initializeBlock;
  54955. private _resetDualBlocks;
  54956. /**
  54957. * Build the material and generates the inner effect
  54958. * @param verbose defines if the build should log activity
  54959. */
  54960. build(verbose?: boolean): void;
  54961. /**
  54962. * Runs an otpimization phase to try to improve the shader code
  54963. */
  54964. optimize(): void;
  54965. private _prepareDefinesForAttributes;
  54966. /**
  54967. * Get if the submesh is ready to be used and all its information available.
  54968. * Child classes can use it to update shaders
  54969. * @param mesh defines the mesh to check
  54970. * @param subMesh defines which submesh to check
  54971. * @param useInstances specifies that instances should be used
  54972. * @returns a boolean indicating that the submesh is ready or not
  54973. */
  54974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54975. /**
  54976. * Get a string representing the shaders built by the current node graph
  54977. */
  54978. readonly compiledShaders: string;
  54979. /**
  54980. * Binds the world matrix to the material
  54981. * @param world defines the world transformation matrix
  54982. */
  54983. bindOnlyWorldMatrix(world: Matrix): void;
  54984. /**
  54985. * Binds the submesh to this material by preparing the effect and shader to draw
  54986. * @param world defines the world transformation matrix
  54987. * @param mesh defines the mesh containing the submesh
  54988. * @param subMesh defines the submesh to bind the material to
  54989. */
  54990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54991. /**
  54992. * Gets the active textures from the material
  54993. * @returns an array of textures
  54994. */
  54995. getActiveTextures(): BaseTexture[];
  54996. /**
  54997. * Gets the list of texture blocks
  54998. * @returns an array of texture blocks
  54999. */
  55000. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55001. /**
  55002. * Specifies if the material uses a texture
  55003. * @param texture defines the texture to check against the material
  55004. * @returns a boolean specifying if the material uses the texture
  55005. */
  55006. hasTexture(texture: BaseTexture): boolean;
  55007. /**
  55008. * Disposes the material
  55009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55011. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55012. */
  55013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55014. /** Creates the node editor window. */
  55015. private _createNodeEditor;
  55016. /**
  55017. * Launch the node material editor
  55018. * @param config Define the configuration of the editor
  55019. * @return a promise fulfilled when the node editor is visible
  55020. */
  55021. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55022. /**
  55023. * Clear the current material
  55024. */
  55025. clear(): void;
  55026. /**
  55027. * Clear the current material and set it to a default state
  55028. */
  55029. setToDefault(): void;
  55030. /**
  55031. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55032. * @param url defines the url to load from
  55033. * @returns a promise that will fullfil when the material is fully loaded
  55034. */
  55035. loadAsync(url: string): Promise<unknown>;
  55036. private _gatherBlocks;
  55037. /**
  55038. * Generate a string containing the code declaration required to create an equivalent of this material
  55039. * @returns a string
  55040. */
  55041. generateCode(): string;
  55042. /**
  55043. * Serializes this material in a JSON representation
  55044. * @returns the serialized material object
  55045. */
  55046. serialize(): any;
  55047. private _restoreConnections;
  55048. /**
  55049. * Clear the current graph and load a new one from a serialization object
  55050. * @param source defines the JSON representation of the material
  55051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55052. */
  55053. loadFromSerialization(source: any, rootUrl?: string): void;
  55054. /**
  55055. * Creates a node material from parsed material data
  55056. * @param source defines the JSON representation of the material
  55057. * @param scene defines the hosting scene
  55058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55059. * @returns a new node material
  55060. */
  55061. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55062. /**
  55063. * Creates a new node material set to default basic configuration
  55064. * @param name defines the name of the material
  55065. * @param scene defines the hosting scene
  55066. * @returns a new NodeMaterial
  55067. */
  55068. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55069. }
  55070. }
  55071. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55074. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55077. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55078. import { Effect } from "babylonjs/Materials/effect";
  55079. import { Mesh } from "babylonjs/Meshes/mesh";
  55080. import { Nullable } from "babylonjs/types";
  55081. import { Texture } from "babylonjs/Materials/Textures/texture";
  55082. import { Scene } from "babylonjs/scene";
  55083. /**
  55084. * Block used to read a texture from a sampler
  55085. */
  55086. export class TextureBlock extends NodeMaterialBlock {
  55087. private _defineName;
  55088. private _samplerName;
  55089. private _transformedUVName;
  55090. private _textureTransformName;
  55091. private _textureInfoName;
  55092. private _mainUVName;
  55093. private _mainUVDefineName;
  55094. /**
  55095. * Gets or sets the texture associated with the node
  55096. */
  55097. texture: Nullable<Texture>;
  55098. /**
  55099. * Create a new TextureBlock
  55100. * @param name defines the block name
  55101. */
  55102. constructor(name: string);
  55103. /**
  55104. * Gets the current class name
  55105. * @returns the class name
  55106. */
  55107. getClassName(): string;
  55108. /**
  55109. * Gets the uv input component
  55110. */
  55111. readonly uv: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the rgba output component
  55114. */
  55115. readonly rgba: NodeMaterialConnectionPoint;
  55116. /**
  55117. * Gets the rgb output component
  55118. */
  55119. readonly rgb: NodeMaterialConnectionPoint;
  55120. /**
  55121. * Gets the r output component
  55122. */
  55123. readonly r: NodeMaterialConnectionPoint;
  55124. /**
  55125. * Gets the g output component
  55126. */
  55127. readonly g: NodeMaterialConnectionPoint;
  55128. /**
  55129. * Gets the b output component
  55130. */
  55131. readonly b: NodeMaterialConnectionPoint;
  55132. /**
  55133. * Gets the a output component
  55134. */
  55135. readonly a: NodeMaterialConnectionPoint;
  55136. readonly target: NodeMaterialBlockTargets;
  55137. autoConfigure(material: NodeMaterial): void;
  55138. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55140. isReady(): boolean;
  55141. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55142. private readonly _isMixed;
  55143. private _injectVertexCode;
  55144. private _writeOutput;
  55145. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55146. protected _dumpPropertiesCode(): string;
  55147. serialize(): any;
  55148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55149. }
  55150. }
  55151. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55154. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55155. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55156. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55157. import { Scene } from "babylonjs/scene";
  55158. /**
  55159. * Class used to store shared data between 2 NodeMaterialBuildState
  55160. */
  55161. export class NodeMaterialBuildStateSharedData {
  55162. /**
  55163. * Gets the list of emitted varyings
  55164. */
  55165. temps: string[];
  55166. /**
  55167. * Gets the list of emitted varyings
  55168. */
  55169. varyings: string[];
  55170. /**
  55171. * Gets the varying declaration string
  55172. */
  55173. varyingDeclaration: string;
  55174. /**
  55175. * Input blocks
  55176. */
  55177. inputBlocks: InputBlock[];
  55178. /**
  55179. * Input blocks
  55180. */
  55181. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55182. /**
  55183. * Bindable blocks (Blocks that need to set data to the effect)
  55184. */
  55185. bindableBlocks: NodeMaterialBlock[];
  55186. /**
  55187. * List of blocks that can provide a compilation fallback
  55188. */
  55189. blocksWithFallbacks: NodeMaterialBlock[];
  55190. /**
  55191. * List of blocks that can provide a define update
  55192. */
  55193. blocksWithDefines: NodeMaterialBlock[];
  55194. /**
  55195. * List of blocks that can provide a repeatable content
  55196. */
  55197. repeatableContentBlocks: NodeMaterialBlock[];
  55198. /**
  55199. * List of blocks that can provide a dynamic list of uniforms
  55200. */
  55201. dynamicUniformBlocks: NodeMaterialBlock[];
  55202. /**
  55203. * List of blocks that can block the isReady function for the material
  55204. */
  55205. blockingBlocks: NodeMaterialBlock[];
  55206. /**
  55207. * Gets the list of animated inputs
  55208. */
  55209. animatedInputs: InputBlock[];
  55210. /**
  55211. * Build Id used to avoid multiple recompilations
  55212. */
  55213. buildId: number;
  55214. /** List of emitted variables */
  55215. variableNames: {
  55216. [key: string]: number;
  55217. };
  55218. /** List of emitted defines */
  55219. defineNames: {
  55220. [key: string]: number;
  55221. };
  55222. /** Should emit comments? */
  55223. emitComments: boolean;
  55224. /** Emit build activity */
  55225. verbose: boolean;
  55226. /** Gets or sets the hosting scene */
  55227. scene: Scene;
  55228. /**
  55229. * Gets the compilation hints emitted at compilation time
  55230. */
  55231. hints: {
  55232. needWorldViewMatrix: boolean;
  55233. needWorldViewProjectionMatrix: boolean;
  55234. needAlphaBlending: boolean;
  55235. needAlphaTesting: boolean;
  55236. };
  55237. /**
  55238. * List of compilation checks
  55239. */
  55240. checks: {
  55241. emitVertex: boolean;
  55242. emitFragment: boolean;
  55243. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55244. };
  55245. /** Creates a new shared data */
  55246. constructor();
  55247. /**
  55248. * Emits console errors and exceptions if there is a failing check
  55249. */
  55250. emitErrors(): void;
  55251. }
  55252. }
  55253. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55254. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55255. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55256. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55257. /**
  55258. * Class used to store node based material build state
  55259. */
  55260. export class NodeMaterialBuildState {
  55261. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55262. supportUniformBuffers: boolean;
  55263. /**
  55264. * Gets the list of emitted attributes
  55265. */
  55266. attributes: string[];
  55267. /**
  55268. * Gets the list of emitted uniforms
  55269. */
  55270. uniforms: string[];
  55271. /**
  55272. * Gets the list of emitted constants
  55273. */
  55274. constants: string[];
  55275. /**
  55276. * Gets the list of emitted uniform buffers
  55277. */
  55278. uniformBuffers: string[];
  55279. /**
  55280. * Gets the list of emitted samplers
  55281. */
  55282. samplers: string[];
  55283. /**
  55284. * Gets the list of emitted functions
  55285. */
  55286. functions: {
  55287. [key: string]: string;
  55288. };
  55289. /**
  55290. * Gets the list of emitted extensions
  55291. */
  55292. extensions: {
  55293. [key: string]: string;
  55294. };
  55295. /**
  55296. * Gets the target of the compilation state
  55297. */
  55298. target: NodeMaterialBlockTargets;
  55299. /**
  55300. * Gets the list of emitted counters
  55301. */
  55302. counters: {
  55303. [key: string]: number;
  55304. };
  55305. /**
  55306. * Shared data between multiple NodeMaterialBuildState instances
  55307. */
  55308. sharedData: NodeMaterialBuildStateSharedData;
  55309. /** @hidden */
  55310. _vertexState: NodeMaterialBuildState;
  55311. /** @hidden */
  55312. _attributeDeclaration: string;
  55313. /** @hidden */
  55314. _uniformDeclaration: string;
  55315. /** @hidden */
  55316. _constantDeclaration: string;
  55317. /** @hidden */
  55318. _samplerDeclaration: string;
  55319. /** @hidden */
  55320. _varyingTransfer: string;
  55321. private _repeatableContentAnchorIndex;
  55322. /** @hidden */
  55323. _builtCompilationString: string;
  55324. /**
  55325. * Gets the emitted compilation strings
  55326. */
  55327. compilationString: string;
  55328. /**
  55329. * Finalize the compilation strings
  55330. * @param state defines the current compilation state
  55331. */
  55332. finalize(state: NodeMaterialBuildState): void;
  55333. /** @hidden */
  55334. readonly _repeatableContentAnchor: string;
  55335. /** @hidden */
  55336. _getFreeVariableName(prefix: string): string;
  55337. /** @hidden */
  55338. _getFreeDefineName(prefix: string): string;
  55339. /** @hidden */
  55340. _excludeVariableName(name: string): void;
  55341. /** @hidden */
  55342. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55343. /** @hidden */
  55344. _emitExtension(name: string, extension: string): void;
  55345. /** @hidden */
  55346. _emitFunction(name: string, code: string, comments: string): void;
  55347. /** @hidden */
  55348. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55349. replaceStrings?: {
  55350. search: RegExp;
  55351. replace: string;
  55352. }[];
  55353. repeatKey?: string;
  55354. }): string;
  55355. /** @hidden */
  55356. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55357. repeatKey?: string;
  55358. removeAttributes?: boolean;
  55359. removeUniforms?: boolean;
  55360. removeVaryings?: boolean;
  55361. removeIfDef?: boolean;
  55362. replaceStrings?: {
  55363. search: RegExp;
  55364. replace: string;
  55365. }[];
  55366. }, storeKey?: string): void;
  55367. /** @hidden */
  55368. _registerTempVariable(name: string): boolean;
  55369. /** @hidden */
  55370. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55371. /** @hidden */
  55372. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55373. }
  55374. }
  55375. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55376. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55378. import { Nullable } from "babylonjs/types";
  55379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55380. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55381. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55383. import { Mesh } from "babylonjs/Meshes/mesh";
  55384. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55385. import { Scene } from "babylonjs/scene";
  55386. /**
  55387. * Defines a block that can be used inside a node based material
  55388. */
  55389. export class NodeMaterialBlock {
  55390. private _buildId;
  55391. private _buildTarget;
  55392. private _target;
  55393. private _isFinalMerger;
  55394. private _isInput;
  55395. /** @hidden */
  55396. _codeVariableName: string;
  55397. /** @hidden */
  55398. _inputs: NodeMaterialConnectionPoint[];
  55399. /** @hidden */
  55400. _outputs: NodeMaterialConnectionPoint[];
  55401. /** @hidden */
  55402. _preparationId: number;
  55403. /**
  55404. * Gets or sets the name of the block
  55405. */
  55406. name: string;
  55407. /**
  55408. * Gets or sets the unique id of the node
  55409. */
  55410. uniqueId: number;
  55411. /**
  55412. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55413. */
  55414. readonly isFinalMerger: boolean;
  55415. /**
  55416. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55417. */
  55418. readonly isInput: boolean;
  55419. /**
  55420. * Gets or sets the build Id
  55421. */
  55422. buildId: number;
  55423. /**
  55424. * Gets or sets the target of the block
  55425. */
  55426. target: NodeMaterialBlockTargets;
  55427. /**
  55428. * Gets the list of input points
  55429. */
  55430. readonly inputs: NodeMaterialConnectionPoint[];
  55431. /** Gets the list of output points */
  55432. readonly outputs: NodeMaterialConnectionPoint[];
  55433. /**
  55434. * Find an input by its name
  55435. * @param name defines the name of the input to look for
  55436. * @returns the input or null if not found
  55437. */
  55438. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55439. /**
  55440. * Find an output by its name
  55441. * @param name defines the name of the outputto look for
  55442. * @returns the output or null if not found
  55443. */
  55444. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55445. /**
  55446. * Creates a new NodeMaterialBlock
  55447. * @param name defines the block name
  55448. * @param target defines the target of that block (Vertex by default)
  55449. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55450. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55451. */
  55452. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55453. /**
  55454. * Initialize the block and prepare the context for build
  55455. * @param state defines the state that will be used for the build
  55456. */
  55457. initialize(state: NodeMaterialBuildState): void;
  55458. /**
  55459. * Bind data to effect. Will only be called for blocks with isBindable === true
  55460. * @param effect defines the effect to bind data to
  55461. * @param nodeMaterial defines the hosting NodeMaterial
  55462. * @param mesh defines the mesh that will be rendered
  55463. */
  55464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55465. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55466. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55467. protected _writeFloat(value: number): string;
  55468. /**
  55469. * Gets the current class name e.g. "NodeMaterialBlock"
  55470. * @returns the class name
  55471. */
  55472. getClassName(): string;
  55473. /**
  55474. * Register a new input. Must be called inside a block constructor
  55475. * @param name defines the connection point name
  55476. * @param type defines the connection point type
  55477. * @param isOptional defines a boolean indicating that this input can be omitted
  55478. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55479. * @returns the current block
  55480. */
  55481. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55482. /**
  55483. * Register a new output. Must be called inside a block constructor
  55484. * @param name defines the connection point name
  55485. * @param type defines the connection point type
  55486. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55487. * @returns the current block
  55488. */
  55489. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55490. /**
  55491. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55492. * @param forOutput defines an optional connection point to check compatibility with
  55493. * @returns the first available input or null
  55494. */
  55495. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55496. /**
  55497. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55498. * @param forBlock defines an optional block to check compatibility with
  55499. * @returns the first available input or null
  55500. */
  55501. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55502. /**
  55503. * Gets the sibling of the given output
  55504. * @param current defines the current output
  55505. * @returns the next output in the list or null
  55506. */
  55507. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55508. /**
  55509. * Connect current block with another block
  55510. * @param other defines the block to connect with
  55511. * @param options define the various options to help pick the right connections
  55512. * @returns the current block
  55513. */
  55514. connectTo(other: NodeMaterialBlock, options?: {
  55515. input?: string;
  55516. output?: string;
  55517. outputSwizzle?: string;
  55518. }): this | undefined;
  55519. protected _buildBlock(state: NodeMaterialBuildState): void;
  55520. /**
  55521. * Add uniforms, samplers and uniform buffers at compilation time
  55522. * @param state defines the state to update
  55523. * @param nodeMaterial defines the node material requesting the update
  55524. * @param defines defines the material defines to update
  55525. */
  55526. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55527. /**
  55528. * Add potential fallbacks if shader compilation fails
  55529. * @param mesh defines the mesh to be rendered
  55530. * @param fallbacks defines the current prioritized list of fallbacks
  55531. */
  55532. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55533. /**
  55534. * Initialize defines for shader compilation
  55535. * @param mesh defines the mesh to be rendered
  55536. * @param nodeMaterial defines the node material requesting the update
  55537. * @param defines defines the material defines to update
  55538. * @param useInstances specifies that instances should be used
  55539. */
  55540. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55541. /**
  55542. * Update defines for shader compilation
  55543. * @param mesh defines the mesh to be rendered
  55544. * @param nodeMaterial defines the node material requesting the update
  55545. * @param defines defines the material defines to update
  55546. * @param useInstances specifies that instances should be used
  55547. */
  55548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55549. /**
  55550. * Lets the block try to connect some inputs automatically
  55551. * @param material defines the hosting NodeMaterial
  55552. */
  55553. autoConfigure(material: NodeMaterial): void;
  55554. /**
  55555. * Function called when a block is declared as repeatable content generator
  55556. * @param vertexShaderState defines the current compilation state for the vertex shader
  55557. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55558. * @param mesh defines the mesh to be rendered
  55559. * @param defines defines the material defines to update
  55560. */
  55561. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55562. /**
  55563. * Checks if the block is ready
  55564. * @param mesh defines the mesh to be rendered
  55565. * @param nodeMaterial defines the node material requesting the update
  55566. * @param defines defines the material defines to update
  55567. * @param useInstances specifies that instances should be used
  55568. * @returns true if the block is ready
  55569. */
  55570. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55571. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55572. private _processBuild;
  55573. /**
  55574. * Compile the current node and generate the shader code
  55575. * @param state defines the current compilation state (uniforms, samplers, current string)
  55576. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55577. * @returns true if already built
  55578. */
  55579. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55580. protected _inputRename(name: string): string;
  55581. protected _outputRename(name: string): string;
  55582. protected _dumpPropertiesCode(): string;
  55583. /** @hidden */
  55584. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55585. /**
  55586. * Clone the current block to a new identical block
  55587. * @param scene defines the hosting scene
  55588. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55589. * @returns a copy of the current block
  55590. */
  55591. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55592. /**
  55593. * Serializes this block in a JSON representation
  55594. * @returns the serialized block object
  55595. */
  55596. serialize(): any;
  55597. /** @hidden */
  55598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55599. }
  55600. }
  55601. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55602. /**
  55603. * Enum defining the type of animations supported by InputBlock
  55604. */
  55605. export enum AnimatedInputBlockTypes {
  55606. /** No animation */
  55607. None = 0,
  55608. /** Time based animation. Will only work for floats */
  55609. Time = 1
  55610. }
  55611. }
  55612. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55614. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55615. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55616. import { Nullable } from "babylonjs/types";
  55617. import { Effect } from "babylonjs/Materials/effect";
  55618. import { Matrix } from "babylonjs/Maths/math.vector";
  55619. import { Scene } from "babylonjs/scene";
  55620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55622. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55623. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55624. /**
  55625. * Block used to expose an input value
  55626. */
  55627. export class InputBlock extends NodeMaterialBlock {
  55628. private _mode;
  55629. private _associatedVariableName;
  55630. private _storedValue;
  55631. private _valueCallback;
  55632. private _type;
  55633. private _animationType;
  55634. /** Gets or set a value used to limit the range of float values */
  55635. min: number;
  55636. /** Gets or set a value used to limit the range of float values */
  55637. max: number;
  55638. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55639. matrixMode: number;
  55640. /** @hidden */
  55641. _systemValue: Nullable<NodeMaterialSystemValues>;
  55642. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55643. visibleInInspector: boolean;
  55644. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55645. isConstant: boolean;
  55646. /**
  55647. * Gets or sets the connection point type (default is float)
  55648. */
  55649. readonly type: NodeMaterialBlockConnectionPointTypes;
  55650. /**
  55651. * Creates a new InputBlock
  55652. * @param name defines the block name
  55653. * @param target defines the target of that block (Vertex by default)
  55654. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55655. */
  55656. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55657. /**
  55658. * Gets the output component
  55659. */
  55660. readonly output: NodeMaterialConnectionPoint;
  55661. /**
  55662. * Set the source of this connection point to a vertex attribute
  55663. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55664. * @returns the current connection point
  55665. */
  55666. setAsAttribute(attributeName?: string): InputBlock;
  55667. /**
  55668. * Set the source of this connection point to a system value
  55669. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55670. * @returns the current connection point
  55671. */
  55672. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55673. /**
  55674. * Gets or sets the value of that point.
  55675. * Please note that this value will be ignored if valueCallback is defined
  55676. */
  55677. value: any;
  55678. /**
  55679. * Gets or sets a callback used to get the value of that point.
  55680. * Please note that setting this value will force the connection point to ignore the value property
  55681. */
  55682. valueCallback: () => any;
  55683. /**
  55684. * Gets or sets the associated variable name in the shader
  55685. */
  55686. associatedVariableName: string;
  55687. /** Gets or sets the type of animation applied to the input */
  55688. animationType: AnimatedInputBlockTypes;
  55689. /**
  55690. * Gets a boolean indicating that this connection point not defined yet
  55691. */
  55692. readonly isUndefined: boolean;
  55693. /**
  55694. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55695. * In this case the connection point name must be the name of the uniform to use.
  55696. * Can only be set on inputs
  55697. */
  55698. isUniform: boolean;
  55699. /**
  55700. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55701. * In this case the connection point name must be the name of the attribute to use
  55702. * Can only be set on inputs
  55703. */
  55704. isAttribute: boolean;
  55705. /**
  55706. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55707. * Can only be set on exit points
  55708. */
  55709. isVarying: boolean;
  55710. /**
  55711. * Gets a boolean indicating that the current connection point is a system value
  55712. */
  55713. readonly isSystemValue: boolean;
  55714. /**
  55715. * Gets or sets the current well known value or null if not defined as a system value
  55716. */
  55717. systemValue: Nullable<NodeMaterialSystemValues>;
  55718. /**
  55719. * Gets the current class name
  55720. * @returns the class name
  55721. */
  55722. getClassName(): string;
  55723. /**
  55724. * Animate the input if animationType !== None
  55725. * @param scene defines the rendering scene
  55726. */
  55727. animate(scene: Scene): void;
  55728. private _emitDefine;
  55729. initialize(state: NodeMaterialBuildState): void;
  55730. /**
  55731. * Set the input block to its default value (based on its type)
  55732. */
  55733. setDefaultValue(): void;
  55734. private _emitConstant;
  55735. private _emit;
  55736. /** @hidden */
  55737. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55738. /** @hidden */
  55739. _transmit(effect: Effect, scene: Scene): void;
  55740. protected _buildBlock(state: NodeMaterialBuildState): void;
  55741. protected _dumpPropertiesCode(): string;
  55742. serialize(): any;
  55743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55744. }
  55745. }
  55746. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55747. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55748. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55749. import { Nullable } from "babylonjs/types";
  55750. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55752. /**
  55753. * Defines a connection point for a block
  55754. */
  55755. export class NodeMaterialConnectionPoint {
  55756. /** @hidden */
  55757. _ownerBlock: NodeMaterialBlock;
  55758. /** @hidden */
  55759. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55760. private _endpoints;
  55761. private _associatedVariableName;
  55762. /** @hidden */
  55763. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55764. /** @hidden */
  55765. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55766. private _type;
  55767. /** @hidden */
  55768. _enforceAssociatedVariableName: boolean;
  55769. /**
  55770. * Gets or sets the additional types supported by this connection point
  55771. */
  55772. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55773. /**
  55774. * Gets or sets the additional types excluded by this connection point
  55775. */
  55776. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55777. /**
  55778. * Gets or sets the associated variable name in the shader
  55779. */
  55780. associatedVariableName: string;
  55781. /**
  55782. * Gets or sets the connection point type (default is float)
  55783. */
  55784. type: NodeMaterialBlockConnectionPointTypes;
  55785. /**
  55786. * Gets or sets the connection point name
  55787. */
  55788. name: string;
  55789. /**
  55790. * Gets or sets a boolean indicating that this connection point can be omitted
  55791. */
  55792. isOptional: boolean;
  55793. /**
  55794. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55795. */
  55796. define: string;
  55797. /** Gets or sets the target of that connection point */
  55798. target: NodeMaterialBlockTargets;
  55799. /**
  55800. * Gets a boolean indicating that the current point is connected
  55801. */
  55802. readonly isConnected: boolean;
  55803. /**
  55804. * Gets a boolean indicating that the current point is connected to an input block
  55805. */
  55806. readonly isConnectedToInputBlock: boolean;
  55807. /**
  55808. * Gets a the connected input block (if any)
  55809. */
  55810. readonly connectInputBlock: Nullable<InputBlock>;
  55811. /** Get the other side of the connection (if any) */
  55812. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55813. /** Get the block that owns this connection point */
  55814. readonly ownerBlock: NodeMaterialBlock;
  55815. /** Get the block connected on the other side of this connection (if any) */
  55816. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55817. /** Get the block connected on the endpoints of this connection (if any) */
  55818. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55819. /** Gets the list of connected endpoints */
  55820. readonly endpoints: NodeMaterialConnectionPoint[];
  55821. /** Gets a boolean indicating if that output point is connected to at least one input */
  55822. readonly hasEndpoints: boolean;
  55823. /**
  55824. * Creates a new connection point
  55825. * @param name defines the connection point name
  55826. * @param ownerBlock defines the block hosting this connection point
  55827. */
  55828. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55829. /**
  55830. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55831. * @returns the class name
  55832. */
  55833. getClassName(): string;
  55834. /**
  55835. * Gets an boolean indicating if the current point can be connected to another point
  55836. * @param connectionPoint defines the other connection point
  55837. * @returns true if the connection is possible
  55838. */
  55839. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55840. /**
  55841. * Connect this point to another connection point
  55842. * @param connectionPoint defines the other connection point
  55843. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55844. * @returns the current connection point
  55845. */
  55846. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55847. /**
  55848. * Disconnect this point from one of his endpoint
  55849. * @param endpoint defines the other connection point
  55850. * @returns the current connection point
  55851. */
  55852. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55853. /**
  55854. * Serializes this point in a JSON representation
  55855. * @returns the serialized point object
  55856. */
  55857. serialize(): any;
  55858. }
  55859. }
  55860. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55864. import { Mesh } from "babylonjs/Meshes/mesh";
  55865. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55867. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55868. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55870. /**
  55871. * Block used to add support for vertex skinning (bones)
  55872. */
  55873. export class BonesBlock extends NodeMaterialBlock {
  55874. /**
  55875. * Creates a new BonesBlock
  55876. * @param name defines the block name
  55877. */
  55878. constructor(name: string);
  55879. /**
  55880. * Initialize the block and prepare the context for build
  55881. * @param state defines the state that will be used for the build
  55882. */
  55883. initialize(state: NodeMaterialBuildState): void;
  55884. /**
  55885. * Gets the current class name
  55886. * @returns the class name
  55887. */
  55888. getClassName(): string;
  55889. /**
  55890. * Gets the matrix indices input component
  55891. */
  55892. readonly matricesIndices: NodeMaterialConnectionPoint;
  55893. /**
  55894. * Gets the matrix weights input component
  55895. */
  55896. readonly matricesWeights: NodeMaterialConnectionPoint;
  55897. /**
  55898. * Gets the extra matrix indices input component
  55899. */
  55900. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55901. /**
  55902. * Gets the extra matrix weights input component
  55903. */
  55904. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55905. /**
  55906. * Gets the world input component
  55907. */
  55908. readonly world: NodeMaterialConnectionPoint;
  55909. /**
  55910. * Gets the output component
  55911. */
  55912. readonly output: NodeMaterialConnectionPoint;
  55913. autoConfigure(material: NodeMaterial): void;
  55914. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55915. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55917. protected _buildBlock(state: NodeMaterialBuildState): this;
  55918. }
  55919. }
  55920. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55925. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55926. /**
  55927. * Block used to add support for instances
  55928. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55929. */
  55930. export class InstancesBlock extends NodeMaterialBlock {
  55931. /**
  55932. * Creates a new InstancesBlock
  55933. * @param name defines the block name
  55934. */
  55935. constructor(name: string);
  55936. /**
  55937. * Gets the current class name
  55938. * @returns the class name
  55939. */
  55940. getClassName(): string;
  55941. /**
  55942. * Gets the first world row input component
  55943. */
  55944. readonly world0: NodeMaterialConnectionPoint;
  55945. /**
  55946. * Gets the second world row input component
  55947. */
  55948. readonly world1: NodeMaterialConnectionPoint;
  55949. /**
  55950. * Gets the third world row input component
  55951. */
  55952. readonly world2: NodeMaterialConnectionPoint;
  55953. /**
  55954. * Gets the forth world row input component
  55955. */
  55956. readonly world3: NodeMaterialConnectionPoint;
  55957. /**
  55958. * Gets the world input component
  55959. */
  55960. readonly world: NodeMaterialConnectionPoint;
  55961. /**
  55962. * Gets the output component
  55963. */
  55964. readonly output: NodeMaterialConnectionPoint;
  55965. autoConfigure(material: NodeMaterial): void;
  55966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55967. protected _buildBlock(state: NodeMaterialBuildState): this;
  55968. }
  55969. }
  55970. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55975. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55976. import { Effect } from "babylonjs/Materials/effect";
  55977. import { Mesh } from "babylonjs/Meshes/mesh";
  55978. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55979. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55980. /**
  55981. * Block used to add morph targets support to vertex shader
  55982. */
  55983. export class MorphTargetsBlock extends NodeMaterialBlock {
  55984. private _repeatableContentAnchor;
  55985. private _repeatebleContentGenerated;
  55986. /**
  55987. * Create a new MorphTargetsBlock
  55988. * @param name defines the block name
  55989. */
  55990. constructor(name: string);
  55991. /**
  55992. * Gets the current class name
  55993. * @returns the class name
  55994. */
  55995. getClassName(): string;
  55996. /**
  55997. * Gets the position input component
  55998. */
  55999. readonly position: NodeMaterialConnectionPoint;
  56000. /**
  56001. * Gets the normal input component
  56002. */
  56003. readonly normal: NodeMaterialConnectionPoint;
  56004. /**
  56005. * Gets the tangent input component
  56006. */
  56007. readonly tangent: NodeMaterialConnectionPoint;
  56008. /**
  56009. * Gets the tangent input component
  56010. */
  56011. readonly uv: NodeMaterialConnectionPoint;
  56012. /**
  56013. * Gets the position output component
  56014. */
  56015. readonly positionOutput: NodeMaterialConnectionPoint;
  56016. /**
  56017. * Gets the normal output component
  56018. */
  56019. readonly normalOutput: NodeMaterialConnectionPoint;
  56020. /**
  56021. * Gets the tangent output component
  56022. */
  56023. readonly tangentOutput: NodeMaterialConnectionPoint;
  56024. /**
  56025. * Gets the tangent output component
  56026. */
  56027. readonly uvOutput: NodeMaterialConnectionPoint;
  56028. initialize(state: NodeMaterialBuildState): void;
  56029. autoConfigure(material: NodeMaterial): void;
  56030. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56031. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56032. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56033. protected _buildBlock(state: NodeMaterialBuildState): this;
  56034. }
  56035. }
  56036. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56038. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56040. import { Nullable } from "babylonjs/types";
  56041. import { Scene } from "babylonjs/scene";
  56042. import { Effect } from "babylonjs/Materials/effect";
  56043. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56044. import { Mesh } from "babylonjs/Meshes/mesh";
  56045. import { Light } from "babylonjs/Lights/light";
  56046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56047. /**
  56048. * Block used to get data information from a light
  56049. */
  56050. export class LightInformationBlock extends NodeMaterialBlock {
  56051. private _lightDataUniformName;
  56052. private _lightColorUniformName;
  56053. private _lightTypeDefineName;
  56054. /**
  56055. * Gets or sets the light associated with this block
  56056. */
  56057. light: Nullable<Light>;
  56058. /**
  56059. * Creates a new LightInformationBlock
  56060. * @param name defines the block name
  56061. */
  56062. constructor(name: string);
  56063. /**
  56064. * Gets the current class name
  56065. * @returns the class name
  56066. */
  56067. getClassName(): string;
  56068. /**
  56069. * Gets the world position input component
  56070. */
  56071. readonly worldPosition: NodeMaterialConnectionPoint;
  56072. /**
  56073. * Gets the direction output component
  56074. */
  56075. readonly direction: NodeMaterialConnectionPoint;
  56076. /**
  56077. * Gets the direction output component
  56078. */
  56079. readonly color: NodeMaterialConnectionPoint;
  56080. /**
  56081. * Gets the direction output component
  56082. */
  56083. readonly intensity: NodeMaterialConnectionPoint;
  56084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56086. protected _buildBlock(state: NodeMaterialBuildState): this;
  56087. serialize(): any;
  56088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56089. }
  56090. }
  56091. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56092. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56093. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56094. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56095. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56096. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56097. }
  56098. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56103. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56104. import { Effect } from "babylonjs/Materials/effect";
  56105. import { Mesh } from "babylonjs/Meshes/mesh";
  56106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56107. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56108. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56109. /**
  56110. * Block used to add image processing support to fragment shader
  56111. */
  56112. export class ImageProcessingBlock extends NodeMaterialBlock {
  56113. /**
  56114. * Create a new ImageProcessingBlock
  56115. * @param name defines the block name
  56116. */
  56117. constructor(name: string);
  56118. /**
  56119. * Gets the current class name
  56120. * @returns the class name
  56121. */
  56122. getClassName(): string;
  56123. /**
  56124. * Gets the color input component
  56125. */
  56126. readonly color: NodeMaterialConnectionPoint;
  56127. /**
  56128. * Gets the output component
  56129. */
  56130. readonly output: NodeMaterialConnectionPoint;
  56131. /**
  56132. * Initialize the block and prepare the context for build
  56133. * @param state defines the state that will be used for the build
  56134. */
  56135. initialize(state: NodeMaterialBuildState): void;
  56136. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56139. protected _buildBlock(state: NodeMaterialBuildState): this;
  56140. }
  56141. }
  56142. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56146. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56148. import { Effect } from "babylonjs/Materials/effect";
  56149. import { Mesh } from "babylonjs/Meshes/mesh";
  56150. import { Scene } from "babylonjs/scene";
  56151. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56152. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56153. /**
  56154. * Block used to pertub normals based on a normal map
  56155. */
  56156. export class PerturbNormalBlock extends NodeMaterialBlock {
  56157. private _tangentSpaceParameterName;
  56158. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56159. invertX: boolean;
  56160. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56161. invertY: boolean;
  56162. /**
  56163. * Create a new PerturbNormalBlock
  56164. * @param name defines the block name
  56165. */
  56166. constructor(name: string);
  56167. /**
  56168. * Gets the current class name
  56169. * @returns the class name
  56170. */
  56171. getClassName(): string;
  56172. /**
  56173. * Gets the world position input component
  56174. */
  56175. readonly worldPosition: NodeMaterialConnectionPoint;
  56176. /**
  56177. * Gets the world normal input component
  56178. */
  56179. readonly worldNormal: NodeMaterialConnectionPoint;
  56180. /**
  56181. * Gets the uv input component
  56182. */
  56183. readonly uv: NodeMaterialConnectionPoint;
  56184. /**
  56185. * Gets the normal map color input component
  56186. */
  56187. readonly normalMapColor: NodeMaterialConnectionPoint;
  56188. /**
  56189. * Gets the strength input component
  56190. */
  56191. readonly strength: NodeMaterialConnectionPoint;
  56192. /**
  56193. * Gets the output component
  56194. */
  56195. readonly output: NodeMaterialConnectionPoint;
  56196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56197. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56198. autoConfigure(material: NodeMaterial): void;
  56199. protected _buildBlock(state: NodeMaterialBuildState): this;
  56200. protected _dumpPropertiesCode(): string;
  56201. serialize(): any;
  56202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56203. }
  56204. }
  56205. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56209. /**
  56210. * Block used to discard a pixel if a value is smaller than a cutoff
  56211. */
  56212. export class DiscardBlock extends NodeMaterialBlock {
  56213. /**
  56214. * Create a new DiscardBlock
  56215. * @param name defines the block name
  56216. */
  56217. constructor(name: string);
  56218. /**
  56219. * Gets the current class name
  56220. * @returns the class name
  56221. */
  56222. getClassName(): string;
  56223. /**
  56224. * Gets the color input component
  56225. */
  56226. readonly value: NodeMaterialConnectionPoint;
  56227. /**
  56228. * Gets the cutoff input component
  56229. */
  56230. readonly cutoff: NodeMaterialConnectionPoint;
  56231. protected _buildBlock(state: NodeMaterialBuildState): this;
  56232. }
  56233. }
  56234. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56235. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56236. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56237. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56238. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56239. }
  56240. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56243. import { Mesh } from "babylonjs/Meshes/mesh";
  56244. import { Effect } from "babylonjs/Materials/effect";
  56245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56247. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56248. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56249. /**
  56250. * Block used to add support for scene fog
  56251. */
  56252. export class FogBlock extends NodeMaterialBlock {
  56253. private _fogDistanceName;
  56254. private _fogParameters;
  56255. /**
  56256. * Create a new FogBlock
  56257. * @param name defines the block name
  56258. */
  56259. constructor(name: string);
  56260. /**
  56261. * Gets the current class name
  56262. * @returns the class name
  56263. */
  56264. getClassName(): string;
  56265. /**
  56266. * Gets the world position input component
  56267. */
  56268. readonly worldPosition: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the view input component
  56271. */
  56272. readonly view: NodeMaterialConnectionPoint;
  56273. /**
  56274. * Gets the color input component
  56275. */
  56276. readonly input: NodeMaterialConnectionPoint;
  56277. /**
  56278. * Gets the fog color input component
  56279. */
  56280. readonly fogColor: NodeMaterialConnectionPoint;
  56281. /**
  56282. * Gets the output component
  56283. */
  56284. readonly output: NodeMaterialConnectionPoint;
  56285. autoConfigure(material: NodeMaterial): void;
  56286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56287. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56288. protected _buildBlock(state: NodeMaterialBuildState): this;
  56289. }
  56290. }
  56291. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56296. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56297. import { Effect } from "babylonjs/Materials/effect";
  56298. import { Mesh } from "babylonjs/Meshes/mesh";
  56299. import { Light } from "babylonjs/Lights/light";
  56300. import { Nullable } from "babylonjs/types";
  56301. import { Scene } from "babylonjs/scene";
  56302. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56303. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56304. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56305. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56306. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56307. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56308. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56309. /**
  56310. * Block used to add light in the fragment shader
  56311. */
  56312. export class LightBlock extends NodeMaterialBlock {
  56313. private _lightId;
  56314. /**
  56315. * Gets or sets the light associated with this block
  56316. */
  56317. light: Nullable<Light>;
  56318. /**
  56319. * Create a new LightBlock
  56320. * @param name defines the block name
  56321. */
  56322. constructor(name: string);
  56323. /**
  56324. * Gets the current class name
  56325. * @returns the class name
  56326. */
  56327. getClassName(): string;
  56328. /**
  56329. * Gets the world position input component
  56330. */
  56331. readonly worldPosition: NodeMaterialConnectionPoint;
  56332. /**
  56333. * Gets the world normal input component
  56334. */
  56335. readonly worldNormal: NodeMaterialConnectionPoint;
  56336. /**
  56337. * Gets the camera (or eye) position component
  56338. */
  56339. readonly cameraPosition: NodeMaterialConnectionPoint;
  56340. /**
  56341. * Gets the diffuse output component
  56342. */
  56343. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56344. /**
  56345. * Gets the specular output component
  56346. */
  56347. readonly specularOutput: NodeMaterialConnectionPoint;
  56348. autoConfigure(material: NodeMaterial): void;
  56349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56350. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56351. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56352. private _injectVertexCode;
  56353. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56354. serialize(): any;
  56355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56356. }
  56357. }
  56358. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56359. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56360. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56361. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56362. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56363. }
  56364. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56365. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56366. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56367. }
  56368. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56372. /**
  56373. * Block used to multiply 2 values
  56374. */
  56375. export class MultiplyBlock extends NodeMaterialBlock {
  56376. /**
  56377. * Creates a new MultiplyBlock
  56378. * @param name defines the block name
  56379. */
  56380. constructor(name: string);
  56381. /**
  56382. * Gets the current class name
  56383. * @returns the class name
  56384. */
  56385. getClassName(): string;
  56386. /**
  56387. * Gets the left operand input component
  56388. */
  56389. readonly left: NodeMaterialConnectionPoint;
  56390. /**
  56391. * Gets the right operand input component
  56392. */
  56393. readonly right: NodeMaterialConnectionPoint;
  56394. /**
  56395. * Gets the output component
  56396. */
  56397. readonly output: NodeMaterialConnectionPoint;
  56398. protected _buildBlock(state: NodeMaterialBuildState): this;
  56399. }
  56400. }
  56401. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56405. /**
  56406. * Block used to add 2 vectors
  56407. */
  56408. export class AddBlock extends NodeMaterialBlock {
  56409. /**
  56410. * Creates a new AddBlock
  56411. * @param name defines the block name
  56412. */
  56413. constructor(name: string);
  56414. /**
  56415. * Gets the current class name
  56416. * @returns the class name
  56417. */
  56418. getClassName(): string;
  56419. /**
  56420. * Gets the left operand input component
  56421. */
  56422. readonly left: NodeMaterialConnectionPoint;
  56423. /**
  56424. * Gets the right operand input component
  56425. */
  56426. readonly right: NodeMaterialConnectionPoint;
  56427. /**
  56428. * Gets the output component
  56429. */
  56430. readonly output: NodeMaterialConnectionPoint;
  56431. protected _buildBlock(state: NodeMaterialBuildState): this;
  56432. }
  56433. }
  56434. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56438. /**
  56439. * Block used to scale a vector by a float
  56440. */
  56441. export class ScaleBlock extends NodeMaterialBlock {
  56442. /**
  56443. * Creates a new ScaleBlock
  56444. * @param name defines the block name
  56445. */
  56446. constructor(name: string);
  56447. /**
  56448. * Gets the current class name
  56449. * @returns the class name
  56450. */
  56451. getClassName(): string;
  56452. /**
  56453. * Gets the input component
  56454. */
  56455. readonly input: NodeMaterialConnectionPoint;
  56456. /**
  56457. * Gets the factor input component
  56458. */
  56459. readonly factor: NodeMaterialConnectionPoint;
  56460. /**
  56461. * Gets the output component
  56462. */
  56463. readonly output: NodeMaterialConnectionPoint;
  56464. protected _buildBlock(state: NodeMaterialBuildState): this;
  56465. }
  56466. }
  56467. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56470. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56471. import { Scene } from "babylonjs/scene";
  56472. /**
  56473. * Block used to clamp a float
  56474. */
  56475. export class ClampBlock extends NodeMaterialBlock {
  56476. /** Gets or sets the minimum range */
  56477. minimum: number;
  56478. /** Gets or sets the maximum range */
  56479. maximum: number;
  56480. /**
  56481. * Creates a new ClampBlock
  56482. * @param name defines the block name
  56483. */
  56484. constructor(name: string);
  56485. /**
  56486. * Gets the current class name
  56487. * @returns the class name
  56488. */
  56489. getClassName(): string;
  56490. /**
  56491. * Gets the value input component
  56492. */
  56493. readonly value: NodeMaterialConnectionPoint;
  56494. /**
  56495. * Gets the output component
  56496. */
  56497. readonly output: NodeMaterialConnectionPoint;
  56498. protected _buildBlock(state: NodeMaterialBuildState): this;
  56499. protected _dumpPropertiesCode(): string;
  56500. serialize(): any;
  56501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56502. }
  56503. }
  56504. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56508. /**
  56509. * Block used to apply a cross product between 2 vectors
  56510. */
  56511. export class CrossBlock extends NodeMaterialBlock {
  56512. /**
  56513. * Creates a new CrossBlock
  56514. * @param name defines the block name
  56515. */
  56516. constructor(name: string);
  56517. /**
  56518. * Gets the current class name
  56519. * @returns the class name
  56520. */
  56521. getClassName(): string;
  56522. /**
  56523. * Gets the left operand input component
  56524. */
  56525. readonly left: NodeMaterialConnectionPoint;
  56526. /**
  56527. * Gets the right operand input component
  56528. */
  56529. readonly right: NodeMaterialConnectionPoint;
  56530. /**
  56531. * Gets the output component
  56532. */
  56533. readonly output: NodeMaterialConnectionPoint;
  56534. protected _buildBlock(state: NodeMaterialBuildState): this;
  56535. }
  56536. }
  56537. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56541. /**
  56542. * Block used to apply a dot product between 2 vectors
  56543. */
  56544. export class DotBlock extends NodeMaterialBlock {
  56545. /**
  56546. * Creates a new DotBlock
  56547. * @param name defines the block name
  56548. */
  56549. constructor(name: string);
  56550. /**
  56551. * Gets the current class name
  56552. * @returns the class name
  56553. */
  56554. getClassName(): string;
  56555. /**
  56556. * Gets the left operand input component
  56557. */
  56558. readonly left: NodeMaterialConnectionPoint;
  56559. /**
  56560. * Gets the right operand input component
  56561. */
  56562. readonly right: NodeMaterialConnectionPoint;
  56563. /**
  56564. * Gets the output component
  56565. */
  56566. readonly output: NodeMaterialConnectionPoint;
  56567. protected _buildBlock(state: NodeMaterialBuildState): this;
  56568. }
  56569. }
  56570. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56574. import { Vector2 } from "babylonjs/Maths/math.vector";
  56575. import { Scene } from "babylonjs/scene";
  56576. /**
  56577. * Block used to remap a float from a range to a new one
  56578. */
  56579. export class RemapBlock extends NodeMaterialBlock {
  56580. /**
  56581. * Gets or sets the source range
  56582. */
  56583. sourceRange: Vector2;
  56584. /**
  56585. * Gets or sets the target range
  56586. */
  56587. targetRange: Vector2;
  56588. /**
  56589. * Creates a new RemapBlock
  56590. * @param name defines the block name
  56591. */
  56592. constructor(name: string);
  56593. /**
  56594. * Gets the current class name
  56595. * @returns the class name
  56596. */
  56597. getClassName(): string;
  56598. /**
  56599. * Gets the input component
  56600. */
  56601. readonly input: NodeMaterialConnectionPoint;
  56602. /**
  56603. * Gets the source min input component
  56604. */
  56605. readonly sourceMin: NodeMaterialConnectionPoint;
  56606. /**
  56607. * Gets the source max input component
  56608. */
  56609. readonly sourceMax: NodeMaterialConnectionPoint;
  56610. /**
  56611. * Gets the target min input component
  56612. */
  56613. readonly targetMin: NodeMaterialConnectionPoint;
  56614. /**
  56615. * Gets the target max input component
  56616. */
  56617. readonly targetMax: NodeMaterialConnectionPoint;
  56618. /**
  56619. * Gets the output component
  56620. */
  56621. readonly output: NodeMaterialConnectionPoint;
  56622. protected _buildBlock(state: NodeMaterialBuildState): this;
  56623. protected _dumpPropertiesCode(): string;
  56624. serialize(): any;
  56625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56626. }
  56627. }
  56628. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56632. /**
  56633. * Block used to normalize a vector
  56634. */
  56635. export class NormalizeBlock extends NodeMaterialBlock {
  56636. /**
  56637. * Creates a new NormalizeBlock
  56638. * @param name defines the block name
  56639. */
  56640. constructor(name: string);
  56641. /**
  56642. * Gets the current class name
  56643. * @returns the class name
  56644. */
  56645. getClassName(): string;
  56646. /**
  56647. * Gets the input component
  56648. */
  56649. readonly input: NodeMaterialConnectionPoint;
  56650. /**
  56651. * Gets the output component
  56652. */
  56653. readonly output: NodeMaterialConnectionPoint;
  56654. protected _buildBlock(state: NodeMaterialBuildState): this;
  56655. }
  56656. }
  56657. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56661. import { Scene } from "babylonjs/scene";
  56662. /**
  56663. * Operations supported by the Trigonometry block
  56664. */
  56665. export enum TrigonometryBlockOperations {
  56666. /** Cos */
  56667. Cos = 0,
  56668. /** Sin */
  56669. Sin = 1,
  56670. /** Abs */
  56671. Abs = 2,
  56672. /** Exp */
  56673. Exp = 3,
  56674. /** Exp2 */
  56675. Exp2 = 4,
  56676. /** Round */
  56677. Round = 5,
  56678. /** Floor */
  56679. Floor = 6,
  56680. /** Ceiling */
  56681. Ceiling = 7,
  56682. /** Square root */
  56683. Sqrt = 8
  56684. }
  56685. /**
  56686. * Block used to apply trigonometry operation to floats
  56687. */
  56688. export class TrigonometryBlock extends NodeMaterialBlock {
  56689. /**
  56690. * Gets or sets the operation applied by the block
  56691. */
  56692. operation: TrigonometryBlockOperations;
  56693. /**
  56694. * Creates a new TrigonometryBlock
  56695. * @param name defines the block name
  56696. */
  56697. constructor(name: string);
  56698. /**
  56699. * Gets the current class name
  56700. * @returns the class name
  56701. */
  56702. getClassName(): string;
  56703. /**
  56704. * Gets the input component
  56705. */
  56706. readonly input: NodeMaterialConnectionPoint;
  56707. /**
  56708. * Gets the output component
  56709. */
  56710. readonly output: NodeMaterialConnectionPoint;
  56711. protected _buildBlock(state: NodeMaterialBuildState): this;
  56712. serialize(): any;
  56713. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56714. }
  56715. }
  56716. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56720. /**
  56721. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56722. */
  56723. export class ColorMergerBlock extends NodeMaterialBlock {
  56724. /**
  56725. * Create a new ColorMergerBlock
  56726. * @param name defines the block name
  56727. */
  56728. constructor(name: string);
  56729. /**
  56730. * Gets the current class name
  56731. * @returns the class name
  56732. */
  56733. getClassName(): string;
  56734. /**
  56735. * Gets the r component (input)
  56736. */
  56737. readonly r: NodeMaterialConnectionPoint;
  56738. /**
  56739. * Gets the g component (input)
  56740. */
  56741. readonly g: NodeMaterialConnectionPoint;
  56742. /**
  56743. * Gets the b component (input)
  56744. */
  56745. readonly b: NodeMaterialConnectionPoint;
  56746. /**
  56747. * Gets the a component (input)
  56748. */
  56749. readonly a: NodeMaterialConnectionPoint;
  56750. /**
  56751. * Gets the rgba component (output)
  56752. */
  56753. readonly rgba: NodeMaterialConnectionPoint;
  56754. /**
  56755. * Gets the rgb component (output)
  56756. */
  56757. readonly rgb: NodeMaterialConnectionPoint;
  56758. protected _buildBlock(state: NodeMaterialBuildState): this;
  56759. }
  56760. }
  56761. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56765. /**
  56766. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56767. */
  56768. export class VectorMergerBlock extends NodeMaterialBlock {
  56769. /**
  56770. * Create a new VectorMergerBlock
  56771. * @param name defines the block name
  56772. */
  56773. constructor(name: string);
  56774. /**
  56775. * Gets the current class name
  56776. * @returns the class name
  56777. */
  56778. getClassName(): string;
  56779. /**
  56780. * Gets the x component (input)
  56781. */
  56782. readonly x: NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the y component (input)
  56785. */
  56786. readonly y: NodeMaterialConnectionPoint;
  56787. /**
  56788. * Gets the z component (input)
  56789. */
  56790. readonly z: NodeMaterialConnectionPoint;
  56791. /**
  56792. * Gets the w component (input)
  56793. */
  56794. readonly w: NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the xyzw component (output)
  56797. */
  56798. readonly xyzw: NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the xyz component (output)
  56801. */
  56802. readonly xyz: NodeMaterialConnectionPoint;
  56803. /**
  56804. * Gets the xy component (output)
  56805. */
  56806. readonly xy: NodeMaterialConnectionPoint;
  56807. protected _buildBlock(state: NodeMaterialBuildState): this;
  56808. }
  56809. }
  56810. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56814. /**
  56815. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56816. */
  56817. export class ColorSplitterBlock extends NodeMaterialBlock {
  56818. /**
  56819. * Create a new ColorSplitterBlock
  56820. * @param name defines the block name
  56821. */
  56822. constructor(name: string);
  56823. /**
  56824. * Gets the current class name
  56825. * @returns the class name
  56826. */
  56827. getClassName(): string;
  56828. /**
  56829. * Gets the rgba component (input)
  56830. */
  56831. readonly rgba: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the rgb component (input)
  56834. */
  56835. readonly rgbIn: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the rgb component (output)
  56838. */
  56839. readonly rgbOut: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the r component (output)
  56842. */
  56843. readonly r: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the g component (output)
  56846. */
  56847. readonly g: NodeMaterialConnectionPoint;
  56848. /**
  56849. * Gets the b component (output)
  56850. */
  56851. readonly b: NodeMaterialConnectionPoint;
  56852. /**
  56853. * Gets the a component (output)
  56854. */
  56855. readonly a: NodeMaterialConnectionPoint;
  56856. protected _inputRename(name: string): string;
  56857. protected _outputRename(name: string): string;
  56858. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56859. }
  56860. }
  56861. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56864. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56865. /**
  56866. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56867. */
  56868. export class VectorSplitterBlock extends NodeMaterialBlock {
  56869. /**
  56870. * Create a new VectorSplitterBlock
  56871. * @param name defines the block name
  56872. */
  56873. constructor(name: string);
  56874. /**
  56875. * Gets the current class name
  56876. * @returns the class name
  56877. */
  56878. getClassName(): string;
  56879. /**
  56880. * Gets the xyzw component (input)
  56881. */
  56882. readonly xyzw: NodeMaterialConnectionPoint;
  56883. /**
  56884. * Gets the xyz component (input)
  56885. */
  56886. readonly xyzIn: NodeMaterialConnectionPoint;
  56887. /**
  56888. * Gets the xy component (input)
  56889. */
  56890. readonly xyIn: NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the xyz component (output)
  56893. */
  56894. readonly xyzOut: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the xy component (output)
  56897. */
  56898. readonly xyOut: NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the x component (output)
  56901. */
  56902. readonly x: NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the y component (output)
  56905. */
  56906. readonly y: NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the z component (output)
  56909. */
  56910. readonly z: NodeMaterialConnectionPoint;
  56911. /**
  56912. * Gets the w component (output)
  56913. */
  56914. readonly w: NodeMaterialConnectionPoint;
  56915. protected _inputRename(name: string): string;
  56916. protected _outputRename(name: string): string;
  56917. protected _buildBlock(state: NodeMaterialBuildState): this;
  56918. }
  56919. }
  56920. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56924. /**
  56925. * Block used to lerp 2 values
  56926. */
  56927. export class LerpBlock extends NodeMaterialBlock {
  56928. /**
  56929. * Creates a new LerpBlock
  56930. * @param name defines the block name
  56931. */
  56932. constructor(name: string);
  56933. /**
  56934. * Gets the current class name
  56935. * @returns the class name
  56936. */
  56937. getClassName(): string;
  56938. /**
  56939. * Gets the left operand input component
  56940. */
  56941. readonly left: NodeMaterialConnectionPoint;
  56942. /**
  56943. * Gets the right operand input component
  56944. */
  56945. readonly right: NodeMaterialConnectionPoint;
  56946. /**
  56947. * Gets the gradient operand input component
  56948. */
  56949. readonly gradient: NodeMaterialConnectionPoint;
  56950. /**
  56951. * Gets the output component
  56952. */
  56953. readonly output: NodeMaterialConnectionPoint;
  56954. protected _buildBlock(state: NodeMaterialBuildState): this;
  56955. }
  56956. }
  56957. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56961. /**
  56962. * Block used to divide 2 vectors
  56963. */
  56964. export class DivideBlock extends NodeMaterialBlock {
  56965. /**
  56966. * Creates a new DivideBlock
  56967. * @param name defines the block name
  56968. */
  56969. constructor(name: string);
  56970. /**
  56971. * Gets the current class name
  56972. * @returns the class name
  56973. */
  56974. getClassName(): string;
  56975. /**
  56976. * Gets the left operand input component
  56977. */
  56978. readonly left: NodeMaterialConnectionPoint;
  56979. /**
  56980. * Gets the right operand input component
  56981. */
  56982. readonly right: NodeMaterialConnectionPoint;
  56983. /**
  56984. * Gets the output component
  56985. */
  56986. readonly output: NodeMaterialConnectionPoint;
  56987. protected _buildBlock(state: NodeMaterialBuildState): this;
  56988. }
  56989. }
  56990. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56994. /**
  56995. * Block used to subtract 2 vectors
  56996. */
  56997. export class SubtractBlock extends NodeMaterialBlock {
  56998. /**
  56999. * Creates a new SubtractBlock
  57000. * @param name defines the block name
  57001. */
  57002. constructor(name: string);
  57003. /**
  57004. * Gets the current class name
  57005. * @returns the class name
  57006. */
  57007. getClassName(): string;
  57008. /**
  57009. * Gets the left operand input component
  57010. */
  57011. readonly left: NodeMaterialConnectionPoint;
  57012. /**
  57013. * Gets the right operand input component
  57014. */
  57015. readonly right: NodeMaterialConnectionPoint;
  57016. /**
  57017. * Gets the output component
  57018. */
  57019. readonly output: NodeMaterialConnectionPoint;
  57020. protected _buildBlock(state: NodeMaterialBuildState): this;
  57021. }
  57022. }
  57023. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57027. /**
  57028. * Block used to step a value
  57029. */
  57030. export class StepBlock extends NodeMaterialBlock {
  57031. /**
  57032. * Creates a new AddBlock
  57033. * @param name defines the block name
  57034. */
  57035. constructor(name: string);
  57036. /**
  57037. * Gets the current class name
  57038. * @returns the class name
  57039. */
  57040. getClassName(): string;
  57041. /**
  57042. * Gets the value operand input component
  57043. */
  57044. readonly value: NodeMaterialConnectionPoint;
  57045. /**
  57046. * Gets the edge operand input component
  57047. */
  57048. readonly edge: NodeMaterialConnectionPoint;
  57049. /**
  57050. * Gets the output component
  57051. */
  57052. readonly output: NodeMaterialConnectionPoint;
  57053. protected _buildBlock(state: NodeMaterialBuildState): this;
  57054. }
  57055. }
  57056. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57060. /**
  57061. * Block used to get the opposite (1 - x) of a value
  57062. */
  57063. export class OneMinusBlock extends NodeMaterialBlock {
  57064. /**
  57065. * Creates a new OneMinusBlock
  57066. * @param name defines the block name
  57067. */
  57068. constructor(name: string);
  57069. /**
  57070. * Gets the current class name
  57071. * @returns the class name
  57072. */
  57073. getClassName(): string;
  57074. /**
  57075. * Gets the input component
  57076. */
  57077. readonly input: NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the output component
  57080. */
  57081. readonly output: NodeMaterialConnectionPoint;
  57082. protected _buildBlock(state: NodeMaterialBuildState): this;
  57083. }
  57084. }
  57085. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57089. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57090. /**
  57091. * Block used to get the view direction
  57092. */
  57093. export class ViewDirectionBlock extends NodeMaterialBlock {
  57094. /**
  57095. * Creates a new ViewDirectionBlock
  57096. * @param name defines the block name
  57097. */
  57098. constructor(name: string);
  57099. /**
  57100. * Gets the current class name
  57101. * @returns the class name
  57102. */
  57103. getClassName(): string;
  57104. /**
  57105. * Gets the world position component
  57106. */
  57107. readonly worldPosition: NodeMaterialConnectionPoint;
  57108. /**
  57109. * Gets the camera position component
  57110. */
  57111. readonly cameraPosition: NodeMaterialConnectionPoint;
  57112. /**
  57113. * Gets the output component
  57114. */
  57115. readonly output: NodeMaterialConnectionPoint;
  57116. autoConfigure(material: NodeMaterial): void;
  57117. protected _buildBlock(state: NodeMaterialBuildState): this;
  57118. }
  57119. }
  57120. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57124. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57125. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57126. /**
  57127. * Block used to compute fresnel value
  57128. */
  57129. export class FresnelBlock extends NodeMaterialBlock {
  57130. /**
  57131. * Create a new FresnelBlock
  57132. * @param name defines the block name
  57133. */
  57134. constructor(name: string);
  57135. /**
  57136. * Gets the current class name
  57137. * @returns the class name
  57138. */
  57139. getClassName(): string;
  57140. /**
  57141. * Gets the world normal input component
  57142. */
  57143. readonly worldNormal: NodeMaterialConnectionPoint;
  57144. /**
  57145. * Gets the view direction input component
  57146. */
  57147. readonly viewDirection: NodeMaterialConnectionPoint;
  57148. /**
  57149. * Gets the bias input component
  57150. */
  57151. readonly bias: NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the camera (or eye) position component
  57154. */
  57155. readonly power: NodeMaterialConnectionPoint;
  57156. /**
  57157. * Gets the fresnel output component
  57158. */
  57159. readonly fresnel: NodeMaterialConnectionPoint;
  57160. autoConfigure(material: NodeMaterial): void;
  57161. protected _buildBlock(state: NodeMaterialBuildState): this;
  57162. }
  57163. }
  57164. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57168. /**
  57169. * Block used to get the max of 2 values
  57170. */
  57171. export class MaxBlock extends NodeMaterialBlock {
  57172. /**
  57173. * Creates a new MaxBlock
  57174. * @param name defines the block name
  57175. */
  57176. constructor(name: string);
  57177. /**
  57178. * Gets the current class name
  57179. * @returns the class name
  57180. */
  57181. getClassName(): string;
  57182. /**
  57183. * Gets the left operand input component
  57184. */
  57185. readonly left: NodeMaterialConnectionPoint;
  57186. /**
  57187. * Gets the right operand input component
  57188. */
  57189. readonly right: NodeMaterialConnectionPoint;
  57190. /**
  57191. * Gets the output component
  57192. */
  57193. readonly output: NodeMaterialConnectionPoint;
  57194. protected _buildBlock(state: NodeMaterialBuildState): this;
  57195. }
  57196. }
  57197. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57201. /**
  57202. * Block used to get the min of 2 values
  57203. */
  57204. export class MinBlock extends NodeMaterialBlock {
  57205. /**
  57206. * Creates a new MinBlock
  57207. * @param name defines the block name
  57208. */
  57209. constructor(name: string);
  57210. /**
  57211. * Gets the current class name
  57212. * @returns the class name
  57213. */
  57214. getClassName(): string;
  57215. /**
  57216. * Gets the left operand input component
  57217. */
  57218. readonly left: NodeMaterialConnectionPoint;
  57219. /**
  57220. * Gets the right operand input component
  57221. */
  57222. readonly right: NodeMaterialConnectionPoint;
  57223. /**
  57224. * Gets the output component
  57225. */
  57226. readonly output: NodeMaterialConnectionPoint;
  57227. protected _buildBlock(state: NodeMaterialBuildState): this;
  57228. }
  57229. }
  57230. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57234. /**
  57235. * Block used to get the distance between 2 values
  57236. */
  57237. export class DistanceBlock extends NodeMaterialBlock {
  57238. /**
  57239. * Creates a new DistanceBlock
  57240. * @param name defines the block name
  57241. */
  57242. constructor(name: string);
  57243. /**
  57244. * Gets the current class name
  57245. * @returns the class name
  57246. */
  57247. getClassName(): string;
  57248. /**
  57249. * Gets the left operand input component
  57250. */
  57251. readonly left: NodeMaterialConnectionPoint;
  57252. /**
  57253. * Gets the right operand input component
  57254. */
  57255. readonly right: NodeMaterialConnectionPoint;
  57256. /**
  57257. * Gets the output component
  57258. */
  57259. readonly output: NodeMaterialConnectionPoint;
  57260. protected _buildBlock(state: NodeMaterialBuildState): this;
  57261. }
  57262. }
  57263. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57267. /**
  57268. * Block used to get the length of a vector
  57269. */
  57270. export class LengthBlock extends NodeMaterialBlock {
  57271. /**
  57272. * Creates a new LengthBlock
  57273. * @param name defines the block name
  57274. */
  57275. constructor(name: string);
  57276. /**
  57277. * Gets the current class name
  57278. * @returns the class name
  57279. */
  57280. getClassName(): string;
  57281. /**
  57282. * Gets the value input component
  57283. */
  57284. readonly value: NodeMaterialConnectionPoint;
  57285. /**
  57286. * Gets the output component
  57287. */
  57288. readonly output: NodeMaterialConnectionPoint;
  57289. protected _buildBlock(state: NodeMaterialBuildState): this;
  57290. }
  57291. }
  57292. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57296. /**
  57297. * Block used to get negative version of a value (i.e. x * -1)
  57298. */
  57299. export class NegateBlock extends NodeMaterialBlock {
  57300. /**
  57301. * Creates a new NegateBlock
  57302. * @param name defines the block name
  57303. */
  57304. constructor(name: string);
  57305. /**
  57306. * Gets the current class name
  57307. * @returns the class name
  57308. */
  57309. getClassName(): string;
  57310. /**
  57311. * Gets the value input component
  57312. */
  57313. readonly value: NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the output component
  57316. */
  57317. readonly output: NodeMaterialConnectionPoint;
  57318. protected _buildBlock(state: NodeMaterialBuildState): this;
  57319. }
  57320. }
  57321. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57325. /**
  57326. * Block used to get the value of the first parameter raised to the power of the second
  57327. */
  57328. export class PowBlock extends NodeMaterialBlock {
  57329. /**
  57330. * Creates a new PowBlock
  57331. * @param name defines the block name
  57332. */
  57333. constructor(name: string);
  57334. /**
  57335. * Gets the current class name
  57336. * @returns the class name
  57337. */
  57338. getClassName(): string;
  57339. /**
  57340. * Gets the value operand input component
  57341. */
  57342. readonly value: NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the power operand input component
  57345. */
  57346. readonly power: NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the output component
  57349. */
  57350. readonly output: NodeMaterialConnectionPoint;
  57351. protected _buildBlock(state: NodeMaterialBuildState): this;
  57352. }
  57353. }
  57354. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57358. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57359. /**
  57360. * Block used to get a random number
  57361. */
  57362. export class RandomNumberBlock extends NodeMaterialBlock {
  57363. /**
  57364. * Creates a new RandomNumberBlock
  57365. * @param name defines the block name
  57366. */
  57367. constructor(name: string);
  57368. /**
  57369. * Gets the current class name
  57370. * @returns the class name
  57371. */
  57372. getClassName(): string;
  57373. /**
  57374. * Gets the seed input component
  57375. */
  57376. readonly seed: NodeMaterialConnectionPoint;
  57377. /**
  57378. * Gets the output component
  57379. */
  57380. readonly output: NodeMaterialConnectionPoint;
  57381. protected _buildBlock(state: NodeMaterialBuildState): this;
  57382. }
  57383. }
  57384. declare module "babylonjs/Materials/Node/Blocks/index" {
  57385. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57386. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57387. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57388. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57389. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57390. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57391. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57392. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57393. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57394. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57395. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57396. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57397. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57398. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57399. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57400. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57401. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57402. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57403. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57404. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57405. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57406. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57407. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57408. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57409. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57410. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57411. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57412. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57413. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57414. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57415. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57416. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  57417. }
  57418. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57419. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57420. }
  57421. declare module "babylonjs/Materials/Node/index" {
  57422. export * from "babylonjs/Materials/Node/Enums/index";
  57423. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57424. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57425. export * from "babylonjs/Materials/Node/nodeMaterial";
  57426. export * from "babylonjs/Materials/Node/Blocks/index";
  57427. export * from "babylonjs/Materials/Node/Optimizers/index";
  57428. }
  57429. declare module "babylonjs/Materials/effectRenderer" {
  57430. import { Nullable } from "babylonjs/types";
  57431. import { Texture } from "babylonjs/Materials/Textures/texture";
  57432. import { Engine } from "babylonjs/Engines/engine";
  57433. import { Viewport } from "babylonjs/Maths/math.viewport";
  57434. import { Observable } from "babylonjs/Misc/observable";
  57435. import { Effect } from "babylonjs/Materials/effect";
  57436. import "babylonjs/Shaders/postprocess.vertex";
  57437. /**
  57438. * Effect Render Options
  57439. */
  57440. export interface IEffectRendererOptions {
  57441. /**
  57442. * Defines the vertices positions.
  57443. */
  57444. positions?: number[];
  57445. /**
  57446. * Defines the indices.
  57447. */
  57448. indices?: number[];
  57449. }
  57450. /**
  57451. * Helper class to render one or more effects
  57452. */
  57453. export class EffectRenderer {
  57454. private engine;
  57455. private static _DefaultOptions;
  57456. private _vertexBuffers;
  57457. private _indexBuffer;
  57458. private _ringBufferIndex;
  57459. private _ringScreenBuffer;
  57460. private _fullscreenViewport;
  57461. private _getNextFrameBuffer;
  57462. /**
  57463. * Creates an effect renderer
  57464. * @param engine the engine to use for rendering
  57465. * @param options defines the options of the effect renderer
  57466. */
  57467. constructor(engine: Engine, options?: IEffectRendererOptions);
  57468. /**
  57469. * Sets the current viewport in normalized coordinates 0-1
  57470. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57471. */
  57472. setViewport(viewport?: Viewport): void;
  57473. /**
  57474. * Binds the embedded attributes buffer to the effect.
  57475. * @param effect Defines the effect to bind the attributes for
  57476. */
  57477. bindBuffers(effect: Effect): void;
  57478. /**
  57479. * Sets the current effect wrapper to use during draw.
  57480. * The effect needs to be ready before calling this api.
  57481. * This also sets the default full screen position attribute.
  57482. * @param effectWrapper Defines the effect to draw with
  57483. */
  57484. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57485. /**
  57486. * Draws a full screen quad.
  57487. */
  57488. draw(): void;
  57489. /**
  57490. * renders one or more effects to a specified texture
  57491. * @param effectWrappers list of effects to renderer
  57492. * @param outputTexture texture to draw to, if null it will render to the screen
  57493. */
  57494. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57495. /**
  57496. * Disposes of the effect renderer
  57497. */
  57498. dispose(): void;
  57499. }
  57500. /**
  57501. * Options to create an EffectWrapper
  57502. */
  57503. interface EffectWrapperCreationOptions {
  57504. /**
  57505. * Engine to use to create the effect
  57506. */
  57507. engine: Engine;
  57508. /**
  57509. * Fragment shader for the effect
  57510. */
  57511. fragmentShader: string;
  57512. /**
  57513. * Vertex shader for the effect
  57514. */
  57515. vertexShader?: string;
  57516. /**
  57517. * Attributes to use in the shader
  57518. */
  57519. attributeNames?: Array<string>;
  57520. /**
  57521. * Uniforms to use in the shader
  57522. */
  57523. uniformNames?: Array<string>;
  57524. /**
  57525. * Texture sampler names to use in the shader
  57526. */
  57527. samplerNames?: Array<string>;
  57528. /**
  57529. * The friendly name of the effect displayed in Spector.
  57530. */
  57531. name?: string;
  57532. }
  57533. /**
  57534. * Wraps an effect to be used for rendering
  57535. */
  57536. export class EffectWrapper {
  57537. /**
  57538. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57539. */
  57540. onApplyObservable: Observable<{}>;
  57541. /**
  57542. * The underlying effect
  57543. */
  57544. effect: Effect;
  57545. /**
  57546. * Creates an effect to be renderer
  57547. * @param creationOptions options to create the effect
  57548. */
  57549. constructor(creationOptions: EffectWrapperCreationOptions);
  57550. /**
  57551. * Disposes of the effect wrapper
  57552. */
  57553. dispose(): void;
  57554. }
  57555. }
  57556. declare module "babylonjs/Materials/index" {
  57557. export * from "babylonjs/Materials/Background/index";
  57558. export * from "babylonjs/Materials/colorCurves";
  57559. export * from "babylonjs/Materials/effect";
  57560. export * from "babylonjs/Materials/fresnelParameters";
  57561. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57562. export * from "babylonjs/Materials/material";
  57563. export * from "babylonjs/Materials/materialDefines";
  57564. export * from "babylonjs/Materials/materialHelper";
  57565. export * from "babylonjs/Materials/multiMaterial";
  57566. export * from "babylonjs/Materials/PBR/index";
  57567. export * from "babylonjs/Materials/pushMaterial";
  57568. export * from "babylonjs/Materials/shaderMaterial";
  57569. export * from "babylonjs/Materials/standardMaterial";
  57570. export * from "babylonjs/Materials/Textures/index";
  57571. export * from "babylonjs/Materials/uniformBuffer";
  57572. export * from "babylonjs/Materials/materialFlags";
  57573. export * from "babylonjs/Materials/Node/index";
  57574. export * from "babylonjs/Materials/effectRenderer";
  57575. }
  57576. declare module "babylonjs/Maths/index" {
  57577. export * from "babylonjs/Maths/math.scalar";
  57578. export * from "babylonjs/Maths/math";
  57579. export * from "babylonjs/Maths/sphericalPolynomial";
  57580. }
  57581. declare module "babylonjs/Misc/workerPool" {
  57582. import { IDisposable } from "babylonjs/scene";
  57583. /**
  57584. * Helper class to push actions to a pool of workers.
  57585. */
  57586. export class WorkerPool implements IDisposable {
  57587. private _workerInfos;
  57588. private _pendingActions;
  57589. /**
  57590. * Constructor
  57591. * @param workers Array of workers to use for actions
  57592. */
  57593. constructor(workers: Array<Worker>);
  57594. /**
  57595. * Terminates all workers and clears any pending actions.
  57596. */
  57597. dispose(): void;
  57598. /**
  57599. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57600. * pended until a worker has completed its action.
  57601. * @param action The action to perform. Call onComplete when the action is complete.
  57602. */
  57603. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57604. private _execute;
  57605. }
  57606. }
  57607. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57608. import { IDisposable } from "babylonjs/scene";
  57609. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57610. /**
  57611. * Configuration for Draco compression
  57612. */
  57613. export interface IDracoCompressionConfiguration {
  57614. /**
  57615. * Configuration for the decoder.
  57616. */
  57617. decoder: {
  57618. /**
  57619. * The url to the WebAssembly module.
  57620. */
  57621. wasmUrl?: string;
  57622. /**
  57623. * The url to the WebAssembly binary.
  57624. */
  57625. wasmBinaryUrl?: string;
  57626. /**
  57627. * The url to the fallback JavaScript module.
  57628. */
  57629. fallbackUrl?: string;
  57630. };
  57631. }
  57632. /**
  57633. * Draco compression (https://google.github.io/draco/)
  57634. *
  57635. * This class wraps the Draco module.
  57636. *
  57637. * **Encoder**
  57638. *
  57639. * The encoder is not currently implemented.
  57640. *
  57641. * **Decoder**
  57642. *
  57643. * 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.
  57644. *
  57645. * To update the configuration, use the following code:
  57646. * ```javascript
  57647. * DracoCompression.Configuration = {
  57648. * decoder: {
  57649. * wasmUrl: "<url to the WebAssembly library>",
  57650. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57651. * fallbackUrl: "<url to the fallback JavaScript library>",
  57652. * }
  57653. * };
  57654. * ```
  57655. *
  57656. * 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.
  57657. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57658. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57659. *
  57660. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57661. * ```javascript
  57662. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57663. * ```
  57664. *
  57665. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57666. */
  57667. export class DracoCompression implements IDisposable {
  57668. private _workerPoolPromise?;
  57669. private _decoderModulePromise?;
  57670. /**
  57671. * The configuration. Defaults to the following urls:
  57672. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57673. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57674. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57675. */
  57676. static Configuration: IDracoCompressionConfiguration;
  57677. /**
  57678. * Returns true if the decoder configuration is available.
  57679. */
  57680. static readonly DecoderAvailable: boolean;
  57681. /**
  57682. * Default number of workers to create when creating the draco compression object.
  57683. */
  57684. static DefaultNumWorkers: number;
  57685. private static GetDefaultNumWorkers;
  57686. private static _Default;
  57687. /**
  57688. * Default instance for the draco compression object.
  57689. */
  57690. static readonly Default: DracoCompression;
  57691. /**
  57692. * Constructor
  57693. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57694. */
  57695. constructor(numWorkers?: number);
  57696. /**
  57697. * Stop all async operations and release resources.
  57698. */
  57699. dispose(): void;
  57700. /**
  57701. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57702. * @returns a promise that resolves when ready
  57703. */
  57704. whenReadyAsync(): Promise<void>;
  57705. /**
  57706. * Decode Draco compressed mesh data to vertex data.
  57707. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57708. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57709. * @returns A promise that resolves with the decoded vertex data
  57710. */
  57711. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57712. [kind: string]: number;
  57713. }): Promise<VertexData>;
  57714. }
  57715. }
  57716. declare module "babylonjs/Meshes/Compression/index" {
  57717. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57718. }
  57719. declare module "babylonjs/Meshes/csg" {
  57720. import { Nullable } from "babylonjs/types";
  57721. import { Scene } from "babylonjs/scene";
  57722. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57723. import { Mesh } from "babylonjs/Meshes/mesh";
  57724. import { Material } from "babylonjs/Materials/material";
  57725. /**
  57726. * Class for building Constructive Solid Geometry
  57727. */
  57728. export class CSG {
  57729. private polygons;
  57730. /**
  57731. * The world matrix
  57732. */
  57733. matrix: Matrix;
  57734. /**
  57735. * Stores the position
  57736. */
  57737. position: Vector3;
  57738. /**
  57739. * Stores the rotation
  57740. */
  57741. rotation: Vector3;
  57742. /**
  57743. * Stores the rotation quaternion
  57744. */
  57745. rotationQuaternion: Nullable<Quaternion>;
  57746. /**
  57747. * Stores the scaling vector
  57748. */
  57749. scaling: Vector3;
  57750. /**
  57751. * Convert the Mesh to CSG
  57752. * @param mesh The Mesh to convert to CSG
  57753. * @returns A new CSG from the Mesh
  57754. */
  57755. static FromMesh(mesh: Mesh): CSG;
  57756. /**
  57757. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57758. * @param polygons Polygons used to construct a CSG solid
  57759. */
  57760. private static FromPolygons;
  57761. /**
  57762. * Clones, or makes a deep copy, of the CSG
  57763. * @returns A new CSG
  57764. */
  57765. clone(): CSG;
  57766. /**
  57767. * Unions this CSG with another CSG
  57768. * @param csg The CSG to union against this CSG
  57769. * @returns The unioned CSG
  57770. */
  57771. union(csg: CSG): CSG;
  57772. /**
  57773. * Unions this CSG with another CSG in place
  57774. * @param csg The CSG to union against this CSG
  57775. */
  57776. unionInPlace(csg: CSG): void;
  57777. /**
  57778. * Subtracts this CSG with another CSG
  57779. * @param csg The CSG to subtract against this CSG
  57780. * @returns A new CSG
  57781. */
  57782. subtract(csg: CSG): CSG;
  57783. /**
  57784. * Subtracts this CSG with another CSG in place
  57785. * @param csg The CSG to subtact against this CSG
  57786. */
  57787. subtractInPlace(csg: CSG): void;
  57788. /**
  57789. * Intersect this CSG with another CSG
  57790. * @param csg The CSG to intersect against this CSG
  57791. * @returns A new CSG
  57792. */
  57793. intersect(csg: CSG): CSG;
  57794. /**
  57795. * Intersects this CSG with another CSG in place
  57796. * @param csg The CSG to intersect against this CSG
  57797. */
  57798. intersectInPlace(csg: CSG): void;
  57799. /**
  57800. * Return a new CSG solid with solid and empty space switched. This solid is
  57801. * not modified.
  57802. * @returns A new CSG solid with solid and empty space switched
  57803. */
  57804. inverse(): CSG;
  57805. /**
  57806. * Inverses the CSG in place
  57807. */
  57808. inverseInPlace(): void;
  57809. /**
  57810. * This is used to keep meshes transformations so they can be restored
  57811. * when we build back a Babylon Mesh
  57812. * NB : All CSG operations are performed in world coordinates
  57813. * @param csg The CSG to copy the transform attributes from
  57814. * @returns This CSG
  57815. */
  57816. copyTransformAttributes(csg: CSG): CSG;
  57817. /**
  57818. * Build Raw mesh from CSG
  57819. * Coordinates here are in world space
  57820. * @param name The name of the mesh geometry
  57821. * @param scene The Scene
  57822. * @param keepSubMeshes Specifies if the submeshes should be kept
  57823. * @returns A new Mesh
  57824. */
  57825. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57826. /**
  57827. * Build Mesh from CSG taking material and transforms into account
  57828. * @param name The name of the Mesh
  57829. * @param material The material of the Mesh
  57830. * @param scene The Scene
  57831. * @param keepSubMeshes Specifies if submeshes should be kept
  57832. * @returns The new Mesh
  57833. */
  57834. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57835. }
  57836. }
  57837. declare module "babylonjs/Meshes/trailMesh" {
  57838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57839. import { Mesh } from "babylonjs/Meshes/mesh";
  57840. import { Scene } from "babylonjs/scene";
  57841. /**
  57842. * Class used to create a trail following a mesh
  57843. */
  57844. export class TrailMesh extends Mesh {
  57845. private _generator;
  57846. private _autoStart;
  57847. private _running;
  57848. private _diameter;
  57849. private _length;
  57850. private _sectionPolygonPointsCount;
  57851. private _sectionVectors;
  57852. private _sectionNormalVectors;
  57853. private _beforeRenderObserver;
  57854. /**
  57855. * @constructor
  57856. * @param name The value used by scene.getMeshByName() to do a lookup.
  57857. * @param generator The mesh to generate a trail.
  57858. * @param scene The scene to add this mesh to.
  57859. * @param diameter Diameter of trailing mesh. Default is 1.
  57860. * @param length Length of trailing mesh. Default is 60.
  57861. * @param autoStart Automatically start trailing mesh. Default true.
  57862. */
  57863. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57864. /**
  57865. * "TrailMesh"
  57866. * @returns "TrailMesh"
  57867. */
  57868. getClassName(): string;
  57869. private _createMesh;
  57870. /**
  57871. * Start trailing mesh.
  57872. */
  57873. start(): void;
  57874. /**
  57875. * Stop trailing mesh.
  57876. */
  57877. stop(): void;
  57878. /**
  57879. * Update trailing mesh geometry.
  57880. */
  57881. update(): void;
  57882. /**
  57883. * Returns a new TrailMesh object.
  57884. * @param name is a string, the name given to the new mesh
  57885. * @param newGenerator use new generator object for cloned trail mesh
  57886. * @returns a new mesh
  57887. */
  57888. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57889. /**
  57890. * Serializes this trail mesh
  57891. * @param serializationObject object to write serialization to
  57892. */
  57893. serialize(serializationObject: any): void;
  57894. /**
  57895. * Parses a serialized trail mesh
  57896. * @param parsedMesh the serialized mesh
  57897. * @param scene the scene to create the trail mesh in
  57898. * @returns the created trail mesh
  57899. */
  57900. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57901. }
  57902. }
  57903. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57904. import { Nullable } from "babylonjs/types";
  57905. import { Scene } from "babylonjs/scene";
  57906. import { Vector4 } from "babylonjs/Maths/math.vector";
  57907. import { Color4 } from "babylonjs/Maths/math.color";
  57908. import { Mesh } from "babylonjs/Meshes/mesh";
  57909. /**
  57910. * Class containing static functions to help procedurally build meshes
  57911. */
  57912. export class TiledBoxBuilder {
  57913. /**
  57914. * Creates a box mesh
  57915. * 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)
  57916. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57920. * @param name defines the name of the mesh
  57921. * @param options defines the options used to create the mesh
  57922. * @param scene defines the hosting scene
  57923. * @returns the box mesh
  57924. */
  57925. static CreateTiledBox(name: string, options: {
  57926. pattern?: number;
  57927. width?: number;
  57928. height?: number;
  57929. depth?: number;
  57930. tileSize?: number;
  57931. tileWidth?: number;
  57932. tileHeight?: number;
  57933. alignHorizontal?: number;
  57934. alignVertical?: number;
  57935. faceUV?: Vector4[];
  57936. faceColors?: Color4[];
  57937. sideOrientation?: number;
  57938. updatable?: boolean;
  57939. }, scene?: Nullable<Scene>): Mesh;
  57940. }
  57941. }
  57942. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57943. import { Vector4 } from "babylonjs/Maths/math.vector";
  57944. import { Mesh } from "babylonjs/Meshes/mesh";
  57945. /**
  57946. * Class containing static functions to help procedurally build meshes
  57947. */
  57948. export class TorusKnotBuilder {
  57949. /**
  57950. * Creates a torus knot mesh
  57951. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57952. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57953. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57954. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57958. * @param name defines the name of the mesh
  57959. * @param options defines the options used to create the mesh
  57960. * @param scene defines the hosting scene
  57961. * @returns the torus knot mesh
  57962. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57963. */
  57964. static CreateTorusKnot(name: string, options: {
  57965. radius?: number;
  57966. tube?: number;
  57967. radialSegments?: number;
  57968. tubularSegments?: number;
  57969. p?: number;
  57970. q?: number;
  57971. updatable?: boolean;
  57972. sideOrientation?: number;
  57973. frontUVs?: Vector4;
  57974. backUVs?: Vector4;
  57975. }, scene: any): Mesh;
  57976. }
  57977. }
  57978. declare module "babylonjs/Meshes/polygonMesh" {
  57979. import { Scene } from "babylonjs/scene";
  57980. import { Vector2 } from "babylonjs/Maths/math.vector";
  57981. import { Mesh } from "babylonjs/Meshes/mesh";
  57982. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57983. import { Path2 } from "babylonjs/Maths/math.path";
  57984. /**
  57985. * Polygon
  57986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57987. */
  57988. export class Polygon {
  57989. /**
  57990. * Creates a rectangle
  57991. * @param xmin bottom X coord
  57992. * @param ymin bottom Y coord
  57993. * @param xmax top X coord
  57994. * @param ymax top Y coord
  57995. * @returns points that make the resulting rectation
  57996. */
  57997. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57998. /**
  57999. * Creates a circle
  58000. * @param radius radius of circle
  58001. * @param cx scale in x
  58002. * @param cy scale in y
  58003. * @param numberOfSides number of sides that make up the circle
  58004. * @returns points that make the resulting circle
  58005. */
  58006. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58007. /**
  58008. * Creates a polygon from input string
  58009. * @param input Input polygon data
  58010. * @returns the parsed points
  58011. */
  58012. static Parse(input: string): Vector2[];
  58013. /**
  58014. * Starts building a polygon from x and y coordinates
  58015. * @param x x coordinate
  58016. * @param y y coordinate
  58017. * @returns the started path2
  58018. */
  58019. static StartingAt(x: number, y: number): Path2;
  58020. }
  58021. /**
  58022. * Builds a polygon
  58023. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58024. */
  58025. export class PolygonMeshBuilder {
  58026. private _points;
  58027. private _outlinepoints;
  58028. private _holes;
  58029. private _name;
  58030. private _scene;
  58031. private _epoints;
  58032. private _eholes;
  58033. private _addToepoint;
  58034. /**
  58035. * Babylon reference to the earcut plugin.
  58036. */
  58037. bjsEarcut: any;
  58038. /**
  58039. * Creates a PolygonMeshBuilder
  58040. * @param name name of the builder
  58041. * @param contours Path of the polygon
  58042. * @param scene scene to add to when creating the mesh
  58043. * @param earcutInjection can be used to inject your own earcut reference
  58044. */
  58045. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58046. /**
  58047. * Adds a whole within the polygon
  58048. * @param hole Array of points defining the hole
  58049. * @returns this
  58050. */
  58051. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58052. /**
  58053. * Creates the polygon
  58054. * @param updatable If the mesh should be updatable
  58055. * @param depth The depth of the mesh created
  58056. * @returns the created mesh
  58057. */
  58058. build(updatable?: boolean, depth?: number): Mesh;
  58059. /**
  58060. * Creates the polygon
  58061. * @param depth The depth of the mesh created
  58062. * @returns the created VertexData
  58063. */
  58064. buildVertexData(depth?: number): VertexData;
  58065. /**
  58066. * Adds a side to the polygon
  58067. * @param positions points that make the polygon
  58068. * @param normals normals of the polygon
  58069. * @param uvs uvs of the polygon
  58070. * @param indices indices of the polygon
  58071. * @param bounds bounds of the polygon
  58072. * @param points points of the polygon
  58073. * @param depth depth of the polygon
  58074. * @param flip flip of the polygon
  58075. */
  58076. private addSide;
  58077. }
  58078. }
  58079. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58080. import { Scene } from "babylonjs/scene";
  58081. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58082. import { Color4 } from "babylonjs/Maths/math.color";
  58083. import { Mesh } from "babylonjs/Meshes/mesh";
  58084. import { Nullable } from "babylonjs/types";
  58085. /**
  58086. * Class containing static functions to help procedurally build meshes
  58087. */
  58088. export class PolygonBuilder {
  58089. /**
  58090. * Creates a polygon mesh
  58091. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58092. * * 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
  58093. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58096. * * Remember you can only change the shape positions, not their number when updating a polygon
  58097. * @param name defines the name of the mesh
  58098. * @param options defines the options used to create the mesh
  58099. * @param scene defines the hosting scene
  58100. * @param earcutInjection can be used to inject your own earcut reference
  58101. * @returns the polygon mesh
  58102. */
  58103. static CreatePolygon(name: string, options: {
  58104. shape: Vector3[];
  58105. holes?: Vector3[][];
  58106. depth?: number;
  58107. faceUV?: Vector4[];
  58108. faceColors?: Color4[];
  58109. updatable?: boolean;
  58110. sideOrientation?: number;
  58111. frontUVs?: Vector4;
  58112. backUVs?: Vector4;
  58113. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58114. /**
  58115. * Creates an extruded polygon mesh, with depth in the Y direction.
  58116. * * 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)
  58117. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58118. * @param name defines the name of the mesh
  58119. * @param options defines the options used to create the mesh
  58120. * @param scene defines the hosting scene
  58121. * @param earcutInjection can be used to inject your own earcut reference
  58122. * @returns the polygon mesh
  58123. */
  58124. static ExtrudePolygon(name: string, options: {
  58125. shape: Vector3[];
  58126. holes?: Vector3[][];
  58127. depth?: number;
  58128. faceUV?: Vector4[];
  58129. faceColors?: Color4[];
  58130. updatable?: boolean;
  58131. sideOrientation?: number;
  58132. frontUVs?: Vector4;
  58133. backUVs?: Vector4;
  58134. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58135. }
  58136. }
  58137. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58138. import { Scene } from "babylonjs/scene";
  58139. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58140. import { Mesh } from "babylonjs/Meshes/mesh";
  58141. import { Nullable } from "babylonjs/types";
  58142. /**
  58143. * Class containing static functions to help procedurally build meshes
  58144. */
  58145. export class LatheBuilder {
  58146. /**
  58147. * Creates lathe mesh.
  58148. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58149. * * 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
  58150. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58151. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58152. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58153. * * 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
  58154. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58155. * * 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
  58156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58158. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58160. * @param name defines the name of the mesh
  58161. * @param options defines the options used to create the mesh
  58162. * @param scene defines the hosting scene
  58163. * @returns the lathe mesh
  58164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58165. */
  58166. static CreateLathe(name: string, options: {
  58167. shape: Vector3[];
  58168. radius?: number;
  58169. tessellation?: number;
  58170. clip?: number;
  58171. arc?: number;
  58172. closed?: boolean;
  58173. updatable?: boolean;
  58174. sideOrientation?: number;
  58175. frontUVs?: Vector4;
  58176. backUVs?: Vector4;
  58177. cap?: number;
  58178. invertUV?: boolean;
  58179. }, scene?: Nullable<Scene>): Mesh;
  58180. }
  58181. }
  58182. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58183. import { Nullable } from "babylonjs/types";
  58184. import { Scene } from "babylonjs/scene";
  58185. import { Vector4 } from "babylonjs/Maths/math.vector";
  58186. import { Mesh } from "babylonjs/Meshes/mesh";
  58187. /**
  58188. * Class containing static functions to help procedurally build meshes
  58189. */
  58190. export class TiledPlaneBuilder {
  58191. /**
  58192. * Creates a tiled plane mesh
  58193. * * The parameter `pattern` will, depending on value, do nothing or
  58194. * * * flip (reflect about central vertical) alternate tiles across and up
  58195. * * * flip every tile on alternate rows
  58196. * * * rotate (180 degs) alternate tiles across and up
  58197. * * * rotate every tile on alternate rows
  58198. * * * flip and rotate alternate tiles across and up
  58199. * * * flip and rotate every tile on alternate rows
  58200. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58201. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58204. * * 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)
  58205. * * 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)
  58206. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58207. * @param name defines the name of the mesh
  58208. * @param options defines the options used to create the mesh
  58209. * @param scene defines the hosting scene
  58210. * @returns the box mesh
  58211. */
  58212. static CreateTiledPlane(name: string, options: {
  58213. pattern?: number;
  58214. tileSize?: number;
  58215. tileWidth?: number;
  58216. tileHeight?: number;
  58217. size?: number;
  58218. width?: number;
  58219. height?: number;
  58220. alignHorizontal?: number;
  58221. alignVertical?: number;
  58222. sideOrientation?: number;
  58223. frontUVs?: Vector4;
  58224. backUVs?: Vector4;
  58225. updatable?: boolean;
  58226. }, scene?: Nullable<Scene>): Mesh;
  58227. }
  58228. }
  58229. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58230. import { Nullable } from "babylonjs/types";
  58231. import { Scene } from "babylonjs/scene";
  58232. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58233. import { Mesh } from "babylonjs/Meshes/mesh";
  58234. /**
  58235. * Class containing static functions to help procedurally build meshes
  58236. */
  58237. export class TubeBuilder {
  58238. /**
  58239. * Creates a tube mesh.
  58240. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58241. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58242. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58243. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58244. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58245. * * 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)
  58246. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58247. * * 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
  58248. * * 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
  58249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58253. * @param name defines the name of the mesh
  58254. * @param options defines the options used to create the mesh
  58255. * @param scene defines the hosting scene
  58256. * @returns the tube mesh
  58257. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58258. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58259. */
  58260. static CreateTube(name: string, options: {
  58261. path: Vector3[];
  58262. radius?: number;
  58263. tessellation?: number;
  58264. radiusFunction?: {
  58265. (i: number, distance: number): number;
  58266. };
  58267. cap?: number;
  58268. arc?: number;
  58269. updatable?: boolean;
  58270. sideOrientation?: number;
  58271. frontUVs?: Vector4;
  58272. backUVs?: Vector4;
  58273. instance?: Mesh;
  58274. invertUV?: boolean;
  58275. }, scene?: Nullable<Scene>): Mesh;
  58276. }
  58277. }
  58278. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58279. import { Scene } from "babylonjs/scene";
  58280. import { Vector4 } from "babylonjs/Maths/math.vector";
  58281. import { Mesh } from "babylonjs/Meshes/mesh";
  58282. import { Nullable } from "babylonjs/types";
  58283. /**
  58284. * Class containing static functions to help procedurally build meshes
  58285. */
  58286. export class IcoSphereBuilder {
  58287. /**
  58288. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58289. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58290. * * 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`)
  58291. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58292. * * 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
  58293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58296. * @param name defines the name of the mesh
  58297. * @param options defines the options used to create the mesh
  58298. * @param scene defines the hosting scene
  58299. * @returns the icosahedron mesh
  58300. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58301. */
  58302. static CreateIcoSphere(name: string, options: {
  58303. radius?: number;
  58304. radiusX?: number;
  58305. radiusY?: number;
  58306. radiusZ?: number;
  58307. flat?: boolean;
  58308. subdivisions?: number;
  58309. sideOrientation?: number;
  58310. frontUVs?: Vector4;
  58311. backUVs?: Vector4;
  58312. updatable?: boolean;
  58313. }, scene?: Nullable<Scene>): Mesh;
  58314. }
  58315. }
  58316. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58317. import { Vector3 } from "babylonjs/Maths/math.vector";
  58318. import { Mesh } from "babylonjs/Meshes/mesh";
  58319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58320. /**
  58321. * Class containing static functions to help procedurally build meshes
  58322. */
  58323. export class DecalBuilder {
  58324. /**
  58325. * Creates a decal mesh.
  58326. * 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
  58327. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58328. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58329. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58330. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58331. * @param name defines the name of the mesh
  58332. * @param sourceMesh defines the mesh where the decal must be applied
  58333. * @param options defines the options used to create the mesh
  58334. * @param scene defines the hosting scene
  58335. * @returns the decal mesh
  58336. * @see https://doc.babylonjs.com/how_to/decals
  58337. */
  58338. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58339. position?: Vector3;
  58340. normal?: Vector3;
  58341. size?: Vector3;
  58342. angle?: number;
  58343. }): Mesh;
  58344. }
  58345. }
  58346. declare module "babylonjs/Meshes/meshBuilder" {
  58347. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58348. import { Nullable } from "babylonjs/types";
  58349. import { Scene } from "babylonjs/scene";
  58350. import { Mesh } from "babylonjs/Meshes/mesh";
  58351. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58352. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58354. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58355. import { Plane } from "babylonjs/Maths/math.plane";
  58356. /**
  58357. * Class containing static functions to help procedurally build meshes
  58358. */
  58359. export class MeshBuilder {
  58360. /**
  58361. * Creates a box mesh
  58362. * * The parameter `size` sets the size (float) of each box side (default 1)
  58363. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58364. * * 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)
  58365. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58369. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58370. * @param name defines the name of the mesh
  58371. * @param options defines the options used to create the mesh
  58372. * @param scene defines the hosting scene
  58373. * @returns the box mesh
  58374. */
  58375. static CreateBox(name: string, options: {
  58376. size?: number;
  58377. width?: number;
  58378. height?: number;
  58379. depth?: number;
  58380. faceUV?: Vector4[];
  58381. faceColors?: Color4[];
  58382. sideOrientation?: number;
  58383. frontUVs?: Vector4;
  58384. backUVs?: Vector4;
  58385. updatable?: boolean;
  58386. }, scene?: Nullable<Scene>): Mesh;
  58387. /**
  58388. * Creates a tiled box mesh
  58389. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58391. * @param name defines the name of the mesh
  58392. * @param options defines the options used to create the mesh
  58393. * @param scene defines the hosting scene
  58394. * @returns the tiled box mesh
  58395. */
  58396. static CreateTiledBox(name: string, options: {
  58397. pattern?: number;
  58398. size?: number;
  58399. width?: number;
  58400. height?: number;
  58401. depth: number;
  58402. tileSize?: number;
  58403. tileWidth?: number;
  58404. tileHeight?: number;
  58405. faceUV?: Vector4[];
  58406. faceColors?: Color4[];
  58407. alignHorizontal?: number;
  58408. alignVertical?: number;
  58409. sideOrientation?: number;
  58410. updatable?: boolean;
  58411. }, scene?: Nullable<Scene>): Mesh;
  58412. /**
  58413. * Creates a sphere mesh
  58414. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58415. * * 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`)
  58416. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58417. * * 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
  58418. * * 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)
  58419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58422. * @param name defines the name of the mesh
  58423. * @param options defines the options used to create the mesh
  58424. * @param scene defines the hosting scene
  58425. * @returns the sphere mesh
  58426. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58427. */
  58428. static CreateSphere(name: string, options: {
  58429. segments?: number;
  58430. diameter?: number;
  58431. diameterX?: number;
  58432. diameterY?: number;
  58433. diameterZ?: number;
  58434. arc?: number;
  58435. slice?: number;
  58436. sideOrientation?: number;
  58437. frontUVs?: Vector4;
  58438. backUVs?: Vector4;
  58439. updatable?: boolean;
  58440. }, scene?: Nullable<Scene>): Mesh;
  58441. /**
  58442. * Creates a plane polygonal mesh. By default, this is a disc
  58443. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58444. * * 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
  58445. * * 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
  58446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58449. * @param name defines the name of the mesh
  58450. * @param options defines the options used to create the mesh
  58451. * @param scene defines the hosting scene
  58452. * @returns the plane polygonal mesh
  58453. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58454. */
  58455. static CreateDisc(name: string, options: {
  58456. radius?: number;
  58457. tessellation?: number;
  58458. arc?: number;
  58459. updatable?: boolean;
  58460. sideOrientation?: number;
  58461. frontUVs?: Vector4;
  58462. backUVs?: Vector4;
  58463. }, scene?: Nullable<Scene>): Mesh;
  58464. /**
  58465. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58466. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58467. * * 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`)
  58468. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58469. * * 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
  58470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58473. * @param name defines the name of the mesh
  58474. * @param options defines the options used to create the mesh
  58475. * @param scene defines the hosting scene
  58476. * @returns the icosahedron mesh
  58477. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58478. */
  58479. static CreateIcoSphere(name: string, options: {
  58480. radius?: number;
  58481. radiusX?: number;
  58482. radiusY?: number;
  58483. radiusZ?: number;
  58484. flat?: boolean;
  58485. subdivisions?: number;
  58486. sideOrientation?: number;
  58487. frontUVs?: Vector4;
  58488. backUVs?: Vector4;
  58489. updatable?: boolean;
  58490. }, scene?: Nullable<Scene>): Mesh;
  58491. /**
  58492. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58493. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58494. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58495. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58496. * * 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
  58497. * * 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
  58498. * * 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
  58499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58502. * * 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
  58503. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58504. * * 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
  58505. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58507. * @param name defines the name of the mesh
  58508. * @param options defines the options used to create the mesh
  58509. * @param scene defines the hosting scene
  58510. * @returns the ribbon mesh
  58511. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58512. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58513. */
  58514. static CreateRibbon(name: string, options: {
  58515. pathArray: Vector3[][];
  58516. closeArray?: boolean;
  58517. closePath?: boolean;
  58518. offset?: number;
  58519. updatable?: boolean;
  58520. sideOrientation?: number;
  58521. frontUVs?: Vector4;
  58522. backUVs?: Vector4;
  58523. instance?: Mesh;
  58524. invertUV?: boolean;
  58525. uvs?: Vector2[];
  58526. colors?: Color4[];
  58527. }, scene?: Nullable<Scene>): Mesh;
  58528. /**
  58529. * Creates a cylinder or a cone mesh
  58530. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58531. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58532. * * 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.
  58533. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58534. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58535. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58536. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58537. * * 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).
  58538. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58539. * * 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).
  58540. * * 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
  58541. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58542. * * 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
  58543. * * 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.
  58544. * * If `enclose` is false, a ring surface is one element.
  58545. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58546. * * 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
  58547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58550. * @param name defines the name of the mesh
  58551. * @param options defines the options used to create the mesh
  58552. * @param scene defines the hosting scene
  58553. * @returns the cylinder mesh
  58554. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58555. */
  58556. static CreateCylinder(name: string, options: {
  58557. height?: number;
  58558. diameterTop?: number;
  58559. diameterBottom?: number;
  58560. diameter?: number;
  58561. tessellation?: number;
  58562. subdivisions?: number;
  58563. arc?: number;
  58564. faceColors?: Color4[];
  58565. faceUV?: Vector4[];
  58566. updatable?: boolean;
  58567. hasRings?: boolean;
  58568. enclose?: boolean;
  58569. cap?: number;
  58570. sideOrientation?: number;
  58571. frontUVs?: Vector4;
  58572. backUVs?: Vector4;
  58573. }, scene?: Nullable<Scene>): Mesh;
  58574. /**
  58575. * Creates a torus mesh
  58576. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58577. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58578. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58582. * @param name defines the name of the mesh
  58583. * @param options defines the options used to create the mesh
  58584. * @param scene defines the hosting scene
  58585. * @returns the torus mesh
  58586. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58587. */
  58588. static CreateTorus(name: string, options: {
  58589. diameter?: number;
  58590. thickness?: number;
  58591. tessellation?: number;
  58592. updatable?: boolean;
  58593. sideOrientation?: number;
  58594. frontUVs?: Vector4;
  58595. backUVs?: Vector4;
  58596. }, scene?: Nullable<Scene>): Mesh;
  58597. /**
  58598. * Creates a torus knot mesh
  58599. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58600. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58601. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58602. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58606. * @param name defines the name of the mesh
  58607. * @param options defines the options used to create the mesh
  58608. * @param scene defines the hosting scene
  58609. * @returns the torus knot mesh
  58610. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58611. */
  58612. static CreateTorusKnot(name: string, options: {
  58613. radius?: number;
  58614. tube?: number;
  58615. radialSegments?: number;
  58616. tubularSegments?: number;
  58617. p?: number;
  58618. q?: number;
  58619. updatable?: boolean;
  58620. sideOrientation?: number;
  58621. frontUVs?: Vector4;
  58622. backUVs?: Vector4;
  58623. }, scene?: Nullable<Scene>): Mesh;
  58624. /**
  58625. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58626. * * 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
  58627. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58628. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58629. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58630. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58631. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58632. * * 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
  58633. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58636. * @param name defines the name of the new line system
  58637. * @param options defines the options used to create the line system
  58638. * @param scene defines the hosting scene
  58639. * @returns a new line system mesh
  58640. */
  58641. static CreateLineSystem(name: string, options: {
  58642. lines: Vector3[][];
  58643. updatable?: boolean;
  58644. instance?: Nullable<LinesMesh>;
  58645. colors?: Nullable<Color4[][]>;
  58646. useVertexAlpha?: boolean;
  58647. }, scene: Nullable<Scene>): LinesMesh;
  58648. /**
  58649. * Creates a line mesh
  58650. * 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
  58651. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58652. * * The parameter `points` is an array successive Vector3
  58653. * * 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
  58654. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58655. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58656. * * When updating an instance, remember that only point positions can change, not the number of points
  58657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58659. * @param name defines the name of the new line system
  58660. * @param options defines the options used to create the line system
  58661. * @param scene defines the hosting scene
  58662. * @returns a new line mesh
  58663. */
  58664. static CreateLines(name: string, options: {
  58665. points: Vector3[];
  58666. updatable?: boolean;
  58667. instance?: Nullable<LinesMesh>;
  58668. colors?: Color4[];
  58669. useVertexAlpha?: boolean;
  58670. }, scene?: Nullable<Scene>): LinesMesh;
  58671. /**
  58672. * Creates a dashed line mesh
  58673. * * 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
  58674. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58675. * * The parameter `points` is an array successive Vector3
  58676. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58677. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58678. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58679. * * 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
  58680. * * When updating an instance, remember that only point positions can change, not the number of points
  58681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58682. * @param name defines the name of the mesh
  58683. * @param options defines the options used to create the mesh
  58684. * @param scene defines the hosting scene
  58685. * @returns the dashed line mesh
  58686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58687. */
  58688. static CreateDashedLines(name: string, options: {
  58689. points: Vector3[];
  58690. dashSize?: number;
  58691. gapSize?: number;
  58692. dashNb?: number;
  58693. updatable?: boolean;
  58694. instance?: LinesMesh;
  58695. }, scene?: Nullable<Scene>): LinesMesh;
  58696. /**
  58697. * 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.
  58698. * * 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.
  58699. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58700. * * 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.
  58701. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58702. * * 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
  58703. * * 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
  58704. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58709. * @param name defines the name of the mesh
  58710. * @param options defines the options used to create the mesh
  58711. * @param scene defines the hosting scene
  58712. * @returns the extruded shape mesh
  58713. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58715. */
  58716. static ExtrudeShape(name: string, options: {
  58717. shape: Vector3[];
  58718. path: Vector3[];
  58719. scale?: number;
  58720. rotation?: number;
  58721. cap?: number;
  58722. updatable?: boolean;
  58723. sideOrientation?: number;
  58724. frontUVs?: Vector4;
  58725. backUVs?: Vector4;
  58726. instance?: Mesh;
  58727. invertUV?: boolean;
  58728. }, scene?: Nullable<Scene>): Mesh;
  58729. /**
  58730. * Creates an custom extruded shape mesh.
  58731. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58732. * * 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.
  58733. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58734. * * 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
  58735. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58736. * * 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
  58737. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58738. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58739. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58740. * * 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
  58741. * * 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
  58742. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58745. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58747. * @param name defines the name of the mesh
  58748. * @param options defines the options used to create the mesh
  58749. * @param scene defines the hosting scene
  58750. * @returns the custom extruded shape mesh
  58751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58754. */
  58755. static ExtrudeShapeCustom(name: string, options: {
  58756. shape: Vector3[];
  58757. path: Vector3[];
  58758. scaleFunction?: any;
  58759. rotationFunction?: any;
  58760. ribbonCloseArray?: boolean;
  58761. ribbonClosePath?: boolean;
  58762. cap?: number;
  58763. updatable?: boolean;
  58764. sideOrientation?: number;
  58765. frontUVs?: Vector4;
  58766. backUVs?: Vector4;
  58767. instance?: Mesh;
  58768. invertUV?: boolean;
  58769. }, scene?: Nullable<Scene>): Mesh;
  58770. /**
  58771. * Creates lathe mesh.
  58772. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58773. * * 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
  58774. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58775. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58776. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58777. * * 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
  58778. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58779. * * 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
  58780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58784. * @param name defines the name of the mesh
  58785. * @param options defines the options used to create the mesh
  58786. * @param scene defines the hosting scene
  58787. * @returns the lathe mesh
  58788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58789. */
  58790. static CreateLathe(name: string, options: {
  58791. shape: Vector3[];
  58792. radius?: number;
  58793. tessellation?: number;
  58794. clip?: number;
  58795. arc?: number;
  58796. closed?: boolean;
  58797. updatable?: boolean;
  58798. sideOrientation?: number;
  58799. frontUVs?: Vector4;
  58800. backUVs?: Vector4;
  58801. cap?: number;
  58802. invertUV?: boolean;
  58803. }, scene?: Nullable<Scene>): Mesh;
  58804. /**
  58805. * Creates a tiled plane mesh
  58806. * * You can set a limited pattern arrangement with the tiles
  58807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58810. * @param name defines the name of the mesh
  58811. * @param options defines the options used to create the mesh
  58812. * @param scene defines the hosting scene
  58813. * @returns the plane mesh
  58814. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58815. */
  58816. static CreateTiledPlane(name: string, options: {
  58817. pattern?: number;
  58818. tileSize?: number;
  58819. tileWidth?: number;
  58820. tileHeight?: number;
  58821. size?: number;
  58822. width?: number;
  58823. height?: number;
  58824. alignHorizontal?: number;
  58825. alignVertical?: number;
  58826. sideOrientation?: number;
  58827. frontUVs?: Vector4;
  58828. backUVs?: Vector4;
  58829. updatable?: boolean;
  58830. }, scene?: Nullable<Scene>): Mesh;
  58831. /**
  58832. * Creates a plane mesh
  58833. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58834. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58835. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58839. * @param name defines the name of the mesh
  58840. * @param options defines the options used to create the mesh
  58841. * @param scene defines the hosting scene
  58842. * @returns the plane mesh
  58843. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58844. */
  58845. static CreatePlane(name: string, options: {
  58846. size?: number;
  58847. width?: number;
  58848. height?: number;
  58849. sideOrientation?: number;
  58850. frontUVs?: Vector4;
  58851. backUVs?: Vector4;
  58852. updatable?: boolean;
  58853. sourcePlane?: Plane;
  58854. }, scene?: Nullable<Scene>): Mesh;
  58855. /**
  58856. * Creates a ground mesh
  58857. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58858. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58860. * @param name defines the name of the mesh
  58861. * @param options defines the options used to create the mesh
  58862. * @param scene defines the hosting scene
  58863. * @returns the ground mesh
  58864. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58865. */
  58866. static CreateGround(name: string, options: {
  58867. width?: number;
  58868. height?: number;
  58869. subdivisions?: number;
  58870. subdivisionsX?: number;
  58871. subdivisionsY?: number;
  58872. updatable?: boolean;
  58873. }, scene?: Nullable<Scene>): Mesh;
  58874. /**
  58875. * Creates a tiled ground mesh
  58876. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58877. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58878. * * 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
  58879. * * 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
  58880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58881. * @param name defines the name of the mesh
  58882. * @param options defines the options used to create the mesh
  58883. * @param scene defines the hosting scene
  58884. * @returns the tiled ground mesh
  58885. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58886. */
  58887. static CreateTiledGround(name: string, options: {
  58888. xmin: number;
  58889. zmin: number;
  58890. xmax: number;
  58891. zmax: number;
  58892. subdivisions?: {
  58893. w: number;
  58894. h: number;
  58895. };
  58896. precision?: {
  58897. w: number;
  58898. h: number;
  58899. };
  58900. updatable?: boolean;
  58901. }, scene?: Nullable<Scene>): Mesh;
  58902. /**
  58903. * Creates a ground mesh from a height map
  58904. * * The parameter `url` sets the URL of the height map image resource.
  58905. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58906. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58907. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58908. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58909. * * 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.
  58910. * * 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).
  58911. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58913. * @param name defines the name of the mesh
  58914. * @param url defines the url to the height map
  58915. * @param options defines the options used to create the mesh
  58916. * @param scene defines the hosting scene
  58917. * @returns the ground mesh
  58918. * @see https://doc.babylonjs.com/babylon101/height_map
  58919. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58920. */
  58921. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58922. width?: number;
  58923. height?: number;
  58924. subdivisions?: number;
  58925. minHeight?: number;
  58926. maxHeight?: number;
  58927. colorFilter?: Color3;
  58928. alphaFilter?: number;
  58929. updatable?: boolean;
  58930. onReady?: (mesh: GroundMesh) => void;
  58931. }, scene?: Nullable<Scene>): GroundMesh;
  58932. /**
  58933. * Creates a polygon mesh
  58934. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58935. * * 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
  58936. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58939. * * Remember you can only change the shape positions, not their number when updating a polygon
  58940. * @param name defines the name of the mesh
  58941. * @param options defines the options used to create the mesh
  58942. * @param scene defines the hosting scene
  58943. * @param earcutInjection can be used to inject your own earcut reference
  58944. * @returns the polygon mesh
  58945. */
  58946. static CreatePolygon(name: string, options: {
  58947. shape: Vector3[];
  58948. holes?: Vector3[][];
  58949. depth?: number;
  58950. faceUV?: Vector4[];
  58951. faceColors?: Color4[];
  58952. updatable?: boolean;
  58953. sideOrientation?: number;
  58954. frontUVs?: Vector4;
  58955. backUVs?: Vector4;
  58956. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58957. /**
  58958. * Creates an extruded polygon mesh, with depth in the Y direction.
  58959. * * 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)
  58960. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58961. * @param name defines the name of the mesh
  58962. * @param options defines the options used to create the mesh
  58963. * @param scene defines the hosting scene
  58964. * @param earcutInjection can be used to inject your own earcut reference
  58965. * @returns the polygon mesh
  58966. */
  58967. static ExtrudePolygon(name: string, options: {
  58968. shape: Vector3[];
  58969. holes?: Vector3[][];
  58970. depth?: number;
  58971. faceUV?: Vector4[];
  58972. faceColors?: Color4[];
  58973. updatable?: boolean;
  58974. sideOrientation?: number;
  58975. frontUVs?: Vector4;
  58976. backUVs?: Vector4;
  58977. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58978. /**
  58979. * Creates a tube mesh.
  58980. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58981. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58982. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58983. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58984. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58985. * * 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)
  58986. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58987. * * 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
  58988. * * 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
  58989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58993. * @param name defines the name of the mesh
  58994. * @param options defines the options used to create the mesh
  58995. * @param scene defines the hosting scene
  58996. * @returns the tube mesh
  58997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58998. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58999. */
  59000. static CreateTube(name: string, options: {
  59001. path: Vector3[];
  59002. radius?: number;
  59003. tessellation?: number;
  59004. radiusFunction?: {
  59005. (i: number, distance: number): number;
  59006. };
  59007. cap?: number;
  59008. arc?: number;
  59009. updatable?: boolean;
  59010. sideOrientation?: number;
  59011. frontUVs?: Vector4;
  59012. backUVs?: Vector4;
  59013. instance?: Mesh;
  59014. invertUV?: boolean;
  59015. }, scene?: Nullable<Scene>): Mesh;
  59016. /**
  59017. * Creates a polyhedron mesh
  59018. * * 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
  59019. * * The parameter `size` (positive float, default 1) sets the polygon size
  59020. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59021. * * 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`
  59022. * * 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
  59023. * * 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)`)
  59024. * * 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
  59025. * * 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
  59026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59029. * @param name defines the name of the mesh
  59030. * @param options defines the options used to create the mesh
  59031. * @param scene defines the hosting scene
  59032. * @returns the polyhedron mesh
  59033. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59034. */
  59035. static CreatePolyhedron(name: string, options: {
  59036. type?: number;
  59037. size?: number;
  59038. sizeX?: number;
  59039. sizeY?: number;
  59040. sizeZ?: number;
  59041. custom?: any;
  59042. faceUV?: Vector4[];
  59043. faceColors?: Color4[];
  59044. flat?: boolean;
  59045. updatable?: boolean;
  59046. sideOrientation?: number;
  59047. frontUVs?: Vector4;
  59048. backUVs?: Vector4;
  59049. }, scene?: Nullable<Scene>): Mesh;
  59050. /**
  59051. * Creates a decal mesh.
  59052. * 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
  59053. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59054. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59055. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59056. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59057. * @param name defines the name of the mesh
  59058. * @param sourceMesh defines the mesh where the decal must be applied
  59059. * @param options defines the options used to create the mesh
  59060. * @param scene defines the hosting scene
  59061. * @returns the decal mesh
  59062. * @see https://doc.babylonjs.com/how_to/decals
  59063. */
  59064. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59065. position?: Vector3;
  59066. normal?: Vector3;
  59067. size?: Vector3;
  59068. angle?: number;
  59069. }): Mesh;
  59070. }
  59071. }
  59072. declare module "babylonjs/Meshes/meshSimplification" {
  59073. import { Mesh } from "babylonjs/Meshes/mesh";
  59074. /**
  59075. * A simplifier interface for future simplification implementations
  59076. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59077. */
  59078. export interface ISimplifier {
  59079. /**
  59080. * Simplification of a given mesh according to the given settings.
  59081. * Since this requires computation, it is assumed that the function runs async.
  59082. * @param settings The settings of the simplification, including quality and distance
  59083. * @param successCallback A callback that will be called after the mesh was simplified.
  59084. * @param errorCallback in case of an error, this callback will be called. optional.
  59085. */
  59086. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59087. }
  59088. /**
  59089. * Expected simplification settings.
  59090. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59091. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59092. */
  59093. export interface ISimplificationSettings {
  59094. /**
  59095. * Gets or sets the expected quality
  59096. */
  59097. quality: number;
  59098. /**
  59099. * Gets or sets the distance when this optimized version should be used
  59100. */
  59101. distance: number;
  59102. /**
  59103. * Gets an already optimized mesh
  59104. */
  59105. optimizeMesh?: boolean;
  59106. }
  59107. /**
  59108. * Class used to specify simplification options
  59109. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59110. */
  59111. export class SimplificationSettings implements ISimplificationSettings {
  59112. /** expected quality */
  59113. quality: number;
  59114. /** distance when this optimized version should be used */
  59115. distance: number;
  59116. /** already optimized mesh */
  59117. optimizeMesh?: boolean | undefined;
  59118. /**
  59119. * Creates a SimplificationSettings
  59120. * @param quality expected quality
  59121. * @param distance distance when this optimized version should be used
  59122. * @param optimizeMesh already optimized mesh
  59123. */
  59124. constructor(
  59125. /** expected quality */
  59126. quality: number,
  59127. /** distance when this optimized version should be used */
  59128. distance: number,
  59129. /** already optimized mesh */
  59130. optimizeMesh?: boolean | undefined);
  59131. }
  59132. /**
  59133. * Interface used to define a simplification task
  59134. */
  59135. export interface ISimplificationTask {
  59136. /**
  59137. * Array of settings
  59138. */
  59139. settings: Array<ISimplificationSettings>;
  59140. /**
  59141. * Simplification type
  59142. */
  59143. simplificationType: SimplificationType;
  59144. /**
  59145. * Mesh to simplify
  59146. */
  59147. mesh: Mesh;
  59148. /**
  59149. * Callback called on success
  59150. */
  59151. successCallback?: () => void;
  59152. /**
  59153. * Defines if parallel processing can be used
  59154. */
  59155. parallelProcessing: boolean;
  59156. }
  59157. /**
  59158. * Queue used to order the simplification tasks
  59159. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59160. */
  59161. export class SimplificationQueue {
  59162. private _simplificationArray;
  59163. /**
  59164. * Gets a boolean indicating that the process is still running
  59165. */
  59166. running: boolean;
  59167. /**
  59168. * Creates a new queue
  59169. */
  59170. constructor();
  59171. /**
  59172. * Adds a new simplification task
  59173. * @param task defines a task to add
  59174. */
  59175. addTask(task: ISimplificationTask): void;
  59176. /**
  59177. * Execute next task
  59178. */
  59179. executeNext(): void;
  59180. /**
  59181. * Execute a simplification task
  59182. * @param task defines the task to run
  59183. */
  59184. runSimplification(task: ISimplificationTask): void;
  59185. private getSimplifier;
  59186. }
  59187. /**
  59188. * The implemented types of simplification
  59189. * At the moment only Quadratic Error Decimation is implemented
  59190. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59191. */
  59192. export enum SimplificationType {
  59193. /** Quadratic error decimation */
  59194. QUADRATIC = 0
  59195. }
  59196. }
  59197. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59198. import { Scene } from "babylonjs/scene";
  59199. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59200. import { ISceneComponent } from "babylonjs/sceneComponent";
  59201. module "babylonjs/scene" {
  59202. interface Scene {
  59203. /** @hidden (Backing field) */
  59204. _simplificationQueue: SimplificationQueue;
  59205. /**
  59206. * Gets or sets the simplification queue attached to the scene
  59207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59208. */
  59209. simplificationQueue: SimplificationQueue;
  59210. }
  59211. }
  59212. module "babylonjs/Meshes/mesh" {
  59213. interface Mesh {
  59214. /**
  59215. * Simplify the mesh according to the given array of settings.
  59216. * Function will return immediately and will simplify async
  59217. * @param settings a collection of simplification settings
  59218. * @param parallelProcessing should all levels calculate parallel or one after the other
  59219. * @param simplificationType the type of simplification to run
  59220. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59221. * @returns the current mesh
  59222. */
  59223. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59224. }
  59225. }
  59226. /**
  59227. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59228. * created in a scene
  59229. */
  59230. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59231. /**
  59232. * The component name helpfull to identify the component in the list of scene components.
  59233. */
  59234. readonly name: string;
  59235. /**
  59236. * The scene the component belongs to.
  59237. */
  59238. scene: Scene;
  59239. /**
  59240. * Creates a new instance of the component for the given scene
  59241. * @param scene Defines the scene to register the component in
  59242. */
  59243. constructor(scene: Scene);
  59244. /**
  59245. * Registers the component in a given scene
  59246. */
  59247. register(): void;
  59248. /**
  59249. * Rebuilds the elements related to this component in case of
  59250. * context lost for instance.
  59251. */
  59252. rebuild(): void;
  59253. /**
  59254. * Disposes the component and the associated ressources
  59255. */
  59256. dispose(): void;
  59257. private _beforeCameraUpdate;
  59258. }
  59259. }
  59260. declare module "babylonjs/Meshes/Builders/index" {
  59261. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59262. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59263. export * from "babylonjs/Meshes/Builders/discBuilder";
  59264. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59265. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59266. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59267. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59268. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59269. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59270. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59271. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59272. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59273. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59274. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59275. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59276. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59277. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59278. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59279. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59280. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59281. }
  59282. declare module "babylonjs/Meshes/index" {
  59283. export * from "babylonjs/Meshes/abstractMesh";
  59284. export * from "babylonjs/Meshes/buffer";
  59285. export * from "babylonjs/Meshes/Compression/index";
  59286. export * from "babylonjs/Meshes/csg";
  59287. export * from "babylonjs/Meshes/geometry";
  59288. export * from "babylonjs/Meshes/groundMesh";
  59289. export * from "babylonjs/Meshes/trailMesh";
  59290. export * from "babylonjs/Meshes/instancedMesh";
  59291. export * from "babylonjs/Meshes/linesMesh";
  59292. export * from "babylonjs/Meshes/mesh";
  59293. export * from "babylonjs/Meshes/mesh.vertexData";
  59294. export * from "babylonjs/Meshes/meshBuilder";
  59295. export * from "babylonjs/Meshes/meshSimplification";
  59296. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59297. export * from "babylonjs/Meshes/polygonMesh";
  59298. export * from "babylonjs/Meshes/subMesh";
  59299. export * from "babylonjs/Meshes/meshLODLevel";
  59300. export * from "babylonjs/Meshes/transformNode";
  59301. export * from "babylonjs/Meshes/Builders/index";
  59302. export * from "babylonjs/Meshes/dataBuffer";
  59303. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59304. }
  59305. declare module "babylonjs/Morph/index" {
  59306. export * from "babylonjs/Morph/morphTarget";
  59307. export * from "babylonjs/Morph/morphTargetManager";
  59308. }
  59309. declare module "babylonjs/Navigation/INavigationEngine" {
  59310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59311. import { Vector3 } from "babylonjs/Maths/math";
  59312. import { Mesh } from "babylonjs/Meshes/mesh";
  59313. import { Scene } from "babylonjs/scene";
  59314. /**
  59315. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59316. */
  59317. export interface INavigationEnginePlugin {
  59318. /**
  59319. * plugin name
  59320. */
  59321. name: string;
  59322. /**
  59323. * Creates a navigation mesh
  59324. * @param meshes array of all the geometry used to compute the navigatio mesh
  59325. * @param parameters bunch of parameters used to filter geometry
  59326. */
  59327. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59328. /**
  59329. * Create a navigation mesh debug mesh
  59330. * @param scene is where the mesh will be added
  59331. * @returns debug display mesh
  59332. */
  59333. createDebugNavMesh(scene: Scene): Mesh;
  59334. /**
  59335. * Get a navigation mesh constrained position, closest to the parameter position
  59336. * @param position world position
  59337. * @returns the closest point to position constrained by the navigation mesh
  59338. */
  59339. getClosestPoint(position: Vector3): Vector3;
  59340. /**
  59341. * Get a navigation mesh constrained position, within a particular radius
  59342. * @param position world position
  59343. * @param maxRadius the maximum distance to the constrained world position
  59344. * @returns the closest point to position constrained by the navigation mesh
  59345. */
  59346. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59347. /**
  59348. * Compute the final position from a segment made of destination-position
  59349. * @param position world position
  59350. * @param destination world position
  59351. * @returns the resulting point along the navmesh
  59352. */
  59353. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59354. /**
  59355. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59356. * @param start world position
  59357. * @param end world position
  59358. * @returns array containing world position composing the path
  59359. */
  59360. computePath(start: Vector3, end: Vector3): Vector3[];
  59361. /**
  59362. * If this plugin is supported
  59363. * @returns true if plugin is supported
  59364. */
  59365. isSupported(): boolean;
  59366. /**
  59367. * Create a new Crowd so you can add agents
  59368. * @param maxAgents the maximum agent count in the crowd
  59369. * @param maxAgentRadius the maximum radius an agent can have
  59370. * @param scene to attach the crowd to
  59371. * @returns the crowd you can add agents to
  59372. */
  59373. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59374. /**
  59375. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59376. * The queries will try to find a solution within those bounds
  59377. * default is (1,1,1)
  59378. * @param extent x,y,z value that define the extent around the queries point of reference
  59379. */
  59380. setDefaultQueryExtent(extent: Vector3): void;
  59381. /**
  59382. * Get the Bounding box extent specified by setDefaultQueryExtent
  59383. * @returns the box extent values
  59384. */
  59385. getDefaultQueryExtent(): Vector3;
  59386. /**
  59387. * Release all resources
  59388. */
  59389. dispose(): void;
  59390. }
  59391. /**
  59392. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59393. */
  59394. export interface ICrowd {
  59395. /**
  59396. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59397. * You can attach anything to that node. The node position is updated in the scene update tick.
  59398. * @param pos world position that will be constrained by the navigation mesh
  59399. * @param parameters agent parameters
  59400. * @param transform hooked to the agent that will be update by the scene
  59401. * @returns agent index
  59402. */
  59403. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59404. /**
  59405. * Returns the agent position in world space
  59406. * @param index agent index returned by addAgent
  59407. * @returns world space position
  59408. */
  59409. getAgentPosition(index: number): Vector3;
  59410. /**
  59411. * Gets the agent velocity in world space
  59412. * @param index agent index returned by addAgent
  59413. * @returns world space velocity
  59414. */
  59415. getAgentVelocity(index: number): Vector3;
  59416. /**
  59417. * remove a particular agent previously created
  59418. * @param index agent index returned by addAgent
  59419. */
  59420. removeAgent(index: number): void;
  59421. /**
  59422. * get the list of all agents attached to this crowd
  59423. * @returns list of agent indices
  59424. */
  59425. getAgents(): number[];
  59426. /**
  59427. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59428. * @param deltaTime in seconds
  59429. */
  59430. update(deltaTime: number): void;
  59431. /**
  59432. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59433. * @param index agent index returned by addAgent
  59434. * @param destination targeted world position
  59435. */
  59436. agentGoto(index: number, destination: Vector3): void;
  59437. /**
  59438. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59439. * The queries will try to find a solution within those bounds
  59440. * default is (1,1,1)
  59441. * @param extent x,y,z value that define the extent around the queries point of reference
  59442. */
  59443. setDefaultQueryExtent(extent: Vector3): void;
  59444. /**
  59445. * Get the Bounding box extent specified by setDefaultQueryExtent
  59446. * @returns the box extent values
  59447. */
  59448. getDefaultQueryExtent(): Vector3;
  59449. /**
  59450. * Release all resources
  59451. */
  59452. dispose(): void;
  59453. }
  59454. /**
  59455. * Configures an agent
  59456. */
  59457. export interface IAgentParameters {
  59458. /**
  59459. * Agent radius. [Limit: >= 0]
  59460. */
  59461. radius: number;
  59462. /**
  59463. * Agent height. [Limit: > 0]
  59464. */
  59465. height: number;
  59466. /**
  59467. * Maximum allowed acceleration. [Limit: >= 0]
  59468. */
  59469. maxAcceleration: number;
  59470. /**
  59471. * Maximum allowed speed. [Limit: >= 0]
  59472. */
  59473. maxSpeed: number;
  59474. /**
  59475. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59476. */
  59477. collisionQueryRange: number;
  59478. /**
  59479. * The path visibility optimization range. [Limit: > 0]
  59480. */
  59481. pathOptimizationRange: number;
  59482. /**
  59483. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59484. */
  59485. separationWeight: number;
  59486. }
  59487. /**
  59488. * Configures the navigation mesh creation
  59489. */
  59490. export interface INavMeshParameters {
  59491. /**
  59492. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59493. */
  59494. cs: number;
  59495. /**
  59496. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59497. */
  59498. ch: number;
  59499. /**
  59500. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59501. */
  59502. walkableSlopeAngle: number;
  59503. /**
  59504. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59505. * be considered walkable. [Limit: >= 3] [Units: vx]
  59506. */
  59507. walkableHeight: number;
  59508. /**
  59509. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59510. */
  59511. walkableClimb: number;
  59512. /**
  59513. * The distance to erode/shrink the walkable area of the heightfield away from
  59514. * obstructions. [Limit: >=0] [Units: vx]
  59515. */
  59516. walkableRadius: number;
  59517. /**
  59518. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59519. */
  59520. maxEdgeLen: number;
  59521. /**
  59522. * The maximum distance a simplfied contour's border edges should deviate
  59523. * the original raw contour. [Limit: >=0] [Units: vx]
  59524. */
  59525. maxSimplificationError: number;
  59526. /**
  59527. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59528. */
  59529. minRegionArea: number;
  59530. /**
  59531. * Any regions with a span count smaller than this value will, if possible,
  59532. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59533. */
  59534. mergeRegionArea: number;
  59535. /**
  59536. * The maximum number of vertices allowed for polygons generated during the
  59537. * contour to polygon conversion process. [Limit: >= 3]
  59538. */
  59539. maxVertsPerPoly: number;
  59540. /**
  59541. * Sets the sampling distance to use when generating the detail mesh.
  59542. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59543. */
  59544. detailSampleDist: number;
  59545. /**
  59546. * The maximum distance the detail mesh surface should deviate from heightfield
  59547. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59548. */
  59549. detailSampleMaxError: number;
  59550. }
  59551. }
  59552. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59553. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59554. import { Mesh } from "babylonjs/Meshes/mesh";
  59555. import { Scene } from "babylonjs/scene";
  59556. import { Vector3 } from "babylonjs/Maths/math";
  59557. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59558. /**
  59559. * RecastJS navigation plugin
  59560. */
  59561. export class RecastJSPlugin implements INavigationEnginePlugin {
  59562. /**
  59563. * Reference to the Recast library
  59564. */
  59565. bjsRECAST: any;
  59566. /**
  59567. * plugin name
  59568. */
  59569. name: string;
  59570. /**
  59571. * the first navmesh created. We might extend this to support multiple navmeshes
  59572. */
  59573. navMesh: any;
  59574. /**
  59575. * Initializes the recastJS plugin
  59576. * @param recastInjection can be used to inject your own recast reference
  59577. */
  59578. constructor(recastInjection?: any);
  59579. /**
  59580. * Creates a navigation mesh
  59581. * @param meshes array of all the geometry used to compute the navigatio mesh
  59582. * @param parameters bunch of parameters used to filter geometry
  59583. */
  59584. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59585. /**
  59586. * Create a navigation mesh debug mesh
  59587. * @param scene is where the mesh will be added
  59588. * @returns debug display mesh
  59589. */
  59590. createDebugNavMesh(scene: Scene): Mesh;
  59591. /**
  59592. * Get a navigation mesh constrained position, closest to the parameter position
  59593. * @param position world position
  59594. * @returns the closest point to position constrained by the navigation mesh
  59595. */
  59596. getClosestPoint(position: Vector3): Vector3;
  59597. /**
  59598. * Get a navigation mesh constrained position, within a particular radius
  59599. * @param position world position
  59600. * @param maxRadius the maximum distance to the constrained world position
  59601. * @returns the closest point to position constrained by the navigation mesh
  59602. */
  59603. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59604. /**
  59605. * Compute the final position from a segment made of destination-position
  59606. * @param position world position
  59607. * @param destination world position
  59608. * @returns the resulting point along the navmesh
  59609. */
  59610. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59611. /**
  59612. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59613. * @param start world position
  59614. * @param end world position
  59615. * @returns array containing world position composing the path
  59616. */
  59617. computePath(start: Vector3, end: Vector3): Vector3[];
  59618. /**
  59619. * Create a new Crowd so you can add agents
  59620. * @param maxAgents the maximum agent count in the crowd
  59621. * @param maxAgentRadius the maximum radius an agent can have
  59622. * @param scene to attach the crowd to
  59623. * @returns the crowd you can add agents to
  59624. */
  59625. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59626. /**
  59627. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59628. * The queries will try to find a solution within those bounds
  59629. * default is (1,1,1)
  59630. * @param extent x,y,z value that define the extent around the queries point of reference
  59631. */
  59632. setDefaultQueryExtent(extent: Vector3): void;
  59633. /**
  59634. * Get the Bounding box extent specified by setDefaultQueryExtent
  59635. * @returns the box extent values
  59636. */
  59637. getDefaultQueryExtent(): Vector3;
  59638. /**
  59639. * Disposes
  59640. */
  59641. dispose(): void;
  59642. /**
  59643. * If this plugin is supported
  59644. * @returns true if plugin is supported
  59645. */
  59646. isSupported(): boolean;
  59647. }
  59648. /**
  59649. * Recast detour crowd implementation
  59650. */
  59651. export class RecastJSCrowd implements ICrowd {
  59652. /**
  59653. * Recast/detour plugin
  59654. */
  59655. bjsRECASTPlugin: RecastJSPlugin;
  59656. /**
  59657. * Link to the detour crowd
  59658. */
  59659. recastCrowd: any;
  59660. /**
  59661. * One transform per agent
  59662. */
  59663. transforms: TransformNode[];
  59664. /**
  59665. * All agents created
  59666. */
  59667. agents: number[];
  59668. /**
  59669. * Link to the scene is kept to unregister the crowd from the scene
  59670. */
  59671. private _scene;
  59672. /**
  59673. * Observer for crowd updates
  59674. */
  59675. private _onBeforeAnimationsObserver;
  59676. /**
  59677. * Constructor
  59678. * @param plugin recastJS plugin
  59679. * @param maxAgents the maximum agent count in the crowd
  59680. * @param maxAgentRadius the maximum radius an agent can have
  59681. * @param scene to attach the crowd to
  59682. * @returns the crowd you can add agents to
  59683. */
  59684. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59685. /**
  59686. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59687. * You can attach anything to that node. The node position is updated in the scene update tick.
  59688. * @param pos world position that will be constrained by the navigation mesh
  59689. * @param parameters agent parameters
  59690. * @param transform hooked to the agent that will be update by the scene
  59691. * @returns agent index
  59692. */
  59693. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59694. /**
  59695. * Returns the agent position in world space
  59696. * @param index agent index returned by addAgent
  59697. * @returns world space position
  59698. */
  59699. getAgentPosition(index: number): Vector3;
  59700. /**
  59701. * Returns the agent velocity in world space
  59702. * @param index agent index returned by addAgent
  59703. * @returns world space velocity
  59704. */
  59705. getAgentVelocity(index: number): Vector3;
  59706. /**
  59707. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59708. * @param index agent index returned by addAgent
  59709. * @param destination targeted world position
  59710. */
  59711. agentGoto(index: number, destination: Vector3): void;
  59712. /**
  59713. * remove a particular agent previously created
  59714. * @param index agent index returned by addAgent
  59715. */
  59716. removeAgent(index: number): void;
  59717. /**
  59718. * get the list of all agents attached to this crowd
  59719. * @returns list of agent indices
  59720. */
  59721. getAgents(): number[];
  59722. /**
  59723. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59724. * @param deltaTime in seconds
  59725. */
  59726. update(deltaTime: number): void;
  59727. /**
  59728. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59729. * The queries will try to find a solution within those bounds
  59730. * default is (1,1,1)
  59731. * @param extent x,y,z value that define the extent around the queries point of reference
  59732. */
  59733. setDefaultQueryExtent(extent: Vector3): void;
  59734. /**
  59735. * Get the Bounding box extent specified by setDefaultQueryExtent
  59736. * @returns the box extent values
  59737. */
  59738. getDefaultQueryExtent(): Vector3;
  59739. /**
  59740. * Release all resources
  59741. */
  59742. dispose(): void;
  59743. }
  59744. }
  59745. declare module "babylonjs/Navigation/Plugins/index" {
  59746. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59747. }
  59748. declare module "babylonjs/Navigation/index" {
  59749. export * from "babylonjs/Navigation/INavigationEngine";
  59750. export * from "babylonjs/Navigation/Plugins/index";
  59751. }
  59752. declare module "babylonjs/Offline/database" {
  59753. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59754. /**
  59755. * Class used to enable access to IndexedDB
  59756. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59757. */
  59758. export class Database implements IOfflineProvider {
  59759. private _callbackManifestChecked;
  59760. private _currentSceneUrl;
  59761. private _db;
  59762. private _enableSceneOffline;
  59763. private _enableTexturesOffline;
  59764. private _manifestVersionFound;
  59765. private _mustUpdateRessources;
  59766. private _hasReachedQuota;
  59767. private _isSupported;
  59768. private _idbFactory;
  59769. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59770. private static IsUASupportingBlobStorage;
  59771. /**
  59772. * Gets a boolean indicating if Database storate is enabled (off by default)
  59773. */
  59774. static IDBStorageEnabled: boolean;
  59775. /**
  59776. * Gets a boolean indicating if scene must be saved in the database
  59777. */
  59778. readonly enableSceneOffline: boolean;
  59779. /**
  59780. * Gets a boolean indicating if textures must be saved in the database
  59781. */
  59782. readonly enableTexturesOffline: boolean;
  59783. /**
  59784. * Creates a new Database
  59785. * @param urlToScene defines the url to load the scene
  59786. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59787. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59788. */
  59789. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59790. private static _ParseURL;
  59791. private static _ReturnFullUrlLocation;
  59792. private _checkManifestFile;
  59793. /**
  59794. * Open the database and make it available
  59795. * @param successCallback defines the callback to call on success
  59796. * @param errorCallback defines the callback to call on error
  59797. */
  59798. open(successCallback: () => void, errorCallback: () => void): void;
  59799. /**
  59800. * Loads an image from the database
  59801. * @param url defines the url to load from
  59802. * @param image defines the target DOM image
  59803. */
  59804. loadImage(url: string, image: HTMLImageElement): void;
  59805. private _loadImageFromDBAsync;
  59806. private _saveImageIntoDBAsync;
  59807. private _checkVersionFromDB;
  59808. private _loadVersionFromDBAsync;
  59809. private _saveVersionIntoDBAsync;
  59810. /**
  59811. * Loads a file from database
  59812. * @param url defines the URL to load from
  59813. * @param sceneLoaded defines a callback to call on success
  59814. * @param progressCallBack defines a callback to call when progress changed
  59815. * @param errorCallback defines a callback to call on error
  59816. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59817. */
  59818. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59819. private _loadFileAsync;
  59820. private _saveFileAsync;
  59821. /**
  59822. * Validates if xhr data is correct
  59823. * @param xhr defines the request to validate
  59824. * @param dataType defines the expected data type
  59825. * @returns true if data is correct
  59826. */
  59827. private static _ValidateXHRData;
  59828. }
  59829. }
  59830. declare module "babylonjs/Offline/index" {
  59831. export * from "babylonjs/Offline/database";
  59832. export * from "babylonjs/Offline/IOfflineProvider";
  59833. }
  59834. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59835. /** @hidden */
  59836. export var gpuUpdateParticlesPixelShader: {
  59837. name: string;
  59838. shader: string;
  59839. };
  59840. }
  59841. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59842. /** @hidden */
  59843. export var gpuUpdateParticlesVertexShader: {
  59844. name: string;
  59845. shader: string;
  59846. };
  59847. }
  59848. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59849. /** @hidden */
  59850. export var clipPlaneFragmentDeclaration2: {
  59851. name: string;
  59852. shader: string;
  59853. };
  59854. }
  59855. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59856. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59857. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59858. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59859. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59860. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59861. /** @hidden */
  59862. export var gpuRenderParticlesPixelShader: {
  59863. name: string;
  59864. shader: string;
  59865. };
  59866. }
  59867. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59868. /** @hidden */
  59869. export var clipPlaneVertexDeclaration2: {
  59870. name: string;
  59871. shader: string;
  59872. };
  59873. }
  59874. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59875. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59876. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59877. /** @hidden */
  59878. export var gpuRenderParticlesVertexShader: {
  59879. name: string;
  59880. shader: string;
  59881. };
  59882. }
  59883. declare module "babylonjs/Particles/gpuParticleSystem" {
  59884. import { Nullable } from "babylonjs/types";
  59885. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59886. import { Observable } from "babylonjs/Misc/observable";
  59887. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59888. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59889. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59890. import { Scene, IDisposable } from "babylonjs/scene";
  59891. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59892. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59893. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59894. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59895. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59896. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59897. /**
  59898. * This represents a GPU particle system in Babylon
  59899. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59900. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59901. */
  59902. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59903. /**
  59904. * The layer mask we are rendering the particles through.
  59905. */
  59906. layerMask: number;
  59907. private _capacity;
  59908. private _activeCount;
  59909. private _currentActiveCount;
  59910. private _accumulatedCount;
  59911. private _renderEffect;
  59912. private _updateEffect;
  59913. private _buffer0;
  59914. private _buffer1;
  59915. private _spriteBuffer;
  59916. private _updateVAO;
  59917. private _renderVAO;
  59918. private _targetIndex;
  59919. private _sourceBuffer;
  59920. private _targetBuffer;
  59921. private _engine;
  59922. private _currentRenderId;
  59923. private _started;
  59924. private _stopped;
  59925. private _timeDelta;
  59926. private _randomTexture;
  59927. private _randomTexture2;
  59928. private _attributesStrideSize;
  59929. private _updateEffectOptions;
  59930. private _randomTextureSize;
  59931. private _actualFrame;
  59932. private readonly _rawTextureWidth;
  59933. /**
  59934. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59935. */
  59936. static readonly IsSupported: boolean;
  59937. /**
  59938. * An event triggered when the system is disposed.
  59939. */
  59940. onDisposeObservable: Observable<GPUParticleSystem>;
  59941. /**
  59942. * Gets the maximum number of particles active at the same time.
  59943. * @returns The max number of active particles.
  59944. */
  59945. getCapacity(): number;
  59946. /**
  59947. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59948. * to override the particles.
  59949. */
  59950. forceDepthWrite: boolean;
  59951. /**
  59952. * Gets or set the number of active particles
  59953. */
  59954. activeParticleCount: number;
  59955. private _preWarmDone;
  59956. /**
  59957. * Is this system ready to be used/rendered
  59958. * @return true if the system is ready
  59959. */
  59960. isReady(): boolean;
  59961. /**
  59962. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59963. * @returns True if it has been started, otherwise false.
  59964. */
  59965. isStarted(): boolean;
  59966. /**
  59967. * Starts the particle system and begins to emit
  59968. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59969. */
  59970. start(delay?: number): void;
  59971. /**
  59972. * Stops the particle system.
  59973. */
  59974. stop(): void;
  59975. /**
  59976. * Remove all active particles
  59977. */
  59978. reset(): void;
  59979. /**
  59980. * Returns the string "GPUParticleSystem"
  59981. * @returns a string containing the class name
  59982. */
  59983. getClassName(): string;
  59984. private _colorGradientsTexture;
  59985. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59986. /**
  59987. * Adds a new color gradient
  59988. * @param gradient defines the gradient to use (between 0 and 1)
  59989. * @param color1 defines the color to affect to the specified gradient
  59990. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59991. * @returns the current particle system
  59992. */
  59993. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59994. /**
  59995. * Remove a specific color gradient
  59996. * @param gradient defines the gradient to remove
  59997. * @returns the current particle system
  59998. */
  59999. removeColorGradient(gradient: number): GPUParticleSystem;
  60000. private _angularSpeedGradientsTexture;
  60001. private _sizeGradientsTexture;
  60002. private _velocityGradientsTexture;
  60003. private _limitVelocityGradientsTexture;
  60004. private _dragGradientsTexture;
  60005. private _addFactorGradient;
  60006. /**
  60007. * Adds a new size gradient
  60008. * @param gradient defines the gradient to use (between 0 and 1)
  60009. * @param factor defines the size factor to affect to the specified gradient
  60010. * @returns the current particle system
  60011. */
  60012. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60013. /**
  60014. * Remove a specific size gradient
  60015. * @param gradient defines the gradient to remove
  60016. * @returns the current particle system
  60017. */
  60018. removeSizeGradient(gradient: number): GPUParticleSystem;
  60019. /**
  60020. * Adds a new angular speed gradient
  60021. * @param gradient defines the gradient to use (between 0 and 1)
  60022. * @param factor defines the angular speed to affect to the specified gradient
  60023. * @returns the current particle system
  60024. */
  60025. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60026. /**
  60027. * Remove a specific angular speed gradient
  60028. * @param gradient defines the gradient to remove
  60029. * @returns the current particle system
  60030. */
  60031. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60032. /**
  60033. * Adds a new velocity gradient
  60034. * @param gradient defines the gradient to use (between 0 and 1)
  60035. * @param factor defines the velocity to affect to the specified gradient
  60036. * @returns the current particle system
  60037. */
  60038. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60039. /**
  60040. * Remove a specific velocity gradient
  60041. * @param gradient defines the gradient to remove
  60042. * @returns the current particle system
  60043. */
  60044. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60045. /**
  60046. * Adds a new limit velocity gradient
  60047. * @param gradient defines the gradient to use (between 0 and 1)
  60048. * @param factor defines the limit velocity value to affect to the specified gradient
  60049. * @returns the current particle system
  60050. */
  60051. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60052. /**
  60053. * Remove a specific limit velocity gradient
  60054. * @param gradient defines the gradient to remove
  60055. * @returns the current particle system
  60056. */
  60057. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60058. /**
  60059. * Adds a new drag gradient
  60060. * @param gradient defines the gradient to use (between 0 and 1)
  60061. * @param factor defines the drag value to affect to the specified gradient
  60062. * @returns the current particle system
  60063. */
  60064. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60065. /**
  60066. * Remove a specific drag gradient
  60067. * @param gradient defines the gradient to remove
  60068. * @returns the current particle system
  60069. */
  60070. removeDragGradient(gradient: number): GPUParticleSystem;
  60071. /**
  60072. * Not supported by GPUParticleSystem
  60073. * @param gradient defines the gradient to use (between 0 and 1)
  60074. * @param factor defines the emit rate value to affect to the specified gradient
  60075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60076. * @returns the current particle system
  60077. */
  60078. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60079. /**
  60080. * Not supported by GPUParticleSystem
  60081. * @param gradient defines the gradient to remove
  60082. * @returns the current particle system
  60083. */
  60084. removeEmitRateGradient(gradient: number): IParticleSystem;
  60085. /**
  60086. * Not supported by GPUParticleSystem
  60087. * @param gradient defines the gradient to use (between 0 and 1)
  60088. * @param factor defines the start size value to affect to the specified gradient
  60089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60090. * @returns the current particle system
  60091. */
  60092. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60093. /**
  60094. * Not supported by GPUParticleSystem
  60095. * @param gradient defines the gradient to remove
  60096. * @returns the current particle system
  60097. */
  60098. removeStartSizeGradient(gradient: number): IParticleSystem;
  60099. /**
  60100. * Not supported by GPUParticleSystem
  60101. * @param gradient defines the gradient to use (between 0 and 1)
  60102. * @param min defines the color remap minimal range
  60103. * @param max defines the color remap maximal range
  60104. * @returns the current particle system
  60105. */
  60106. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60107. /**
  60108. * Not supported by GPUParticleSystem
  60109. * @param gradient defines the gradient to remove
  60110. * @returns the current particle system
  60111. */
  60112. removeColorRemapGradient(): IParticleSystem;
  60113. /**
  60114. * Not supported by GPUParticleSystem
  60115. * @param gradient defines the gradient to use (between 0 and 1)
  60116. * @param min defines the alpha remap minimal range
  60117. * @param max defines the alpha remap maximal range
  60118. * @returns the current particle system
  60119. */
  60120. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60121. /**
  60122. * Not supported by GPUParticleSystem
  60123. * @param gradient defines the gradient to remove
  60124. * @returns the current particle system
  60125. */
  60126. removeAlphaRemapGradient(): IParticleSystem;
  60127. /**
  60128. * Not supported by GPUParticleSystem
  60129. * @param gradient defines the gradient to use (between 0 and 1)
  60130. * @param color defines the color to affect to the specified gradient
  60131. * @returns the current particle system
  60132. */
  60133. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60134. /**
  60135. * Not supported by GPUParticleSystem
  60136. * @param gradient defines the gradient to remove
  60137. * @returns the current particle system
  60138. */
  60139. removeRampGradient(): IParticleSystem;
  60140. /**
  60141. * Not supported by GPUParticleSystem
  60142. * @returns the list of ramp gradients
  60143. */
  60144. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60145. /**
  60146. * Not supported by GPUParticleSystem
  60147. * Gets or sets a boolean indicating that ramp gradients must be used
  60148. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60149. */
  60150. useRampGradients: boolean;
  60151. /**
  60152. * Not supported by GPUParticleSystem
  60153. * @param gradient defines the gradient to use (between 0 and 1)
  60154. * @param factor defines the life time factor to affect to the specified gradient
  60155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60156. * @returns the current particle system
  60157. */
  60158. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60159. /**
  60160. * Not supported by GPUParticleSystem
  60161. * @param gradient defines the gradient to remove
  60162. * @returns the current particle system
  60163. */
  60164. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60165. /**
  60166. * Instantiates a GPU particle system.
  60167. * 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.
  60168. * @param name The name of the particle system
  60169. * @param options The options used to create the system
  60170. * @param scene The scene the particle system belongs to
  60171. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60172. */
  60173. constructor(name: string, options: Partial<{
  60174. capacity: number;
  60175. randomTextureSize: number;
  60176. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60177. protected _reset(): void;
  60178. private _createUpdateVAO;
  60179. private _createRenderVAO;
  60180. private _initialize;
  60181. /** @hidden */
  60182. _recreateUpdateEffect(): void;
  60183. /** @hidden */
  60184. _recreateRenderEffect(): void;
  60185. /**
  60186. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60187. * @param preWarm defines if we are in the pre-warmimg phase
  60188. */
  60189. animate(preWarm?: boolean): void;
  60190. private _createFactorGradientTexture;
  60191. private _createSizeGradientTexture;
  60192. private _createAngularSpeedGradientTexture;
  60193. private _createVelocityGradientTexture;
  60194. private _createLimitVelocityGradientTexture;
  60195. private _createDragGradientTexture;
  60196. private _createColorGradientTexture;
  60197. /**
  60198. * Renders the particle system in its current state
  60199. * @param preWarm defines if the system should only update the particles but not render them
  60200. * @returns the current number of particles
  60201. */
  60202. render(preWarm?: boolean): number;
  60203. /**
  60204. * Rebuilds the particle system
  60205. */
  60206. rebuild(): void;
  60207. private _releaseBuffers;
  60208. private _releaseVAOs;
  60209. /**
  60210. * Disposes the particle system and free the associated resources
  60211. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60212. */
  60213. dispose(disposeTexture?: boolean): void;
  60214. /**
  60215. * Clones the particle system.
  60216. * @param name The name of the cloned object
  60217. * @param newEmitter The new emitter to use
  60218. * @returns the cloned particle system
  60219. */
  60220. clone(name: string, newEmitter: any): GPUParticleSystem;
  60221. /**
  60222. * Serializes the particle system to a JSON object.
  60223. * @returns the JSON object
  60224. */
  60225. serialize(): any;
  60226. /**
  60227. * Parses a JSON object to create a GPU particle system.
  60228. * @param parsedParticleSystem The JSON object to parse
  60229. * @param scene The scene to create the particle system in
  60230. * @param rootUrl The root url to use to load external dependencies like texture
  60231. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60232. * @returns the parsed GPU particle system
  60233. */
  60234. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60235. }
  60236. }
  60237. declare module "babylonjs/Particles/particleSystemSet" {
  60238. import { Nullable } from "babylonjs/types";
  60239. import { Color3 } from "babylonjs/Maths/math.color";
  60240. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60242. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60243. import { Scene, IDisposable } from "babylonjs/scene";
  60244. /**
  60245. * Represents a set of particle systems working together to create a specific effect
  60246. */
  60247. export class ParticleSystemSet implements IDisposable {
  60248. private _emitterCreationOptions;
  60249. private _emitterNode;
  60250. /**
  60251. * Gets the particle system list
  60252. */
  60253. systems: IParticleSystem[];
  60254. /**
  60255. * Gets the emitter node used with this set
  60256. */
  60257. readonly emitterNode: Nullable<TransformNode>;
  60258. /**
  60259. * Creates a new emitter mesh as a sphere
  60260. * @param options defines the options used to create the sphere
  60261. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60262. * @param scene defines the hosting scene
  60263. */
  60264. setEmitterAsSphere(options: {
  60265. diameter: number;
  60266. segments: number;
  60267. color: Color3;
  60268. }, renderingGroupId: number, scene: Scene): void;
  60269. /**
  60270. * Starts all particle systems of the set
  60271. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60272. */
  60273. start(emitter?: AbstractMesh): void;
  60274. /**
  60275. * Release all associated resources
  60276. */
  60277. dispose(): void;
  60278. /**
  60279. * Serialize the set into a JSON compatible object
  60280. * @returns a JSON compatible representation of the set
  60281. */
  60282. serialize(): any;
  60283. /**
  60284. * Parse a new ParticleSystemSet from a serialized source
  60285. * @param data defines a JSON compatible representation of the set
  60286. * @param scene defines the hosting scene
  60287. * @param gpu defines if we want GPU particles or CPU particles
  60288. * @returns a new ParticleSystemSet
  60289. */
  60290. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60291. }
  60292. }
  60293. declare module "babylonjs/Particles/particleHelper" {
  60294. import { Nullable } from "babylonjs/types";
  60295. import { Scene } from "babylonjs/scene";
  60296. import { Vector3 } from "babylonjs/Maths/math.vector";
  60297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60298. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60299. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60300. /**
  60301. * This class is made for on one-liner static method to help creating particle system set.
  60302. */
  60303. export class ParticleHelper {
  60304. /**
  60305. * Gets or sets base Assets URL
  60306. */
  60307. static BaseAssetsUrl: string;
  60308. /**
  60309. * Create a default particle system that you can tweak
  60310. * @param emitter defines the emitter to use
  60311. * @param capacity defines the system capacity (default is 500 particles)
  60312. * @param scene defines the hosting scene
  60313. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60314. * @returns the new Particle system
  60315. */
  60316. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60317. /**
  60318. * This is the main static method (one-liner) of this helper to create different particle systems
  60319. * @param type This string represents the type to the particle system to create
  60320. * @param scene The scene where the particle system should live
  60321. * @param gpu If the system will use gpu
  60322. * @returns the ParticleSystemSet created
  60323. */
  60324. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60325. /**
  60326. * Static function used to export a particle system to a ParticleSystemSet variable.
  60327. * Please note that the emitter shape is not exported
  60328. * @param systems defines the particle systems to export
  60329. * @returns the created particle system set
  60330. */
  60331. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60332. }
  60333. }
  60334. declare module "babylonjs/Particles/particleSystemComponent" {
  60335. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60336. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60337. import "babylonjs/Shaders/particles.vertex";
  60338. module "babylonjs/Engines/engine" {
  60339. interface Engine {
  60340. /**
  60341. * Create an effect to use with particle systems.
  60342. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60343. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60344. * @param uniformsNames defines a list of attribute names
  60345. * @param samplers defines an array of string used to represent textures
  60346. * @param defines defines the string containing the defines to use to compile the shaders
  60347. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60348. * @param onCompiled defines a function to call when the effect creation is successful
  60349. * @param onError defines a function to call when the effect creation has failed
  60350. * @returns the new Effect
  60351. */
  60352. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60353. }
  60354. }
  60355. module "babylonjs/Meshes/mesh" {
  60356. interface Mesh {
  60357. /**
  60358. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60359. * @returns an array of IParticleSystem
  60360. */
  60361. getEmittedParticleSystems(): IParticleSystem[];
  60362. /**
  60363. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60364. * @returns an array of IParticleSystem
  60365. */
  60366. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60367. }
  60368. }
  60369. /**
  60370. * @hidden
  60371. */
  60372. export var _IDoNeedToBeInTheBuild: number;
  60373. }
  60374. declare module "babylonjs/Particles/index" {
  60375. export * from "babylonjs/Particles/baseParticleSystem";
  60376. export * from "babylonjs/Particles/EmitterTypes/index";
  60377. export * from "babylonjs/Particles/gpuParticleSystem";
  60378. export * from "babylonjs/Particles/IParticleSystem";
  60379. export * from "babylonjs/Particles/particle";
  60380. export * from "babylonjs/Particles/particleHelper";
  60381. export * from "babylonjs/Particles/particleSystem";
  60382. export * from "babylonjs/Particles/particleSystemComponent";
  60383. export * from "babylonjs/Particles/particleSystemSet";
  60384. export * from "babylonjs/Particles/solidParticle";
  60385. export * from "babylonjs/Particles/solidParticleSystem";
  60386. export * from "babylonjs/Particles/subEmitter";
  60387. }
  60388. declare module "babylonjs/Physics/physicsEngineComponent" {
  60389. import { Nullable } from "babylonjs/types";
  60390. import { Observable, Observer } from "babylonjs/Misc/observable";
  60391. import { Vector3 } from "babylonjs/Maths/math.vector";
  60392. import { Mesh } from "babylonjs/Meshes/mesh";
  60393. import { ISceneComponent } from "babylonjs/sceneComponent";
  60394. import { Scene } from "babylonjs/scene";
  60395. import { Node } from "babylonjs/node";
  60396. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60397. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60398. module "babylonjs/scene" {
  60399. interface Scene {
  60400. /** @hidden (Backing field) */
  60401. _physicsEngine: Nullable<IPhysicsEngine>;
  60402. /**
  60403. * Gets the current physics engine
  60404. * @returns a IPhysicsEngine or null if none attached
  60405. */
  60406. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60407. /**
  60408. * Enables physics to the current scene
  60409. * @param gravity defines the scene's gravity for the physics engine
  60410. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60411. * @return a boolean indicating if the physics engine was initialized
  60412. */
  60413. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60414. /**
  60415. * Disables and disposes the physics engine associated with the scene
  60416. */
  60417. disablePhysicsEngine(): void;
  60418. /**
  60419. * Gets a boolean indicating if there is an active physics engine
  60420. * @returns a boolean indicating if there is an active physics engine
  60421. */
  60422. isPhysicsEnabled(): boolean;
  60423. /**
  60424. * Deletes a physics compound impostor
  60425. * @param compound defines the compound to delete
  60426. */
  60427. deleteCompoundImpostor(compound: any): void;
  60428. /**
  60429. * An event triggered when physic simulation is about to be run
  60430. */
  60431. onBeforePhysicsObservable: Observable<Scene>;
  60432. /**
  60433. * An event triggered when physic simulation has been done
  60434. */
  60435. onAfterPhysicsObservable: Observable<Scene>;
  60436. }
  60437. }
  60438. module "babylonjs/Meshes/abstractMesh" {
  60439. interface AbstractMesh {
  60440. /** @hidden */
  60441. _physicsImpostor: Nullable<PhysicsImpostor>;
  60442. /**
  60443. * Gets or sets impostor used for physic simulation
  60444. * @see http://doc.babylonjs.com/features/physics_engine
  60445. */
  60446. physicsImpostor: Nullable<PhysicsImpostor>;
  60447. /**
  60448. * Gets the current physics impostor
  60449. * @see http://doc.babylonjs.com/features/physics_engine
  60450. * @returns a physics impostor or null
  60451. */
  60452. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60453. /** Apply a physic impulse to the mesh
  60454. * @param force defines the force to apply
  60455. * @param contactPoint defines where to apply the force
  60456. * @returns the current mesh
  60457. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60458. */
  60459. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60460. /**
  60461. * Creates a physic joint between two meshes
  60462. * @param otherMesh defines the other mesh to use
  60463. * @param pivot1 defines the pivot to use on this mesh
  60464. * @param pivot2 defines the pivot to use on the other mesh
  60465. * @param options defines additional options (can be plugin dependent)
  60466. * @returns the current mesh
  60467. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60468. */
  60469. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60470. /** @hidden */
  60471. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60472. }
  60473. }
  60474. /**
  60475. * Defines the physics engine scene component responsible to manage a physics engine
  60476. */
  60477. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60478. /**
  60479. * The component name helpful to identify the component in the list of scene components.
  60480. */
  60481. readonly name: string;
  60482. /**
  60483. * The scene the component belongs to.
  60484. */
  60485. scene: Scene;
  60486. /**
  60487. * Creates a new instance of the component for the given scene
  60488. * @param scene Defines the scene to register the component in
  60489. */
  60490. constructor(scene: Scene);
  60491. /**
  60492. * Registers the component in a given scene
  60493. */
  60494. register(): void;
  60495. /**
  60496. * Rebuilds the elements related to this component in case of
  60497. * context lost for instance.
  60498. */
  60499. rebuild(): void;
  60500. /**
  60501. * Disposes the component and the associated ressources
  60502. */
  60503. dispose(): void;
  60504. }
  60505. }
  60506. declare module "babylonjs/Physics/physicsHelper" {
  60507. import { Nullable } from "babylonjs/types";
  60508. import { Vector3 } from "babylonjs/Maths/math.vector";
  60509. import { Mesh } from "babylonjs/Meshes/mesh";
  60510. import { Scene } from "babylonjs/scene";
  60511. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60512. /**
  60513. * A helper for physics simulations
  60514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60515. */
  60516. export class PhysicsHelper {
  60517. private _scene;
  60518. private _physicsEngine;
  60519. /**
  60520. * Initializes the Physics helper
  60521. * @param scene Babylon.js scene
  60522. */
  60523. constructor(scene: Scene);
  60524. /**
  60525. * Applies a radial explosion impulse
  60526. * @param origin the origin of the explosion
  60527. * @param radiusOrEventOptions the radius or the options of radial explosion
  60528. * @param strength the explosion strength
  60529. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60530. * @returns A physics radial explosion event, or null
  60531. */
  60532. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60533. /**
  60534. * Applies a radial explosion force
  60535. * @param origin the origin of the explosion
  60536. * @param radiusOrEventOptions the radius or the options of radial explosion
  60537. * @param strength the explosion strength
  60538. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60539. * @returns A physics radial explosion event, or null
  60540. */
  60541. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60542. /**
  60543. * Creates a gravitational field
  60544. * @param origin the origin of the explosion
  60545. * @param radiusOrEventOptions the radius or the options of radial explosion
  60546. * @param strength the explosion strength
  60547. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60548. * @returns A physics gravitational field event, or null
  60549. */
  60550. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60551. /**
  60552. * Creates a physics updraft event
  60553. * @param origin the origin of the updraft
  60554. * @param radiusOrEventOptions the radius or the options of the updraft
  60555. * @param strength the strength of the updraft
  60556. * @param height the height of the updraft
  60557. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60558. * @returns A physics updraft event, or null
  60559. */
  60560. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60561. /**
  60562. * Creates a physics vortex event
  60563. * @param origin the of the vortex
  60564. * @param radiusOrEventOptions the radius or the options of the vortex
  60565. * @param strength the strength of the vortex
  60566. * @param height the height of the vortex
  60567. * @returns a Physics vortex event, or null
  60568. * A physics vortex event or null
  60569. */
  60570. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60571. }
  60572. /**
  60573. * Represents a physics radial explosion event
  60574. */
  60575. class PhysicsRadialExplosionEvent {
  60576. private _scene;
  60577. private _options;
  60578. private _sphere;
  60579. private _dataFetched;
  60580. /**
  60581. * Initializes a radial explosioin event
  60582. * @param _scene BabylonJS scene
  60583. * @param _options The options for the vortex event
  60584. */
  60585. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60586. /**
  60587. * Returns the data related to the radial explosion event (sphere).
  60588. * @returns The radial explosion event data
  60589. */
  60590. getData(): PhysicsRadialExplosionEventData;
  60591. /**
  60592. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60593. * @param impostor A physics imposter
  60594. * @param origin the origin of the explosion
  60595. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60596. */
  60597. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60598. /**
  60599. * Triggers affecterd impostors callbacks
  60600. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60601. */
  60602. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60603. /**
  60604. * Disposes the sphere.
  60605. * @param force Specifies if the sphere should be disposed by force
  60606. */
  60607. dispose(force?: boolean): void;
  60608. /*** Helpers ***/
  60609. private _prepareSphere;
  60610. private _intersectsWithSphere;
  60611. }
  60612. /**
  60613. * Represents a gravitational field event
  60614. */
  60615. class PhysicsGravitationalFieldEvent {
  60616. private _physicsHelper;
  60617. private _scene;
  60618. private _origin;
  60619. private _options;
  60620. private _tickCallback;
  60621. private _sphere;
  60622. private _dataFetched;
  60623. /**
  60624. * Initializes the physics gravitational field event
  60625. * @param _physicsHelper A physics helper
  60626. * @param _scene BabylonJS scene
  60627. * @param _origin The origin position of the gravitational field event
  60628. * @param _options The options for the vortex event
  60629. */
  60630. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60631. /**
  60632. * Returns the data related to the gravitational field event (sphere).
  60633. * @returns A gravitational field event
  60634. */
  60635. getData(): PhysicsGravitationalFieldEventData;
  60636. /**
  60637. * Enables the gravitational field.
  60638. */
  60639. enable(): void;
  60640. /**
  60641. * Disables the gravitational field.
  60642. */
  60643. disable(): void;
  60644. /**
  60645. * Disposes the sphere.
  60646. * @param force The force to dispose from the gravitational field event
  60647. */
  60648. dispose(force?: boolean): void;
  60649. private _tick;
  60650. }
  60651. /**
  60652. * Represents a physics updraft event
  60653. */
  60654. class PhysicsUpdraftEvent {
  60655. private _scene;
  60656. private _origin;
  60657. private _options;
  60658. private _physicsEngine;
  60659. private _originTop;
  60660. private _originDirection;
  60661. private _tickCallback;
  60662. private _cylinder;
  60663. private _cylinderPosition;
  60664. private _dataFetched;
  60665. /**
  60666. * Initializes the physics updraft event
  60667. * @param _scene BabylonJS scene
  60668. * @param _origin The origin position of the updraft
  60669. * @param _options The options for the updraft event
  60670. */
  60671. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60672. /**
  60673. * Returns the data related to the updraft event (cylinder).
  60674. * @returns A physics updraft event
  60675. */
  60676. getData(): PhysicsUpdraftEventData;
  60677. /**
  60678. * Enables the updraft.
  60679. */
  60680. enable(): void;
  60681. /**
  60682. * Disables the updraft.
  60683. */
  60684. disable(): void;
  60685. /**
  60686. * Disposes the cylinder.
  60687. * @param force Specifies if the updraft should be disposed by force
  60688. */
  60689. dispose(force?: boolean): void;
  60690. private getImpostorHitData;
  60691. private _tick;
  60692. /*** Helpers ***/
  60693. private _prepareCylinder;
  60694. private _intersectsWithCylinder;
  60695. }
  60696. /**
  60697. * Represents a physics vortex event
  60698. */
  60699. class PhysicsVortexEvent {
  60700. private _scene;
  60701. private _origin;
  60702. private _options;
  60703. private _physicsEngine;
  60704. private _originTop;
  60705. private _tickCallback;
  60706. private _cylinder;
  60707. private _cylinderPosition;
  60708. private _dataFetched;
  60709. /**
  60710. * Initializes the physics vortex event
  60711. * @param _scene The BabylonJS scene
  60712. * @param _origin The origin position of the vortex
  60713. * @param _options The options for the vortex event
  60714. */
  60715. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60716. /**
  60717. * Returns the data related to the vortex event (cylinder).
  60718. * @returns The physics vortex event data
  60719. */
  60720. getData(): PhysicsVortexEventData;
  60721. /**
  60722. * Enables the vortex.
  60723. */
  60724. enable(): void;
  60725. /**
  60726. * Disables the cortex.
  60727. */
  60728. disable(): void;
  60729. /**
  60730. * Disposes the sphere.
  60731. * @param force
  60732. */
  60733. dispose(force?: boolean): void;
  60734. private getImpostorHitData;
  60735. private _tick;
  60736. /*** Helpers ***/
  60737. private _prepareCylinder;
  60738. private _intersectsWithCylinder;
  60739. }
  60740. /**
  60741. * Options fot the radial explosion event
  60742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60743. */
  60744. export class PhysicsRadialExplosionEventOptions {
  60745. /**
  60746. * The radius of the sphere for the radial explosion.
  60747. */
  60748. radius: number;
  60749. /**
  60750. * The strenth of the explosion.
  60751. */
  60752. strength: number;
  60753. /**
  60754. * The strenght of the force in correspondence to the distance of the affected object
  60755. */
  60756. falloff: PhysicsRadialImpulseFalloff;
  60757. /**
  60758. * Sphere options for the radial explosion.
  60759. */
  60760. sphere: {
  60761. segments: number;
  60762. diameter: number;
  60763. };
  60764. /**
  60765. * Sphere options for the radial explosion.
  60766. */
  60767. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60768. }
  60769. /**
  60770. * Options fot the updraft event
  60771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60772. */
  60773. export class PhysicsUpdraftEventOptions {
  60774. /**
  60775. * The radius of the cylinder for the vortex
  60776. */
  60777. radius: number;
  60778. /**
  60779. * The strenth of the updraft.
  60780. */
  60781. strength: number;
  60782. /**
  60783. * The height of the cylinder for the updraft.
  60784. */
  60785. height: number;
  60786. /**
  60787. * The mode for the the updraft.
  60788. */
  60789. updraftMode: PhysicsUpdraftMode;
  60790. }
  60791. /**
  60792. * Options fot the vortex event
  60793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60794. */
  60795. export class PhysicsVortexEventOptions {
  60796. /**
  60797. * The radius of the cylinder for the vortex
  60798. */
  60799. radius: number;
  60800. /**
  60801. * The strenth of the vortex.
  60802. */
  60803. strength: number;
  60804. /**
  60805. * The height of the cylinder for the vortex.
  60806. */
  60807. height: number;
  60808. /**
  60809. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60810. */
  60811. centripetalForceThreshold: number;
  60812. /**
  60813. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60814. */
  60815. centripetalForceMultiplier: number;
  60816. /**
  60817. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60818. */
  60819. centrifugalForceMultiplier: number;
  60820. /**
  60821. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60822. */
  60823. updraftForceMultiplier: number;
  60824. }
  60825. /**
  60826. * The strenght of the force in correspondence to the distance of the affected object
  60827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60828. */
  60829. export enum PhysicsRadialImpulseFalloff {
  60830. /** Defines that impulse is constant in strength across it's whole radius */
  60831. Constant = 0,
  60832. /** Defines that impulse gets weaker if it's further from the origin */
  60833. Linear = 1
  60834. }
  60835. /**
  60836. * The strength of the force in correspondence to the distance of the affected object
  60837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60838. */
  60839. export enum PhysicsUpdraftMode {
  60840. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60841. Center = 0,
  60842. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60843. Perpendicular = 1
  60844. }
  60845. /**
  60846. * Interface for a physics hit data
  60847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60848. */
  60849. export interface PhysicsHitData {
  60850. /**
  60851. * The force applied at the contact point
  60852. */
  60853. force: Vector3;
  60854. /**
  60855. * The contact point
  60856. */
  60857. contactPoint: Vector3;
  60858. /**
  60859. * The distance from the origin to the contact point
  60860. */
  60861. distanceFromOrigin: number;
  60862. }
  60863. /**
  60864. * Interface for radial explosion event data
  60865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60866. */
  60867. export interface PhysicsRadialExplosionEventData {
  60868. /**
  60869. * A sphere used for the radial explosion event
  60870. */
  60871. sphere: Mesh;
  60872. }
  60873. /**
  60874. * Interface for gravitational field event data
  60875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60876. */
  60877. export interface PhysicsGravitationalFieldEventData {
  60878. /**
  60879. * A sphere mesh used for the gravitational field event
  60880. */
  60881. sphere: Mesh;
  60882. }
  60883. /**
  60884. * Interface for updraft event data
  60885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60886. */
  60887. export interface PhysicsUpdraftEventData {
  60888. /**
  60889. * A cylinder used for the updraft event
  60890. */
  60891. cylinder: Mesh;
  60892. }
  60893. /**
  60894. * Interface for vortex event data
  60895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60896. */
  60897. export interface PhysicsVortexEventData {
  60898. /**
  60899. * A cylinder used for the vortex event
  60900. */
  60901. cylinder: Mesh;
  60902. }
  60903. /**
  60904. * Interface for an affected physics impostor
  60905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60906. */
  60907. export interface PhysicsAffectedImpostorWithData {
  60908. /**
  60909. * The impostor affected by the effect
  60910. */
  60911. impostor: PhysicsImpostor;
  60912. /**
  60913. * The data about the hit/horce from the explosion
  60914. */
  60915. hitData: PhysicsHitData;
  60916. }
  60917. }
  60918. declare module "babylonjs/Physics/Plugins/index" {
  60919. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60920. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60921. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60922. }
  60923. declare module "babylonjs/Physics/index" {
  60924. export * from "babylonjs/Physics/IPhysicsEngine";
  60925. export * from "babylonjs/Physics/physicsEngine";
  60926. export * from "babylonjs/Physics/physicsEngineComponent";
  60927. export * from "babylonjs/Physics/physicsHelper";
  60928. export * from "babylonjs/Physics/physicsImpostor";
  60929. export * from "babylonjs/Physics/physicsJoint";
  60930. export * from "babylonjs/Physics/Plugins/index";
  60931. }
  60932. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60933. /** @hidden */
  60934. export var blackAndWhitePixelShader: {
  60935. name: string;
  60936. shader: string;
  60937. };
  60938. }
  60939. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60941. import { Camera } from "babylonjs/Cameras/camera";
  60942. import { Engine } from "babylonjs/Engines/engine";
  60943. import "babylonjs/Shaders/blackAndWhite.fragment";
  60944. /**
  60945. * Post process used to render in black and white
  60946. */
  60947. export class BlackAndWhitePostProcess extends PostProcess {
  60948. /**
  60949. * Linear about to convert he result to black and white (default: 1)
  60950. */
  60951. degree: number;
  60952. /**
  60953. * Creates a black and white post process
  60954. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60955. * @param name The name of the effect.
  60956. * @param options The required width/height ratio to downsize to before computing the render pass.
  60957. * @param camera The camera to apply the render pass to.
  60958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60959. * @param engine The engine which the post process will be applied. (default: current engine)
  60960. * @param reusable If the post process can be reused on the same frame. (default: false)
  60961. */
  60962. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60963. }
  60964. }
  60965. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60966. import { Nullable } from "babylonjs/types";
  60967. import { Camera } from "babylonjs/Cameras/camera";
  60968. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60969. import { Engine } from "babylonjs/Engines/engine";
  60970. /**
  60971. * This represents a set of one or more post processes in Babylon.
  60972. * A post process can be used to apply a shader to a texture after it is rendered.
  60973. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60974. */
  60975. export class PostProcessRenderEffect {
  60976. private _postProcesses;
  60977. private _getPostProcesses;
  60978. private _singleInstance;
  60979. private _cameras;
  60980. private _indicesForCamera;
  60981. /**
  60982. * Name of the effect
  60983. * @hidden
  60984. */
  60985. _name: string;
  60986. /**
  60987. * Instantiates a post process render effect.
  60988. * A post process can be used to apply a shader to a texture after it is rendered.
  60989. * @param engine The engine the effect is tied to
  60990. * @param name The name of the effect
  60991. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60992. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60993. */
  60994. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60995. /**
  60996. * Checks if all the post processes in the effect are supported.
  60997. */
  60998. readonly isSupported: boolean;
  60999. /**
  61000. * Updates the current state of the effect
  61001. * @hidden
  61002. */
  61003. _update(): void;
  61004. /**
  61005. * Attaches the effect on cameras
  61006. * @param cameras The camera to attach to.
  61007. * @hidden
  61008. */
  61009. _attachCameras(cameras: Camera): void;
  61010. /**
  61011. * Attaches the effect on cameras
  61012. * @param cameras The camera to attach to.
  61013. * @hidden
  61014. */
  61015. _attachCameras(cameras: Camera[]): void;
  61016. /**
  61017. * Detaches the effect on cameras
  61018. * @param cameras The camera to detatch from.
  61019. * @hidden
  61020. */
  61021. _detachCameras(cameras: Camera): void;
  61022. /**
  61023. * Detatches the effect on cameras
  61024. * @param cameras The camera to detatch from.
  61025. * @hidden
  61026. */
  61027. _detachCameras(cameras: Camera[]): void;
  61028. /**
  61029. * Enables the effect on given cameras
  61030. * @param cameras The camera to enable.
  61031. * @hidden
  61032. */
  61033. _enable(cameras: Camera): void;
  61034. /**
  61035. * Enables the effect on given cameras
  61036. * @param cameras The camera to enable.
  61037. * @hidden
  61038. */
  61039. _enable(cameras: Nullable<Camera[]>): void;
  61040. /**
  61041. * Disables the effect on the given cameras
  61042. * @param cameras The camera to disable.
  61043. * @hidden
  61044. */
  61045. _disable(cameras: Camera): void;
  61046. /**
  61047. * Disables the effect on the given cameras
  61048. * @param cameras The camera to disable.
  61049. * @hidden
  61050. */
  61051. _disable(cameras: Nullable<Camera[]>): void;
  61052. /**
  61053. * Gets a list of the post processes contained in the effect.
  61054. * @param camera The camera to get the post processes on.
  61055. * @returns The list of the post processes in the effect.
  61056. */
  61057. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61058. }
  61059. }
  61060. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61061. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61062. /** @hidden */
  61063. export var extractHighlightsPixelShader: {
  61064. name: string;
  61065. shader: string;
  61066. };
  61067. }
  61068. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61069. import { Nullable } from "babylonjs/types";
  61070. import { Camera } from "babylonjs/Cameras/camera";
  61071. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61072. import { Engine } from "babylonjs/Engines/engine";
  61073. import "babylonjs/Shaders/extractHighlights.fragment";
  61074. /**
  61075. * 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.
  61076. */
  61077. export class ExtractHighlightsPostProcess extends PostProcess {
  61078. /**
  61079. * The luminance threshold, pixels below this value will be set to black.
  61080. */
  61081. threshold: number;
  61082. /** @hidden */
  61083. _exposure: number;
  61084. /**
  61085. * Post process which has the input texture to be used when performing highlight extraction
  61086. * @hidden
  61087. */
  61088. _inputPostProcess: Nullable<PostProcess>;
  61089. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61090. }
  61091. }
  61092. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61093. /** @hidden */
  61094. export var bloomMergePixelShader: {
  61095. name: string;
  61096. shader: string;
  61097. };
  61098. }
  61099. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61100. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61101. import { Nullable } from "babylonjs/types";
  61102. import { Engine } from "babylonjs/Engines/engine";
  61103. import { Camera } from "babylonjs/Cameras/camera";
  61104. import "babylonjs/Shaders/bloomMerge.fragment";
  61105. /**
  61106. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61107. */
  61108. export class BloomMergePostProcess extends PostProcess {
  61109. /** Weight of the bloom to be added to the original input. */
  61110. weight: number;
  61111. /**
  61112. * Creates a new instance of @see BloomMergePostProcess
  61113. * @param name The name of the effect.
  61114. * @param originalFromInput Post process which's input will be used for the merge.
  61115. * @param blurred Blurred highlights post process which's output will be used.
  61116. * @param weight Weight of the bloom to be added to the original input.
  61117. * @param options The required width/height ratio to downsize to before computing the render pass.
  61118. * @param camera The camera to apply the render pass to.
  61119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61120. * @param engine The engine which the post process will be applied. (default: current engine)
  61121. * @param reusable If the post process can be reused on the same frame. (default: false)
  61122. * @param textureType Type of textures used when performing the post process. (default: 0)
  61123. * @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)
  61124. */
  61125. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61126. /** Weight of the bloom to be added to the original input. */
  61127. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61128. }
  61129. }
  61130. declare module "babylonjs/PostProcesses/bloomEffect" {
  61131. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61132. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61133. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61134. import { Camera } from "babylonjs/Cameras/camera";
  61135. import { Scene } from "babylonjs/scene";
  61136. /**
  61137. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61138. */
  61139. export class BloomEffect extends PostProcessRenderEffect {
  61140. private bloomScale;
  61141. /**
  61142. * @hidden Internal
  61143. */
  61144. _effects: Array<PostProcess>;
  61145. /**
  61146. * @hidden Internal
  61147. */
  61148. _downscale: ExtractHighlightsPostProcess;
  61149. private _blurX;
  61150. private _blurY;
  61151. private _merge;
  61152. /**
  61153. * The luminance threshold to find bright areas of the image to bloom.
  61154. */
  61155. threshold: number;
  61156. /**
  61157. * The strength of the bloom.
  61158. */
  61159. weight: number;
  61160. /**
  61161. * Specifies the size of the bloom blur kernel, relative to the final output size
  61162. */
  61163. kernel: number;
  61164. /**
  61165. * Creates a new instance of @see BloomEffect
  61166. * @param scene The scene the effect belongs to.
  61167. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61168. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61169. * @param bloomWeight The the strength of bloom.
  61170. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61171. * @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)
  61172. */
  61173. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61174. /**
  61175. * Disposes each of the internal effects for a given camera.
  61176. * @param camera The camera to dispose the effect on.
  61177. */
  61178. disposeEffects(camera: Camera): void;
  61179. /**
  61180. * @hidden Internal
  61181. */
  61182. _updateEffects(): void;
  61183. /**
  61184. * Internal
  61185. * @returns if all the contained post processes are ready.
  61186. * @hidden
  61187. */
  61188. _isReady(): boolean;
  61189. }
  61190. }
  61191. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61192. /** @hidden */
  61193. export var chromaticAberrationPixelShader: {
  61194. name: string;
  61195. shader: string;
  61196. };
  61197. }
  61198. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61199. import { Vector2 } from "babylonjs/Maths/math.vector";
  61200. import { Nullable } from "babylonjs/types";
  61201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61202. import { Camera } from "babylonjs/Cameras/camera";
  61203. import { Engine } from "babylonjs/Engines/engine";
  61204. import "babylonjs/Shaders/chromaticAberration.fragment";
  61205. /**
  61206. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61207. */
  61208. export class ChromaticAberrationPostProcess extends PostProcess {
  61209. /**
  61210. * The amount of seperation of rgb channels (default: 30)
  61211. */
  61212. aberrationAmount: number;
  61213. /**
  61214. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61215. */
  61216. radialIntensity: number;
  61217. /**
  61218. * 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))
  61219. */
  61220. direction: Vector2;
  61221. /**
  61222. * 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))
  61223. */
  61224. centerPosition: Vector2;
  61225. /**
  61226. * Creates a new instance ChromaticAberrationPostProcess
  61227. * @param name The name of the effect.
  61228. * @param screenWidth The width of the screen to apply the effect on.
  61229. * @param screenHeight The height of the screen to apply the effect on.
  61230. * @param options The required width/height ratio to downsize to before computing the render pass.
  61231. * @param camera The camera to apply the render pass to.
  61232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61233. * @param engine The engine which the post process will be applied. (default: current engine)
  61234. * @param reusable If the post process can be reused on the same frame. (default: false)
  61235. * @param textureType Type of textures used when performing the post process. (default: 0)
  61236. * @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)
  61237. */
  61238. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61239. }
  61240. }
  61241. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61242. /** @hidden */
  61243. export var circleOfConfusionPixelShader: {
  61244. name: string;
  61245. shader: string;
  61246. };
  61247. }
  61248. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61249. import { Nullable } from "babylonjs/types";
  61250. import { Engine } from "babylonjs/Engines/engine";
  61251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61252. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61253. import { Camera } from "babylonjs/Cameras/camera";
  61254. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61255. /**
  61256. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61257. */
  61258. export class CircleOfConfusionPostProcess extends PostProcess {
  61259. /**
  61260. * 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.
  61261. */
  61262. lensSize: number;
  61263. /**
  61264. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61265. */
  61266. fStop: number;
  61267. /**
  61268. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61269. */
  61270. focusDistance: number;
  61271. /**
  61272. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61273. */
  61274. focalLength: number;
  61275. private _depthTexture;
  61276. /**
  61277. * Creates a new instance CircleOfConfusionPostProcess
  61278. * @param name The name of the effect.
  61279. * @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.
  61280. * @param options The required width/height ratio to downsize to before computing the render pass.
  61281. * @param camera The camera to apply the render pass to.
  61282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61283. * @param engine The engine which the post process will be applied. (default: current engine)
  61284. * @param reusable If the post process can be reused on the same frame. (default: false)
  61285. * @param textureType Type of textures used when performing the post process. (default: 0)
  61286. * @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)
  61287. */
  61288. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61289. /**
  61290. * 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.
  61291. */
  61292. depthTexture: RenderTargetTexture;
  61293. }
  61294. }
  61295. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61296. /** @hidden */
  61297. export var colorCorrectionPixelShader: {
  61298. name: string;
  61299. shader: string;
  61300. };
  61301. }
  61302. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61303. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61304. import { Engine } from "babylonjs/Engines/engine";
  61305. import { Camera } from "babylonjs/Cameras/camera";
  61306. import "babylonjs/Shaders/colorCorrection.fragment";
  61307. /**
  61308. *
  61309. * This post-process allows the modification of rendered colors by using
  61310. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61311. *
  61312. * The object needs to be provided an url to a texture containing the color
  61313. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61314. * Use an image editing software to tweak the LUT to match your needs.
  61315. *
  61316. * For an example of a color LUT, see here:
  61317. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61318. * For explanations on color grading, see here:
  61319. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61320. *
  61321. */
  61322. export class ColorCorrectionPostProcess extends PostProcess {
  61323. private _colorTableTexture;
  61324. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61325. }
  61326. }
  61327. declare module "babylonjs/Shaders/convolution.fragment" {
  61328. /** @hidden */
  61329. export var convolutionPixelShader: {
  61330. name: string;
  61331. shader: string;
  61332. };
  61333. }
  61334. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61336. import { Nullable } from "babylonjs/types";
  61337. import { Camera } from "babylonjs/Cameras/camera";
  61338. import { Engine } from "babylonjs/Engines/engine";
  61339. import "babylonjs/Shaders/convolution.fragment";
  61340. /**
  61341. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61342. * input texture to perform effects such as edge detection or sharpening
  61343. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61344. */
  61345. export class ConvolutionPostProcess extends PostProcess {
  61346. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61347. kernel: number[];
  61348. /**
  61349. * Creates a new instance ConvolutionPostProcess
  61350. * @param name The name of the effect.
  61351. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61352. * @param options The required width/height ratio to downsize to before computing the render pass.
  61353. * @param camera The camera to apply the render pass to.
  61354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61355. * @param engine The engine which the post process will be applied. (default: current engine)
  61356. * @param reusable If the post process can be reused on the same frame. (default: false)
  61357. * @param textureType Type of textures used when performing the post process. (default: 0)
  61358. */
  61359. constructor(name: string,
  61360. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61361. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61362. /**
  61363. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61364. */
  61365. static EdgeDetect0Kernel: number[];
  61366. /**
  61367. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61368. */
  61369. static EdgeDetect1Kernel: number[];
  61370. /**
  61371. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61372. */
  61373. static EdgeDetect2Kernel: number[];
  61374. /**
  61375. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61376. */
  61377. static SharpenKernel: number[];
  61378. /**
  61379. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61380. */
  61381. static EmbossKernel: number[];
  61382. /**
  61383. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61384. */
  61385. static GaussianKernel: number[];
  61386. }
  61387. }
  61388. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61389. import { Nullable } from "babylonjs/types";
  61390. import { Vector2 } from "babylonjs/Maths/math.vector";
  61391. import { Camera } from "babylonjs/Cameras/camera";
  61392. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61393. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61394. import { Engine } from "babylonjs/Engines/engine";
  61395. import { Scene } from "babylonjs/scene";
  61396. /**
  61397. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61398. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61399. * based on samples that have a large difference in distance than the center pixel.
  61400. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61401. */
  61402. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61403. direction: Vector2;
  61404. /**
  61405. * Creates a new instance CircleOfConfusionPostProcess
  61406. * @param name The name of the effect.
  61407. * @param scene The scene the effect belongs to.
  61408. * @param direction The direction the blur should be applied.
  61409. * @param kernel The size of the kernel used to blur.
  61410. * @param options The required width/height ratio to downsize to before computing the render pass.
  61411. * @param camera The camera to apply the render pass to.
  61412. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61413. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61415. * @param engine The engine which the post process will be applied. (default: current engine)
  61416. * @param reusable If the post process can be reused on the same frame. (default: false)
  61417. * @param textureType Type of textures used when performing the post process. (default: 0)
  61418. * @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)
  61419. */
  61420. 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);
  61421. }
  61422. }
  61423. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61424. /** @hidden */
  61425. export var depthOfFieldMergePixelShader: {
  61426. name: string;
  61427. shader: string;
  61428. };
  61429. }
  61430. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61431. import { Nullable } from "babylonjs/types";
  61432. import { Camera } from "babylonjs/Cameras/camera";
  61433. import { Effect } from "babylonjs/Materials/effect";
  61434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61435. import { Engine } from "babylonjs/Engines/engine";
  61436. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61437. /**
  61438. * Options to be set when merging outputs from the default pipeline.
  61439. */
  61440. export class DepthOfFieldMergePostProcessOptions {
  61441. /**
  61442. * The original image to merge on top of
  61443. */
  61444. originalFromInput: PostProcess;
  61445. /**
  61446. * Parameters to perform the merge of the depth of field effect
  61447. */
  61448. depthOfField?: {
  61449. circleOfConfusion: PostProcess;
  61450. blurSteps: Array<PostProcess>;
  61451. };
  61452. /**
  61453. * Parameters to perform the merge of bloom effect
  61454. */
  61455. bloom?: {
  61456. blurred: PostProcess;
  61457. weight: number;
  61458. };
  61459. }
  61460. /**
  61461. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61462. */
  61463. export class DepthOfFieldMergePostProcess extends PostProcess {
  61464. private blurSteps;
  61465. /**
  61466. * Creates a new instance of DepthOfFieldMergePostProcess
  61467. * @param name The name of the effect.
  61468. * @param originalFromInput Post process which's input will be used for the merge.
  61469. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61470. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61471. * @param options The required width/height ratio to downsize to before computing the render pass.
  61472. * @param camera The camera to apply the render pass to.
  61473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61474. * @param engine The engine which the post process will be applied. (default: current engine)
  61475. * @param reusable If the post process can be reused on the same frame. (default: false)
  61476. * @param textureType Type of textures used when performing the post process. (default: 0)
  61477. * @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)
  61478. */
  61479. 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);
  61480. /**
  61481. * Updates the effect with the current post process compile time values and recompiles the shader.
  61482. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61483. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61484. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61485. * @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
  61486. * @param onCompiled Called when the shader has been compiled.
  61487. * @param onError Called if there is an error when compiling a shader.
  61488. */
  61489. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61490. }
  61491. }
  61492. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61493. import { Nullable } from "babylonjs/types";
  61494. import { Camera } from "babylonjs/Cameras/camera";
  61495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61496. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61497. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61498. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61499. import { Scene } from "babylonjs/scene";
  61500. /**
  61501. * Specifies the level of max blur that should be applied when using the depth of field effect
  61502. */
  61503. export enum DepthOfFieldEffectBlurLevel {
  61504. /**
  61505. * Subtle blur
  61506. */
  61507. Low = 0,
  61508. /**
  61509. * Medium blur
  61510. */
  61511. Medium = 1,
  61512. /**
  61513. * Large blur
  61514. */
  61515. High = 2
  61516. }
  61517. /**
  61518. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61519. */
  61520. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61521. private _circleOfConfusion;
  61522. /**
  61523. * @hidden Internal, blurs from high to low
  61524. */
  61525. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61526. private _depthOfFieldBlurY;
  61527. private _dofMerge;
  61528. /**
  61529. * @hidden Internal post processes in depth of field effect
  61530. */
  61531. _effects: Array<PostProcess>;
  61532. /**
  61533. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61534. */
  61535. focalLength: number;
  61536. /**
  61537. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61538. */
  61539. fStop: number;
  61540. /**
  61541. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61542. */
  61543. focusDistance: number;
  61544. /**
  61545. * 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.
  61546. */
  61547. lensSize: number;
  61548. /**
  61549. * Creates a new instance DepthOfFieldEffect
  61550. * @param scene The scene the effect belongs to.
  61551. * @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.
  61552. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61553. * @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)
  61554. */
  61555. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61556. /**
  61557. * Get the current class name of the current effet
  61558. * @returns "DepthOfFieldEffect"
  61559. */
  61560. getClassName(): string;
  61561. /**
  61562. * 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.
  61563. */
  61564. depthTexture: RenderTargetTexture;
  61565. /**
  61566. * Disposes each of the internal effects for a given camera.
  61567. * @param camera The camera to dispose the effect on.
  61568. */
  61569. disposeEffects(camera: Camera): void;
  61570. /**
  61571. * @hidden Internal
  61572. */
  61573. _updateEffects(): void;
  61574. /**
  61575. * Internal
  61576. * @returns if all the contained post processes are ready.
  61577. * @hidden
  61578. */
  61579. _isReady(): boolean;
  61580. }
  61581. }
  61582. declare module "babylonjs/Shaders/displayPass.fragment" {
  61583. /** @hidden */
  61584. export var displayPassPixelShader: {
  61585. name: string;
  61586. shader: string;
  61587. };
  61588. }
  61589. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61590. import { Nullable } from "babylonjs/types";
  61591. import { Camera } from "babylonjs/Cameras/camera";
  61592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61593. import { Engine } from "babylonjs/Engines/engine";
  61594. import "babylonjs/Shaders/displayPass.fragment";
  61595. /**
  61596. * DisplayPassPostProcess which produces an output the same as it's input
  61597. */
  61598. export class DisplayPassPostProcess extends PostProcess {
  61599. /**
  61600. * Creates the DisplayPassPostProcess
  61601. * @param name The name of the effect.
  61602. * @param options The required width/height ratio to downsize to before computing the render pass.
  61603. * @param camera The camera to apply the render pass to.
  61604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61605. * @param engine The engine which the post process will be applied. (default: current engine)
  61606. * @param reusable If the post process can be reused on the same frame. (default: false)
  61607. */
  61608. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61609. }
  61610. }
  61611. declare module "babylonjs/Shaders/filter.fragment" {
  61612. /** @hidden */
  61613. export var filterPixelShader: {
  61614. name: string;
  61615. shader: string;
  61616. };
  61617. }
  61618. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61619. import { Nullable } from "babylonjs/types";
  61620. import { Matrix } from "babylonjs/Maths/math.vector";
  61621. import { Camera } from "babylonjs/Cameras/camera";
  61622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61623. import { Engine } from "babylonjs/Engines/engine";
  61624. import "babylonjs/Shaders/filter.fragment";
  61625. /**
  61626. * Applies a kernel filter to the image
  61627. */
  61628. export class FilterPostProcess extends PostProcess {
  61629. /** The matrix to be applied to the image */
  61630. kernelMatrix: Matrix;
  61631. /**
  61632. *
  61633. * @param name The name of the effect.
  61634. * @param kernelMatrix The matrix to be applied to the image
  61635. * @param options The required width/height ratio to downsize to before computing the render pass.
  61636. * @param camera The camera to apply the render pass to.
  61637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61638. * @param engine The engine which the post process will be applied. (default: current engine)
  61639. * @param reusable If the post process can be reused on the same frame. (default: false)
  61640. */
  61641. constructor(name: string,
  61642. /** The matrix to be applied to the image */
  61643. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61644. }
  61645. }
  61646. declare module "babylonjs/Shaders/fxaa.fragment" {
  61647. /** @hidden */
  61648. export var fxaaPixelShader: {
  61649. name: string;
  61650. shader: string;
  61651. };
  61652. }
  61653. declare module "babylonjs/Shaders/fxaa.vertex" {
  61654. /** @hidden */
  61655. export var fxaaVertexShader: {
  61656. name: string;
  61657. shader: string;
  61658. };
  61659. }
  61660. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61661. import { Nullable } from "babylonjs/types";
  61662. import { Camera } from "babylonjs/Cameras/camera";
  61663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61664. import { Engine } from "babylonjs/Engines/engine";
  61665. import "babylonjs/Shaders/fxaa.fragment";
  61666. import "babylonjs/Shaders/fxaa.vertex";
  61667. /**
  61668. * Fxaa post process
  61669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61670. */
  61671. export class FxaaPostProcess extends PostProcess {
  61672. /** @hidden */
  61673. texelWidth: number;
  61674. /** @hidden */
  61675. texelHeight: number;
  61676. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61677. private _getDefines;
  61678. }
  61679. }
  61680. declare module "babylonjs/Shaders/grain.fragment" {
  61681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61682. /** @hidden */
  61683. export var grainPixelShader: {
  61684. name: string;
  61685. shader: string;
  61686. };
  61687. }
  61688. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61689. import { Nullable } from "babylonjs/types";
  61690. import { Camera } from "babylonjs/Cameras/camera";
  61691. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61692. import { Engine } from "babylonjs/Engines/engine";
  61693. import "babylonjs/Shaders/grain.fragment";
  61694. /**
  61695. * The GrainPostProcess adds noise to the image at mid luminance levels
  61696. */
  61697. export class GrainPostProcess extends PostProcess {
  61698. /**
  61699. * The intensity of the grain added (default: 30)
  61700. */
  61701. intensity: number;
  61702. /**
  61703. * If the grain should be randomized on every frame
  61704. */
  61705. animated: boolean;
  61706. /**
  61707. * Creates a new instance of @see GrainPostProcess
  61708. * @param name The name of the effect.
  61709. * @param options The required width/height ratio to downsize to before computing the render pass.
  61710. * @param camera The camera to apply the render pass to.
  61711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61712. * @param engine The engine which the post process will be applied. (default: current engine)
  61713. * @param reusable If the post process can be reused on the same frame. (default: false)
  61714. * @param textureType Type of textures used when performing the post process. (default: 0)
  61715. * @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)
  61716. */
  61717. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61718. }
  61719. }
  61720. declare module "babylonjs/Shaders/highlights.fragment" {
  61721. /** @hidden */
  61722. export var highlightsPixelShader: {
  61723. name: string;
  61724. shader: string;
  61725. };
  61726. }
  61727. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61728. import { Nullable } from "babylonjs/types";
  61729. import { Camera } from "babylonjs/Cameras/camera";
  61730. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61731. import { Engine } from "babylonjs/Engines/engine";
  61732. import "babylonjs/Shaders/highlights.fragment";
  61733. /**
  61734. * Extracts highlights from the image
  61735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61736. */
  61737. export class HighlightsPostProcess extends PostProcess {
  61738. /**
  61739. * Extracts highlights from the image
  61740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61741. * @param name The name of the effect.
  61742. * @param options The required width/height ratio to downsize to before computing the render pass.
  61743. * @param camera The camera to apply the render pass to.
  61744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61745. * @param engine The engine which the post process will be applied. (default: current engine)
  61746. * @param reusable If the post process can be reused on the same frame. (default: false)
  61747. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61748. */
  61749. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61750. }
  61751. }
  61752. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61753. /** @hidden */
  61754. export var mrtFragmentDeclaration: {
  61755. name: string;
  61756. shader: string;
  61757. };
  61758. }
  61759. declare module "babylonjs/Shaders/geometry.fragment" {
  61760. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61761. /** @hidden */
  61762. export var geometryPixelShader: {
  61763. name: string;
  61764. shader: string;
  61765. };
  61766. }
  61767. declare module "babylonjs/Shaders/geometry.vertex" {
  61768. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61770. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61771. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61772. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61773. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61774. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61775. /** @hidden */
  61776. export var geometryVertexShader: {
  61777. name: string;
  61778. shader: string;
  61779. };
  61780. }
  61781. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61782. import { Matrix } from "babylonjs/Maths/math.vector";
  61783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61784. import { Mesh } from "babylonjs/Meshes/mesh";
  61785. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61786. import { Effect } from "babylonjs/Materials/effect";
  61787. import { Scene } from "babylonjs/scene";
  61788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61789. import "babylonjs/Shaders/geometry.fragment";
  61790. import "babylonjs/Shaders/geometry.vertex";
  61791. /** @hidden */
  61792. interface ISavedTransformationMatrix {
  61793. world: Matrix;
  61794. viewProjection: Matrix;
  61795. }
  61796. /**
  61797. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61798. */
  61799. export class GeometryBufferRenderer {
  61800. /**
  61801. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61802. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61803. */
  61804. static readonly POSITION_TEXTURE_TYPE: number;
  61805. /**
  61806. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61807. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61808. */
  61809. static readonly VELOCITY_TEXTURE_TYPE: number;
  61810. /**
  61811. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61812. * in order to compute objects velocities when enableVelocity is set to "true"
  61813. * @hidden
  61814. */
  61815. _previousTransformationMatrices: {
  61816. [index: number]: ISavedTransformationMatrix;
  61817. };
  61818. /**
  61819. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61820. * in order to compute objects velocities when enableVelocity is set to "true"
  61821. * @hidden
  61822. */
  61823. _previousBonesTransformationMatrices: {
  61824. [index: number]: Float32Array;
  61825. };
  61826. /**
  61827. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61828. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61829. */
  61830. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61831. private _scene;
  61832. private _multiRenderTarget;
  61833. private _ratio;
  61834. private _enablePosition;
  61835. private _enableVelocity;
  61836. private _positionIndex;
  61837. private _velocityIndex;
  61838. protected _effect: Effect;
  61839. protected _cachedDefines: string;
  61840. /**
  61841. * Set the render list (meshes to be rendered) used in the G buffer.
  61842. */
  61843. renderList: Mesh[];
  61844. /**
  61845. * Gets wether or not G buffer are supported by the running hardware.
  61846. * This requires draw buffer supports
  61847. */
  61848. readonly isSupported: boolean;
  61849. /**
  61850. * Returns the index of the given texture type in the G-Buffer textures array
  61851. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61852. * @returns the index of the given texture type in the G-Buffer textures array
  61853. */
  61854. getTextureIndex(textureType: number): number;
  61855. /**
  61856. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61857. */
  61858. /**
  61859. * Sets whether or not objects positions are enabled for the G buffer.
  61860. */
  61861. enablePosition: boolean;
  61862. /**
  61863. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61864. */
  61865. /**
  61866. * Sets wether or not objects velocities are enabled for the G buffer.
  61867. */
  61868. enableVelocity: boolean;
  61869. /**
  61870. * Gets the scene associated with the buffer.
  61871. */
  61872. readonly scene: Scene;
  61873. /**
  61874. * Gets the ratio used by the buffer during its creation.
  61875. * How big is the buffer related to the main canvas.
  61876. */
  61877. readonly ratio: number;
  61878. /** @hidden */
  61879. static _SceneComponentInitialization: (scene: Scene) => void;
  61880. /**
  61881. * Creates a new G Buffer for the scene
  61882. * @param scene The scene the buffer belongs to
  61883. * @param ratio How big is the buffer related to the main canvas.
  61884. */
  61885. constructor(scene: Scene, ratio?: number);
  61886. /**
  61887. * Checks wether everything is ready to render a submesh to the G buffer.
  61888. * @param subMesh the submesh to check readiness for
  61889. * @param useInstances is the mesh drawn using instance or not
  61890. * @returns true if ready otherwise false
  61891. */
  61892. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61893. /**
  61894. * Gets the current underlying G Buffer.
  61895. * @returns the buffer
  61896. */
  61897. getGBuffer(): MultiRenderTarget;
  61898. /**
  61899. * Gets the number of samples used to render the buffer (anti aliasing).
  61900. */
  61901. /**
  61902. * Sets the number of samples used to render the buffer (anti aliasing).
  61903. */
  61904. samples: number;
  61905. /**
  61906. * Disposes the renderer and frees up associated resources.
  61907. */
  61908. dispose(): void;
  61909. protected _createRenderTargets(): void;
  61910. private _copyBonesTransformationMatrices;
  61911. }
  61912. }
  61913. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61914. import { Nullable } from "babylonjs/types";
  61915. import { Scene } from "babylonjs/scene";
  61916. import { ISceneComponent } from "babylonjs/sceneComponent";
  61917. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61918. module "babylonjs/scene" {
  61919. interface Scene {
  61920. /** @hidden (Backing field) */
  61921. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61922. /**
  61923. * Gets or Sets the current geometry buffer associated to the scene.
  61924. */
  61925. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61926. /**
  61927. * Enables a GeometryBufferRender and associates it with the scene
  61928. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61929. * @returns the GeometryBufferRenderer
  61930. */
  61931. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61932. /**
  61933. * Disables the GeometryBufferRender associated with the scene
  61934. */
  61935. disableGeometryBufferRenderer(): void;
  61936. }
  61937. }
  61938. /**
  61939. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61940. * in several rendering techniques.
  61941. */
  61942. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61943. /**
  61944. * The component name helpful to identify the component in the list of scene components.
  61945. */
  61946. readonly name: string;
  61947. /**
  61948. * The scene the component belongs to.
  61949. */
  61950. scene: Scene;
  61951. /**
  61952. * Creates a new instance of the component for the given scene
  61953. * @param scene Defines the scene to register the component in
  61954. */
  61955. constructor(scene: Scene);
  61956. /**
  61957. * Registers the component in a given scene
  61958. */
  61959. register(): void;
  61960. /**
  61961. * Rebuilds the elements related to this component in case of
  61962. * context lost for instance.
  61963. */
  61964. rebuild(): void;
  61965. /**
  61966. * Disposes the component and the associated ressources
  61967. */
  61968. dispose(): void;
  61969. private _gatherRenderTargets;
  61970. }
  61971. }
  61972. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61973. /** @hidden */
  61974. export var motionBlurPixelShader: {
  61975. name: string;
  61976. shader: string;
  61977. };
  61978. }
  61979. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61980. import { Nullable } from "babylonjs/types";
  61981. import { Camera } from "babylonjs/Cameras/camera";
  61982. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61983. import { Scene } from "babylonjs/scene";
  61984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61985. import "babylonjs/Animations/animatable";
  61986. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61987. import "babylonjs/Shaders/motionBlur.fragment";
  61988. import { Engine } from "babylonjs/Engines/engine";
  61989. /**
  61990. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61991. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61992. * As an example, all you have to do is to create the post-process:
  61993. * var mb = new BABYLON.MotionBlurPostProcess(
  61994. * 'mb', // The name of the effect.
  61995. * scene, // The scene containing the objects to blur according to their velocity.
  61996. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61997. * camera // The camera to apply the render pass to.
  61998. * );
  61999. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62000. */
  62001. export class MotionBlurPostProcess extends PostProcess {
  62002. /**
  62003. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62004. */
  62005. motionStrength: number;
  62006. /**
  62007. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62008. */
  62009. /**
  62010. * Sets the number of iterations to be used for motion blur quality
  62011. */
  62012. motionBlurSamples: number;
  62013. private _motionBlurSamples;
  62014. private _geometryBufferRenderer;
  62015. /**
  62016. * Creates a new instance MotionBlurPostProcess
  62017. * @param name The name of the effect.
  62018. * @param scene The scene containing the objects to blur according to their velocity.
  62019. * @param options The required width/height ratio to downsize to before computing the render pass.
  62020. * @param camera The camera to apply the render pass to.
  62021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62022. * @param engine The engine which the post process will be applied. (default: current engine)
  62023. * @param reusable If the post process can be reused on the same frame. (default: false)
  62024. * @param textureType Type of textures used when performing the post process. (default: 0)
  62025. * @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)
  62026. */
  62027. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62028. /**
  62029. * Excludes the given skinned mesh from computing bones velocities.
  62030. * 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.
  62031. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62032. */
  62033. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62034. /**
  62035. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62036. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62037. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62038. */
  62039. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62040. /**
  62041. * Disposes the post process.
  62042. * @param camera The camera to dispose the post process on.
  62043. */
  62044. dispose(camera?: Camera): void;
  62045. }
  62046. }
  62047. declare module "babylonjs/Shaders/refraction.fragment" {
  62048. /** @hidden */
  62049. export var refractionPixelShader: {
  62050. name: string;
  62051. shader: string;
  62052. };
  62053. }
  62054. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62055. import { Color3 } from "babylonjs/Maths/math.color";
  62056. import { Camera } from "babylonjs/Cameras/camera";
  62057. import { Texture } from "babylonjs/Materials/Textures/texture";
  62058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62059. import { Engine } from "babylonjs/Engines/engine";
  62060. import "babylonjs/Shaders/refraction.fragment";
  62061. /**
  62062. * Post process which applies a refractin texture
  62063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62064. */
  62065. export class RefractionPostProcess extends PostProcess {
  62066. /** the base color of the refraction (used to taint the rendering) */
  62067. color: Color3;
  62068. /** simulated refraction depth */
  62069. depth: number;
  62070. /** the coefficient of the base color (0 to remove base color tainting) */
  62071. colorLevel: number;
  62072. private _refTexture;
  62073. private _ownRefractionTexture;
  62074. /**
  62075. * Gets or sets the refraction texture
  62076. * Please note that you are responsible for disposing the texture if you set it manually
  62077. */
  62078. refractionTexture: Texture;
  62079. /**
  62080. * Initializes the RefractionPostProcess
  62081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62082. * @param name The name of the effect.
  62083. * @param refractionTextureUrl Url of the refraction texture to use
  62084. * @param color the base color of the refraction (used to taint the rendering)
  62085. * @param depth simulated refraction depth
  62086. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62087. * @param camera The camera to apply the render pass to.
  62088. * @param options The required width/height ratio to downsize to before computing the render pass.
  62089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62090. * @param engine The engine which the post process will be applied. (default: current engine)
  62091. * @param reusable If the post process can be reused on the same frame. (default: false)
  62092. */
  62093. constructor(name: string, refractionTextureUrl: string,
  62094. /** the base color of the refraction (used to taint the rendering) */
  62095. color: Color3,
  62096. /** simulated refraction depth */
  62097. depth: number,
  62098. /** the coefficient of the base color (0 to remove base color tainting) */
  62099. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62100. /**
  62101. * Disposes of the post process
  62102. * @param camera Camera to dispose post process on
  62103. */
  62104. dispose(camera: Camera): void;
  62105. }
  62106. }
  62107. declare module "babylonjs/Shaders/sharpen.fragment" {
  62108. /** @hidden */
  62109. export var sharpenPixelShader: {
  62110. name: string;
  62111. shader: string;
  62112. };
  62113. }
  62114. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62115. import { Nullable } from "babylonjs/types";
  62116. import { Camera } from "babylonjs/Cameras/camera";
  62117. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62118. import "babylonjs/Shaders/sharpen.fragment";
  62119. import { Engine } from "babylonjs/Engines/engine";
  62120. /**
  62121. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62122. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62123. */
  62124. export class SharpenPostProcess extends PostProcess {
  62125. /**
  62126. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62127. */
  62128. colorAmount: number;
  62129. /**
  62130. * How much sharpness should be applied (default: 0.3)
  62131. */
  62132. edgeAmount: number;
  62133. /**
  62134. * Creates a new instance ConvolutionPostProcess
  62135. * @param name The name of the effect.
  62136. * @param options The required width/height ratio to downsize to before computing the render pass.
  62137. * @param camera The camera to apply the render pass to.
  62138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62139. * @param engine The engine which the post process will be applied. (default: current engine)
  62140. * @param reusable If the post process can be reused on the same frame. (default: false)
  62141. * @param textureType Type of textures used when performing the post process. (default: 0)
  62142. * @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)
  62143. */
  62144. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62145. }
  62146. }
  62147. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62148. import { Nullable } from "babylonjs/types";
  62149. import { Camera } from "babylonjs/Cameras/camera";
  62150. import { Engine } from "babylonjs/Engines/engine";
  62151. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62152. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62153. /**
  62154. * PostProcessRenderPipeline
  62155. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62156. */
  62157. export class PostProcessRenderPipeline {
  62158. private engine;
  62159. private _renderEffects;
  62160. private _renderEffectsForIsolatedPass;
  62161. /**
  62162. * List of inspectable custom properties (used by the Inspector)
  62163. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62164. */
  62165. inspectableCustomProperties: IInspectable[];
  62166. /**
  62167. * @hidden
  62168. */
  62169. protected _cameras: Camera[];
  62170. /** @hidden */
  62171. _name: string;
  62172. /**
  62173. * Gets pipeline name
  62174. */
  62175. readonly name: string;
  62176. /**
  62177. * Initializes a PostProcessRenderPipeline
  62178. * @param engine engine to add the pipeline to
  62179. * @param name name of the pipeline
  62180. */
  62181. constructor(engine: Engine, name: string);
  62182. /**
  62183. * Gets the class name
  62184. * @returns "PostProcessRenderPipeline"
  62185. */
  62186. getClassName(): string;
  62187. /**
  62188. * If all the render effects in the pipeline are supported
  62189. */
  62190. readonly isSupported: boolean;
  62191. /**
  62192. * Adds an effect to the pipeline
  62193. * @param renderEffect the effect to add
  62194. */
  62195. addEffect(renderEffect: PostProcessRenderEffect): void;
  62196. /** @hidden */
  62197. _rebuild(): void;
  62198. /** @hidden */
  62199. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62200. /** @hidden */
  62201. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62202. /** @hidden */
  62203. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62204. /** @hidden */
  62205. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62206. /** @hidden */
  62207. _attachCameras(cameras: Camera, unique: boolean): void;
  62208. /** @hidden */
  62209. _attachCameras(cameras: Camera[], unique: boolean): void;
  62210. /** @hidden */
  62211. _detachCameras(cameras: Camera): void;
  62212. /** @hidden */
  62213. _detachCameras(cameras: Nullable<Camera[]>): void;
  62214. /** @hidden */
  62215. _update(): void;
  62216. /** @hidden */
  62217. _reset(): void;
  62218. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62219. /**
  62220. * Disposes of the pipeline
  62221. */
  62222. dispose(): void;
  62223. }
  62224. }
  62225. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62226. import { Camera } from "babylonjs/Cameras/camera";
  62227. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62228. /**
  62229. * PostProcessRenderPipelineManager class
  62230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62231. */
  62232. export class PostProcessRenderPipelineManager {
  62233. private _renderPipelines;
  62234. /**
  62235. * Initializes a PostProcessRenderPipelineManager
  62236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62237. */
  62238. constructor();
  62239. /**
  62240. * Gets the list of supported render pipelines
  62241. */
  62242. readonly supportedPipelines: PostProcessRenderPipeline[];
  62243. /**
  62244. * Adds a pipeline to the manager
  62245. * @param renderPipeline The pipeline to add
  62246. */
  62247. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62248. /**
  62249. * Attaches a camera to the pipeline
  62250. * @param renderPipelineName The name of the pipeline to attach to
  62251. * @param cameras the camera to attach
  62252. * @param unique if the camera can be attached multiple times to the pipeline
  62253. */
  62254. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62255. /**
  62256. * Detaches a camera from the pipeline
  62257. * @param renderPipelineName The name of the pipeline to detach from
  62258. * @param cameras the camera to detach
  62259. */
  62260. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62261. /**
  62262. * Enables an effect by name on a pipeline
  62263. * @param renderPipelineName the name of the pipeline to enable the effect in
  62264. * @param renderEffectName the name of the effect to enable
  62265. * @param cameras the cameras that the effect should be enabled on
  62266. */
  62267. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62268. /**
  62269. * Disables an effect by name on a pipeline
  62270. * @param renderPipelineName the name of the pipeline to disable the effect in
  62271. * @param renderEffectName the name of the effect to disable
  62272. * @param cameras the cameras that the effect should be disabled on
  62273. */
  62274. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62275. /**
  62276. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62277. */
  62278. update(): void;
  62279. /** @hidden */
  62280. _rebuild(): void;
  62281. /**
  62282. * Disposes of the manager and pipelines
  62283. */
  62284. dispose(): void;
  62285. }
  62286. }
  62287. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62288. import { ISceneComponent } from "babylonjs/sceneComponent";
  62289. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62290. import { Scene } from "babylonjs/scene";
  62291. module "babylonjs/scene" {
  62292. interface Scene {
  62293. /** @hidden (Backing field) */
  62294. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62295. /**
  62296. * Gets the postprocess render pipeline manager
  62297. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62298. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62299. */
  62300. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62301. }
  62302. }
  62303. /**
  62304. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62305. */
  62306. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62307. /**
  62308. * The component name helpfull to identify the component in the list of scene components.
  62309. */
  62310. readonly name: string;
  62311. /**
  62312. * The scene the component belongs to.
  62313. */
  62314. scene: Scene;
  62315. /**
  62316. * Creates a new instance of the component for the given scene
  62317. * @param scene Defines the scene to register the component in
  62318. */
  62319. constructor(scene: Scene);
  62320. /**
  62321. * Registers the component in a given scene
  62322. */
  62323. register(): void;
  62324. /**
  62325. * Rebuilds the elements related to this component in case of
  62326. * context lost for instance.
  62327. */
  62328. rebuild(): void;
  62329. /**
  62330. * Disposes the component and the associated ressources
  62331. */
  62332. dispose(): void;
  62333. private _gatherRenderTargets;
  62334. }
  62335. }
  62336. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62337. import { Nullable } from "babylonjs/types";
  62338. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62339. import { Camera } from "babylonjs/Cameras/camera";
  62340. import { IDisposable } from "babylonjs/scene";
  62341. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62342. import { Scene } from "babylonjs/scene";
  62343. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62344. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62345. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62346. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62347. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62348. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62349. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62350. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62351. import { Animation } from "babylonjs/Animations/animation";
  62352. /**
  62353. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62354. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62355. */
  62356. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62357. private _scene;
  62358. private _camerasToBeAttached;
  62359. /**
  62360. * ID of the sharpen post process,
  62361. */
  62362. private readonly SharpenPostProcessId;
  62363. /**
  62364. * @ignore
  62365. * ID of the image processing post process;
  62366. */
  62367. readonly ImageProcessingPostProcessId: string;
  62368. /**
  62369. * @ignore
  62370. * ID of the Fast Approximate Anti-Aliasing post process;
  62371. */
  62372. readonly FxaaPostProcessId: string;
  62373. /**
  62374. * ID of the chromatic aberration post process,
  62375. */
  62376. private readonly ChromaticAberrationPostProcessId;
  62377. /**
  62378. * ID of the grain post process
  62379. */
  62380. private readonly GrainPostProcessId;
  62381. /**
  62382. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62383. */
  62384. sharpen: SharpenPostProcess;
  62385. private _sharpenEffect;
  62386. private bloom;
  62387. /**
  62388. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62389. */
  62390. depthOfField: DepthOfFieldEffect;
  62391. /**
  62392. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62393. */
  62394. fxaa: FxaaPostProcess;
  62395. /**
  62396. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62397. */
  62398. imageProcessing: ImageProcessingPostProcess;
  62399. /**
  62400. * Chromatic aberration post process which will shift rgb colors in the image
  62401. */
  62402. chromaticAberration: ChromaticAberrationPostProcess;
  62403. private _chromaticAberrationEffect;
  62404. /**
  62405. * Grain post process which add noise to the image
  62406. */
  62407. grain: GrainPostProcess;
  62408. private _grainEffect;
  62409. /**
  62410. * Glow post process which adds a glow to emissive areas of the image
  62411. */
  62412. private _glowLayer;
  62413. /**
  62414. * Animations which can be used to tweak settings over a period of time
  62415. */
  62416. animations: Animation[];
  62417. private _imageProcessingConfigurationObserver;
  62418. private _sharpenEnabled;
  62419. private _bloomEnabled;
  62420. private _depthOfFieldEnabled;
  62421. private _depthOfFieldBlurLevel;
  62422. private _fxaaEnabled;
  62423. private _imageProcessingEnabled;
  62424. private _defaultPipelineTextureType;
  62425. private _bloomScale;
  62426. private _chromaticAberrationEnabled;
  62427. private _grainEnabled;
  62428. private _buildAllowed;
  62429. /**
  62430. * Gets active scene
  62431. */
  62432. readonly scene: Scene;
  62433. /**
  62434. * Enable or disable the sharpen process from the pipeline
  62435. */
  62436. sharpenEnabled: boolean;
  62437. private _resizeObserver;
  62438. private _hardwareScaleLevel;
  62439. private _bloomKernel;
  62440. /**
  62441. * Specifies the size of the bloom blur kernel, relative to the final output size
  62442. */
  62443. bloomKernel: number;
  62444. /**
  62445. * Specifies the weight of the bloom in the final rendering
  62446. */
  62447. private _bloomWeight;
  62448. /**
  62449. * Specifies the luma threshold for the area that will be blurred by the bloom
  62450. */
  62451. private _bloomThreshold;
  62452. private _hdr;
  62453. /**
  62454. * The strength of the bloom.
  62455. */
  62456. bloomWeight: number;
  62457. /**
  62458. * The strength of the bloom.
  62459. */
  62460. bloomThreshold: number;
  62461. /**
  62462. * The scale of the bloom, lower value will provide better performance.
  62463. */
  62464. bloomScale: number;
  62465. /**
  62466. * Enable or disable the bloom from the pipeline
  62467. */
  62468. bloomEnabled: boolean;
  62469. private _rebuildBloom;
  62470. /**
  62471. * If the depth of field is enabled.
  62472. */
  62473. depthOfFieldEnabled: boolean;
  62474. /**
  62475. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62476. */
  62477. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62478. /**
  62479. * If the anti aliasing is enabled.
  62480. */
  62481. fxaaEnabled: boolean;
  62482. private _samples;
  62483. /**
  62484. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62485. */
  62486. samples: number;
  62487. /**
  62488. * If image processing is enabled.
  62489. */
  62490. imageProcessingEnabled: boolean;
  62491. /**
  62492. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62493. */
  62494. glowLayerEnabled: boolean;
  62495. /**
  62496. * Gets the glow layer (or null if not defined)
  62497. */
  62498. readonly glowLayer: Nullable<GlowLayer>;
  62499. /**
  62500. * Enable or disable the chromaticAberration process from the pipeline
  62501. */
  62502. chromaticAberrationEnabled: boolean;
  62503. /**
  62504. * Enable or disable the grain process from the pipeline
  62505. */
  62506. grainEnabled: boolean;
  62507. /**
  62508. * @constructor
  62509. * @param name - The rendering pipeline name (default: "")
  62510. * @param hdr - If high dynamic range textures should be used (default: true)
  62511. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62512. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62513. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62514. */
  62515. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62516. /**
  62517. * Get the class name
  62518. * @returns "DefaultRenderingPipeline"
  62519. */
  62520. getClassName(): string;
  62521. /**
  62522. * Force the compilation of the entire pipeline.
  62523. */
  62524. prepare(): void;
  62525. private _hasCleared;
  62526. private _prevPostProcess;
  62527. private _prevPrevPostProcess;
  62528. private _setAutoClearAndTextureSharing;
  62529. private _depthOfFieldSceneObserver;
  62530. private _buildPipeline;
  62531. private _disposePostProcesses;
  62532. /**
  62533. * Adds a camera to the pipeline
  62534. * @param camera the camera to be added
  62535. */
  62536. addCamera(camera: Camera): void;
  62537. /**
  62538. * Removes a camera from the pipeline
  62539. * @param camera the camera to remove
  62540. */
  62541. removeCamera(camera: Camera): void;
  62542. /**
  62543. * Dispose of the pipeline and stop all post processes
  62544. */
  62545. dispose(): void;
  62546. /**
  62547. * Serialize the rendering pipeline (Used when exporting)
  62548. * @returns the serialized object
  62549. */
  62550. serialize(): any;
  62551. /**
  62552. * Parse the serialized pipeline
  62553. * @param source Source pipeline.
  62554. * @param scene The scene to load the pipeline to.
  62555. * @param rootUrl The URL of the serialized pipeline.
  62556. * @returns An instantiated pipeline from the serialized object.
  62557. */
  62558. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62559. }
  62560. }
  62561. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62562. /** @hidden */
  62563. export var lensHighlightsPixelShader: {
  62564. name: string;
  62565. shader: string;
  62566. };
  62567. }
  62568. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62569. /** @hidden */
  62570. export var depthOfFieldPixelShader: {
  62571. name: string;
  62572. shader: string;
  62573. };
  62574. }
  62575. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62576. import { Camera } from "babylonjs/Cameras/camera";
  62577. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62578. import { Scene } from "babylonjs/scene";
  62579. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62580. import "babylonjs/Shaders/chromaticAberration.fragment";
  62581. import "babylonjs/Shaders/lensHighlights.fragment";
  62582. import "babylonjs/Shaders/depthOfField.fragment";
  62583. /**
  62584. * BABYLON.JS Chromatic Aberration GLSL Shader
  62585. * Author: Olivier Guyot
  62586. * Separates very slightly R, G and B colors on the edges of the screen
  62587. * Inspired by Francois Tarlier & Martins Upitis
  62588. */
  62589. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62590. /**
  62591. * @ignore
  62592. * The chromatic aberration PostProcess id in the pipeline
  62593. */
  62594. LensChromaticAberrationEffect: string;
  62595. /**
  62596. * @ignore
  62597. * The highlights enhancing PostProcess id in the pipeline
  62598. */
  62599. HighlightsEnhancingEffect: string;
  62600. /**
  62601. * @ignore
  62602. * The depth-of-field PostProcess id in the pipeline
  62603. */
  62604. LensDepthOfFieldEffect: string;
  62605. private _scene;
  62606. private _depthTexture;
  62607. private _grainTexture;
  62608. private _chromaticAberrationPostProcess;
  62609. private _highlightsPostProcess;
  62610. private _depthOfFieldPostProcess;
  62611. private _edgeBlur;
  62612. private _grainAmount;
  62613. private _chromaticAberration;
  62614. private _distortion;
  62615. private _highlightsGain;
  62616. private _highlightsThreshold;
  62617. private _dofDistance;
  62618. private _dofAperture;
  62619. private _dofDarken;
  62620. private _dofPentagon;
  62621. private _blurNoise;
  62622. /**
  62623. * @constructor
  62624. *
  62625. * Effect parameters are as follow:
  62626. * {
  62627. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62628. * edge_blur: number; // from 0 to x (1 for realism)
  62629. * distortion: number; // from 0 to x (1 for realism)
  62630. * grain_amount: number; // from 0 to 1
  62631. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62632. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62633. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62634. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62635. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62636. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62637. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62638. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62639. * }
  62640. * Note: if an effect parameter is unset, effect is disabled
  62641. *
  62642. * @param name The rendering pipeline name
  62643. * @param parameters - An object containing all parameters (see above)
  62644. * @param scene The scene linked to this pipeline
  62645. * @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)
  62646. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62647. */
  62648. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62649. /**
  62650. * Get the class name
  62651. * @returns "LensRenderingPipeline"
  62652. */
  62653. getClassName(): string;
  62654. /**
  62655. * Gets associated scene
  62656. */
  62657. readonly scene: Scene;
  62658. /**
  62659. * Gets or sets the edge blur
  62660. */
  62661. edgeBlur: number;
  62662. /**
  62663. * Gets or sets the grain amount
  62664. */
  62665. grainAmount: number;
  62666. /**
  62667. * Gets or sets the chromatic aberration amount
  62668. */
  62669. chromaticAberration: number;
  62670. /**
  62671. * Gets or sets the depth of field aperture
  62672. */
  62673. dofAperture: number;
  62674. /**
  62675. * Gets or sets the edge distortion
  62676. */
  62677. edgeDistortion: number;
  62678. /**
  62679. * Gets or sets the depth of field distortion
  62680. */
  62681. dofDistortion: number;
  62682. /**
  62683. * Gets or sets the darken out of focus amount
  62684. */
  62685. darkenOutOfFocus: number;
  62686. /**
  62687. * Gets or sets a boolean indicating if blur noise is enabled
  62688. */
  62689. blurNoise: boolean;
  62690. /**
  62691. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62692. */
  62693. pentagonBokeh: boolean;
  62694. /**
  62695. * Gets or sets the highlight grain amount
  62696. */
  62697. highlightsGain: number;
  62698. /**
  62699. * Gets or sets the highlight threshold
  62700. */
  62701. highlightsThreshold: number;
  62702. /**
  62703. * Sets the amount of blur at the edges
  62704. * @param amount blur amount
  62705. */
  62706. setEdgeBlur(amount: number): void;
  62707. /**
  62708. * Sets edge blur to 0
  62709. */
  62710. disableEdgeBlur(): void;
  62711. /**
  62712. * Sets the amout of grain
  62713. * @param amount Amount of grain
  62714. */
  62715. setGrainAmount(amount: number): void;
  62716. /**
  62717. * Set grain amount to 0
  62718. */
  62719. disableGrain(): void;
  62720. /**
  62721. * Sets the chromatic aberration amount
  62722. * @param amount amount of chromatic aberration
  62723. */
  62724. setChromaticAberration(amount: number): void;
  62725. /**
  62726. * Sets chromatic aberration amount to 0
  62727. */
  62728. disableChromaticAberration(): void;
  62729. /**
  62730. * Sets the EdgeDistortion amount
  62731. * @param amount amount of EdgeDistortion
  62732. */
  62733. setEdgeDistortion(amount: number): void;
  62734. /**
  62735. * Sets edge distortion to 0
  62736. */
  62737. disableEdgeDistortion(): void;
  62738. /**
  62739. * Sets the FocusDistance amount
  62740. * @param amount amount of FocusDistance
  62741. */
  62742. setFocusDistance(amount: number): void;
  62743. /**
  62744. * Disables depth of field
  62745. */
  62746. disableDepthOfField(): void;
  62747. /**
  62748. * Sets the Aperture amount
  62749. * @param amount amount of Aperture
  62750. */
  62751. setAperture(amount: number): void;
  62752. /**
  62753. * Sets the DarkenOutOfFocus amount
  62754. * @param amount amount of DarkenOutOfFocus
  62755. */
  62756. setDarkenOutOfFocus(amount: number): void;
  62757. private _pentagonBokehIsEnabled;
  62758. /**
  62759. * Creates a pentagon bokeh effect
  62760. */
  62761. enablePentagonBokeh(): void;
  62762. /**
  62763. * Disables the pentagon bokeh effect
  62764. */
  62765. disablePentagonBokeh(): void;
  62766. /**
  62767. * Enables noise blur
  62768. */
  62769. enableNoiseBlur(): void;
  62770. /**
  62771. * Disables noise blur
  62772. */
  62773. disableNoiseBlur(): void;
  62774. /**
  62775. * Sets the HighlightsGain amount
  62776. * @param amount amount of HighlightsGain
  62777. */
  62778. setHighlightsGain(amount: number): void;
  62779. /**
  62780. * Sets the HighlightsThreshold amount
  62781. * @param amount amount of HighlightsThreshold
  62782. */
  62783. setHighlightsThreshold(amount: number): void;
  62784. /**
  62785. * Disables highlights
  62786. */
  62787. disableHighlights(): void;
  62788. /**
  62789. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62790. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62791. */
  62792. dispose(disableDepthRender?: boolean): void;
  62793. private _createChromaticAberrationPostProcess;
  62794. private _createHighlightsPostProcess;
  62795. private _createDepthOfFieldPostProcess;
  62796. private _createGrainTexture;
  62797. }
  62798. }
  62799. declare module "babylonjs/Shaders/ssao2.fragment" {
  62800. /** @hidden */
  62801. export var ssao2PixelShader: {
  62802. name: string;
  62803. shader: string;
  62804. };
  62805. }
  62806. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62807. /** @hidden */
  62808. export var ssaoCombinePixelShader: {
  62809. name: string;
  62810. shader: string;
  62811. };
  62812. }
  62813. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62814. import { Camera } from "babylonjs/Cameras/camera";
  62815. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62816. import { Scene } from "babylonjs/scene";
  62817. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62818. import "babylonjs/Shaders/ssao2.fragment";
  62819. import "babylonjs/Shaders/ssaoCombine.fragment";
  62820. /**
  62821. * Render pipeline to produce ssao effect
  62822. */
  62823. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62824. /**
  62825. * @ignore
  62826. * The PassPostProcess id in the pipeline that contains the original scene color
  62827. */
  62828. SSAOOriginalSceneColorEffect: string;
  62829. /**
  62830. * @ignore
  62831. * The SSAO PostProcess id in the pipeline
  62832. */
  62833. SSAORenderEffect: string;
  62834. /**
  62835. * @ignore
  62836. * The horizontal blur PostProcess id in the pipeline
  62837. */
  62838. SSAOBlurHRenderEffect: string;
  62839. /**
  62840. * @ignore
  62841. * The vertical blur PostProcess id in the pipeline
  62842. */
  62843. SSAOBlurVRenderEffect: string;
  62844. /**
  62845. * @ignore
  62846. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62847. */
  62848. SSAOCombineRenderEffect: string;
  62849. /**
  62850. * The output strength of the SSAO post-process. Default value is 1.0.
  62851. */
  62852. totalStrength: number;
  62853. /**
  62854. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62855. */
  62856. maxZ: number;
  62857. /**
  62858. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62859. */
  62860. minZAspect: number;
  62861. private _samples;
  62862. /**
  62863. * Number of samples used for the SSAO calculations. Default value is 8
  62864. */
  62865. samples: number;
  62866. private _textureSamples;
  62867. /**
  62868. * Number of samples to use for antialiasing
  62869. */
  62870. textureSamples: number;
  62871. /**
  62872. * Ratio object used for SSAO ratio and blur ratio
  62873. */
  62874. private _ratio;
  62875. /**
  62876. * Dynamically generated sphere sampler.
  62877. */
  62878. private _sampleSphere;
  62879. /**
  62880. * Blur filter offsets
  62881. */
  62882. private _samplerOffsets;
  62883. private _expensiveBlur;
  62884. /**
  62885. * If bilateral blur should be used
  62886. */
  62887. expensiveBlur: boolean;
  62888. /**
  62889. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62890. */
  62891. radius: number;
  62892. /**
  62893. * The base color of the SSAO post-process
  62894. * The final result is "base + ssao" between [0, 1]
  62895. */
  62896. base: number;
  62897. /**
  62898. * Support test.
  62899. */
  62900. static readonly IsSupported: boolean;
  62901. private _scene;
  62902. private _depthTexture;
  62903. private _normalTexture;
  62904. private _randomTexture;
  62905. private _originalColorPostProcess;
  62906. private _ssaoPostProcess;
  62907. private _blurHPostProcess;
  62908. private _blurVPostProcess;
  62909. private _ssaoCombinePostProcess;
  62910. private _firstUpdate;
  62911. /**
  62912. * Gets active scene
  62913. */
  62914. readonly scene: Scene;
  62915. /**
  62916. * @constructor
  62917. * @param name The rendering pipeline name
  62918. * @param scene The scene linked to this pipeline
  62919. * @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 }
  62920. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62921. */
  62922. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62923. /**
  62924. * Get the class name
  62925. * @returns "SSAO2RenderingPipeline"
  62926. */
  62927. getClassName(): string;
  62928. /**
  62929. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62930. */
  62931. dispose(disableGeometryBufferRenderer?: boolean): void;
  62932. private _createBlurPostProcess;
  62933. /** @hidden */
  62934. _rebuild(): void;
  62935. private _bits;
  62936. private _radicalInverse_VdC;
  62937. private _hammersley;
  62938. private _hemisphereSample_uniform;
  62939. private _generateHemisphere;
  62940. private _createSSAOPostProcess;
  62941. private _createSSAOCombinePostProcess;
  62942. private _createRandomTexture;
  62943. /**
  62944. * Serialize the rendering pipeline (Used when exporting)
  62945. * @returns the serialized object
  62946. */
  62947. serialize(): any;
  62948. /**
  62949. * Parse the serialized pipeline
  62950. * @param source Source pipeline.
  62951. * @param scene The scene to load the pipeline to.
  62952. * @param rootUrl The URL of the serialized pipeline.
  62953. * @returns An instantiated pipeline from the serialized object.
  62954. */
  62955. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62956. }
  62957. }
  62958. declare module "babylonjs/Shaders/ssao.fragment" {
  62959. /** @hidden */
  62960. export var ssaoPixelShader: {
  62961. name: string;
  62962. shader: string;
  62963. };
  62964. }
  62965. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62966. import { Camera } from "babylonjs/Cameras/camera";
  62967. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62968. import { Scene } from "babylonjs/scene";
  62969. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62970. import "babylonjs/Shaders/ssao.fragment";
  62971. import "babylonjs/Shaders/ssaoCombine.fragment";
  62972. /**
  62973. * Render pipeline to produce ssao effect
  62974. */
  62975. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62976. /**
  62977. * @ignore
  62978. * The PassPostProcess id in the pipeline that contains the original scene color
  62979. */
  62980. SSAOOriginalSceneColorEffect: string;
  62981. /**
  62982. * @ignore
  62983. * The SSAO PostProcess id in the pipeline
  62984. */
  62985. SSAORenderEffect: string;
  62986. /**
  62987. * @ignore
  62988. * The horizontal blur PostProcess id in the pipeline
  62989. */
  62990. SSAOBlurHRenderEffect: string;
  62991. /**
  62992. * @ignore
  62993. * The vertical blur PostProcess id in the pipeline
  62994. */
  62995. SSAOBlurVRenderEffect: string;
  62996. /**
  62997. * @ignore
  62998. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62999. */
  63000. SSAOCombineRenderEffect: string;
  63001. /**
  63002. * The output strength of the SSAO post-process. Default value is 1.0.
  63003. */
  63004. totalStrength: number;
  63005. /**
  63006. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63007. */
  63008. radius: number;
  63009. /**
  63010. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63011. * Must not be equal to fallOff and superior to fallOff.
  63012. * Default value is 0.0075
  63013. */
  63014. area: number;
  63015. /**
  63016. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63017. * Must not be equal to area and inferior to area.
  63018. * Default value is 0.000001
  63019. */
  63020. fallOff: number;
  63021. /**
  63022. * The base color of the SSAO post-process
  63023. * The final result is "base + ssao" between [0, 1]
  63024. */
  63025. base: number;
  63026. private _scene;
  63027. private _depthTexture;
  63028. private _randomTexture;
  63029. private _originalColorPostProcess;
  63030. private _ssaoPostProcess;
  63031. private _blurHPostProcess;
  63032. private _blurVPostProcess;
  63033. private _ssaoCombinePostProcess;
  63034. private _firstUpdate;
  63035. /**
  63036. * Gets active scene
  63037. */
  63038. readonly scene: Scene;
  63039. /**
  63040. * @constructor
  63041. * @param name - The rendering pipeline name
  63042. * @param scene - The scene linked to this pipeline
  63043. * @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 }
  63044. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63045. */
  63046. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63047. /**
  63048. * Get the class name
  63049. * @returns "SSAORenderingPipeline"
  63050. */
  63051. getClassName(): string;
  63052. /**
  63053. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63054. */
  63055. dispose(disableDepthRender?: boolean): void;
  63056. private _createBlurPostProcess;
  63057. /** @hidden */
  63058. _rebuild(): void;
  63059. private _createSSAOPostProcess;
  63060. private _createSSAOCombinePostProcess;
  63061. private _createRandomTexture;
  63062. }
  63063. }
  63064. declare module "babylonjs/Shaders/standard.fragment" {
  63065. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63066. /** @hidden */
  63067. export var standardPixelShader: {
  63068. name: string;
  63069. shader: string;
  63070. };
  63071. }
  63072. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63073. import { Nullable } from "babylonjs/types";
  63074. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63075. import { Camera } from "babylonjs/Cameras/camera";
  63076. import { Texture } from "babylonjs/Materials/Textures/texture";
  63077. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63078. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63079. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63080. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63081. import { IDisposable } from "babylonjs/scene";
  63082. import { SpotLight } from "babylonjs/Lights/spotLight";
  63083. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63084. import { Scene } from "babylonjs/scene";
  63085. import { Animation } from "babylonjs/Animations/animation";
  63086. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63087. import "babylonjs/Shaders/standard.fragment";
  63088. /**
  63089. * Standard rendering pipeline
  63090. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63091. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63092. */
  63093. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63094. /**
  63095. * Public members
  63096. */
  63097. /**
  63098. * Post-process which contains the original scene color before the pipeline applies all the effects
  63099. */
  63100. originalPostProcess: Nullable<PostProcess>;
  63101. /**
  63102. * Post-process used to down scale an image x4
  63103. */
  63104. downSampleX4PostProcess: Nullable<PostProcess>;
  63105. /**
  63106. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63107. */
  63108. brightPassPostProcess: Nullable<PostProcess>;
  63109. /**
  63110. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63111. */
  63112. blurHPostProcesses: PostProcess[];
  63113. /**
  63114. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63115. */
  63116. blurVPostProcesses: PostProcess[];
  63117. /**
  63118. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63119. */
  63120. textureAdderPostProcess: Nullable<PostProcess>;
  63121. /**
  63122. * Post-process used to create volumetric lighting effect
  63123. */
  63124. volumetricLightPostProcess: Nullable<PostProcess>;
  63125. /**
  63126. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63127. */
  63128. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63129. /**
  63130. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63131. */
  63132. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63133. /**
  63134. * Post-process used to merge the volumetric light effect and the real scene color
  63135. */
  63136. volumetricLightMergePostProces: Nullable<PostProcess>;
  63137. /**
  63138. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63139. */
  63140. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63141. /**
  63142. * Base post-process used to calculate the average luminance of the final image for HDR
  63143. */
  63144. luminancePostProcess: Nullable<PostProcess>;
  63145. /**
  63146. * Post-processes used to create down sample post-processes in order to get
  63147. * the average luminance of the final image for HDR
  63148. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63149. */
  63150. luminanceDownSamplePostProcesses: PostProcess[];
  63151. /**
  63152. * Post-process used to create a HDR effect (light adaptation)
  63153. */
  63154. hdrPostProcess: Nullable<PostProcess>;
  63155. /**
  63156. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63157. */
  63158. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63159. /**
  63160. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63161. */
  63162. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63163. /**
  63164. * Post-process used to merge the final HDR post-process and the real scene color
  63165. */
  63166. hdrFinalPostProcess: Nullable<PostProcess>;
  63167. /**
  63168. * Post-process used to create a lens flare effect
  63169. */
  63170. lensFlarePostProcess: Nullable<PostProcess>;
  63171. /**
  63172. * Post-process that merges the result of the lens flare post-process and the real scene color
  63173. */
  63174. lensFlareComposePostProcess: Nullable<PostProcess>;
  63175. /**
  63176. * Post-process used to create a motion blur effect
  63177. */
  63178. motionBlurPostProcess: Nullable<PostProcess>;
  63179. /**
  63180. * Post-process used to create a depth of field effect
  63181. */
  63182. depthOfFieldPostProcess: Nullable<PostProcess>;
  63183. /**
  63184. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63185. */
  63186. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63187. /**
  63188. * Represents the brightness threshold in order to configure the illuminated surfaces
  63189. */
  63190. brightThreshold: number;
  63191. /**
  63192. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63193. */
  63194. blurWidth: number;
  63195. /**
  63196. * Sets if the blur for highlighted surfaces must be only horizontal
  63197. */
  63198. horizontalBlur: boolean;
  63199. /**
  63200. * Gets the overall exposure used by the pipeline
  63201. */
  63202. /**
  63203. * Sets the overall exposure used by the pipeline
  63204. */
  63205. exposure: number;
  63206. /**
  63207. * Texture used typically to simulate "dirty" on camera lens
  63208. */
  63209. lensTexture: Nullable<Texture>;
  63210. /**
  63211. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63212. */
  63213. volumetricLightCoefficient: number;
  63214. /**
  63215. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63216. */
  63217. volumetricLightPower: number;
  63218. /**
  63219. * Used the set the blur intensity to smooth the volumetric lights
  63220. */
  63221. volumetricLightBlurScale: number;
  63222. /**
  63223. * Light (spot or directional) used to generate the volumetric lights rays
  63224. * The source light must have a shadow generate so the pipeline can get its
  63225. * depth map
  63226. */
  63227. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63228. /**
  63229. * For eye adaptation, represents the minimum luminance the eye can see
  63230. */
  63231. hdrMinimumLuminance: number;
  63232. /**
  63233. * For eye adaptation, represents the decrease luminance speed
  63234. */
  63235. hdrDecreaseRate: number;
  63236. /**
  63237. * For eye adaptation, represents the increase luminance speed
  63238. */
  63239. hdrIncreaseRate: number;
  63240. /**
  63241. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63242. */
  63243. /**
  63244. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63245. */
  63246. hdrAutoExposure: boolean;
  63247. /**
  63248. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63249. */
  63250. lensColorTexture: Nullable<Texture>;
  63251. /**
  63252. * The overall strengh for the lens flare effect
  63253. */
  63254. lensFlareStrength: number;
  63255. /**
  63256. * Dispersion coefficient for lens flare ghosts
  63257. */
  63258. lensFlareGhostDispersal: number;
  63259. /**
  63260. * Main lens flare halo width
  63261. */
  63262. lensFlareHaloWidth: number;
  63263. /**
  63264. * Based on the lens distortion effect, defines how much the lens flare result
  63265. * is distorted
  63266. */
  63267. lensFlareDistortionStrength: number;
  63268. /**
  63269. * Configures the blur intensity used for for lens flare (halo)
  63270. */
  63271. lensFlareBlurWidth: number;
  63272. /**
  63273. * Lens star texture must be used to simulate rays on the flares and is available
  63274. * in the documentation
  63275. */
  63276. lensStarTexture: Nullable<Texture>;
  63277. /**
  63278. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63279. * flare effect by taking account of the dirt texture
  63280. */
  63281. lensFlareDirtTexture: Nullable<Texture>;
  63282. /**
  63283. * Represents the focal length for the depth of field effect
  63284. */
  63285. depthOfFieldDistance: number;
  63286. /**
  63287. * Represents the blur intensity for the blurred part of the depth of field effect
  63288. */
  63289. depthOfFieldBlurWidth: number;
  63290. /**
  63291. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63292. */
  63293. /**
  63294. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63295. */
  63296. motionStrength: number;
  63297. /**
  63298. * Gets wether or not the motion blur post-process is object based or screen based.
  63299. */
  63300. /**
  63301. * Sets wether or not the motion blur post-process should be object based or screen based
  63302. */
  63303. objectBasedMotionBlur: boolean;
  63304. /**
  63305. * List of animations for the pipeline (IAnimatable implementation)
  63306. */
  63307. animations: Animation[];
  63308. /**
  63309. * Private members
  63310. */
  63311. private _scene;
  63312. private _currentDepthOfFieldSource;
  63313. private _basePostProcess;
  63314. private _fixedExposure;
  63315. private _currentExposure;
  63316. private _hdrAutoExposure;
  63317. private _hdrCurrentLuminance;
  63318. private _motionStrength;
  63319. private _isObjectBasedMotionBlur;
  63320. private _floatTextureType;
  63321. private _camerasToBeAttached;
  63322. private _ratio;
  63323. private _bloomEnabled;
  63324. private _depthOfFieldEnabled;
  63325. private _vlsEnabled;
  63326. private _lensFlareEnabled;
  63327. private _hdrEnabled;
  63328. private _motionBlurEnabled;
  63329. private _fxaaEnabled;
  63330. private _motionBlurSamples;
  63331. private _volumetricLightStepsCount;
  63332. private _samples;
  63333. /**
  63334. * @ignore
  63335. * Specifies if the bloom pipeline is enabled
  63336. */
  63337. BloomEnabled: boolean;
  63338. /**
  63339. * @ignore
  63340. * Specifies if the depth of field pipeline is enabed
  63341. */
  63342. DepthOfFieldEnabled: boolean;
  63343. /**
  63344. * @ignore
  63345. * Specifies if the lens flare pipeline is enabed
  63346. */
  63347. LensFlareEnabled: boolean;
  63348. /**
  63349. * @ignore
  63350. * Specifies if the HDR pipeline is enabled
  63351. */
  63352. HDREnabled: boolean;
  63353. /**
  63354. * @ignore
  63355. * Specifies if the volumetric lights scattering effect is enabled
  63356. */
  63357. VLSEnabled: boolean;
  63358. /**
  63359. * @ignore
  63360. * Specifies if the motion blur effect is enabled
  63361. */
  63362. MotionBlurEnabled: boolean;
  63363. /**
  63364. * Specifies if anti-aliasing is enabled
  63365. */
  63366. fxaaEnabled: boolean;
  63367. /**
  63368. * Specifies the number of steps used to calculate the volumetric lights
  63369. * Typically in interval [50, 200]
  63370. */
  63371. volumetricLightStepsCount: number;
  63372. /**
  63373. * Specifies the number of samples used for the motion blur effect
  63374. * Typically in interval [16, 64]
  63375. */
  63376. motionBlurSamples: number;
  63377. /**
  63378. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63379. */
  63380. samples: number;
  63381. /**
  63382. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63383. * @constructor
  63384. * @param name The rendering pipeline name
  63385. * @param scene The scene linked to this pipeline
  63386. * @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)
  63387. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63388. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63389. */
  63390. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63391. private _buildPipeline;
  63392. private _createDownSampleX4PostProcess;
  63393. private _createBrightPassPostProcess;
  63394. private _createBlurPostProcesses;
  63395. private _createTextureAdderPostProcess;
  63396. private _createVolumetricLightPostProcess;
  63397. private _createLuminancePostProcesses;
  63398. private _createHdrPostProcess;
  63399. private _createLensFlarePostProcess;
  63400. private _createDepthOfFieldPostProcess;
  63401. private _createMotionBlurPostProcess;
  63402. private _getDepthTexture;
  63403. private _disposePostProcesses;
  63404. /**
  63405. * Dispose of the pipeline and stop all post processes
  63406. */
  63407. dispose(): void;
  63408. /**
  63409. * Serialize the rendering pipeline (Used when exporting)
  63410. * @returns the serialized object
  63411. */
  63412. serialize(): any;
  63413. /**
  63414. * Parse the serialized pipeline
  63415. * @param source Source pipeline.
  63416. * @param scene The scene to load the pipeline to.
  63417. * @param rootUrl The URL of the serialized pipeline.
  63418. * @returns An instantiated pipeline from the serialized object.
  63419. */
  63420. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63421. /**
  63422. * Luminance steps
  63423. */
  63424. static LuminanceSteps: number;
  63425. }
  63426. }
  63427. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63428. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63429. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63430. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63431. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63432. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63433. }
  63434. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63435. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63436. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63437. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63438. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63439. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63440. }
  63441. declare module "babylonjs/Shaders/tonemap.fragment" {
  63442. /** @hidden */
  63443. export var tonemapPixelShader: {
  63444. name: string;
  63445. shader: string;
  63446. };
  63447. }
  63448. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63449. import { Camera } from "babylonjs/Cameras/camera";
  63450. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63451. import "babylonjs/Shaders/tonemap.fragment";
  63452. import { Engine } from "babylonjs/Engines/engine";
  63453. /** Defines operator used for tonemapping */
  63454. export enum TonemappingOperator {
  63455. /** Hable */
  63456. Hable = 0,
  63457. /** Reinhard */
  63458. Reinhard = 1,
  63459. /** HejiDawson */
  63460. HejiDawson = 2,
  63461. /** Photographic */
  63462. Photographic = 3
  63463. }
  63464. /**
  63465. * Defines a post process to apply tone mapping
  63466. */
  63467. export class TonemapPostProcess extends PostProcess {
  63468. private _operator;
  63469. /** Defines the required exposure adjustement */
  63470. exposureAdjustment: number;
  63471. /**
  63472. * Creates a new TonemapPostProcess
  63473. * @param name defines the name of the postprocess
  63474. * @param _operator defines the operator to use
  63475. * @param exposureAdjustment defines the required exposure adjustement
  63476. * @param camera defines the camera to use (can be null)
  63477. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63478. * @param engine defines the hosting engine (can be ignore if camera is set)
  63479. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63480. */
  63481. constructor(name: string, _operator: TonemappingOperator,
  63482. /** Defines the required exposure adjustement */
  63483. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63484. }
  63485. }
  63486. declare module "babylonjs/Shaders/depth.vertex" {
  63487. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63488. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63490. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63492. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63493. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63494. /** @hidden */
  63495. export var depthVertexShader: {
  63496. name: string;
  63497. shader: string;
  63498. };
  63499. }
  63500. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63501. /** @hidden */
  63502. export var volumetricLightScatteringPixelShader: {
  63503. name: string;
  63504. shader: string;
  63505. };
  63506. }
  63507. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63508. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63509. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63511. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63512. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63513. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63514. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63515. /** @hidden */
  63516. export var volumetricLightScatteringPassVertexShader: {
  63517. name: string;
  63518. shader: string;
  63519. };
  63520. }
  63521. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63522. /** @hidden */
  63523. export var volumetricLightScatteringPassPixelShader: {
  63524. name: string;
  63525. shader: string;
  63526. };
  63527. }
  63528. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63529. import { Vector3 } from "babylonjs/Maths/math.vector";
  63530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63531. import { Mesh } from "babylonjs/Meshes/mesh";
  63532. import { Camera } from "babylonjs/Cameras/camera";
  63533. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63534. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63535. import { Scene } from "babylonjs/scene";
  63536. import "babylonjs/Meshes/Builders/planeBuilder";
  63537. import "babylonjs/Shaders/depth.vertex";
  63538. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63539. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63540. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63541. import { Engine } from "babylonjs/Engines/engine";
  63542. /**
  63543. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63544. */
  63545. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63546. private _volumetricLightScatteringPass;
  63547. private _volumetricLightScatteringRTT;
  63548. private _viewPort;
  63549. private _screenCoordinates;
  63550. private _cachedDefines;
  63551. /**
  63552. * If not undefined, the mesh position is computed from the attached node position
  63553. */
  63554. attachedNode: {
  63555. position: Vector3;
  63556. };
  63557. /**
  63558. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63559. */
  63560. customMeshPosition: Vector3;
  63561. /**
  63562. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63563. */
  63564. useCustomMeshPosition: boolean;
  63565. /**
  63566. * If the post-process should inverse the light scattering direction
  63567. */
  63568. invert: boolean;
  63569. /**
  63570. * The internal mesh used by the post-process
  63571. */
  63572. mesh: Mesh;
  63573. /**
  63574. * @hidden
  63575. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63576. */
  63577. useDiffuseColor: boolean;
  63578. /**
  63579. * Array containing the excluded meshes not rendered in the internal pass
  63580. */
  63581. excludedMeshes: AbstractMesh[];
  63582. /**
  63583. * Controls the overall intensity of the post-process
  63584. */
  63585. exposure: number;
  63586. /**
  63587. * Dissipates each sample's contribution in range [0, 1]
  63588. */
  63589. decay: number;
  63590. /**
  63591. * Controls the overall intensity of each sample
  63592. */
  63593. weight: number;
  63594. /**
  63595. * Controls the density of each sample
  63596. */
  63597. density: number;
  63598. /**
  63599. * @constructor
  63600. * @param name The post-process name
  63601. * @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)
  63602. * @param camera The camera that the post-process will be attached to
  63603. * @param mesh The mesh used to create the light scattering
  63604. * @param samples The post-process quality, default 100
  63605. * @param samplingModeThe post-process filtering mode
  63606. * @param engine The babylon engine
  63607. * @param reusable If the post-process is reusable
  63608. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63609. */
  63610. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63611. /**
  63612. * Returns the string "VolumetricLightScatteringPostProcess"
  63613. * @returns "VolumetricLightScatteringPostProcess"
  63614. */
  63615. getClassName(): string;
  63616. private _isReady;
  63617. /**
  63618. * Sets the new light position for light scattering effect
  63619. * @param position The new custom light position
  63620. */
  63621. setCustomMeshPosition(position: Vector3): void;
  63622. /**
  63623. * Returns the light position for light scattering effect
  63624. * @return Vector3 The custom light position
  63625. */
  63626. getCustomMeshPosition(): Vector3;
  63627. /**
  63628. * Disposes the internal assets and detaches the post-process from the camera
  63629. */
  63630. dispose(camera: Camera): void;
  63631. /**
  63632. * Returns the render target texture used by the post-process
  63633. * @return the render target texture used by the post-process
  63634. */
  63635. getPass(): RenderTargetTexture;
  63636. private _meshExcluded;
  63637. private _createPass;
  63638. private _updateMeshScreenCoordinates;
  63639. /**
  63640. * Creates a default mesh for the Volumeric Light Scattering post-process
  63641. * @param name The mesh name
  63642. * @param scene The scene where to create the mesh
  63643. * @return the default mesh
  63644. */
  63645. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63646. }
  63647. }
  63648. declare module "babylonjs/PostProcesses/index" {
  63649. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63650. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63651. export * from "babylonjs/PostProcesses/bloomEffect";
  63652. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63653. export * from "babylonjs/PostProcesses/blurPostProcess";
  63654. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63655. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63656. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63657. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63658. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63659. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63660. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63661. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63662. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63663. export * from "babylonjs/PostProcesses/filterPostProcess";
  63664. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63665. export * from "babylonjs/PostProcesses/grainPostProcess";
  63666. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63667. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63668. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63669. export * from "babylonjs/PostProcesses/passPostProcess";
  63670. export * from "babylonjs/PostProcesses/postProcess";
  63671. export * from "babylonjs/PostProcesses/postProcessManager";
  63672. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63673. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63674. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63675. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63676. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63677. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63678. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63679. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63680. }
  63681. declare module "babylonjs/Probes/index" {
  63682. export * from "babylonjs/Probes/reflectionProbe";
  63683. }
  63684. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63685. import { Scene } from "babylonjs/scene";
  63686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63687. import { SmartArray } from "babylonjs/Misc/smartArray";
  63688. import { ISceneComponent } from "babylonjs/sceneComponent";
  63689. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63690. import "babylonjs/Meshes/Builders/boxBuilder";
  63691. import "babylonjs/Shaders/color.fragment";
  63692. import "babylonjs/Shaders/color.vertex";
  63693. import { Color3 } from "babylonjs/Maths/math.color";
  63694. module "babylonjs/scene" {
  63695. interface Scene {
  63696. /** @hidden (Backing field) */
  63697. _boundingBoxRenderer: BoundingBoxRenderer;
  63698. /** @hidden (Backing field) */
  63699. _forceShowBoundingBoxes: boolean;
  63700. /**
  63701. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63702. */
  63703. forceShowBoundingBoxes: boolean;
  63704. /**
  63705. * Gets the bounding box renderer associated with the scene
  63706. * @returns a BoundingBoxRenderer
  63707. */
  63708. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63709. }
  63710. }
  63711. module "babylonjs/Meshes/abstractMesh" {
  63712. interface AbstractMesh {
  63713. /** @hidden (Backing field) */
  63714. _showBoundingBox: boolean;
  63715. /**
  63716. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63717. */
  63718. showBoundingBox: boolean;
  63719. }
  63720. }
  63721. /**
  63722. * Component responsible of rendering the bounding box of the meshes in a scene.
  63723. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63724. */
  63725. export class BoundingBoxRenderer implements ISceneComponent {
  63726. /**
  63727. * The component name helpfull to identify the component in the list of scene components.
  63728. */
  63729. readonly name: string;
  63730. /**
  63731. * The scene the component belongs to.
  63732. */
  63733. scene: Scene;
  63734. /**
  63735. * Color of the bounding box lines placed in front of an object
  63736. */
  63737. frontColor: Color3;
  63738. /**
  63739. * Color of the bounding box lines placed behind an object
  63740. */
  63741. backColor: Color3;
  63742. /**
  63743. * Defines if the renderer should show the back lines or not
  63744. */
  63745. showBackLines: boolean;
  63746. /**
  63747. * @hidden
  63748. */
  63749. renderList: SmartArray<BoundingBox>;
  63750. private _colorShader;
  63751. private _vertexBuffers;
  63752. private _indexBuffer;
  63753. private _fillIndexBuffer;
  63754. private _fillIndexData;
  63755. /**
  63756. * Instantiates a new bounding box renderer in a scene.
  63757. * @param scene the scene the renderer renders in
  63758. */
  63759. constructor(scene: Scene);
  63760. /**
  63761. * Registers the component in a given scene
  63762. */
  63763. register(): void;
  63764. private _evaluateSubMesh;
  63765. private _activeMesh;
  63766. private _prepareRessources;
  63767. private _createIndexBuffer;
  63768. /**
  63769. * Rebuilds the elements related to this component in case of
  63770. * context lost for instance.
  63771. */
  63772. rebuild(): void;
  63773. /**
  63774. * @hidden
  63775. */
  63776. reset(): void;
  63777. /**
  63778. * Render the bounding boxes of a specific rendering group
  63779. * @param renderingGroupId defines the rendering group to render
  63780. */
  63781. render(renderingGroupId: number): void;
  63782. /**
  63783. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63784. * @param mesh Define the mesh to render the occlusion bounding box for
  63785. */
  63786. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63787. /**
  63788. * Dispose and release the resources attached to this renderer.
  63789. */
  63790. dispose(): void;
  63791. }
  63792. }
  63793. declare module "babylonjs/Shaders/depth.fragment" {
  63794. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63795. /** @hidden */
  63796. export var depthPixelShader: {
  63797. name: string;
  63798. shader: string;
  63799. };
  63800. }
  63801. declare module "babylonjs/Rendering/depthRenderer" {
  63802. import { Nullable } from "babylonjs/types";
  63803. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63804. import { Scene } from "babylonjs/scene";
  63805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63806. import { Camera } from "babylonjs/Cameras/camera";
  63807. import "babylonjs/Shaders/depth.fragment";
  63808. import "babylonjs/Shaders/depth.vertex";
  63809. /**
  63810. * This represents a depth renderer in Babylon.
  63811. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63812. */
  63813. export class DepthRenderer {
  63814. private _scene;
  63815. private _depthMap;
  63816. private _effect;
  63817. private readonly _storeNonLinearDepth;
  63818. private readonly _clearColor;
  63819. /** Get if the depth renderer is using packed depth or not */
  63820. readonly isPacked: boolean;
  63821. private _cachedDefines;
  63822. private _camera;
  63823. /**
  63824. * Specifiess that the depth renderer will only be used within
  63825. * the camera it is created for.
  63826. * This can help forcing its rendering during the camera processing.
  63827. */
  63828. useOnlyInActiveCamera: boolean;
  63829. /** @hidden */
  63830. static _SceneComponentInitialization: (scene: Scene) => void;
  63831. /**
  63832. * Instantiates a depth renderer
  63833. * @param scene The scene the renderer belongs to
  63834. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63835. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63836. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63837. */
  63838. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63839. /**
  63840. * Creates the depth rendering effect and checks if the effect is ready.
  63841. * @param subMesh The submesh to be used to render the depth map of
  63842. * @param useInstances If multiple world instances should be used
  63843. * @returns if the depth renderer is ready to render the depth map
  63844. */
  63845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63846. /**
  63847. * Gets the texture which the depth map will be written to.
  63848. * @returns The depth map texture
  63849. */
  63850. getDepthMap(): RenderTargetTexture;
  63851. /**
  63852. * Disposes of the depth renderer.
  63853. */
  63854. dispose(): void;
  63855. }
  63856. }
  63857. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63858. import { Nullable } from "babylonjs/types";
  63859. import { Scene } from "babylonjs/scene";
  63860. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63861. import { Camera } from "babylonjs/Cameras/camera";
  63862. import { ISceneComponent } from "babylonjs/sceneComponent";
  63863. module "babylonjs/scene" {
  63864. interface Scene {
  63865. /** @hidden (Backing field) */
  63866. _depthRenderer: {
  63867. [id: string]: DepthRenderer;
  63868. };
  63869. /**
  63870. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63871. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63872. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63873. * @returns the created depth renderer
  63874. */
  63875. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63876. /**
  63877. * Disables a depth renderer for a given camera
  63878. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63879. */
  63880. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63881. }
  63882. }
  63883. /**
  63884. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63885. * in several rendering techniques.
  63886. */
  63887. export class DepthRendererSceneComponent implements ISceneComponent {
  63888. /**
  63889. * The component name helpfull to identify the component in the list of scene components.
  63890. */
  63891. readonly name: string;
  63892. /**
  63893. * The scene the component belongs to.
  63894. */
  63895. scene: Scene;
  63896. /**
  63897. * Creates a new instance of the component for the given scene
  63898. * @param scene Defines the scene to register the component in
  63899. */
  63900. constructor(scene: Scene);
  63901. /**
  63902. * Registers the component in a given scene
  63903. */
  63904. register(): void;
  63905. /**
  63906. * Rebuilds the elements related to this component in case of
  63907. * context lost for instance.
  63908. */
  63909. rebuild(): void;
  63910. /**
  63911. * Disposes the component and the associated ressources
  63912. */
  63913. dispose(): void;
  63914. private _gatherRenderTargets;
  63915. private _gatherActiveCameraRenderTargets;
  63916. }
  63917. }
  63918. declare module "babylonjs/Shaders/outline.fragment" {
  63919. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63920. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63921. /** @hidden */
  63922. export var outlinePixelShader: {
  63923. name: string;
  63924. shader: string;
  63925. };
  63926. }
  63927. declare module "babylonjs/Shaders/outline.vertex" {
  63928. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63929. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63931. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63932. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63933. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63934. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63935. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63936. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63937. /** @hidden */
  63938. export var outlineVertexShader: {
  63939. name: string;
  63940. shader: string;
  63941. };
  63942. }
  63943. declare module "babylonjs/Rendering/outlineRenderer" {
  63944. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63945. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63946. import { Scene } from "babylonjs/scene";
  63947. import { ISceneComponent } from "babylonjs/sceneComponent";
  63948. import "babylonjs/Shaders/outline.fragment";
  63949. import "babylonjs/Shaders/outline.vertex";
  63950. module "babylonjs/scene" {
  63951. interface Scene {
  63952. /** @hidden */
  63953. _outlineRenderer: OutlineRenderer;
  63954. /**
  63955. * Gets the outline renderer associated with the scene
  63956. * @returns a OutlineRenderer
  63957. */
  63958. getOutlineRenderer(): OutlineRenderer;
  63959. }
  63960. }
  63961. module "babylonjs/Meshes/abstractMesh" {
  63962. interface AbstractMesh {
  63963. /** @hidden (Backing field) */
  63964. _renderOutline: boolean;
  63965. /**
  63966. * Gets or sets a boolean indicating if the outline must be rendered as well
  63967. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63968. */
  63969. renderOutline: boolean;
  63970. /** @hidden (Backing field) */
  63971. _renderOverlay: boolean;
  63972. /**
  63973. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63974. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63975. */
  63976. renderOverlay: boolean;
  63977. }
  63978. }
  63979. /**
  63980. * This class is responsible to draw bothe outline/overlay of meshes.
  63981. * It should not be used directly but through the available method on mesh.
  63982. */
  63983. export class OutlineRenderer implements ISceneComponent {
  63984. /**
  63985. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63986. */
  63987. private static _StencilReference;
  63988. /**
  63989. * The name of the component. Each component must have a unique name.
  63990. */
  63991. name: string;
  63992. /**
  63993. * The scene the component belongs to.
  63994. */
  63995. scene: Scene;
  63996. /**
  63997. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63998. */
  63999. zOffset: number;
  64000. private _engine;
  64001. private _effect;
  64002. private _cachedDefines;
  64003. private _savedDepthWrite;
  64004. /**
  64005. * Instantiates a new outline renderer. (There could be only one per scene).
  64006. * @param scene Defines the scene it belongs to
  64007. */
  64008. constructor(scene: Scene);
  64009. /**
  64010. * Register the component to one instance of a scene.
  64011. */
  64012. register(): void;
  64013. /**
  64014. * Rebuilds the elements related to this component in case of
  64015. * context lost for instance.
  64016. */
  64017. rebuild(): void;
  64018. /**
  64019. * Disposes the component and the associated ressources.
  64020. */
  64021. dispose(): void;
  64022. /**
  64023. * Renders the outline in the canvas.
  64024. * @param subMesh Defines the sumesh to render
  64025. * @param batch Defines the batch of meshes in case of instances
  64026. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64027. */
  64028. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64029. /**
  64030. * Returns whether or not the outline renderer is ready for a given submesh.
  64031. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64032. * @param subMesh Defines the submesh to check readyness for
  64033. * @param useInstances Defines wheter wee are trying to render instances or not
  64034. * @returns true if ready otherwise false
  64035. */
  64036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64037. private _beforeRenderingMesh;
  64038. private _afterRenderingMesh;
  64039. }
  64040. }
  64041. declare module "babylonjs/Rendering/index" {
  64042. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64043. export * from "babylonjs/Rendering/depthRenderer";
  64044. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64045. export * from "babylonjs/Rendering/edgesRenderer";
  64046. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64047. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64048. export * from "babylonjs/Rendering/outlineRenderer";
  64049. export * from "babylonjs/Rendering/renderingGroup";
  64050. export * from "babylonjs/Rendering/renderingManager";
  64051. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64052. }
  64053. declare module "babylonjs/Sprites/spritePackedManager" {
  64054. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64055. import { Scene } from "babylonjs/scene";
  64056. /**
  64057. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64058. * @see http://doc.babylonjs.com/babylon101/sprites
  64059. */
  64060. export class SpritePackedManager extends SpriteManager {
  64061. /** defines the packed manager's name */
  64062. name: string;
  64063. /**
  64064. * Creates a new sprite manager from a packed sprite sheet
  64065. * @param name defines the manager's name
  64066. * @param imgUrl defines the sprite sheet url
  64067. * @param capacity defines the maximum allowed number of sprites
  64068. * @param scene defines the hosting scene
  64069. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64070. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64071. * @param samplingMode defines the smapling mode to use with spritesheet
  64072. * @param fromPacked set to true; do not alter
  64073. */
  64074. constructor(
  64075. /** defines the packed manager's name */
  64076. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64077. }
  64078. }
  64079. declare module "babylonjs/Sprites/index" {
  64080. export * from "babylonjs/Sprites/sprite";
  64081. export * from "babylonjs/Sprites/spriteManager";
  64082. export * from "babylonjs/Sprites/spritePackedManager";
  64083. export * from "babylonjs/Sprites/spriteSceneComponent";
  64084. }
  64085. declare module "babylonjs/Misc/assetsManager" {
  64086. import { Scene } from "babylonjs/scene";
  64087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64088. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64089. import { Skeleton } from "babylonjs/Bones/skeleton";
  64090. import { Observable } from "babylonjs/Misc/observable";
  64091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64092. import { Texture } from "babylonjs/Materials/Textures/texture";
  64093. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64094. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64095. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64096. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64097. /**
  64098. * Defines the list of states available for a task inside a AssetsManager
  64099. */
  64100. export enum AssetTaskState {
  64101. /**
  64102. * Initialization
  64103. */
  64104. INIT = 0,
  64105. /**
  64106. * Running
  64107. */
  64108. RUNNING = 1,
  64109. /**
  64110. * Done
  64111. */
  64112. DONE = 2,
  64113. /**
  64114. * Error
  64115. */
  64116. ERROR = 3
  64117. }
  64118. /**
  64119. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64120. */
  64121. export abstract class AbstractAssetTask {
  64122. /**
  64123. * Task name
  64124. */ name: string;
  64125. /**
  64126. * Callback called when the task is successful
  64127. */
  64128. onSuccess: (task: any) => void;
  64129. /**
  64130. * Callback called when the task is not successful
  64131. */
  64132. onError: (task: any, message?: string, exception?: any) => void;
  64133. /**
  64134. * Creates a new AssetsManager
  64135. * @param name defines the name of the task
  64136. */
  64137. constructor(
  64138. /**
  64139. * Task name
  64140. */ name: string);
  64141. private _isCompleted;
  64142. private _taskState;
  64143. private _errorObject;
  64144. /**
  64145. * Get if the task is completed
  64146. */
  64147. readonly isCompleted: boolean;
  64148. /**
  64149. * Gets the current state of the task
  64150. */
  64151. readonly taskState: AssetTaskState;
  64152. /**
  64153. * Gets the current error object (if task is in error)
  64154. */
  64155. readonly errorObject: {
  64156. message?: string;
  64157. exception?: any;
  64158. };
  64159. /**
  64160. * Internal only
  64161. * @hidden
  64162. */
  64163. _setErrorObject(message?: string, exception?: any): void;
  64164. /**
  64165. * Execute the current task
  64166. * @param scene defines the scene where you want your assets to be loaded
  64167. * @param onSuccess is a callback called when the task is successfully executed
  64168. * @param onError is a callback called if an error occurs
  64169. */
  64170. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64171. /**
  64172. * Execute the current task
  64173. * @param scene defines the scene where you want your assets to be loaded
  64174. * @param onSuccess is a callback called when the task is successfully executed
  64175. * @param onError is a callback called if an error occurs
  64176. */
  64177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64178. /**
  64179. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64180. * This can be used with failed tasks that have the reason for failure fixed.
  64181. */
  64182. reset(): void;
  64183. private onErrorCallback;
  64184. private onDoneCallback;
  64185. }
  64186. /**
  64187. * Define the interface used by progress events raised during assets loading
  64188. */
  64189. export interface IAssetsProgressEvent {
  64190. /**
  64191. * Defines the number of remaining tasks to process
  64192. */
  64193. remainingCount: number;
  64194. /**
  64195. * Defines the total number of tasks
  64196. */
  64197. totalCount: number;
  64198. /**
  64199. * Defines the task that was just processed
  64200. */
  64201. task: AbstractAssetTask;
  64202. }
  64203. /**
  64204. * Class used to share progress information about assets loading
  64205. */
  64206. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64207. /**
  64208. * Defines the number of remaining tasks to process
  64209. */
  64210. remainingCount: number;
  64211. /**
  64212. * Defines the total number of tasks
  64213. */
  64214. totalCount: number;
  64215. /**
  64216. * Defines the task that was just processed
  64217. */
  64218. task: AbstractAssetTask;
  64219. /**
  64220. * Creates a AssetsProgressEvent
  64221. * @param remainingCount defines the number of remaining tasks to process
  64222. * @param totalCount defines the total number of tasks
  64223. * @param task defines the task that was just processed
  64224. */
  64225. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64226. }
  64227. /**
  64228. * Define a task used by AssetsManager to load meshes
  64229. */
  64230. export class MeshAssetTask extends AbstractAssetTask {
  64231. /**
  64232. * Defines the name of the task
  64233. */
  64234. name: string;
  64235. /**
  64236. * Defines the list of mesh's names you want to load
  64237. */
  64238. meshesNames: any;
  64239. /**
  64240. * Defines the root url to use as a base to load your meshes and associated resources
  64241. */
  64242. rootUrl: string;
  64243. /**
  64244. * Defines the filename of the scene to load from
  64245. */
  64246. sceneFilename: string;
  64247. /**
  64248. * Gets the list of loaded meshes
  64249. */
  64250. loadedMeshes: Array<AbstractMesh>;
  64251. /**
  64252. * Gets the list of loaded particle systems
  64253. */
  64254. loadedParticleSystems: Array<IParticleSystem>;
  64255. /**
  64256. * Gets the list of loaded skeletons
  64257. */
  64258. loadedSkeletons: Array<Skeleton>;
  64259. /**
  64260. * Gets the list of loaded animation groups
  64261. */
  64262. loadedAnimationGroups: Array<AnimationGroup>;
  64263. /**
  64264. * Callback called when the task is successful
  64265. */
  64266. onSuccess: (task: MeshAssetTask) => void;
  64267. /**
  64268. * Callback called when the task is successful
  64269. */
  64270. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64271. /**
  64272. * Creates a new MeshAssetTask
  64273. * @param name defines the name of the task
  64274. * @param meshesNames defines the list of mesh's names you want to load
  64275. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64276. * @param sceneFilename defines the filename of the scene to load from
  64277. */
  64278. constructor(
  64279. /**
  64280. * Defines the name of the task
  64281. */
  64282. name: string,
  64283. /**
  64284. * Defines the list of mesh's names you want to load
  64285. */
  64286. meshesNames: any,
  64287. /**
  64288. * Defines the root url to use as a base to load your meshes and associated resources
  64289. */
  64290. rootUrl: string,
  64291. /**
  64292. * Defines the filename of the scene to load from
  64293. */
  64294. sceneFilename: string);
  64295. /**
  64296. * Execute the current task
  64297. * @param scene defines the scene where you want your assets to be loaded
  64298. * @param onSuccess is a callback called when the task is successfully executed
  64299. * @param onError is a callback called if an error occurs
  64300. */
  64301. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64302. }
  64303. /**
  64304. * Define a task used by AssetsManager to load text content
  64305. */
  64306. export class TextFileAssetTask extends AbstractAssetTask {
  64307. /**
  64308. * Defines the name of the task
  64309. */
  64310. name: string;
  64311. /**
  64312. * Defines the location of the file to load
  64313. */
  64314. url: string;
  64315. /**
  64316. * Gets the loaded text string
  64317. */
  64318. text: string;
  64319. /**
  64320. * Callback called when the task is successful
  64321. */
  64322. onSuccess: (task: TextFileAssetTask) => void;
  64323. /**
  64324. * Callback called when the task is successful
  64325. */
  64326. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64327. /**
  64328. * Creates a new TextFileAssetTask object
  64329. * @param name defines the name of the task
  64330. * @param url defines the location of the file to load
  64331. */
  64332. constructor(
  64333. /**
  64334. * Defines the name of the task
  64335. */
  64336. name: string,
  64337. /**
  64338. * Defines the location of the file to load
  64339. */
  64340. url: string);
  64341. /**
  64342. * Execute the current task
  64343. * @param scene defines the scene where you want your assets to be loaded
  64344. * @param onSuccess is a callback called when the task is successfully executed
  64345. * @param onError is a callback called if an error occurs
  64346. */
  64347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64348. }
  64349. /**
  64350. * Define a task used by AssetsManager to load binary data
  64351. */
  64352. export class BinaryFileAssetTask extends AbstractAssetTask {
  64353. /**
  64354. * Defines the name of the task
  64355. */
  64356. name: string;
  64357. /**
  64358. * Defines the location of the file to load
  64359. */
  64360. url: string;
  64361. /**
  64362. * Gets the lodaded data (as an array buffer)
  64363. */
  64364. data: ArrayBuffer;
  64365. /**
  64366. * Callback called when the task is successful
  64367. */
  64368. onSuccess: (task: BinaryFileAssetTask) => void;
  64369. /**
  64370. * Callback called when the task is successful
  64371. */
  64372. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64373. /**
  64374. * Creates a new BinaryFileAssetTask object
  64375. * @param name defines the name of the new task
  64376. * @param url defines the location of the file to load
  64377. */
  64378. constructor(
  64379. /**
  64380. * Defines the name of the task
  64381. */
  64382. name: string,
  64383. /**
  64384. * Defines the location of the file to load
  64385. */
  64386. url: string);
  64387. /**
  64388. * Execute the current task
  64389. * @param scene defines the scene where you want your assets to be loaded
  64390. * @param onSuccess is a callback called when the task is successfully executed
  64391. * @param onError is a callback called if an error occurs
  64392. */
  64393. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64394. }
  64395. /**
  64396. * Define a task used by AssetsManager to load images
  64397. */
  64398. export class ImageAssetTask extends AbstractAssetTask {
  64399. /**
  64400. * Defines the name of the task
  64401. */
  64402. name: string;
  64403. /**
  64404. * Defines the location of the image to load
  64405. */
  64406. url: string;
  64407. /**
  64408. * Gets the loaded images
  64409. */
  64410. image: HTMLImageElement;
  64411. /**
  64412. * Callback called when the task is successful
  64413. */
  64414. onSuccess: (task: ImageAssetTask) => void;
  64415. /**
  64416. * Callback called when the task is successful
  64417. */
  64418. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64419. /**
  64420. * Creates a new ImageAssetTask
  64421. * @param name defines the name of the task
  64422. * @param url defines the location of the image to load
  64423. */
  64424. constructor(
  64425. /**
  64426. * Defines the name of the task
  64427. */
  64428. name: string,
  64429. /**
  64430. * Defines the location of the image to load
  64431. */
  64432. url: string);
  64433. /**
  64434. * Execute the current task
  64435. * @param scene defines the scene where you want your assets to be loaded
  64436. * @param onSuccess is a callback called when the task is successfully executed
  64437. * @param onError is a callback called if an error occurs
  64438. */
  64439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64440. }
  64441. /**
  64442. * Defines the interface used by texture loading tasks
  64443. */
  64444. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64445. /**
  64446. * Gets the loaded texture
  64447. */
  64448. texture: TEX;
  64449. }
  64450. /**
  64451. * Define a task used by AssetsManager to load 2D textures
  64452. */
  64453. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64454. /**
  64455. * Defines the name of the task
  64456. */
  64457. name: string;
  64458. /**
  64459. * Defines the location of the file to load
  64460. */
  64461. url: string;
  64462. /**
  64463. * Defines if mipmap should not be generated (default is false)
  64464. */
  64465. noMipmap?: boolean | undefined;
  64466. /**
  64467. * Defines if texture must be inverted on Y axis (default is false)
  64468. */
  64469. invertY?: boolean | undefined;
  64470. /**
  64471. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64472. */
  64473. samplingMode: number;
  64474. /**
  64475. * Gets the loaded texture
  64476. */
  64477. texture: Texture;
  64478. /**
  64479. * Callback called when the task is successful
  64480. */
  64481. onSuccess: (task: TextureAssetTask) => void;
  64482. /**
  64483. * Callback called when the task is successful
  64484. */
  64485. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64486. /**
  64487. * Creates a new TextureAssetTask object
  64488. * @param name defines the name of the task
  64489. * @param url defines the location of the file to load
  64490. * @param noMipmap defines if mipmap should not be generated (default is false)
  64491. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64492. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64493. */
  64494. constructor(
  64495. /**
  64496. * Defines the name of the task
  64497. */
  64498. name: string,
  64499. /**
  64500. * Defines the location of the file to load
  64501. */
  64502. url: string,
  64503. /**
  64504. * Defines if mipmap should not be generated (default is false)
  64505. */
  64506. noMipmap?: boolean | undefined,
  64507. /**
  64508. * Defines if texture must be inverted on Y axis (default is false)
  64509. */
  64510. invertY?: boolean | undefined,
  64511. /**
  64512. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64513. */
  64514. samplingMode?: number);
  64515. /**
  64516. * Execute the current task
  64517. * @param scene defines the scene where you want your assets to be loaded
  64518. * @param onSuccess is a callback called when the task is successfully executed
  64519. * @param onError is a callback called if an error occurs
  64520. */
  64521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64522. }
  64523. /**
  64524. * Define a task used by AssetsManager to load cube textures
  64525. */
  64526. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64527. /**
  64528. * Defines the name of the task
  64529. */
  64530. name: string;
  64531. /**
  64532. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64533. */
  64534. url: string;
  64535. /**
  64536. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64537. */
  64538. extensions?: string[] | undefined;
  64539. /**
  64540. * Defines if mipmaps should not be generated (default is false)
  64541. */
  64542. noMipmap?: boolean | undefined;
  64543. /**
  64544. * Defines the explicit list of files (undefined by default)
  64545. */
  64546. files?: string[] | undefined;
  64547. /**
  64548. * Gets the loaded texture
  64549. */
  64550. texture: CubeTexture;
  64551. /**
  64552. * Callback called when the task is successful
  64553. */
  64554. onSuccess: (task: CubeTextureAssetTask) => void;
  64555. /**
  64556. * Callback called when the task is successful
  64557. */
  64558. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64559. /**
  64560. * Creates a new CubeTextureAssetTask
  64561. * @param name defines the name of the task
  64562. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64563. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64564. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64565. * @param files defines the explicit list of files (undefined by default)
  64566. */
  64567. constructor(
  64568. /**
  64569. * Defines the name of the task
  64570. */
  64571. name: string,
  64572. /**
  64573. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64574. */
  64575. url: string,
  64576. /**
  64577. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64578. */
  64579. extensions?: string[] | undefined,
  64580. /**
  64581. * Defines if mipmaps should not be generated (default is false)
  64582. */
  64583. noMipmap?: boolean | undefined,
  64584. /**
  64585. * Defines the explicit list of files (undefined by default)
  64586. */
  64587. files?: string[] | undefined);
  64588. /**
  64589. * Execute the current task
  64590. * @param scene defines the scene where you want your assets to be loaded
  64591. * @param onSuccess is a callback called when the task is successfully executed
  64592. * @param onError is a callback called if an error occurs
  64593. */
  64594. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64595. }
  64596. /**
  64597. * Define a task used by AssetsManager to load HDR cube textures
  64598. */
  64599. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64600. /**
  64601. * Defines the name of the task
  64602. */
  64603. name: string;
  64604. /**
  64605. * Defines the location of the file to load
  64606. */
  64607. url: string;
  64608. /**
  64609. * Defines the desired size (the more it increases the longer the generation will be)
  64610. */
  64611. size: number;
  64612. /**
  64613. * Defines if mipmaps should not be generated (default is false)
  64614. */
  64615. noMipmap: boolean;
  64616. /**
  64617. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64618. */
  64619. generateHarmonics: boolean;
  64620. /**
  64621. * 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)
  64622. */
  64623. gammaSpace: boolean;
  64624. /**
  64625. * Internal Use Only
  64626. */
  64627. reserved: boolean;
  64628. /**
  64629. * Gets the loaded texture
  64630. */
  64631. texture: HDRCubeTexture;
  64632. /**
  64633. * Callback called when the task is successful
  64634. */
  64635. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64636. /**
  64637. * Callback called when the task is successful
  64638. */
  64639. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64640. /**
  64641. * Creates a new HDRCubeTextureAssetTask object
  64642. * @param name defines the name of the task
  64643. * @param url defines the location of the file to load
  64644. * @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.
  64645. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64646. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64647. * @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)
  64648. * @param reserved Internal use only
  64649. */
  64650. constructor(
  64651. /**
  64652. * Defines the name of the task
  64653. */
  64654. name: string,
  64655. /**
  64656. * Defines the location of the file to load
  64657. */
  64658. url: string,
  64659. /**
  64660. * Defines the desired size (the more it increases the longer the generation will be)
  64661. */
  64662. size: number,
  64663. /**
  64664. * Defines if mipmaps should not be generated (default is false)
  64665. */
  64666. noMipmap?: boolean,
  64667. /**
  64668. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64669. */
  64670. generateHarmonics?: boolean,
  64671. /**
  64672. * 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)
  64673. */
  64674. gammaSpace?: boolean,
  64675. /**
  64676. * Internal Use Only
  64677. */
  64678. reserved?: boolean);
  64679. /**
  64680. * Execute the current task
  64681. * @param scene defines the scene where you want your assets to be loaded
  64682. * @param onSuccess is a callback called when the task is successfully executed
  64683. * @param onError is a callback called if an error occurs
  64684. */
  64685. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64686. }
  64687. /**
  64688. * Define a task used by AssetsManager to load Equirectangular cube textures
  64689. */
  64690. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64691. /**
  64692. * Defines the name of the task
  64693. */
  64694. name: string;
  64695. /**
  64696. * Defines the location of the file to load
  64697. */
  64698. url: string;
  64699. /**
  64700. * Defines the desired size (the more it increases the longer the generation will be)
  64701. */
  64702. size: number;
  64703. /**
  64704. * Defines if mipmaps should not be generated (default is false)
  64705. */
  64706. noMipmap: boolean;
  64707. /**
  64708. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64709. * but the standard material would require them in Gamma space) (default is true)
  64710. */
  64711. gammaSpace: boolean;
  64712. /**
  64713. * Gets the loaded texture
  64714. */
  64715. texture: EquiRectangularCubeTexture;
  64716. /**
  64717. * Callback called when the task is successful
  64718. */
  64719. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64720. /**
  64721. * Callback called when the task is successful
  64722. */
  64723. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64724. /**
  64725. * Creates a new EquiRectangularCubeTextureAssetTask object
  64726. * @param name defines the name of the task
  64727. * @param url defines the location of the file to load
  64728. * @param size defines the desired size (the more it increases the longer the generation will be)
  64729. * If the size is omitted this implies you are using a preprocessed cubemap.
  64730. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64731. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64732. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64733. * (default is true)
  64734. */
  64735. constructor(
  64736. /**
  64737. * Defines the name of the task
  64738. */
  64739. name: string,
  64740. /**
  64741. * Defines the location of the file to load
  64742. */
  64743. url: string,
  64744. /**
  64745. * Defines the desired size (the more it increases the longer the generation will be)
  64746. */
  64747. size: number,
  64748. /**
  64749. * Defines if mipmaps should not be generated (default is false)
  64750. */
  64751. noMipmap?: boolean,
  64752. /**
  64753. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64754. * but the standard material would require them in Gamma space) (default is true)
  64755. */
  64756. gammaSpace?: boolean);
  64757. /**
  64758. * Execute the current task
  64759. * @param scene defines the scene where you want your assets to be loaded
  64760. * @param onSuccess is a callback called when the task is successfully executed
  64761. * @param onError is a callback called if an error occurs
  64762. */
  64763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64764. }
  64765. /**
  64766. * This class can be used to easily import assets into a scene
  64767. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64768. */
  64769. export class AssetsManager {
  64770. private _scene;
  64771. private _isLoading;
  64772. protected _tasks: AbstractAssetTask[];
  64773. protected _waitingTasksCount: number;
  64774. protected _totalTasksCount: number;
  64775. /**
  64776. * Callback called when all tasks are processed
  64777. */
  64778. onFinish: (tasks: AbstractAssetTask[]) => void;
  64779. /**
  64780. * Callback called when a task is successful
  64781. */
  64782. onTaskSuccess: (task: AbstractAssetTask) => void;
  64783. /**
  64784. * Callback called when a task had an error
  64785. */
  64786. onTaskError: (task: AbstractAssetTask) => void;
  64787. /**
  64788. * Callback called when a task is done (whatever the result is)
  64789. */
  64790. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64791. /**
  64792. * Observable called when all tasks are processed
  64793. */
  64794. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64795. /**
  64796. * Observable called when a task had an error
  64797. */
  64798. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64799. /**
  64800. * Observable called when all tasks were executed
  64801. */
  64802. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64803. /**
  64804. * Observable called when a task is done (whatever the result is)
  64805. */
  64806. onProgressObservable: Observable<IAssetsProgressEvent>;
  64807. /**
  64808. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64810. */
  64811. useDefaultLoadingScreen: boolean;
  64812. /**
  64813. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64814. * when all assets have been downloaded.
  64815. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64816. */
  64817. autoHideLoadingUI: boolean;
  64818. /**
  64819. * Creates a new AssetsManager
  64820. * @param scene defines the scene to work on
  64821. */
  64822. constructor(scene: Scene);
  64823. /**
  64824. * Add a MeshAssetTask to the list of active tasks
  64825. * @param taskName defines the name of the new task
  64826. * @param meshesNames defines the name of meshes to load
  64827. * @param rootUrl defines the root url to use to locate files
  64828. * @param sceneFilename defines the filename of the scene file
  64829. * @returns a new MeshAssetTask object
  64830. */
  64831. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64832. /**
  64833. * Add a TextFileAssetTask to the list of active tasks
  64834. * @param taskName defines the name of the new task
  64835. * @param url defines the url of the file to load
  64836. * @returns a new TextFileAssetTask object
  64837. */
  64838. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64839. /**
  64840. * Add a BinaryFileAssetTask to the list of active tasks
  64841. * @param taskName defines the name of the new task
  64842. * @param url defines the url of the file to load
  64843. * @returns a new BinaryFileAssetTask object
  64844. */
  64845. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64846. /**
  64847. * Add a ImageAssetTask to the list of active tasks
  64848. * @param taskName defines the name of the new task
  64849. * @param url defines the url of the file to load
  64850. * @returns a new ImageAssetTask object
  64851. */
  64852. addImageTask(taskName: string, url: string): ImageAssetTask;
  64853. /**
  64854. * Add a TextureAssetTask to the list of active tasks
  64855. * @param taskName defines the name of the new task
  64856. * @param url defines the url of the file to load
  64857. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64858. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64859. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64860. * @returns a new TextureAssetTask object
  64861. */
  64862. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64863. /**
  64864. * Add a CubeTextureAssetTask to the list of active tasks
  64865. * @param taskName defines the name of the new task
  64866. * @param url defines the url of the file to load
  64867. * @param extensions defines the extension to use to load the cube map (can be null)
  64868. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64869. * @param files defines the list of files to load (can be null)
  64870. * @returns a new CubeTextureAssetTask object
  64871. */
  64872. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64873. /**
  64874. *
  64875. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64876. * @param taskName defines the name of the new task
  64877. * @param url defines the url of the file to load
  64878. * @param size defines the size you want for the cubemap (can be null)
  64879. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64880. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64881. * @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)
  64882. * @param reserved Internal use only
  64883. * @returns a new HDRCubeTextureAssetTask object
  64884. */
  64885. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64886. /**
  64887. *
  64888. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64889. * @param taskName defines the name of the new task
  64890. * @param url defines the url of the file to load
  64891. * @param size defines the size you want for the cubemap (can be null)
  64892. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64893. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64894. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64895. * @returns a new EquiRectangularCubeTextureAssetTask object
  64896. */
  64897. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64898. /**
  64899. * Remove a task from the assets manager.
  64900. * @param task the task to remove
  64901. */
  64902. removeTask(task: AbstractAssetTask): void;
  64903. private _decreaseWaitingTasksCount;
  64904. private _runTask;
  64905. /**
  64906. * Reset the AssetsManager and remove all tasks
  64907. * @return the current instance of the AssetsManager
  64908. */
  64909. reset(): AssetsManager;
  64910. /**
  64911. * Start the loading process
  64912. * @return the current instance of the AssetsManager
  64913. */
  64914. load(): AssetsManager;
  64915. /**
  64916. * Start the loading process as an async operation
  64917. * @return a promise returning the list of failed tasks
  64918. */
  64919. loadAsync(): Promise<void>;
  64920. }
  64921. }
  64922. declare module "babylonjs/Misc/deferred" {
  64923. /**
  64924. * Wrapper class for promise with external resolve and reject.
  64925. */
  64926. export class Deferred<T> {
  64927. /**
  64928. * The promise associated with this deferred object.
  64929. */
  64930. readonly promise: Promise<T>;
  64931. private _resolve;
  64932. private _reject;
  64933. /**
  64934. * The resolve method of the promise associated with this deferred object.
  64935. */
  64936. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64937. /**
  64938. * The reject method of the promise associated with this deferred object.
  64939. */
  64940. readonly reject: (reason?: any) => void;
  64941. /**
  64942. * Constructor for this deferred object.
  64943. */
  64944. constructor();
  64945. }
  64946. }
  64947. declare module "babylonjs/Misc/meshExploder" {
  64948. import { Mesh } from "babylonjs/Meshes/mesh";
  64949. /**
  64950. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64951. */
  64952. export class MeshExploder {
  64953. private _centerMesh;
  64954. private _meshes;
  64955. private _meshesOrigins;
  64956. private _toCenterVectors;
  64957. private _scaledDirection;
  64958. private _newPosition;
  64959. private _centerPosition;
  64960. /**
  64961. * Explodes meshes from a center mesh.
  64962. * @param meshes The meshes to explode.
  64963. * @param centerMesh The mesh to be center of explosion.
  64964. */
  64965. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64966. private _setCenterMesh;
  64967. /**
  64968. * Get class name
  64969. * @returns "MeshExploder"
  64970. */
  64971. getClassName(): string;
  64972. /**
  64973. * "Exploded meshes"
  64974. * @returns Array of meshes with the centerMesh at index 0.
  64975. */
  64976. getMeshes(): Array<Mesh>;
  64977. /**
  64978. * Explodes meshes giving a specific direction
  64979. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64980. */
  64981. explode(direction?: number): void;
  64982. }
  64983. }
  64984. declare module "babylonjs/Misc/filesInput" {
  64985. import { Engine } from "babylonjs/Engines/engine";
  64986. import { Scene } from "babylonjs/scene";
  64987. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64988. /**
  64989. * Class used to help managing file picking and drag'n'drop
  64990. */
  64991. export class FilesInput {
  64992. /**
  64993. * List of files ready to be loaded
  64994. */
  64995. static readonly FilesToLoad: {
  64996. [key: string]: File;
  64997. };
  64998. /**
  64999. * Callback called when a file is processed
  65000. */
  65001. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65002. private _engine;
  65003. private _currentScene;
  65004. private _sceneLoadedCallback;
  65005. private _progressCallback;
  65006. private _additionalRenderLoopLogicCallback;
  65007. private _textureLoadingCallback;
  65008. private _startingProcessingFilesCallback;
  65009. private _onReloadCallback;
  65010. private _errorCallback;
  65011. private _elementToMonitor;
  65012. private _sceneFileToLoad;
  65013. private _filesToLoad;
  65014. /**
  65015. * Creates a new FilesInput
  65016. * @param engine defines the rendering engine
  65017. * @param scene defines the hosting scene
  65018. * @param sceneLoadedCallback callback called when scene is loaded
  65019. * @param progressCallback callback called to track progress
  65020. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65021. * @param textureLoadingCallback callback called when a texture is loading
  65022. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65023. * @param onReloadCallback callback called when a reload is requested
  65024. * @param errorCallback callback call if an error occurs
  65025. */
  65026. 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);
  65027. private _dragEnterHandler;
  65028. private _dragOverHandler;
  65029. private _dropHandler;
  65030. /**
  65031. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65032. * @param elementToMonitor defines the DOM element to track
  65033. */
  65034. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65035. /**
  65036. * Release all associated resources
  65037. */
  65038. dispose(): void;
  65039. private renderFunction;
  65040. private drag;
  65041. private drop;
  65042. private _traverseFolder;
  65043. private _processFiles;
  65044. /**
  65045. * Load files from a drop event
  65046. * @param event defines the drop event to use as source
  65047. */
  65048. loadFiles(event: any): void;
  65049. private _processReload;
  65050. /**
  65051. * Reload the current scene from the loaded files
  65052. */
  65053. reload(): void;
  65054. }
  65055. }
  65056. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65057. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65058. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65059. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65060. }
  65061. declare module "babylonjs/Misc/sceneOptimizer" {
  65062. import { Scene, IDisposable } from "babylonjs/scene";
  65063. import { Observable } from "babylonjs/Misc/observable";
  65064. /**
  65065. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65067. */
  65068. export class SceneOptimization {
  65069. /**
  65070. * Defines the priority of this optimization (0 by default which means first in the list)
  65071. */
  65072. priority: number;
  65073. /**
  65074. * Gets a string describing the action executed by the current optimization
  65075. * @returns description string
  65076. */
  65077. getDescription(): string;
  65078. /**
  65079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65080. * @param scene defines the current scene where to apply this optimization
  65081. * @param optimizer defines the current optimizer
  65082. * @returns true if everything that can be done was applied
  65083. */
  65084. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65085. /**
  65086. * Creates the SceneOptimization object
  65087. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65088. * @param desc defines the description associated with the optimization
  65089. */
  65090. constructor(
  65091. /**
  65092. * Defines the priority of this optimization (0 by default which means first in the list)
  65093. */
  65094. priority?: number);
  65095. }
  65096. /**
  65097. * Defines an optimization used to reduce the size of render target textures
  65098. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65099. */
  65100. export class TextureOptimization extends SceneOptimization {
  65101. /**
  65102. * Defines the priority of this optimization (0 by default which means first in the list)
  65103. */
  65104. priority: number;
  65105. /**
  65106. * 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
  65107. */
  65108. maximumSize: number;
  65109. /**
  65110. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65111. */
  65112. step: number;
  65113. /**
  65114. * Gets a string describing the action executed by the current optimization
  65115. * @returns description string
  65116. */
  65117. getDescription(): string;
  65118. /**
  65119. * Creates the TextureOptimization object
  65120. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65121. * @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
  65122. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65123. */
  65124. constructor(
  65125. /**
  65126. * Defines the priority of this optimization (0 by default which means first in the list)
  65127. */
  65128. priority?: number,
  65129. /**
  65130. * 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
  65131. */
  65132. maximumSize?: number,
  65133. /**
  65134. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65135. */
  65136. step?: number);
  65137. /**
  65138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65139. * @param scene defines the current scene where to apply this optimization
  65140. * @param optimizer defines the current optimizer
  65141. * @returns true if everything that can be done was applied
  65142. */
  65143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65144. }
  65145. /**
  65146. * Defines an optimization used to increase or decrease the rendering resolution
  65147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65148. */
  65149. export class HardwareScalingOptimization extends SceneOptimization {
  65150. /**
  65151. * Defines the priority of this optimization (0 by default which means first in the list)
  65152. */
  65153. priority: number;
  65154. /**
  65155. * Defines the maximum scale to use (2 by default)
  65156. */
  65157. maximumScale: number;
  65158. /**
  65159. * Defines the step to use between two passes (0.5 by default)
  65160. */
  65161. step: number;
  65162. private _currentScale;
  65163. private _directionOffset;
  65164. /**
  65165. * Gets a string describing the action executed by the current optimization
  65166. * @return description string
  65167. */
  65168. getDescription(): string;
  65169. /**
  65170. * Creates the HardwareScalingOptimization object
  65171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65172. * @param maximumScale defines the maximum scale to use (2 by default)
  65173. * @param step defines the step to use between two passes (0.5 by default)
  65174. */
  65175. constructor(
  65176. /**
  65177. * Defines the priority of this optimization (0 by default which means first in the list)
  65178. */
  65179. priority?: number,
  65180. /**
  65181. * Defines the maximum scale to use (2 by default)
  65182. */
  65183. maximumScale?: number,
  65184. /**
  65185. * Defines the step to use between two passes (0.5 by default)
  65186. */
  65187. step?: number);
  65188. /**
  65189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65190. * @param scene defines the current scene where to apply this optimization
  65191. * @param optimizer defines the current optimizer
  65192. * @returns true if everything that can be done was applied
  65193. */
  65194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65195. }
  65196. /**
  65197. * Defines an optimization used to remove shadows
  65198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65199. */
  65200. export class ShadowsOptimization extends SceneOptimization {
  65201. /**
  65202. * Gets a string describing the action executed by the current optimization
  65203. * @return description string
  65204. */
  65205. getDescription(): string;
  65206. /**
  65207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65208. * @param scene defines the current scene where to apply this optimization
  65209. * @param optimizer defines the current optimizer
  65210. * @returns true if everything that can be done was applied
  65211. */
  65212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65213. }
  65214. /**
  65215. * Defines an optimization used to turn post-processes off
  65216. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65217. */
  65218. export class PostProcessesOptimization extends SceneOptimization {
  65219. /**
  65220. * Gets a string describing the action executed by the current optimization
  65221. * @return description string
  65222. */
  65223. getDescription(): string;
  65224. /**
  65225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65226. * @param scene defines the current scene where to apply this optimization
  65227. * @param optimizer defines the current optimizer
  65228. * @returns true if everything that can be done was applied
  65229. */
  65230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65231. }
  65232. /**
  65233. * Defines an optimization used to turn lens flares off
  65234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65235. */
  65236. export class LensFlaresOptimization extends SceneOptimization {
  65237. /**
  65238. * Gets a string describing the action executed by the current optimization
  65239. * @return description string
  65240. */
  65241. getDescription(): string;
  65242. /**
  65243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65244. * @param scene defines the current scene where to apply this optimization
  65245. * @param optimizer defines the current optimizer
  65246. * @returns true if everything that can be done was applied
  65247. */
  65248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65249. }
  65250. /**
  65251. * Defines an optimization based on user defined callback.
  65252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65253. */
  65254. export class CustomOptimization extends SceneOptimization {
  65255. /**
  65256. * Callback called to apply the custom optimization.
  65257. */
  65258. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65259. /**
  65260. * Callback called to get custom description
  65261. */
  65262. onGetDescription: () => string;
  65263. /**
  65264. * Gets a string describing the action executed by the current optimization
  65265. * @returns description string
  65266. */
  65267. getDescription(): string;
  65268. /**
  65269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65270. * @param scene defines the current scene where to apply this optimization
  65271. * @param optimizer defines the current optimizer
  65272. * @returns true if everything that can be done was applied
  65273. */
  65274. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65275. }
  65276. /**
  65277. * Defines an optimization used to turn particles off
  65278. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65279. */
  65280. export class ParticlesOptimization extends SceneOptimization {
  65281. /**
  65282. * Gets a string describing the action executed by the current optimization
  65283. * @return description string
  65284. */
  65285. getDescription(): string;
  65286. /**
  65287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65288. * @param scene defines the current scene where to apply this optimization
  65289. * @param optimizer defines the current optimizer
  65290. * @returns true if everything that can be done was applied
  65291. */
  65292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65293. }
  65294. /**
  65295. * Defines an optimization used to turn render targets off
  65296. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65297. */
  65298. export class RenderTargetsOptimization extends SceneOptimization {
  65299. /**
  65300. * Gets a string describing the action executed by the current optimization
  65301. * @return description string
  65302. */
  65303. getDescription(): string;
  65304. /**
  65305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65306. * @param scene defines the current scene where to apply this optimization
  65307. * @param optimizer defines the current optimizer
  65308. * @returns true if everything that can be done was applied
  65309. */
  65310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65311. }
  65312. /**
  65313. * Defines an optimization used to merge meshes with compatible materials
  65314. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65315. */
  65316. export class MergeMeshesOptimization extends SceneOptimization {
  65317. private static _UpdateSelectionTree;
  65318. /**
  65319. * Gets or sets a boolean which defines if optimization octree has to be updated
  65320. */
  65321. /**
  65322. * Gets or sets a boolean which defines if optimization octree has to be updated
  65323. */
  65324. static UpdateSelectionTree: boolean;
  65325. /**
  65326. * Gets a string describing the action executed by the current optimization
  65327. * @return description string
  65328. */
  65329. getDescription(): string;
  65330. private _canBeMerged;
  65331. /**
  65332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65333. * @param scene defines the current scene where to apply this optimization
  65334. * @param optimizer defines the current optimizer
  65335. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65336. * @returns true if everything that can be done was applied
  65337. */
  65338. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65339. }
  65340. /**
  65341. * Defines a list of options used by SceneOptimizer
  65342. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65343. */
  65344. export class SceneOptimizerOptions {
  65345. /**
  65346. * Defines the target frame rate to reach (60 by default)
  65347. */
  65348. targetFrameRate: number;
  65349. /**
  65350. * Defines the interval between two checkes (2000ms by default)
  65351. */
  65352. trackerDuration: number;
  65353. /**
  65354. * Gets the list of optimizations to apply
  65355. */
  65356. optimizations: SceneOptimization[];
  65357. /**
  65358. * Creates a new list of options used by SceneOptimizer
  65359. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65360. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65361. */
  65362. constructor(
  65363. /**
  65364. * Defines the target frame rate to reach (60 by default)
  65365. */
  65366. targetFrameRate?: number,
  65367. /**
  65368. * Defines the interval between two checkes (2000ms by default)
  65369. */
  65370. trackerDuration?: number);
  65371. /**
  65372. * Add a new optimization
  65373. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65374. * @returns the current SceneOptimizerOptions
  65375. */
  65376. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65377. /**
  65378. * Add a new custom optimization
  65379. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65380. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65381. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65382. * @returns the current SceneOptimizerOptions
  65383. */
  65384. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65385. /**
  65386. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65387. * @param targetFrameRate defines the target frame rate (60 by default)
  65388. * @returns a SceneOptimizerOptions object
  65389. */
  65390. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65391. /**
  65392. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65393. * @param targetFrameRate defines the target frame rate (60 by default)
  65394. * @returns a SceneOptimizerOptions object
  65395. */
  65396. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65397. /**
  65398. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65399. * @param targetFrameRate defines the target frame rate (60 by default)
  65400. * @returns a SceneOptimizerOptions object
  65401. */
  65402. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65403. }
  65404. /**
  65405. * Class used to run optimizations in order to reach a target frame rate
  65406. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65407. */
  65408. export class SceneOptimizer implements IDisposable {
  65409. private _isRunning;
  65410. private _options;
  65411. private _scene;
  65412. private _currentPriorityLevel;
  65413. private _targetFrameRate;
  65414. private _trackerDuration;
  65415. private _currentFrameRate;
  65416. private _sceneDisposeObserver;
  65417. private _improvementMode;
  65418. /**
  65419. * Defines an observable called when the optimizer reaches the target frame rate
  65420. */
  65421. onSuccessObservable: Observable<SceneOptimizer>;
  65422. /**
  65423. * Defines an observable called when the optimizer enables an optimization
  65424. */
  65425. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65426. /**
  65427. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65428. */
  65429. onFailureObservable: Observable<SceneOptimizer>;
  65430. /**
  65431. * Gets a boolean indicating if the optimizer is in improvement mode
  65432. */
  65433. readonly isInImprovementMode: boolean;
  65434. /**
  65435. * Gets the current priority level (0 at start)
  65436. */
  65437. readonly currentPriorityLevel: number;
  65438. /**
  65439. * Gets the current frame rate checked by the SceneOptimizer
  65440. */
  65441. readonly currentFrameRate: number;
  65442. /**
  65443. * Gets or sets the current target frame rate (60 by default)
  65444. */
  65445. /**
  65446. * Gets or sets the current target frame rate (60 by default)
  65447. */
  65448. targetFrameRate: number;
  65449. /**
  65450. * Gets or sets the current interval between two checks (every 2000ms by default)
  65451. */
  65452. /**
  65453. * Gets or sets the current interval between two checks (every 2000ms by default)
  65454. */
  65455. trackerDuration: number;
  65456. /**
  65457. * Gets the list of active optimizations
  65458. */
  65459. readonly optimizations: SceneOptimization[];
  65460. /**
  65461. * Creates a new SceneOptimizer
  65462. * @param scene defines the scene to work on
  65463. * @param options defines the options to use with the SceneOptimizer
  65464. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65465. * @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)
  65466. */
  65467. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65468. /**
  65469. * Stops the current optimizer
  65470. */
  65471. stop(): void;
  65472. /**
  65473. * Reset the optimizer to initial step (current priority level = 0)
  65474. */
  65475. reset(): void;
  65476. /**
  65477. * Start the optimizer. By default it will try to reach a specific framerate
  65478. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65479. */
  65480. start(): void;
  65481. private _checkCurrentState;
  65482. /**
  65483. * Release all resources
  65484. */
  65485. dispose(): void;
  65486. /**
  65487. * Helper function to create a SceneOptimizer with one single line of code
  65488. * @param scene defines the scene to work on
  65489. * @param options defines the options to use with the SceneOptimizer
  65490. * @param onSuccess defines a callback to call on success
  65491. * @param onFailure defines a callback to call on failure
  65492. * @returns the new SceneOptimizer object
  65493. */
  65494. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65495. }
  65496. }
  65497. declare module "babylonjs/Misc/sceneSerializer" {
  65498. import { Scene } from "babylonjs/scene";
  65499. /**
  65500. * Class used to serialize a scene into a string
  65501. */
  65502. export class SceneSerializer {
  65503. /**
  65504. * Clear cache used by a previous serialization
  65505. */
  65506. static ClearCache(): void;
  65507. /**
  65508. * Serialize a scene into a JSON compatible object
  65509. * @param scene defines the scene to serialize
  65510. * @returns a JSON compatible object
  65511. */
  65512. static Serialize(scene: Scene): any;
  65513. /**
  65514. * Serialize a mesh into a JSON compatible object
  65515. * @param toSerialize defines the mesh to serialize
  65516. * @param withParents defines if parents must be serialized as well
  65517. * @param withChildren defines if children must be serialized as well
  65518. * @returns a JSON compatible object
  65519. */
  65520. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65521. }
  65522. }
  65523. declare module "babylonjs/Misc/textureTools" {
  65524. import { Texture } from "babylonjs/Materials/Textures/texture";
  65525. /**
  65526. * Class used to host texture specific utilities
  65527. */
  65528. export class TextureTools {
  65529. /**
  65530. * Uses the GPU to create a copy texture rescaled at a given size
  65531. * @param texture Texture to copy from
  65532. * @param width defines the desired width
  65533. * @param height defines the desired height
  65534. * @param useBilinearMode defines if bilinear mode has to be used
  65535. * @return the generated texture
  65536. */
  65537. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65538. }
  65539. }
  65540. declare module "babylonjs/Misc/videoRecorder" {
  65541. import { Nullable } from "babylonjs/types";
  65542. import { Engine } from "babylonjs/Engines/engine";
  65543. /**
  65544. * This represents the different options available for the video capture.
  65545. */
  65546. export interface VideoRecorderOptions {
  65547. /** Defines the mime type of the video. */
  65548. mimeType: string;
  65549. /** Defines the FPS the video should be recorded at. */
  65550. fps: number;
  65551. /** Defines the chunk size for the recording data. */
  65552. recordChunckSize: number;
  65553. /** The audio tracks to attach to the recording. */
  65554. audioTracks?: MediaStreamTrack[];
  65555. }
  65556. /**
  65557. * This can help with recording videos from BabylonJS.
  65558. * This is based on the available WebRTC functionalities of the browser.
  65559. *
  65560. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65561. */
  65562. export class VideoRecorder {
  65563. private static readonly _defaultOptions;
  65564. /**
  65565. * Returns whether or not the VideoRecorder is available in your browser.
  65566. * @param engine Defines the Babylon Engine.
  65567. * @returns true if supported otherwise false.
  65568. */
  65569. static IsSupported(engine: Engine): boolean;
  65570. private readonly _options;
  65571. private _canvas;
  65572. private _mediaRecorder;
  65573. private _recordedChunks;
  65574. private _fileName;
  65575. private _resolve;
  65576. private _reject;
  65577. /**
  65578. * True when a recording is already in progress.
  65579. */
  65580. readonly isRecording: boolean;
  65581. /**
  65582. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65583. * @param engine Defines the BabylonJS Engine you wish to record.
  65584. * @param options Defines options that can be used to customize the capture.
  65585. */
  65586. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65587. /**
  65588. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65589. */
  65590. stopRecording(): void;
  65591. /**
  65592. * Starts recording the canvas for a max duration specified in parameters.
  65593. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65594. * If null no automatic download will start and you can rely on the promise to get the data back.
  65595. * @param maxDuration Defines the maximum recording time in seconds.
  65596. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65597. * @return A promise callback at the end of the recording with the video data in Blob.
  65598. */
  65599. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65600. /**
  65601. * Releases internal resources used during the recording.
  65602. */
  65603. dispose(): void;
  65604. private _handleDataAvailable;
  65605. private _handleError;
  65606. private _handleStop;
  65607. }
  65608. }
  65609. declare module "babylonjs/Misc/screenshotTools" {
  65610. import { Camera } from "babylonjs/Cameras/camera";
  65611. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65612. import { Engine } from "babylonjs/Engines/engine";
  65613. /**
  65614. * Class containing a set of static utilities functions for screenshots
  65615. */
  65616. export class ScreenshotTools {
  65617. /**
  65618. * Captures a screenshot of the current rendering
  65619. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65620. * @param engine defines the rendering engine
  65621. * @param camera defines the source camera
  65622. * @param size This parameter can be set to a single number or to an object with the
  65623. * following (optional) properties: precision, width, height. If a single number is passed,
  65624. * it will be used for both width and height. If an object is passed, the screenshot size
  65625. * will be derived from the parameters. The precision property is a multiplier allowing
  65626. * rendering at a higher or lower resolution
  65627. * @param successCallback defines the callback receives a single parameter which contains the
  65628. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65629. * src parameter of an <img> to display it
  65630. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65631. * Check your browser for supported MIME types
  65632. */
  65633. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65634. /**
  65635. * Captures a screenshot of the current rendering
  65636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65637. * @param engine defines the rendering engine
  65638. * @param camera defines the source camera
  65639. * @param size This parameter can be set to a single number or to an object with the
  65640. * following (optional) properties: precision, width, height. If a single number is passed,
  65641. * it will be used for both width and height. If an object is passed, the screenshot size
  65642. * will be derived from the parameters. The precision property is a multiplier allowing
  65643. * rendering at a higher or lower resolution
  65644. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65645. * Check your browser for supported MIME types
  65646. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65647. * to the src parameter of an <img> to display it
  65648. */
  65649. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65650. /**
  65651. * Generates an image screenshot from the specified camera.
  65652. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65653. * @param engine The engine to use for rendering
  65654. * @param camera The camera to use for rendering
  65655. * @param size This parameter can be set to a single number or to an object with the
  65656. * following (optional) properties: precision, width, height. If a single number is passed,
  65657. * it will be used for both width and height. If an object is passed, the screenshot size
  65658. * will be derived from the parameters. The precision property is a multiplier allowing
  65659. * rendering at a higher or lower resolution
  65660. * @param successCallback The callback receives a single parameter which contains the
  65661. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65662. * src parameter of an <img> to display it
  65663. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65664. * Check your browser for supported MIME types
  65665. * @param samples Texture samples (default: 1)
  65666. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65667. * @param fileName A name for for the downloaded file.
  65668. */
  65669. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65670. /**
  65671. * Generates an image screenshot from the specified camera.
  65672. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65673. * @param engine The engine to use for rendering
  65674. * @param camera The camera to use for rendering
  65675. * @param size This parameter can be set to a single number or to an object with the
  65676. * following (optional) properties: precision, width, height. If a single number is passed,
  65677. * it will be used for both width and height. If an object is passed, the screenshot size
  65678. * will be derived from the parameters. The precision property is a multiplier allowing
  65679. * rendering at a higher or lower resolution
  65680. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65681. * Check your browser for supported MIME types
  65682. * @param samples Texture samples (default: 1)
  65683. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65684. * @param fileName A name for for the downloaded file.
  65685. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65686. * to the src parameter of an <img> to display it
  65687. */
  65688. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65689. /**
  65690. * Gets height and width for screenshot size
  65691. * @private
  65692. */
  65693. private static _getScreenshotSize;
  65694. }
  65695. }
  65696. declare module "babylonjs/Misc/index" {
  65697. export * from "babylonjs/Misc/andOrNotEvaluator";
  65698. export * from "babylonjs/Misc/assetsManager";
  65699. export * from "babylonjs/Misc/dds";
  65700. export * from "babylonjs/Misc/decorators";
  65701. export * from "babylonjs/Misc/deferred";
  65702. export * from "babylonjs/Misc/environmentTextureTools";
  65703. export * from "babylonjs/Misc/meshExploder";
  65704. export * from "babylonjs/Misc/filesInput";
  65705. export * from "babylonjs/Misc/HighDynamicRange/index";
  65706. export * from "babylonjs/Misc/khronosTextureContainer";
  65707. export * from "babylonjs/Misc/observable";
  65708. export * from "babylonjs/Misc/performanceMonitor";
  65709. export * from "babylonjs/Misc/promise";
  65710. export * from "babylonjs/Misc/sceneOptimizer";
  65711. export * from "babylonjs/Misc/sceneSerializer";
  65712. export * from "babylonjs/Misc/smartArray";
  65713. export * from "babylonjs/Misc/stringDictionary";
  65714. export * from "babylonjs/Misc/tags";
  65715. export * from "babylonjs/Misc/textureTools";
  65716. export * from "babylonjs/Misc/tga";
  65717. export * from "babylonjs/Misc/tools";
  65718. export * from "babylonjs/Misc/videoRecorder";
  65719. export * from "babylonjs/Misc/virtualJoystick";
  65720. export * from "babylonjs/Misc/workerPool";
  65721. export * from "babylonjs/Misc/logger";
  65722. export * from "babylonjs/Misc/typeStore";
  65723. export * from "babylonjs/Misc/filesInputStore";
  65724. export * from "babylonjs/Misc/deepCopier";
  65725. export * from "babylonjs/Misc/pivotTools";
  65726. export * from "babylonjs/Misc/precisionDate";
  65727. export * from "babylonjs/Misc/screenshotTools";
  65728. export * from "babylonjs/Misc/typeStore";
  65729. export * from "babylonjs/Misc/webRequest";
  65730. export * from "babylonjs/Misc/iInspectable";
  65731. export * from "babylonjs/Misc/brdfTextureTools";
  65732. export * from "babylonjs/Misc/rgbdTextureTools";
  65733. export * from "babylonjs/Misc/gradients";
  65734. export * from "babylonjs/Misc/perfCounter";
  65735. export * from "babylonjs/Misc/fileRequest";
  65736. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65737. export * from "babylonjs/Misc/retryStrategy";
  65738. export * from "babylonjs/Misc/loadFileError";
  65739. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65740. }
  65741. declare module "babylonjs/index" {
  65742. export * from "babylonjs/abstractScene";
  65743. export * from "babylonjs/Actions/index";
  65744. export * from "babylonjs/Animations/index";
  65745. export * from "babylonjs/assetContainer";
  65746. export * from "babylonjs/Audio/index";
  65747. export * from "babylonjs/Behaviors/index";
  65748. export * from "babylonjs/Bones/index";
  65749. export * from "babylonjs/Cameras/index";
  65750. export * from "babylonjs/Collisions/index";
  65751. export * from "babylonjs/Culling/index";
  65752. export * from "babylonjs/Debug/index";
  65753. export * from "babylonjs/Engines/index";
  65754. export * from "babylonjs/Events/index";
  65755. export * from "babylonjs/Gamepads/index";
  65756. export * from "babylonjs/Gizmos/index";
  65757. export * from "babylonjs/Helpers/index";
  65758. export * from "babylonjs/Instrumentation/index";
  65759. export * from "babylonjs/Layers/index";
  65760. export * from "babylonjs/LensFlares/index";
  65761. export * from "babylonjs/Lights/index";
  65762. export * from "babylonjs/Loading/index";
  65763. export * from "babylonjs/Materials/index";
  65764. export * from "babylonjs/Maths/index";
  65765. export * from "babylonjs/Meshes/index";
  65766. export * from "babylonjs/Morph/index";
  65767. export * from "babylonjs/Navigation/index";
  65768. export * from "babylonjs/node";
  65769. export * from "babylonjs/Offline/index";
  65770. export * from "babylonjs/Particles/index";
  65771. export * from "babylonjs/Physics/index";
  65772. export * from "babylonjs/PostProcesses/index";
  65773. export * from "babylonjs/Probes/index";
  65774. export * from "babylonjs/Rendering/index";
  65775. export * from "babylonjs/scene";
  65776. export * from "babylonjs/sceneComponent";
  65777. export * from "babylonjs/Sprites/index";
  65778. export * from "babylonjs/States/index";
  65779. export * from "babylonjs/Misc/index";
  65780. export * from "babylonjs/types";
  65781. }
  65782. declare module "babylonjs/Animations/pathCursor" {
  65783. import { Vector3 } from "babylonjs/Maths/math.vector";
  65784. import { Path2 } from "babylonjs/Maths/math.path";
  65785. /**
  65786. * A cursor which tracks a point on a path
  65787. */
  65788. export class PathCursor {
  65789. private path;
  65790. /**
  65791. * Stores path cursor callbacks for when an onchange event is triggered
  65792. */
  65793. private _onchange;
  65794. /**
  65795. * The value of the path cursor
  65796. */
  65797. value: number;
  65798. /**
  65799. * The animation array of the path cursor
  65800. */
  65801. animations: Animation[];
  65802. /**
  65803. * Initializes the path cursor
  65804. * @param path The path to track
  65805. */
  65806. constructor(path: Path2);
  65807. /**
  65808. * Gets the cursor point on the path
  65809. * @returns A point on the path cursor at the cursor location
  65810. */
  65811. getPoint(): Vector3;
  65812. /**
  65813. * Moves the cursor ahead by the step amount
  65814. * @param step The amount to move the cursor forward
  65815. * @returns This path cursor
  65816. */
  65817. moveAhead(step?: number): PathCursor;
  65818. /**
  65819. * Moves the cursor behind by the step amount
  65820. * @param step The amount to move the cursor back
  65821. * @returns This path cursor
  65822. */
  65823. moveBack(step?: number): PathCursor;
  65824. /**
  65825. * Moves the cursor by the step amount
  65826. * If the step amount is greater than one, an exception is thrown
  65827. * @param step The amount to move the cursor
  65828. * @returns This path cursor
  65829. */
  65830. move(step: number): PathCursor;
  65831. /**
  65832. * Ensures that the value is limited between zero and one
  65833. * @returns This path cursor
  65834. */
  65835. private ensureLimits;
  65836. /**
  65837. * Runs onchange callbacks on change (used by the animation engine)
  65838. * @returns This path cursor
  65839. */
  65840. private raiseOnChange;
  65841. /**
  65842. * Executes a function on change
  65843. * @param f A path cursor onchange callback
  65844. * @returns This path cursor
  65845. */
  65846. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65847. }
  65848. }
  65849. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65850. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65851. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65852. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65853. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65854. }
  65855. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65856. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65857. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65858. }
  65859. declare module "babylonjs/Engines/Processors/index" {
  65860. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65861. export * from "babylonjs/Engines/Processors/Expressions/index";
  65862. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65863. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65864. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65865. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65866. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65867. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65868. }
  65869. declare module "babylonjs/Legacy/legacy" {
  65870. import * as Babylon from "babylonjs/index";
  65871. export * from "babylonjs/index";
  65872. }
  65873. declare module "babylonjs/Shaders/blur.fragment" {
  65874. /** @hidden */
  65875. export var blurPixelShader: {
  65876. name: string;
  65877. shader: string;
  65878. };
  65879. }
  65880. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65881. /** @hidden */
  65882. export var pointCloudVertexDeclaration: {
  65883. name: string;
  65884. shader: string;
  65885. };
  65886. }
  65887. declare module "babylonjs" {
  65888. export * from "babylonjs/Legacy/legacy";
  65889. }
  65890. declare module BABYLON {
  65891. /** Alias type for value that can be null */
  65892. export type Nullable<T> = T | null;
  65893. /**
  65894. * Alias type for number that are floats
  65895. * @ignorenaming
  65896. */
  65897. export type float = number;
  65898. /**
  65899. * Alias type for number that are doubles.
  65900. * @ignorenaming
  65901. */
  65902. export type double = number;
  65903. /**
  65904. * Alias type for number that are integer
  65905. * @ignorenaming
  65906. */
  65907. export type int = number;
  65908. /** Alias type for number array or Float32Array */
  65909. export type FloatArray = number[] | Float32Array;
  65910. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65911. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65912. /**
  65913. * Alias for types that can be used by a Buffer or VertexBuffer.
  65914. */
  65915. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65916. /**
  65917. * Alias type for primitive types
  65918. * @ignorenaming
  65919. */
  65920. type Primitive = undefined | null | boolean | string | number | Function;
  65921. /**
  65922. * Type modifier to make all the properties of an object Readonly
  65923. */
  65924. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65925. /**
  65926. * Type modifier to make all the properties of an object Readonly recursively
  65927. */
  65928. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65929. /** @hidden */
  65930. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65931. }
  65932. /** @hidden */
  65933. /** @hidden */
  65934. type DeepImmutableObject<T> = {
  65935. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65936. };
  65937. }
  65938. declare module BABYLON {
  65939. /**
  65940. * A class serves as a medium between the observable and its observers
  65941. */
  65942. export class EventState {
  65943. /**
  65944. * Create a new EventState
  65945. * @param mask defines the mask associated with this state
  65946. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65947. * @param target defines the original target of the state
  65948. * @param currentTarget defines the current target of the state
  65949. */
  65950. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65951. /**
  65952. * Initialize the current event state
  65953. * @param mask defines the mask associated with this state
  65954. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65955. * @param target defines the original target of the state
  65956. * @param currentTarget defines the current target of the state
  65957. * @returns the current event state
  65958. */
  65959. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65960. /**
  65961. * An Observer can set this property to true to prevent subsequent observers of being notified
  65962. */
  65963. skipNextObservers: boolean;
  65964. /**
  65965. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65966. */
  65967. mask: number;
  65968. /**
  65969. * The object that originally notified the event
  65970. */
  65971. target?: any;
  65972. /**
  65973. * The current object in the bubbling phase
  65974. */
  65975. currentTarget?: any;
  65976. /**
  65977. * This will be populated with the return value of the last function that was executed.
  65978. * If it is the first function in the callback chain it will be the event data.
  65979. */
  65980. lastReturnValue?: any;
  65981. }
  65982. /**
  65983. * Represent an Observer registered to a given Observable object.
  65984. */
  65985. export class Observer<T> {
  65986. /**
  65987. * Defines the callback to call when the observer is notified
  65988. */
  65989. callback: (eventData: T, eventState: EventState) => void;
  65990. /**
  65991. * Defines the mask of the observer (used to filter notifications)
  65992. */
  65993. mask: number;
  65994. /**
  65995. * Defines the current scope used to restore the JS context
  65996. */
  65997. scope: any;
  65998. /** @hidden */
  65999. _willBeUnregistered: boolean;
  66000. /**
  66001. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66002. */
  66003. unregisterOnNextCall: boolean;
  66004. /**
  66005. * Creates a new observer
  66006. * @param callback defines the callback to call when the observer is notified
  66007. * @param mask defines the mask of the observer (used to filter notifications)
  66008. * @param scope defines the current scope used to restore the JS context
  66009. */
  66010. constructor(
  66011. /**
  66012. * Defines the callback to call when the observer is notified
  66013. */
  66014. callback: (eventData: T, eventState: EventState) => void,
  66015. /**
  66016. * Defines the mask of the observer (used to filter notifications)
  66017. */
  66018. mask: number,
  66019. /**
  66020. * Defines the current scope used to restore the JS context
  66021. */
  66022. scope?: any);
  66023. }
  66024. /**
  66025. * Represent a list of observers registered to multiple Observables object.
  66026. */
  66027. export class MultiObserver<T> {
  66028. private _observers;
  66029. private _observables;
  66030. /**
  66031. * Release associated resources
  66032. */
  66033. dispose(): void;
  66034. /**
  66035. * Raise a callback when one of the observable will notify
  66036. * @param observables defines a list of observables to watch
  66037. * @param callback defines the callback to call on notification
  66038. * @param mask defines the mask used to filter notifications
  66039. * @param scope defines the current scope used to restore the JS context
  66040. * @returns the new MultiObserver
  66041. */
  66042. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66043. }
  66044. /**
  66045. * The Observable class is a simple implementation of the Observable pattern.
  66046. *
  66047. * 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.
  66048. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66049. * 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).
  66050. * 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.
  66051. */
  66052. export class Observable<T> {
  66053. private _observers;
  66054. private _eventState;
  66055. private _onObserverAdded;
  66056. /**
  66057. * Gets the list of observers
  66058. */
  66059. readonly observers: Array<Observer<T>>;
  66060. /**
  66061. * Creates a new observable
  66062. * @param onObserverAdded defines a callback to call when a new observer is added
  66063. */
  66064. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66065. /**
  66066. * Create a new Observer with the specified callback
  66067. * @param callback the callback that will be executed for that Observer
  66068. * @param mask the mask used to filter observers
  66069. * @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.
  66070. * @param scope optional scope for the callback to be called from
  66071. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66072. * @returns the new observer created for the callback
  66073. */
  66074. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66075. /**
  66076. * Create a new Observer with the specified callback and unregisters after the next notification
  66077. * @param callback the callback that will be executed for that Observer
  66078. * @returns the new observer created for the callback
  66079. */
  66080. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66081. /**
  66082. * Remove an Observer from the Observable object
  66083. * @param observer the instance of the Observer to remove
  66084. * @returns false if it doesn't belong to this Observable
  66085. */
  66086. remove(observer: Nullable<Observer<T>>): boolean;
  66087. /**
  66088. * Remove a callback from the Observable object
  66089. * @param callback the callback to remove
  66090. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66091. * @returns false if it doesn't belong to this Observable
  66092. */
  66093. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66094. private _deferUnregister;
  66095. private _remove;
  66096. /**
  66097. * Moves the observable to the top of the observer list making it get called first when notified
  66098. * @param observer the observer to move
  66099. */
  66100. makeObserverTopPriority(observer: Observer<T>): void;
  66101. /**
  66102. * Moves the observable to the bottom of the observer list making it get called last when notified
  66103. * @param observer the observer to move
  66104. */
  66105. makeObserverBottomPriority(observer: Observer<T>): void;
  66106. /**
  66107. * Notify all Observers by calling their respective callback with the given data
  66108. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66109. * @param eventData defines the data to send to all observers
  66110. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66111. * @param target defines the original target of the state
  66112. * @param currentTarget defines the current target of the state
  66113. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66114. */
  66115. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66116. /**
  66117. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66118. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66119. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66120. * and it is crucial that all callbacks will be executed.
  66121. * The order of the callbacks is kept, callbacks are not executed parallel.
  66122. *
  66123. * @param eventData The data to be sent to each callback
  66124. * @param mask is used to filter observers defaults to -1
  66125. * @param target defines the callback target (see EventState)
  66126. * @param currentTarget defines he current object in the bubbling phase
  66127. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66128. */
  66129. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66130. /**
  66131. * Notify a specific observer
  66132. * @param observer defines the observer to notify
  66133. * @param eventData defines the data to be sent to each callback
  66134. * @param mask is used to filter observers defaults to -1
  66135. */
  66136. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66137. /**
  66138. * Gets a boolean indicating if the observable has at least one observer
  66139. * @returns true is the Observable has at least one Observer registered
  66140. */
  66141. hasObservers(): boolean;
  66142. /**
  66143. * Clear the list of observers
  66144. */
  66145. clear(): void;
  66146. /**
  66147. * Clone the current observable
  66148. * @returns a new observable
  66149. */
  66150. clone(): Observable<T>;
  66151. /**
  66152. * Does this observable handles observer registered with a given mask
  66153. * @param mask defines the mask to be tested
  66154. * @return whether or not one observer registered with the given mask is handeled
  66155. **/
  66156. hasSpecificMask(mask?: number): boolean;
  66157. }
  66158. }
  66159. declare module BABYLON {
  66160. /**
  66161. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66162. * Babylon.js
  66163. */
  66164. export class DomManagement {
  66165. /**
  66166. * Checks if the window object exists
  66167. * @returns true if the window object exists
  66168. */
  66169. static IsWindowObjectExist(): boolean;
  66170. /**
  66171. * Checks if the navigator object exists
  66172. * @returns true if the navigator object exists
  66173. */
  66174. static IsNavigatorAvailable(): boolean;
  66175. /**
  66176. * Extracts text content from a DOM element hierarchy
  66177. * @param element defines the root element
  66178. * @returns a string
  66179. */
  66180. static GetDOMTextContent(element: HTMLElement): string;
  66181. }
  66182. }
  66183. declare module BABYLON {
  66184. /**
  66185. * Logger used througouht the application to allow configuration of
  66186. * the log level required for the messages.
  66187. */
  66188. export class Logger {
  66189. /**
  66190. * No log
  66191. */
  66192. static readonly NoneLogLevel: number;
  66193. /**
  66194. * Only message logs
  66195. */
  66196. static readonly MessageLogLevel: number;
  66197. /**
  66198. * Only warning logs
  66199. */
  66200. static readonly WarningLogLevel: number;
  66201. /**
  66202. * Only error logs
  66203. */
  66204. static readonly ErrorLogLevel: number;
  66205. /**
  66206. * All logs
  66207. */
  66208. static readonly AllLogLevel: number;
  66209. private static _LogCache;
  66210. /**
  66211. * Gets a value indicating the number of loading errors
  66212. * @ignorenaming
  66213. */
  66214. static errorsCount: number;
  66215. /**
  66216. * Callback called when a new log is added
  66217. */
  66218. static OnNewCacheEntry: (entry: string) => void;
  66219. private static _AddLogEntry;
  66220. private static _FormatMessage;
  66221. private static _LogDisabled;
  66222. private static _LogEnabled;
  66223. private static _WarnDisabled;
  66224. private static _WarnEnabled;
  66225. private static _ErrorDisabled;
  66226. private static _ErrorEnabled;
  66227. /**
  66228. * Log a message to the console
  66229. */
  66230. static Log: (message: string) => void;
  66231. /**
  66232. * Write a warning message to the console
  66233. */
  66234. static Warn: (message: string) => void;
  66235. /**
  66236. * Write an error message to the console
  66237. */
  66238. static Error: (message: string) => void;
  66239. /**
  66240. * Gets current log cache (list of logs)
  66241. */
  66242. static readonly LogCache: string;
  66243. /**
  66244. * Clears the log cache
  66245. */
  66246. static ClearLogCache(): void;
  66247. /**
  66248. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66249. */
  66250. static LogLevels: number;
  66251. }
  66252. }
  66253. declare module BABYLON {
  66254. /** @hidden */
  66255. export class _TypeStore {
  66256. /** @hidden */
  66257. static RegisteredTypes: {
  66258. [key: string]: Object;
  66259. };
  66260. /** @hidden */
  66261. static GetClass(fqdn: string): any;
  66262. }
  66263. }
  66264. declare module BABYLON {
  66265. /**
  66266. * Class containing a set of static utilities functions for deep copy.
  66267. */
  66268. export class DeepCopier {
  66269. /**
  66270. * Tries to copy an object by duplicating every property
  66271. * @param source defines the source object
  66272. * @param destination defines the target object
  66273. * @param doNotCopyList defines a list of properties to avoid
  66274. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66275. */
  66276. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66277. }
  66278. }
  66279. declare module BABYLON {
  66280. /**
  66281. * Class containing a set of static utilities functions for precision date
  66282. */
  66283. export class PrecisionDate {
  66284. /**
  66285. * Gets either window.performance.now() if supported or Date.now() else
  66286. */
  66287. static readonly Now: number;
  66288. }
  66289. }
  66290. declare module BABYLON {
  66291. /** @hidden */
  66292. export class _DevTools {
  66293. static WarnImport(name: string): string;
  66294. }
  66295. }
  66296. declare module BABYLON {
  66297. /**
  66298. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66299. */
  66300. export class WebRequest {
  66301. private _xhr;
  66302. /**
  66303. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66304. * i.e. when loading files, where the server/service expects an Authorization header
  66305. */
  66306. static CustomRequestHeaders: {
  66307. [key: string]: string;
  66308. };
  66309. /**
  66310. * Add callback functions in this array to update all the requests before they get sent to the network
  66311. */
  66312. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66313. private _injectCustomRequestHeaders;
  66314. /**
  66315. * Gets or sets a function to be called when loading progress changes
  66316. */
  66317. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66318. /**
  66319. * Returns client's state
  66320. */
  66321. readonly readyState: number;
  66322. /**
  66323. * Returns client's status
  66324. */
  66325. readonly status: number;
  66326. /**
  66327. * Returns client's status as a text
  66328. */
  66329. readonly statusText: string;
  66330. /**
  66331. * Returns client's response
  66332. */
  66333. readonly response: any;
  66334. /**
  66335. * Returns client's response url
  66336. */
  66337. readonly responseURL: string;
  66338. /**
  66339. * Returns client's response as text
  66340. */
  66341. readonly responseText: string;
  66342. /**
  66343. * Gets or sets the expected response type
  66344. */
  66345. responseType: XMLHttpRequestResponseType;
  66346. /** @hidden */
  66347. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66348. /** @hidden */
  66349. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66350. /**
  66351. * Cancels any network activity
  66352. */
  66353. abort(): void;
  66354. /**
  66355. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66356. * @param body defines an optional request body
  66357. */
  66358. send(body?: Document | BodyInit | null): void;
  66359. /**
  66360. * Sets the request method, request URL
  66361. * @param method defines the method to use (GET, POST, etc..)
  66362. * @param url defines the url to connect with
  66363. */
  66364. open(method: string, url: string): void;
  66365. }
  66366. }
  66367. declare module BABYLON {
  66368. /**
  66369. * File request interface
  66370. */
  66371. export interface IFileRequest {
  66372. /**
  66373. * Raised when the request is complete (success or error).
  66374. */
  66375. onCompleteObservable: Observable<IFileRequest>;
  66376. /**
  66377. * Aborts the request for a file.
  66378. */
  66379. abort: () => void;
  66380. }
  66381. }
  66382. declare module BABYLON {
  66383. /**
  66384. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66385. */
  66386. export class PerformanceMonitor {
  66387. private _enabled;
  66388. private _rollingFrameTime;
  66389. private _lastFrameTimeMs;
  66390. /**
  66391. * constructor
  66392. * @param frameSampleSize The number of samples required to saturate the sliding window
  66393. */
  66394. constructor(frameSampleSize?: number);
  66395. /**
  66396. * Samples current frame
  66397. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66398. */
  66399. sampleFrame(timeMs?: number): void;
  66400. /**
  66401. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66402. */
  66403. readonly averageFrameTime: number;
  66404. /**
  66405. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66406. */
  66407. readonly averageFrameTimeVariance: number;
  66408. /**
  66409. * Returns the frame time of the most recent frame
  66410. */
  66411. readonly instantaneousFrameTime: number;
  66412. /**
  66413. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66414. */
  66415. readonly averageFPS: number;
  66416. /**
  66417. * Returns the average framerate in frames per second using the most recent frame time
  66418. */
  66419. readonly instantaneousFPS: number;
  66420. /**
  66421. * Returns true if enough samples have been taken to completely fill the sliding window
  66422. */
  66423. readonly isSaturated: boolean;
  66424. /**
  66425. * Enables contributions to the sliding window sample set
  66426. */
  66427. enable(): void;
  66428. /**
  66429. * Disables contributions to the sliding window sample set
  66430. * Samples will not be interpolated over the disabled period
  66431. */
  66432. disable(): void;
  66433. /**
  66434. * Returns true if sampling is enabled
  66435. */
  66436. readonly isEnabled: boolean;
  66437. /**
  66438. * Resets performance monitor
  66439. */
  66440. reset(): void;
  66441. }
  66442. /**
  66443. * RollingAverage
  66444. *
  66445. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66446. */
  66447. export class RollingAverage {
  66448. /**
  66449. * Current average
  66450. */
  66451. average: number;
  66452. /**
  66453. * Current variance
  66454. */
  66455. variance: number;
  66456. protected _samples: Array<number>;
  66457. protected _sampleCount: number;
  66458. protected _pos: number;
  66459. protected _m2: number;
  66460. /**
  66461. * constructor
  66462. * @param length The number of samples required to saturate the sliding window
  66463. */
  66464. constructor(length: number);
  66465. /**
  66466. * Adds a sample to the sample set
  66467. * @param v The sample value
  66468. */
  66469. add(v: number): void;
  66470. /**
  66471. * Returns previously added values or null if outside of history or outside the sliding window domain
  66472. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66473. * @return Value previously recorded with add() or null if outside of range
  66474. */
  66475. history(i: number): number;
  66476. /**
  66477. * Returns true if enough samples have been taken to completely fill the sliding window
  66478. * @return true if sample-set saturated
  66479. */
  66480. isSaturated(): boolean;
  66481. /**
  66482. * Resets the rolling average (equivalent to 0 samples taken so far)
  66483. */
  66484. reset(): void;
  66485. /**
  66486. * Wraps a value around the sample range boundaries
  66487. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66488. * @return Wrapped position in sample range
  66489. */
  66490. protected _wrapPosition(i: number): number;
  66491. }
  66492. }
  66493. declare module BABYLON {
  66494. /**
  66495. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66496. * The underlying implementation relies on an associative array to ensure the best performances.
  66497. * The value can be anything including 'null' but except 'undefined'
  66498. */
  66499. export class StringDictionary<T> {
  66500. /**
  66501. * This will clear this dictionary and copy the content from the 'source' one.
  66502. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66503. * @param source the dictionary to take the content from and copy to this dictionary
  66504. */
  66505. copyFrom(source: StringDictionary<T>): void;
  66506. /**
  66507. * Get a value based from its key
  66508. * @param key the given key to get the matching value from
  66509. * @return the value if found, otherwise undefined is returned
  66510. */
  66511. get(key: string): T | undefined;
  66512. /**
  66513. * Get a value from its key or add it if it doesn't exist.
  66514. * This method will ensure you that a given key/data will be present in the dictionary.
  66515. * @param key the given key to get the matching value from
  66516. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66517. * The factory will only be invoked if there's no data for the given key.
  66518. * @return the value corresponding to the key.
  66519. */
  66520. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66521. /**
  66522. * Get a value from its key if present in the dictionary otherwise add it
  66523. * @param key the key to get the value from
  66524. * @param val if there's no such key/value pair in the dictionary add it with this value
  66525. * @return the value corresponding to the key
  66526. */
  66527. getOrAdd(key: string, val: T): T;
  66528. /**
  66529. * Check if there's a given key in the dictionary
  66530. * @param key the key to check for
  66531. * @return true if the key is present, false otherwise
  66532. */
  66533. contains(key: string): boolean;
  66534. /**
  66535. * Add a new key and its corresponding value
  66536. * @param key the key to add
  66537. * @param value the value corresponding to the key
  66538. * @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
  66539. */
  66540. add(key: string, value: T): boolean;
  66541. /**
  66542. * Update a specific value associated to a key
  66543. * @param key defines the key to use
  66544. * @param value defines the value to store
  66545. * @returns true if the value was updated (or false if the key was not found)
  66546. */
  66547. set(key: string, value: T): boolean;
  66548. /**
  66549. * Get the element of the given key and remove it from the dictionary
  66550. * @param key defines the key to search
  66551. * @returns the value associated with the key or null if not found
  66552. */
  66553. getAndRemove(key: string): Nullable<T>;
  66554. /**
  66555. * Remove a key/value from the dictionary.
  66556. * @param key the key to remove
  66557. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66558. */
  66559. remove(key: string): boolean;
  66560. /**
  66561. * Clear the whole content of the dictionary
  66562. */
  66563. clear(): void;
  66564. /**
  66565. * Gets the current count
  66566. */
  66567. readonly count: number;
  66568. /**
  66569. * Execute a callback on each key/val of the dictionary.
  66570. * Note that you can remove any element in this dictionary in the callback implementation
  66571. * @param callback the callback to execute on a given key/value pair
  66572. */
  66573. forEach(callback: (key: string, val: T) => void): void;
  66574. /**
  66575. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66576. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66577. * Note that you can remove any element in this dictionary in the callback implementation
  66578. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66579. * @returns the first item
  66580. */
  66581. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66582. private _count;
  66583. private _data;
  66584. }
  66585. }
  66586. declare module BABYLON {
  66587. /**
  66588. * Class used to store gfx data (like WebGLBuffer)
  66589. */
  66590. export class DataBuffer {
  66591. /**
  66592. * Gets or sets the number of objects referencing this buffer
  66593. */
  66594. references: number;
  66595. /** Gets or sets the size of the underlying buffer */
  66596. capacity: number;
  66597. /**
  66598. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66599. */
  66600. is32Bits: boolean;
  66601. /**
  66602. * Gets the underlying buffer
  66603. */
  66604. readonly underlyingResource: any;
  66605. }
  66606. }
  66607. declare module BABYLON {
  66608. /**
  66609. * Class used to store data that will be store in GPU memory
  66610. */
  66611. export class Buffer {
  66612. private _engine;
  66613. private _buffer;
  66614. /** @hidden */
  66615. _data: Nullable<DataArray>;
  66616. private _updatable;
  66617. private _instanced;
  66618. /**
  66619. * Gets the byte stride.
  66620. */
  66621. readonly byteStride: number;
  66622. /**
  66623. * Constructor
  66624. * @param engine the engine
  66625. * @param data the data to use for this buffer
  66626. * @param updatable whether the data is updatable
  66627. * @param stride the stride (optional)
  66628. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66629. * @param instanced whether the buffer is instanced (optional)
  66630. * @param useBytes set to true if the stride in in bytes (optional)
  66631. */
  66632. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66633. /**
  66634. * Create a new VertexBuffer based on the current buffer
  66635. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66636. * @param offset defines offset in the buffer (0 by default)
  66637. * @param size defines the size in floats of attributes (position is 3 for instance)
  66638. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66639. * @param instanced defines if the vertex buffer contains indexed data
  66640. * @param useBytes defines if the offset and stride are in bytes
  66641. * @returns the new vertex buffer
  66642. */
  66643. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66644. /**
  66645. * Gets a boolean indicating if the Buffer is updatable?
  66646. * @returns true if the buffer is updatable
  66647. */
  66648. isUpdatable(): boolean;
  66649. /**
  66650. * Gets current buffer's data
  66651. * @returns a DataArray or null
  66652. */
  66653. getData(): Nullable<DataArray>;
  66654. /**
  66655. * Gets underlying native buffer
  66656. * @returns underlying native buffer
  66657. */
  66658. getBuffer(): Nullable<DataBuffer>;
  66659. /**
  66660. * Gets the stride in float32 units (i.e. byte stride / 4).
  66661. * May not be an integer if the byte stride is not divisible by 4.
  66662. * DEPRECATED. Use byteStride instead.
  66663. * @returns the stride in float32 units
  66664. */
  66665. getStrideSize(): number;
  66666. /**
  66667. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66668. * @param data defines the data to store
  66669. */
  66670. create(data?: Nullable<DataArray>): void;
  66671. /** @hidden */
  66672. _rebuild(): void;
  66673. /**
  66674. * Update current buffer data
  66675. * @param data defines the data to store
  66676. */
  66677. update(data: DataArray): void;
  66678. /**
  66679. * Updates the data directly.
  66680. * @param data the new data
  66681. * @param offset the new offset
  66682. * @param vertexCount the vertex count (optional)
  66683. * @param useBytes set to true if the offset is in bytes
  66684. */
  66685. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66686. /**
  66687. * Release all resources
  66688. */
  66689. dispose(): void;
  66690. }
  66691. /**
  66692. * Specialized buffer used to store vertex data
  66693. */
  66694. export class VertexBuffer {
  66695. /** @hidden */
  66696. _buffer: Buffer;
  66697. private _kind;
  66698. private _size;
  66699. private _ownsBuffer;
  66700. private _instanced;
  66701. private _instanceDivisor;
  66702. /**
  66703. * The byte type.
  66704. */
  66705. static readonly BYTE: number;
  66706. /**
  66707. * The unsigned byte type.
  66708. */
  66709. static readonly UNSIGNED_BYTE: number;
  66710. /**
  66711. * The short type.
  66712. */
  66713. static readonly SHORT: number;
  66714. /**
  66715. * The unsigned short type.
  66716. */
  66717. static readonly UNSIGNED_SHORT: number;
  66718. /**
  66719. * The integer type.
  66720. */
  66721. static readonly INT: number;
  66722. /**
  66723. * The unsigned integer type.
  66724. */
  66725. static readonly UNSIGNED_INT: number;
  66726. /**
  66727. * The float type.
  66728. */
  66729. static readonly FLOAT: number;
  66730. /**
  66731. * Gets or sets the instance divisor when in instanced mode
  66732. */
  66733. instanceDivisor: number;
  66734. /**
  66735. * Gets the byte stride.
  66736. */
  66737. readonly byteStride: number;
  66738. /**
  66739. * Gets the byte offset.
  66740. */
  66741. readonly byteOffset: number;
  66742. /**
  66743. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66744. */
  66745. readonly normalized: boolean;
  66746. /**
  66747. * Gets the data type of each component in the array.
  66748. */
  66749. readonly type: number;
  66750. /**
  66751. * Constructor
  66752. * @param engine the engine
  66753. * @param data the data to use for this vertex buffer
  66754. * @param kind the vertex buffer kind
  66755. * @param updatable whether the data is updatable
  66756. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66757. * @param stride the stride (optional)
  66758. * @param instanced whether the buffer is instanced (optional)
  66759. * @param offset the offset of the data (optional)
  66760. * @param size the number of components (optional)
  66761. * @param type the type of the component (optional)
  66762. * @param normalized whether the data contains normalized data (optional)
  66763. * @param useBytes set to true if stride and offset are in bytes (optional)
  66764. */
  66765. 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);
  66766. /** @hidden */
  66767. _rebuild(): void;
  66768. /**
  66769. * Returns the kind of the VertexBuffer (string)
  66770. * @returns a string
  66771. */
  66772. getKind(): string;
  66773. /**
  66774. * Gets a boolean indicating if the VertexBuffer is updatable?
  66775. * @returns true if the buffer is updatable
  66776. */
  66777. isUpdatable(): boolean;
  66778. /**
  66779. * Gets current buffer's data
  66780. * @returns a DataArray or null
  66781. */
  66782. getData(): Nullable<DataArray>;
  66783. /**
  66784. * Gets underlying native buffer
  66785. * @returns underlying native buffer
  66786. */
  66787. getBuffer(): Nullable<DataBuffer>;
  66788. /**
  66789. * Gets the stride in float32 units (i.e. byte stride / 4).
  66790. * May not be an integer if the byte stride is not divisible by 4.
  66791. * DEPRECATED. Use byteStride instead.
  66792. * @returns the stride in float32 units
  66793. */
  66794. getStrideSize(): number;
  66795. /**
  66796. * Returns the offset as a multiple of the type byte length.
  66797. * DEPRECATED. Use byteOffset instead.
  66798. * @returns the offset in bytes
  66799. */
  66800. getOffset(): number;
  66801. /**
  66802. * Returns the number of components per vertex attribute (integer)
  66803. * @returns the size in float
  66804. */
  66805. getSize(): number;
  66806. /**
  66807. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66808. * @returns true if this buffer is instanced
  66809. */
  66810. getIsInstanced(): boolean;
  66811. /**
  66812. * Returns the instancing divisor, zero for non-instanced (integer).
  66813. * @returns a number
  66814. */
  66815. getInstanceDivisor(): number;
  66816. /**
  66817. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66818. * @param data defines the data to store
  66819. */
  66820. create(data?: DataArray): void;
  66821. /**
  66822. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66823. * This function will create a new buffer if the current one is not updatable
  66824. * @param data defines the data to store
  66825. */
  66826. update(data: DataArray): void;
  66827. /**
  66828. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66829. * Returns the directly updated WebGLBuffer.
  66830. * @param data the new data
  66831. * @param offset the new offset
  66832. * @param useBytes set to true if the offset is in bytes
  66833. */
  66834. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66835. /**
  66836. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66837. */
  66838. dispose(): void;
  66839. /**
  66840. * Enumerates each value of this vertex buffer as numbers.
  66841. * @param count the number of values to enumerate
  66842. * @param callback the callback function called for each value
  66843. */
  66844. forEach(count: number, callback: (value: number, index: number) => void): void;
  66845. /**
  66846. * Positions
  66847. */
  66848. static readonly PositionKind: string;
  66849. /**
  66850. * Normals
  66851. */
  66852. static readonly NormalKind: string;
  66853. /**
  66854. * Tangents
  66855. */
  66856. static readonly TangentKind: string;
  66857. /**
  66858. * Texture coordinates
  66859. */
  66860. static readonly UVKind: string;
  66861. /**
  66862. * Texture coordinates 2
  66863. */
  66864. static readonly UV2Kind: string;
  66865. /**
  66866. * Texture coordinates 3
  66867. */
  66868. static readonly UV3Kind: string;
  66869. /**
  66870. * Texture coordinates 4
  66871. */
  66872. static readonly UV4Kind: string;
  66873. /**
  66874. * Texture coordinates 5
  66875. */
  66876. static readonly UV5Kind: string;
  66877. /**
  66878. * Texture coordinates 6
  66879. */
  66880. static readonly UV6Kind: string;
  66881. /**
  66882. * Colors
  66883. */
  66884. static readonly ColorKind: string;
  66885. /**
  66886. * Matrix indices (for bones)
  66887. */
  66888. static readonly MatricesIndicesKind: string;
  66889. /**
  66890. * Matrix weights (for bones)
  66891. */
  66892. static readonly MatricesWeightsKind: string;
  66893. /**
  66894. * Additional matrix indices (for bones)
  66895. */
  66896. static readonly MatricesIndicesExtraKind: string;
  66897. /**
  66898. * Additional matrix weights (for bones)
  66899. */
  66900. static readonly MatricesWeightsExtraKind: string;
  66901. /**
  66902. * Deduces the stride given a kind.
  66903. * @param kind The kind string to deduce
  66904. * @returns The deduced stride
  66905. */
  66906. static DeduceStride(kind: string): number;
  66907. /**
  66908. * Gets the byte length of the given type.
  66909. * @param type the type
  66910. * @returns the number of bytes
  66911. */
  66912. static GetTypeByteLength(type: number): number;
  66913. /**
  66914. * Enumerates each value of the given parameters as numbers.
  66915. * @param data the data to enumerate
  66916. * @param byteOffset the byte offset of the data
  66917. * @param byteStride the byte stride of the data
  66918. * @param componentCount the number of components per element
  66919. * @param componentType the type of the component
  66920. * @param count the number of values to enumerate
  66921. * @param normalized whether the data is normalized
  66922. * @param callback the callback function called for each value
  66923. */
  66924. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66925. private static _GetFloatValue;
  66926. }
  66927. }
  66928. declare module BABYLON {
  66929. /**
  66930. * Scalar computation library
  66931. */
  66932. export class Scalar {
  66933. /**
  66934. * Two pi constants convenient for computation.
  66935. */
  66936. static TwoPi: number;
  66937. /**
  66938. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66939. * @param a number
  66940. * @param b number
  66941. * @param epsilon (default = 1.401298E-45)
  66942. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66943. */
  66944. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66945. /**
  66946. * Returns a string : the upper case translation of the number i to hexadecimal.
  66947. * @param i number
  66948. * @returns the upper case translation of the number i to hexadecimal.
  66949. */
  66950. static ToHex(i: number): string;
  66951. /**
  66952. * Returns -1 if value is negative and +1 is value is positive.
  66953. * @param value the value
  66954. * @returns the value itself if it's equal to zero.
  66955. */
  66956. static Sign(value: number): number;
  66957. /**
  66958. * Returns the value itself if it's between min and max.
  66959. * Returns min if the value is lower than min.
  66960. * Returns max if the value is greater than max.
  66961. * @param value the value to clmap
  66962. * @param min the min value to clamp to (default: 0)
  66963. * @param max the max value to clamp to (default: 1)
  66964. * @returns the clamped value
  66965. */
  66966. static Clamp(value: number, min?: number, max?: number): number;
  66967. /**
  66968. * the log2 of value.
  66969. * @param value the value to compute log2 of
  66970. * @returns the log2 of value.
  66971. */
  66972. static Log2(value: number): number;
  66973. /**
  66974. * Loops the value, so that it is never larger than length and never smaller than 0.
  66975. *
  66976. * This is similar to the modulo operator but it works with floating point numbers.
  66977. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66978. * With t = 5 and length = 2.5, the result would be 0.0.
  66979. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66980. * @param value the value
  66981. * @param length the length
  66982. * @returns the looped value
  66983. */
  66984. static Repeat(value: number, length: number): number;
  66985. /**
  66986. * Normalize the value between 0.0 and 1.0 using min and max values
  66987. * @param value value to normalize
  66988. * @param min max to normalize between
  66989. * @param max min to normalize between
  66990. * @returns the normalized value
  66991. */
  66992. static Normalize(value: number, min: number, max: number): number;
  66993. /**
  66994. * Denormalize the value from 0.0 and 1.0 using min and max values
  66995. * @param normalized value to denormalize
  66996. * @param min max to denormalize between
  66997. * @param max min to denormalize between
  66998. * @returns the denormalized value
  66999. */
  67000. static Denormalize(normalized: number, min: number, max: number): number;
  67001. /**
  67002. * Calculates the shortest difference between two given angles given in degrees.
  67003. * @param current current angle in degrees
  67004. * @param target target angle in degrees
  67005. * @returns the delta
  67006. */
  67007. static DeltaAngle(current: number, target: number): number;
  67008. /**
  67009. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67010. * @param tx value
  67011. * @param length length
  67012. * @returns The returned value will move back and forth between 0 and length
  67013. */
  67014. static PingPong(tx: number, length: number): number;
  67015. /**
  67016. * Interpolates between min and max with smoothing at the limits.
  67017. *
  67018. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67019. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67020. * @param from from
  67021. * @param to to
  67022. * @param tx value
  67023. * @returns the smooth stepped value
  67024. */
  67025. static SmoothStep(from: number, to: number, tx: number): number;
  67026. /**
  67027. * Moves a value current towards target.
  67028. *
  67029. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67030. * Negative values of maxDelta pushes the value away from target.
  67031. * @param current current value
  67032. * @param target target value
  67033. * @param maxDelta max distance to move
  67034. * @returns resulting value
  67035. */
  67036. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67037. /**
  67038. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67039. *
  67040. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67041. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67042. * @param current current value
  67043. * @param target target value
  67044. * @param maxDelta max distance to move
  67045. * @returns resulting angle
  67046. */
  67047. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67048. /**
  67049. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67050. * @param start start value
  67051. * @param end target value
  67052. * @param amount amount to lerp between
  67053. * @returns the lerped value
  67054. */
  67055. static Lerp(start: number, end: number, amount: number): number;
  67056. /**
  67057. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67058. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67059. * @param start start value
  67060. * @param end target value
  67061. * @param amount amount to lerp between
  67062. * @returns the lerped value
  67063. */
  67064. static LerpAngle(start: number, end: number, amount: number): number;
  67065. /**
  67066. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67067. * @param a start value
  67068. * @param b target value
  67069. * @param value value between a and b
  67070. * @returns the inverseLerp value
  67071. */
  67072. static InverseLerp(a: number, b: number, value: number): number;
  67073. /**
  67074. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67075. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67076. * @param value1 spline value
  67077. * @param tangent1 spline value
  67078. * @param value2 spline value
  67079. * @param tangent2 spline value
  67080. * @param amount input value
  67081. * @returns hermite result
  67082. */
  67083. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67084. /**
  67085. * Returns a random float number between and min and max values
  67086. * @param min min value of random
  67087. * @param max max value of random
  67088. * @returns random value
  67089. */
  67090. static RandomRange(min: number, max: number): number;
  67091. /**
  67092. * This function returns percentage of a number in a given range.
  67093. *
  67094. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67095. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67096. * @param number to convert to percentage
  67097. * @param min min range
  67098. * @param max max range
  67099. * @returns the percentage
  67100. */
  67101. static RangeToPercent(number: number, min: number, max: number): number;
  67102. /**
  67103. * This function returns number that corresponds to the percentage in a given range.
  67104. *
  67105. * PercentToRange(0.34,0,100) will return 34.
  67106. * @param percent to convert to number
  67107. * @param min min range
  67108. * @param max max range
  67109. * @returns the number
  67110. */
  67111. static PercentToRange(percent: number, min: number, max: number): number;
  67112. /**
  67113. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67114. * @param angle The angle to normalize in radian.
  67115. * @return The converted angle.
  67116. */
  67117. static NormalizeRadians(angle: number): number;
  67118. }
  67119. }
  67120. declare module BABYLON {
  67121. /**
  67122. * Constant used to convert a value to gamma space
  67123. * @ignorenaming
  67124. */
  67125. export const ToGammaSpace: number;
  67126. /**
  67127. * Constant used to convert a value to linear space
  67128. * @ignorenaming
  67129. */
  67130. export const ToLinearSpace = 2.2;
  67131. /**
  67132. * Constant used to define the minimal number value in Babylon.js
  67133. * @ignorenaming
  67134. */
  67135. let Epsilon: number;
  67136. }
  67137. declare module BABYLON {
  67138. /**
  67139. * Class used to represent a viewport on screen
  67140. */
  67141. export class Viewport {
  67142. /** viewport left coordinate */
  67143. x: number;
  67144. /** viewport top coordinate */
  67145. y: number;
  67146. /**viewport width */
  67147. width: number;
  67148. /** viewport height */
  67149. height: number;
  67150. /**
  67151. * Creates a Viewport object located at (x, y) and sized (width, height)
  67152. * @param x defines viewport left coordinate
  67153. * @param y defines viewport top coordinate
  67154. * @param width defines the viewport width
  67155. * @param height defines the viewport height
  67156. */
  67157. constructor(
  67158. /** viewport left coordinate */
  67159. x: number,
  67160. /** viewport top coordinate */
  67161. y: number,
  67162. /**viewport width */
  67163. width: number,
  67164. /** viewport height */
  67165. height: number);
  67166. /**
  67167. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67168. * @param renderWidth defines the rendering width
  67169. * @param renderHeight defines the rendering height
  67170. * @returns a new Viewport
  67171. */
  67172. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67173. /**
  67174. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67175. * @param renderWidth defines the rendering width
  67176. * @param renderHeight defines the rendering height
  67177. * @param ref defines the target viewport
  67178. * @returns the current viewport
  67179. */
  67180. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67181. /**
  67182. * Returns a new Viewport copied from the current one
  67183. * @returns a new Viewport
  67184. */
  67185. clone(): Viewport;
  67186. }
  67187. }
  67188. declare module BABYLON {
  67189. /**
  67190. * Class containing a set of static utilities functions for arrays.
  67191. */
  67192. export class ArrayTools {
  67193. /**
  67194. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67195. * @param size the number of element to construct and put in the array
  67196. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67197. * @returns a new array filled with new objects
  67198. */
  67199. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67200. }
  67201. }
  67202. declare module BABYLON {
  67203. /**
  67204. * @hidden
  67205. */
  67206. export interface IColor4Like {
  67207. r: float;
  67208. g: float;
  67209. b: float;
  67210. a: float;
  67211. }
  67212. /**
  67213. * @hidden
  67214. */
  67215. export interface IColor3Like {
  67216. r: float;
  67217. g: float;
  67218. b: float;
  67219. }
  67220. /**
  67221. * @hidden
  67222. */
  67223. export interface IVector4Like {
  67224. x: float;
  67225. y: float;
  67226. z: float;
  67227. w: float;
  67228. }
  67229. /**
  67230. * @hidden
  67231. */
  67232. export interface IVector3Like {
  67233. x: float;
  67234. y: float;
  67235. z: float;
  67236. }
  67237. /**
  67238. * @hidden
  67239. */
  67240. export interface IVector2Like {
  67241. x: float;
  67242. y: float;
  67243. }
  67244. /**
  67245. * @hidden
  67246. */
  67247. export interface IMatrixLike {
  67248. toArray(): DeepImmutable<Float32Array>;
  67249. updateFlag: int;
  67250. }
  67251. /**
  67252. * @hidden
  67253. */
  67254. export interface IViewportLike {
  67255. x: float;
  67256. y: float;
  67257. width: float;
  67258. height: float;
  67259. }
  67260. /**
  67261. * @hidden
  67262. */
  67263. export interface IPlaneLike {
  67264. normal: IVector3Like;
  67265. d: float;
  67266. normalize(): void;
  67267. }
  67268. }
  67269. declare module BABYLON {
  67270. /**
  67271. * Class representing a vector containing 2 coordinates
  67272. */
  67273. export class Vector2 {
  67274. /** defines the first coordinate */
  67275. x: number;
  67276. /** defines the second coordinate */
  67277. y: number;
  67278. /**
  67279. * Creates a new Vector2 from the given x and y coordinates
  67280. * @param x defines the first coordinate
  67281. * @param y defines the second coordinate
  67282. */
  67283. constructor(
  67284. /** defines the first coordinate */
  67285. x?: number,
  67286. /** defines the second coordinate */
  67287. y?: number);
  67288. /**
  67289. * Gets a string with the Vector2 coordinates
  67290. * @returns a string with the Vector2 coordinates
  67291. */
  67292. toString(): string;
  67293. /**
  67294. * Gets class name
  67295. * @returns the string "Vector2"
  67296. */
  67297. getClassName(): string;
  67298. /**
  67299. * Gets current vector hash code
  67300. * @returns the Vector2 hash code as a number
  67301. */
  67302. getHashCode(): number;
  67303. /**
  67304. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67305. * @param array defines the source array
  67306. * @param index defines the offset in source array
  67307. * @returns the current Vector2
  67308. */
  67309. toArray(array: FloatArray, index?: number): Vector2;
  67310. /**
  67311. * Copy the current vector to an array
  67312. * @returns a new array with 2 elements: the Vector2 coordinates.
  67313. */
  67314. asArray(): number[];
  67315. /**
  67316. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67317. * @param source defines the source Vector2
  67318. * @returns the current updated Vector2
  67319. */
  67320. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67321. /**
  67322. * Sets the Vector2 coordinates with the given floats
  67323. * @param x defines the first coordinate
  67324. * @param y defines the second coordinate
  67325. * @returns the current updated Vector2
  67326. */
  67327. copyFromFloats(x: number, y: number): Vector2;
  67328. /**
  67329. * Sets the Vector2 coordinates with the given floats
  67330. * @param x defines the first coordinate
  67331. * @param y defines the second coordinate
  67332. * @returns the current updated Vector2
  67333. */
  67334. set(x: number, y: number): Vector2;
  67335. /**
  67336. * Add another vector with the current one
  67337. * @param otherVector defines the other vector
  67338. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67339. */
  67340. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67341. /**
  67342. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67343. * @param otherVector defines the other vector
  67344. * @param result defines the target vector
  67345. * @returns the unmodified current Vector2
  67346. */
  67347. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67348. /**
  67349. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67350. * @param otherVector defines the other vector
  67351. * @returns the current updated Vector2
  67352. */
  67353. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67354. /**
  67355. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67356. * @param otherVector defines the other vector
  67357. * @returns a new Vector2
  67358. */
  67359. addVector3(otherVector: Vector3): Vector2;
  67360. /**
  67361. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67362. * @param otherVector defines the other vector
  67363. * @returns a new Vector2
  67364. */
  67365. subtract(otherVector: Vector2): Vector2;
  67366. /**
  67367. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67368. * @param otherVector defines the other vector
  67369. * @param result defines the target vector
  67370. * @returns the unmodified current Vector2
  67371. */
  67372. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67373. /**
  67374. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67375. * @param otherVector defines the other vector
  67376. * @returns the current updated Vector2
  67377. */
  67378. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67379. /**
  67380. * Multiplies in place the current Vector2 coordinates by the given ones
  67381. * @param otherVector defines the other vector
  67382. * @returns the current updated Vector2
  67383. */
  67384. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67385. /**
  67386. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67387. * @param otherVector defines the other vector
  67388. * @returns a new Vector2
  67389. */
  67390. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67391. /**
  67392. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67393. * @param otherVector defines the other vector
  67394. * @param result defines the target vector
  67395. * @returns the unmodified current Vector2
  67396. */
  67397. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67398. /**
  67399. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67400. * @param x defines the first coordinate
  67401. * @param y defines the second coordinate
  67402. * @returns a new Vector2
  67403. */
  67404. multiplyByFloats(x: number, y: number): Vector2;
  67405. /**
  67406. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67407. * @param otherVector defines the other vector
  67408. * @returns a new Vector2
  67409. */
  67410. divide(otherVector: Vector2): Vector2;
  67411. /**
  67412. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67413. * @param otherVector defines the other vector
  67414. * @param result defines the target vector
  67415. * @returns the unmodified current Vector2
  67416. */
  67417. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67418. /**
  67419. * Divides the current Vector2 coordinates by the given ones
  67420. * @param otherVector defines the other vector
  67421. * @returns the current updated Vector2
  67422. */
  67423. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67424. /**
  67425. * Gets a new Vector2 with current Vector2 negated coordinates
  67426. * @returns a new Vector2
  67427. */
  67428. negate(): Vector2;
  67429. /**
  67430. * Multiply the Vector2 coordinates by scale
  67431. * @param scale defines the scaling factor
  67432. * @returns the current updated Vector2
  67433. */
  67434. scaleInPlace(scale: number): Vector2;
  67435. /**
  67436. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67437. * @param scale defines the scaling factor
  67438. * @returns a new Vector2
  67439. */
  67440. scale(scale: number): Vector2;
  67441. /**
  67442. * Scale the current Vector2 values by a factor to a given Vector2
  67443. * @param scale defines the scale factor
  67444. * @param result defines the Vector2 object where to store the result
  67445. * @returns the unmodified current Vector2
  67446. */
  67447. scaleToRef(scale: number, result: Vector2): Vector2;
  67448. /**
  67449. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67450. * @param scale defines the scale factor
  67451. * @param result defines the Vector2 object where to store the result
  67452. * @returns the unmodified current Vector2
  67453. */
  67454. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67455. /**
  67456. * Gets a boolean if two vectors are equals
  67457. * @param otherVector defines the other vector
  67458. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67459. */
  67460. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67461. /**
  67462. * Gets a boolean if two vectors are equals (using an epsilon value)
  67463. * @param otherVector defines the other vector
  67464. * @param epsilon defines the minimal distance to consider equality
  67465. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67466. */
  67467. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67468. /**
  67469. * Gets a new Vector2 from current Vector2 floored values
  67470. * @returns a new Vector2
  67471. */
  67472. floor(): Vector2;
  67473. /**
  67474. * Gets a new Vector2 from current Vector2 floored values
  67475. * @returns a new Vector2
  67476. */
  67477. fract(): Vector2;
  67478. /**
  67479. * Gets the length of the vector
  67480. * @returns the vector length (float)
  67481. */
  67482. length(): number;
  67483. /**
  67484. * Gets the vector squared length
  67485. * @returns the vector squared length (float)
  67486. */
  67487. lengthSquared(): number;
  67488. /**
  67489. * Normalize the vector
  67490. * @returns the current updated Vector2
  67491. */
  67492. normalize(): Vector2;
  67493. /**
  67494. * Gets a new Vector2 copied from the Vector2
  67495. * @returns a new Vector2
  67496. */
  67497. clone(): Vector2;
  67498. /**
  67499. * Gets a new Vector2(0, 0)
  67500. * @returns a new Vector2
  67501. */
  67502. static Zero(): Vector2;
  67503. /**
  67504. * Gets a new Vector2(1, 1)
  67505. * @returns a new Vector2
  67506. */
  67507. static One(): Vector2;
  67508. /**
  67509. * Gets a new Vector2 set from the given index element of the given array
  67510. * @param array defines the data source
  67511. * @param offset defines the offset in the data source
  67512. * @returns a new Vector2
  67513. */
  67514. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67515. /**
  67516. * Sets "result" from the given index element of the given array
  67517. * @param array defines the data source
  67518. * @param offset defines the offset in the data source
  67519. * @param result defines the target vector
  67520. */
  67521. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67522. /**
  67523. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67524. * @param value1 defines 1st point of control
  67525. * @param value2 defines 2nd point of control
  67526. * @param value3 defines 3rd point of control
  67527. * @param value4 defines 4th point of control
  67528. * @param amount defines the interpolation factor
  67529. * @returns a new Vector2
  67530. */
  67531. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67532. /**
  67533. * 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".
  67534. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67535. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67536. * @param value defines the value to clamp
  67537. * @param min defines the lower limit
  67538. * @param max defines the upper limit
  67539. * @returns a new Vector2
  67540. */
  67541. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67542. /**
  67543. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67544. * @param value1 defines the 1st control point
  67545. * @param tangent1 defines the outgoing tangent
  67546. * @param value2 defines the 2nd control point
  67547. * @param tangent2 defines the incoming tangent
  67548. * @param amount defines the interpolation factor
  67549. * @returns a new Vector2
  67550. */
  67551. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67552. /**
  67553. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67554. * @param start defines the start vector
  67555. * @param end defines the end vector
  67556. * @param amount defines the interpolation factor
  67557. * @returns a new Vector2
  67558. */
  67559. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67560. /**
  67561. * Gets the dot product of the vector "left" and the vector "right"
  67562. * @param left defines first vector
  67563. * @param right defines second vector
  67564. * @returns the dot product (float)
  67565. */
  67566. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67567. /**
  67568. * Returns a new Vector2 equal to the normalized given vector
  67569. * @param vector defines the vector to normalize
  67570. * @returns a new Vector2
  67571. */
  67572. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67573. /**
  67574. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67575. * @param left defines 1st vector
  67576. * @param right defines 2nd vector
  67577. * @returns a new Vector2
  67578. */
  67579. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67580. /**
  67581. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67582. * @param left defines 1st vector
  67583. * @param right defines 2nd vector
  67584. * @returns a new Vector2
  67585. */
  67586. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67587. /**
  67588. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67589. * @param vector defines the vector to transform
  67590. * @param transformation defines the matrix to apply
  67591. * @returns a new Vector2
  67592. */
  67593. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67594. /**
  67595. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67596. * @param vector defines the vector to transform
  67597. * @param transformation defines the matrix to apply
  67598. * @param result defines the target vector
  67599. */
  67600. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67601. /**
  67602. * Determines if a given vector is included in a triangle
  67603. * @param p defines the vector to test
  67604. * @param p0 defines 1st triangle point
  67605. * @param p1 defines 2nd triangle point
  67606. * @param p2 defines 3rd triangle point
  67607. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67608. */
  67609. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67610. /**
  67611. * Gets the distance between the vectors "value1" and "value2"
  67612. * @param value1 defines first vector
  67613. * @param value2 defines second vector
  67614. * @returns the distance between vectors
  67615. */
  67616. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67617. /**
  67618. * Returns the squared distance between the vectors "value1" and "value2"
  67619. * @param value1 defines first vector
  67620. * @param value2 defines second vector
  67621. * @returns the squared distance between vectors
  67622. */
  67623. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67624. /**
  67625. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67626. * @param value1 defines first vector
  67627. * @param value2 defines second vector
  67628. * @returns a new Vector2
  67629. */
  67630. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67631. /**
  67632. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67633. * @param p defines the middle point
  67634. * @param segA defines one point of the segment
  67635. * @param segB defines the other point of the segment
  67636. * @returns the shortest distance
  67637. */
  67638. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67639. }
  67640. /**
  67641. * Classed used to store (x,y,z) vector representation
  67642. * A Vector3 is the main object used in 3D geometry
  67643. * It can represent etiher the coordinates of a point the space, either a direction
  67644. * Reminder: js uses a left handed forward facing system
  67645. */
  67646. export class Vector3 {
  67647. /**
  67648. * Defines the first coordinates (on X axis)
  67649. */
  67650. x: number;
  67651. /**
  67652. * Defines the second coordinates (on Y axis)
  67653. */
  67654. y: number;
  67655. /**
  67656. * Defines the third coordinates (on Z axis)
  67657. */
  67658. z: number;
  67659. private static _UpReadOnly;
  67660. private static _ZeroReadOnly;
  67661. /**
  67662. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67663. * @param x defines the first coordinates (on X axis)
  67664. * @param y defines the second coordinates (on Y axis)
  67665. * @param z defines the third coordinates (on Z axis)
  67666. */
  67667. constructor(
  67668. /**
  67669. * Defines the first coordinates (on X axis)
  67670. */
  67671. x?: number,
  67672. /**
  67673. * Defines the second coordinates (on Y axis)
  67674. */
  67675. y?: number,
  67676. /**
  67677. * Defines the third coordinates (on Z axis)
  67678. */
  67679. z?: number);
  67680. /**
  67681. * Creates a string representation of the Vector3
  67682. * @returns a string with the Vector3 coordinates.
  67683. */
  67684. toString(): string;
  67685. /**
  67686. * Gets the class name
  67687. * @returns the string "Vector3"
  67688. */
  67689. getClassName(): string;
  67690. /**
  67691. * Creates the Vector3 hash code
  67692. * @returns a number which tends to be unique between Vector3 instances
  67693. */
  67694. getHashCode(): number;
  67695. /**
  67696. * Creates an array containing three elements : the coordinates of the Vector3
  67697. * @returns a new array of numbers
  67698. */
  67699. asArray(): number[];
  67700. /**
  67701. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67702. * @param array defines the destination array
  67703. * @param index defines the offset in the destination array
  67704. * @returns the current Vector3
  67705. */
  67706. toArray(array: FloatArray, index?: number): Vector3;
  67707. /**
  67708. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67709. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67710. */
  67711. toQuaternion(): Quaternion;
  67712. /**
  67713. * Adds the given vector to the current Vector3
  67714. * @param otherVector defines the second operand
  67715. * @returns the current updated Vector3
  67716. */
  67717. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67718. /**
  67719. * Adds the given coordinates to the current Vector3
  67720. * @param x defines the x coordinate of the operand
  67721. * @param y defines the y coordinate of the operand
  67722. * @param z defines the z coordinate of the operand
  67723. * @returns the current updated Vector3
  67724. */
  67725. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67726. /**
  67727. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67728. * @param otherVector defines the second operand
  67729. * @returns the resulting Vector3
  67730. */
  67731. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67732. /**
  67733. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67734. * @param otherVector defines the second operand
  67735. * @param result defines the Vector3 object where to store the result
  67736. * @returns the current Vector3
  67737. */
  67738. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67739. /**
  67740. * Subtract the given vector from the current Vector3
  67741. * @param otherVector defines the second operand
  67742. * @returns the current updated Vector3
  67743. */
  67744. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67745. /**
  67746. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67747. * @param otherVector defines the second operand
  67748. * @returns the resulting Vector3
  67749. */
  67750. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67751. /**
  67752. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67753. * @param otherVector defines the second operand
  67754. * @param result defines the Vector3 object where to store the result
  67755. * @returns the current Vector3
  67756. */
  67757. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67758. /**
  67759. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67760. * @param x defines the x coordinate of the operand
  67761. * @param y defines the y coordinate of the operand
  67762. * @param z defines the z coordinate of the operand
  67763. * @returns the resulting Vector3
  67764. */
  67765. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67766. /**
  67767. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67768. * @param x defines the x coordinate of the operand
  67769. * @param y defines the y coordinate of the operand
  67770. * @param z defines the z coordinate of the operand
  67771. * @param result defines the Vector3 object where to store the result
  67772. * @returns the current Vector3
  67773. */
  67774. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67775. /**
  67776. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67777. * @returns a new Vector3
  67778. */
  67779. negate(): Vector3;
  67780. /**
  67781. * Multiplies the Vector3 coordinates by the float "scale"
  67782. * @param scale defines the multiplier factor
  67783. * @returns the current updated Vector3
  67784. */
  67785. scaleInPlace(scale: number): Vector3;
  67786. /**
  67787. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67788. * @param scale defines the multiplier factor
  67789. * @returns a new Vector3
  67790. */
  67791. scale(scale: number): Vector3;
  67792. /**
  67793. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67794. * @param scale defines the multiplier factor
  67795. * @param result defines the Vector3 object where to store the result
  67796. * @returns the current Vector3
  67797. */
  67798. scaleToRef(scale: number, result: Vector3): Vector3;
  67799. /**
  67800. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67801. * @param scale defines the scale factor
  67802. * @param result defines the Vector3 object where to store the result
  67803. * @returns the unmodified current Vector3
  67804. */
  67805. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67806. /**
  67807. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67808. * @param otherVector defines the second operand
  67809. * @returns true if both vectors are equals
  67810. */
  67811. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67812. /**
  67813. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67814. * @param otherVector defines the second operand
  67815. * @param epsilon defines the minimal distance to define values as equals
  67816. * @returns true if both vectors are distant less than epsilon
  67817. */
  67818. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67819. /**
  67820. * Returns true if the current Vector3 coordinates equals the given floats
  67821. * @param x defines the x coordinate of the operand
  67822. * @param y defines the y coordinate of the operand
  67823. * @param z defines the z coordinate of the operand
  67824. * @returns true if both vectors are equals
  67825. */
  67826. equalsToFloats(x: number, y: number, z: number): boolean;
  67827. /**
  67828. * Multiplies the current Vector3 coordinates by the given ones
  67829. * @param otherVector defines the second operand
  67830. * @returns the current updated Vector3
  67831. */
  67832. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67833. /**
  67834. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67835. * @param otherVector defines the second operand
  67836. * @returns the new Vector3
  67837. */
  67838. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67839. /**
  67840. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67841. * @param otherVector defines the second operand
  67842. * @param result defines the Vector3 object where to store the result
  67843. * @returns the current Vector3
  67844. */
  67845. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67846. /**
  67847. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67848. * @param x defines the x coordinate of the operand
  67849. * @param y defines the y coordinate of the operand
  67850. * @param z defines the z coordinate of the operand
  67851. * @returns the new Vector3
  67852. */
  67853. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67854. /**
  67855. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67856. * @param otherVector defines the second operand
  67857. * @returns the new Vector3
  67858. */
  67859. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67860. /**
  67861. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67862. * @param otherVector defines the second operand
  67863. * @param result defines the Vector3 object where to store the result
  67864. * @returns the current Vector3
  67865. */
  67866. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67867. /**
  67868. * Divides the current Vector3 coordinates by the given ones.
  67869. * @param otherVector defines the second operand
  67870. * @returns the current updated Vector3
  67871. */
  67872. divideInPlace(otherVector: Vector3): Vector3;
  67873. /**
  67874. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67875. * @param other defines the second operand
  67876. * @returns the current updated Vector3
  67877. */
  67878. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67879. /**
  67880. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67881. * @param other defines the second operand
  67882. * @returns the current updated Vector3
  67883. */
  67884. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67885. /**
  67886. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67887. * @param x defines the x coordinate of the operand
  67888. * @param y defines the y coordinate of the operand
  67889. * @param z defines the z coordinate of the operand
  67890. * @returns the current updated Vector3
  67891. */
  67892. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67893. /**
  67894. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67895. * @param x defines the x coordinate of the operand
  67896. * @param y defines the y coordinate of the operand
  67897. * @param z defines the z coordinate of the operand
  67898. * @returns the current updated Vector3
  67899. */
  67900. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67901. /**
  67902. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67903. * Check if is non uniform within a certain amount of decimal places to account for this
  67904. * @param epsilon the amount the values can differ
  67905. * @returns if the the vector is non uniform to a certain number of decimal places
  67906. */
  67907. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67908. /**
  67909. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67910. */
  67911. readonly isNonUniform: boolean;
  67912. /**
  67913. * Gets a new Vector3 from current Vector3 floored values
  67914. * @returns a new Vector3
  67915. */
  67916. floor(): Vector3;
  67917. /**
  67918. * Gets a new Vector3 from current Vector3 floored values
  67919. * @returns a new Vector3
  67920. */
  67921. fract(): Vector3;
  67922. /**
  67923. * Gets the length of the Vector3
  67924. * @returns the length of the Vector3
  67925. */
  67926. length(): number;
  67927. /**
  67928. * Gets the squared length of the Vector3
  67929. * @returns squared length of the Vector3
  67930. */
  67931. lengthSquared(): number;
  67932. /**
  67933. * Normalize the current Vector3.
  67934. * Please note that this is an in place operation.
  67935. * @returns the current updated Vector3
  67936. */
  67937. normalize(): Vector3;
  67938. /**
  67939. * Reorders the x y z properties of the vector in place
  67940. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67941. * @returns the current updated vector
  67942. */
  67943. reorderInPlace(order: string): this;
  67944. /**
  67945. * Rotates the vector around 0,0,0 by a quaternion
  67946. * @param quaternion the rotation quaternion
  67947. * @param result vector to store the result
  67948. * @returns the resulting vector
  67949. */
  67950. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67951. /**
  67952. * Rotates a vector around a given point
  67953. * @param quaternion the rotation quaternion
  67954. * @param point the point to rotate around
  67955. * @param result vector to store the result
  67956. * @returns the resulting vector
  67957. */
  67958. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67959. /**
  67960. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67961. * The cross product is then orthogonal to both current and "other"
  67962. * @param other defines the right operand
  67963. * @returns the cross product
  67964. */
  67965. cross(other: Vector3): Vector3;
  67966. /**
  67967. * Normalize the current Vector3 with the given input length.
  67968. * Please note that this is an in place operation.
  67969. * @param len the length of the vector
  67970. * @returns the current updated Vector3
  67971. */
  67972. normalizeFromLength(len: number): Vector3;
  67973. /**
  67974. * Normalize the current Vector3 to a new vector
  67975. * @returns the new Vector3
  67976. */
  67977. normalizeToNew(): Vector3;
  67978. /**
  67979. * Normalize the current Vector3 to the reference
  67980. * @param reference define the Vector3 to update
  67981. * @returns the updated Vector3
  67982. */
  67983. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67984. /**
  67985. * Creates a new Vector3 copied from the current Vector3
  67986. * @returns the new Vector3
  67987. */
  67988. clone(): Vector3;
  67989. /**
  67990. * Copies the given vector coordinates to the current Vector3 ones
  67991. * @param source defines the source Vector3
  67992. * @returns the current updated Vector3
  67993. */
  67994. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67995. /**
  67996. * Copies the given floats to the current Vector3 coordinates
  67997. * @param x defines the x coordinate of the operand
  67998. * @param y defines the y coordinate of the operand
  67999. * @param z defines the z coordinate of the operand
  68000. * @returns the current updated Vector3
  68001. */
  68002. copyFromFloats(x: number, y: number, z: number): Vector3;
  68003. /**
  68004. * Copies the given floats to the current Vector3 coordinates
  68005. * @param x defines the x coordinate of the operand
  68006. * @param y defines the y coordinate of the operand
  68007. * @param z defines the z coordinate of the operand
  68008. * @returns the current updated Vector3
  68009. */
  68010. set(x: number, y: number, z: number): Vector3;
  68011. /**
  68012. * Copies the given float to the current Vector3 coordinates
  68013. * @param v defines the x, y and z coordinates of the operand
  68014. * @returns the current updated Vector3
  68015. */
  68016. setAll(v: number): Vector3;
  68017. /**
  68018. * Get the clip factor between two vectors
  68019. * @param vector0 defines the first operand
  68020. * @param vector1 defines the second operand
  68021. * @param axis defines the axis to use
  68022. * @param size defines the size along the axis
  68023. * @returns the clip factor
  68024. */
  68025. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68026. /**
  68027. * Get angle between two vectors
  68028. * @param vector0 angle between vector0 and vector1
  68029. * @param vector1 angle between vector0 and vector1
  68030. * @param normal direction of the normal
  68031. * @return the angle between vector0 and vector1
  68032. */
  68033. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68034. /**
  68035. * Returns a new Vector3 set from the index "offset" of the given array
  68036. * @param array defines the source array
  68037. * @param offset defines the offset in the source array
  68038. * @returns the new Vector3
  68039. */
  68040. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68041. /**
  68042. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68043. * This function is deprecated. Use FromArray instead
  68044. * @param array defines the source array
  68045. * @param offset defines the offset in the source array
  68046. * @returns the new Vector3
  68047. */
  68048. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68049. /**
  68050. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68051. * @param array defines the source array
  68052. * @param offset defines the offset in the source array
  68053. * @param result defines the Vector3 where to store the result
  68054. */
  68055. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68056. /**
  68057. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68058. * This function is deprecated. Use FromArrayToRef instead.
  68059. * @param array defines the source array
  68060. * @param offset defines the offset in the source array
  68061. * @param result defines the Vector3 where to store the result
  68062. */
  68063. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68064. /**
  68065. * Sets the given vector "result" with the given floats.
  68066. * @param x defines the x coordinate of the source
  68067. * @param y defines the y coordinate of the source
  68068. * @param z defines the z coordinate of the source
  68069. * @param result defines the Vector3 where to store the result
  68070. */
  68071. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68072. /**
  68073. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68074. * @returns a new empty Vector3
  68075. */
  68076. static Zero(): Vector3;
  68077. /**
  68078. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68079. * @returns a new unit Vector3
  68080. */
  68081. static One(): Vector3;
  68082. /**
  68083. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68084. * @returns a new up Vector3
  68085. */
  68086. static Up(): Vector3;
  68087. /**
  68088. * Gets a up Vector3 that must not be updated
  68089. */
  68090. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68091. /**
  68092. * Gets a zero Vector3 that must not be updated
  68093. */
  68094. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68095. /**
  68096. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68097. * @returns a new down Vector3
  68098. */
  68099. static Down(): Vector3;
  68100. /**
  68101. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68102. * @returns a new forward Vector3
  68103. */
  68104. static Forward(): Vector3;
  68105. /**
  68106. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68107. * @returns a new forward Vector3
  68108. */
  68109. static Backward(): Vector3;
  68110. /**
  68111. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68112. * @returns a new right Vector3
  68113. */
  68114. static Right(): Vector3;
  68115. /**
  68116. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68117. * @returns a new left Vector3
  68118. */
  68119. static Left(): Vector3;
  68120. /**
  68121. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68122. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68123. * @param vector defines the Vector3 to transform
  68124. * @param transformation defines the transformation matrix
  68125. * @returns the transformed Vector3
  68126. */
  68127. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68128. /**
  68129. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68130. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68131. * @param vector defines the Vector3 to transform
  68132. * @param transformation defines the transformation matrix
  68133. * @param result defines the Vector3 where to store the result
  68134. */
  68135. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68136. /**
  68137. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68138. * This method computes tranformed coordinates only, not transformed direction vectors
  68139. * @param x define the x coordinate of the source vector
  68140. * @param y define the y coordinate of the source vector
  68141. * @param z define the z coordinate of the source vector
  68142. * @param transformation defines the transformation matrix
  68143. * @param result defines the Vector3 where to store the result
  68144. */
  68145. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68146. /**
  68147. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68148. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68149. * @param vector defines the Vector3 to transform
  68150. * @param transformation defines the transformation matrix
  68151. * @returns the new Vector3
  68152. */
  68153. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68154. /**
  68155. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68156. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68157. * @param vector defines the Vector3 to transform
  68158. * @param transformation defines the transformation matrix
  68159. * @param result defines the Vector3 where to store the result
  68160. */
  68161. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68162. /**
  68163. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68164. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68165. * @param x define the x coordinate of the source vector
  68166. * @param y define the y coordinate of the source vector
  68167. * @param z define the z coordinate of the source vector
  68168. * @param transformation defines the transformation matrix
  68169. * @param result defines the Vector3 where to store the result
  68170. */
  68171. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68172. /**
  68173. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68174. * @param value1 defines the first control point
  68175. * @param value2 defines the second control point
  68176. * @param value3 defines the third control point
  68177. * @param value4 defines the fourth control point
  68178. * @param amount defines the amount on the spline to use
  68179. * @returns the new Vector3
  68180. */
  68181. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68182. /**
  68183. * 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"
  68184. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68185. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68186. * @param value defines the current value
  68187. * @param min defines the lower range value
  68188. * @param max defines the upper range value
  68189. * @returns the new Vector3
  68190. */
  68191. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68192. /**
  68193. * 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"
  68194. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68195. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68196. * @param value defines the current value
  68197. * @param min defines the lower range value
  68198. * @param max defines the upper range value
  68199. * @param result defines the Vector3 where to store the result
  68200. */
  68201. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68202. /**
  68203. * Checks if a given vector is inside a specific range
  68204. * @param v defines the vector to test
  68205. * @param min defines the minimum range
  68206. * @param max defines the maximum range
  68207. */
  68208. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68209. /**
  68210. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68211. * @param value1 defines the first control point
  68212. * @param tangent1 defines the first tangent vector
  68213. * @param value2 defines the second control point
  68214. * @param tangent2 defines the second tangent vector
  68215. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68216. * @returns the new Vector3
  68217. */
  68218. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68219. /**
  68220. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68221. * @param start defines the start value
  68222. * @param end defines the end value
  68223. * @param amount max defines amount between both (between 0 and 1)
  68224. * @returns the new Vector3
  68225. */
  68226. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68227. /**
  68228. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68229. * @param start defines the start value
  68230. * @param end defines the end value
  68231. * @param amount max defines amount between both (between 0 and 1)
  68232. * @param result defines the Vector3 where to store the result
  68233. */
  68234. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68235. /**
  68236. * Returns the dot product (float) between the vectors "left" and "right"
  68237. * @param left defines the left operand
  68238. * @param right defines the right operand
  68239. * @returns the dot product
  68240. */
  68241. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68242. /**
  68243. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68244. * The cross product is then orthogonal to both "left" and "right"
  68245. * @param left defines the left operand
  68246. * @param right defines the right operand
  68247. * @returns the cross product
  68248. */
  68249. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68250. /**
  68251. * Sets the given vector "result" with the cross product of "left" and "right"
  68252. * The cross product is then orthogonal to both "left" and "right"
  68253. * @param left defines the left operand
  68254. * @param right defines the right operand
  68255. * @param result defines the Vector3 where to store the result
  68256. */
  68257. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68258. /**
  68259. * Returns a new Vector3 as the normalization of the given vector
  68260. * @param vector defines the Vector3 to normalize
  68261. * @returns the new Vector3
  68262. */
  68263. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68264. /**
  68265. * Sets the given vector "result" with the normalization of the given first vector
  68266. * @param vector defines the Vector3 to normalize
  68267. * @param result defines the Vector3 where to store the result
  68268. */
  68269. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68270. /**
  68271. * Project a Vector3 onto screen space
  68272. * @param vector defines the Vector3 to project
  68273. * @param world defines the world matrix to use
  68274. * @param transform defines the transform (view x projection) matrix to use
  68275. * @param viewport defines the screen viewport to use
  68276. * @returns the new Vector3
  68277. */
  68278. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68279. /** @hidden */
  68280. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68281. /**
  68282. * Unproject from screen space to object space
  68283. * @param source defines the screen space Vector3 to use
  68284. * @param viewportWidth defines the current width of the viewport
  68285. * @param viewportHeight defines the current height of the viewport
  68286. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68287. * @param transform defines the transform (view x projection) matrix to use
  68288. * @returns the new Vector3
  68289. */
  68290. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68291. /**
  68292. * Unproject from screen space to object space
  68293. * @param source defines the screen space Vector3 to use
  68294. * @param viewportWidth defines the current width of the viewport
  68295. * @param viewportHeight defines the current height of the viewport
  68296. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68297. * @param view defines the view matrix to use
  68298. * @param projection defines the projection matrix to use
  68299. * @returns the new Vector3
  68300. */
  68301. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68302. /**
  68303. * Unproject from screen space to object space
  68304. * @param source defines the screen space Vector3 to use
  68305. * @param viewportWidth defines the current width of the viewport
  68306. * @param viewportHeight defines the current height of the viewport
  68307. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68308. * @param view defines the view matrix to use
  68309. * @param projection defines the projection matrix to use
  68310. * @param result defines the Vector3 where to store the result
  68311. */
  68312. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68313. /**
  68314. * Unproject from screen space to object space
  68315. * @param sourceX defines the screen space x coordinate to use
  68316. * @param sourceY defines the screen space y coordinate to use
  68317. * @param sourceZ defines the screen space z coordinate to use
  68318. * @param viewportWidth defines the current width of the viewport
  68319. * @param viewportHeight defines the current height of the viewport
  68320. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68321. * @param view defines the view matrix to use
  68322. * @param projection defines the projection matrix to use
  68323. * @param result defines the Vector3 where to store the result
  68324. */
  68325. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68326. /**
  68327. * Gets the minimal coordinate values between two Vector3
  68328. * @param left defines the first operand
  68329. * @param right defines the second operand
  68330. * @returns the new Vector3
  68331. */
  68332. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68333. /**
  68334. * Gets the maximal coordinate values between two Vector3
  68335. * @param left defines the first operand
  68336. * @param right defines the second operand
  68337. * @returns the new Vector3
  68338. */
  68339. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68340. /**
  68341. * Returns the distance between the vectors "value1" and "value2"
  68342. * @param value1 defines the first operand
  68343. * @param value2 defines the second operand
  68344. * @returns the distance
  68345. */
  68346. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68347. /**
  68348. * Returns the squared distance between the vectors "value1" and "value2"
  68349. * @param value1 defines the first operand
  68350. * @param value2 defines the second operand
  68351. * @returns the squared distance
  68352. */
  68353. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68354. /**
  68355. * Returns a new Vector3 located at the center between "value1" and "value2"
  68356. * @param value1 defines the first operand
  68357. * @param value2 defines the second operand
  68358. * @returns the new Vector3
  68359. */
  68360. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68361. /**
  68362. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68363. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68364. * to something in order to rotate it from its local system to the given target system
  68365. * Note: axis1, axis2 and axis3 are normalized during this operation
  68366. * @param axis1 defines the first axis
  68367. * @param axis2 defines the second axis
  68368. * @param axis3 defines the third axis
  68369. * @returns a new Vector3
  68370. */
  68371. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68372. /**
  68373. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68374. * @param axis1 defines the first axis
  68375. * @param axis2 defines the second axis
  68376. * @param axis3 defines the third axis
  68377. * @param ref defines the Vector3 where to store the result
  68378. */
  68379. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68380. }
  68381. /**
  68382. * Vector4 class created for EulerAngle class conversion to Quaternion
  68383. */
  68384. export class Vector4 {
  68385. /** x value of the vector */
  68386. x: number;
  68387. /** y value of the vector */
  68388. y: number;
  68389. /** z value of the vector */
  68390. z: number;
  68391. /** w value of the vector */
  68392. w: number;
  68393. /**
  68394. * Creates a Vector4 object from the given floats.
  68395. * @param x x value of the vector
  68396. * @param y y value of the vector
  68397. * @param z z value of the vector
  68398. * @param w w value of the vector
  68399. */
  68400. constructor(
  68401. /** x value of the vector */
  68402. x: number,
  68403. /** y value of the vector */
  68404. y: number,
  68405. /** z value of the vector */
  68406. z: number,
  68407. /** w value of the vector */
  68408. w: number);
  68409. /**
  68410. * Returns the string with the Vector4 coordinates.
  68411. * @returns a string containing all the vector values
  68412. */
  68413. toString(): string;
  68414. /**
  68415. * Returns the string "Vector4".
  68416. * @returns "Vector4"
  68417. */
  68418. getClassName(): string;
  68419. /**
  68420. * Returns the Vector4 hash code.
  68421. * @returns a unique hash code
  68422. */
  68423. getHashCode(): number;
  68424. /**
  68425. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68426. * @returns the resulting array
  68427. */
  68428. asArray(): number[];
  68429. /**
  68430. * Populates the given array from the given index with the Vector4 coordinates.
  68431. * @param array array to populate
  68432. * @param index index of the array to start at (default: 0)
  68433. * @returns the Vector4.
  68434. */
  68435. toArray(array: FloatArray, index?: number): Vector4;
  68436. /**
  68437. * Adds the given vector to the current Vector4.
  68438. * @param otherVector the vector to add
  68439. * @returns the updated Vector4.
  68440. */
  68441. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68442. /**
  68443. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68444. * @param otherVector the vector to add
  68445. * @returns the resulting vector
  68446. */
  68447. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68448. /**
  68449. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68450. * @param otherVector the vector to add
  68451. * @param result the vector to store the result
  68452. * @returns the current Vector4.
  68453. */
  68454. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68455. /**
  68456. * Subtract in place the given vector from the current Vector4.
  68457. * @param otherVector the vector to subtract
  68458. * @returns the updated Vector4.
  68459. */
  68460. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68461. /**
  68462. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68463. * @param otherVector the vector to add
  68464. * @returns the new vector with the result
  68465. */
  68466. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68467. /**
  68468. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68469. * @param otherVector the vector to subtract
  68470. * @param result the vector to store the result
  68471. * @returns the current Vector4.
  68472. */
  68473. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68474. /**
  68475. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68476. */
  68477. /**
  68478. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68479. * @param x value to subtract
  68480. * @param y value to subtract
  68481. * @param z value to subtract
  68482. * @param w value to subtract
  68483. * @returns new vector containing the result
  68484. */
  68485. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68486. /**
  68487. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68488. * @param x value to subtract
  68489. * @param y value to subtract
  68490. * @param z value to subtract
  68491. * @param w value to subtract
  68492. * @param result the vector to store the result in
  68493. * @returns the current Vector4.
  68494. */
  68495. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68496. /**
  68497. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68498. * @returns a new vector with the negated values
  68499. */
  68500. negate(): Vector4;
  68501. /**
  68502. * Multiplies the current Vector4 coordinates by scale (float).
  68503. * @param scale the number to scale with
  68504. * @returns the updated Vector4.
  68505. */
  68506. scaleInPlace(scale: number): Vector4;
  68507. /**
  68508. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68509. * @param scale the number to scale with
  68510. * @returns a new vector with the result
  68511. */
  68512. scale(scale: number): Vector4;
  68513. /**
  68514. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68515. * @param scale the number to scale with
  68516. * @param result a vector to store the result in
  68517. * @returns the current Vector4.
  68518. */
  68519. scaleToRef(scale: number, result: Vector4): Vector4;
  68520. /**
  68521. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68522. * @param scale defines the scale factor
  68523. * @param result defines the Vector4 object where to store the result
  68524. * @returns the unmodified current Vector4
  68525. */
  68526. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68527. /**
  68528. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68529. * @param otherVector the vector to compare against
  68530. * @returns true if they are equal
  68531. */
  68532. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68533. /**
  68534. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68535. * @param otherVector vector to compare against
  68536. * @param epsilon (Default: very small number)
  68537. * @returns true if they are equal
  68538. */
  68539. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68540. /**
  68541. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68542. * @param x x value to compare against
  68543. * @param y y value to compare against
  68544. * @param z z value to compare against
  68545. * @param w w value to compare against
  68546. * @returns true if equal
  68547. */
  68548. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68549. /**
  68550. * Multiplies in place the current Vector4 by the given one.
  68551. * @param otherVector vector to multiple with
  68552. * @returns the updated Vector4.
  68553. */
  68554. multiplyInPlace(otherVector: Vector4): Vector4;
  68555. /**
  68556. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68557. * @param otherVector vector to multiple with
  68558. * @returns resulting new vector
  68559. */
  68560. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68561. /**
  68562. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68563. * @param otherVector vector to multiple with
  68564. * @param result vector to store the result
  68565. * @returns the current Vector4.
  68566. */
  68567. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68568. /**
  68569. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68570. * @param x x value multiply with
  68571. * @param y y value multiply with
  68572. * @param z z value multiply with
  68573. * @param w w value multiply with
  68574. * @returns resulting new vector
  68575. */
  68576. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68577. /**
  68578. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68579. * @param otherVector vector to devide with
  68580. * @returns resulting new vector
  68581. */
  68582. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68583. /**
  68584. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68585. * @param otherVector vector to devide with
  68586. * @param result vector to store the result
  68587. * @returns the current Vector4.
  68588. */
  68589. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68590. /**
  68591. * Divides the current Vector3 coordinates by the given ones.
  68592. * @param otherVector vector to devide with
  68593. * @returns the updated Vector3.
  68594. */
  68595. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68596. /**
  68597. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68598. * @param other defines the second operand
  68599. * @returns the current updated Vector4
  68600. */
  68601. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68602. /**
  68603. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68604. * @param other defines the second operand
  68605. * @returns the current updated Vector4
  68606. */
  68607. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68608. /**
  68609. * Gets a new Vector4 from current Vector4 floored values
  68610. * @returns a new Vector4
  68611. */
  68612. floor(): Vector4;
  68613. /**
  68614. * Gets a new Vector4 from current Vector3 floored values
  68615. * @returns a new Vector4
  68616. */
  68617. fract(): Vector4;
  68618. /**
  68619. * Returns the Vector4 length (float).
  68620. * @returns the length
  68621. */
  68622. length(): number;
  68623. /**
  68624. * Returns the Vector4 squared length (float).
  68625. * @returns the length squared
  68626. */
  68627. lengthSquared(): number;
  68628. /**
  68629. * Normalizes in place the Vector4.
  68630. * @returns the updated Vector4.
  68631. */
  68632. normalize(): Vector4;
  68633. /**
  68634. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68635. * @returns this converted to a new vector3
  68636. */
  68637. toVector3(): Vector3;
  68638. /**
  68639. * Returns a new Vector4 copied from the current one.
  68640. * @returns the new cloned vector
  68641. */
  68642. clone(): Vector4;
  68643. /**
  68644. * Updates the current Vector4 with the given one coordinates.
  68645. * @param source the source vector to copy from
  68646. * @returns the updated Vector4.
  68647. */
  68648. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68649. /**
  68650. * Updates the current Vector4 coordinates with the given floats.
  68651. * @param x float to copy from
  68652. * @param y float to copy from
  68653. * @param z float to copy from
  68654. * @param w float to copy from
  68655. * @returns the updated Vector4.
  68656. */
  68657. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68658. /**
  68659. * Updates the current Vector4 coordinates with the given floats.
  68660. * @param x float to set from
  68661. * @param y float to set from
  68662. * @param z float to set from
  68663. * @param w float to set from
  68664. * @returns the updated Vector4.
  68665. */
  68666. set(x: number, y: number, z: number, w: number): Vector4;
  68667. /**
  68668. * Copies the given float to the current Vector3 coordinates
  68669. * @param v defines the x, y, z and w coordinates of the operand
  68670. * @returns the current updated Vector3
  68671. */
  68672. setAll(v: number): Vector4;
  68673. /**
  68674. * Returns a new Vector4 set from the starting index of the given array.
  68675. * @param array the array to pull values from
  68676. * @param offset the offset into the array to start at
  68677. * @returns the new vector
  68678. */
  68679. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68680. /**
  68681. * Updates the given vector "result" from the starting index of the given array.
  68682. * @param array the array to pull values from
  68683. * @param offset the offset into the array to start at
  68684. * @param result the vector to store the result in
  68685. */
  68686. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68687. /**
  68688. * Updates the given vector "result" from the starting index of the given Float32Array.
  68689. * @param array the array to pull values from
  68690. * @param offset the offset into the array to start at
  68691. * @param result the vector to store the result in
  68692. */
  68693. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68694. /**
  68695. * Updates the given vector "result" coordinates from the given floats.
  68696. * @param x float to set from
  68697. * @param y float to set from
  68698. * @param z float to set from
  68699. * @param w float to set from
  68700. * @param result the vector to the floats in
  68701. */
  68702. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68703. /**
  68704. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68705. * @returns the new vector
  68706. */
  68707. static Zero(): Vector4;
  68708. /**
  68709. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68710. * @returns the new vector
  68711. */
  68712. static One(): Vector4;
  68713. /**
  68714. * Returns a new normalized Vector4 from the given one.
  68715. * @param vector the vector to normalize
  68716. * @returns the vector
  68717. */
  68718. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68719. /**
  68720. * Updates the given vector "result" from the normalization of the given one.
  68721. * @param vector the vector to normalize
  68722. * @param result the vector to store the result in
  68723. */
  68724. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68725. /**
  68726. * Returns a vector with the minimum values from the left and right vectors
  68727. * @param left left vector to minimize
  68728. * @param right right vector to minimize
  68729. * @returns a new vector with the minimum of the left and right vector values
  68730. */
  68731. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68732. /**
  68733. * Returns a vector with the maximum values from the left and right vectors
  68734. * @param left left vector to maximize
  68735. * @param right right vector to maximize
  68736. * @returns a new vector with the maximum of the left and right vector values
  68737. */
  68738. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68739. /**
  68740. * Returns the distance (float) between the vectors "value1" and "value2".
  68741. * @param value1 value to calulate the distance between
  68742. * @param value2 value to calulate the distance between
  68743. * @return the distance between the two vectors
  68744. */
  68745. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68746. /**
  68747. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68748. * @param value1 value to calulate the distance between
  68749. * @param value2 value to calulate the distance between
  68750. * @return the distance between the two vectors squared
  68751. */
  68752. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68753. /**
  68754. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68755. * @param value1 value to calulate the center between
  68756. * @param value2 value to calulate the center between
  68757. * @return the center between the two vectors
  68758. */
  68759. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68760. /**
  68761. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68762. * This methods computes transformed normalized direction vectors only.
  68763. * @param vector the vector to transform
  68764. * @param transformation the transformation matrix to apply
  68765. * @returns the new vector
  68766. */
  68767. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68768. /**
  68769. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68770. * This methods computes transformed normalized direction vectors only.
  68771. * @param vector the vector to transform
  68772. * @param transformation the transformation matrix to apply
  68773. * @param result the vector to store the result in
  68774. */
  68775. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68776. /**
  68777. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68778. * This methods computes transformed normalized direction vectors only.
  68779. * @param x value to transform
  68780. * @param y value to transform
  68781. * @param z value to transform
  68782. * @param w value to transform
  68783. * @param transformation the transformation matrix to apply
  68784. * @param result the vector to store the results in
  68785. */
  68786. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68787. /**
  68788. * Creates a new Vector4 from a Vector3
  68789. * @param source defines the source data
  68790. * @param w defines the 4th component (default is 0)
  68791. * @returns a new Vector4
  68792. */
  68793. static FromVector3(source: Vector3, w?: number): Vector4;
  68794. }
  68795. /**
  68796. * Class used to store quaternion data
  68797. * @see https://en.wikipedia.org/wiki/Quaternion
  68798. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68799. */
  68800. export class Quaternion {
  68801. /** defines the first component (0 by default) */
  68802. x: number;
  68803. /** defines the second component (0 by default) */
  68804. y: number;
  68805. /** defines the third component (0 by default) */
  68806. z: number;
  68807. /** defines the fourth component (1.0 by default) */
  68808. w: number;
  68809. /**
  68810. * Creates a new Quaternion from the given floats
  68811. * @param x defines the first component (0 by default)
  68812. * @param y defines the second component (0 by default)
  68813. * @param z defines the third component (0 by default)
  68814. * @param w defines the fourth component (1.0 by default)
  68815. */
  68816. constructor(
  68817. /** defines the first component (0 by default) */
  68818. x?: number,
  68819. /** defines the second component (0 by default) */
  68820. y?: number,
  68821. /** defines the third component (0 by default) */
  68822. z?: number,
  68823. /** defines the fourth component (1.0 by default) */
  68824. w?: number);
  68825. /**
  68826. * Gets a string representation for the current quaternion
  68827. * @returns a string with the Quaternion coordinates
  68828. */
  68829. toString(): string;
  68830. /**
  68831. * Gets the class name of the quaternion
  68832. * @returns the string "Quaternion"
  68833. */
  68834. getClassName(): string;
  68835. /**
  68836. * Gets a hash code for this quaternion
  68837. * @returns the quaternion hash code
  68838. */
  68839. getHashCode(): number;
  68840. /**
  68841. * Copy the quaternion to an array
  68842. * @returns a new array populated with 4 elements from the quaternion coordinates
  68843. */
  68844. asArray(): number[];
  68845. /**
  68846. * Check if two quaternions are equals
  68847. * @param otherQuaternion defines the second operand
  68848. * @return true if the current quaternion and the given one coordinates are strictly equals
  68849. */
  68850. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68851. /**
  68852. * Clone the current quaternion
  68853. * @returns a new quaternion copied from the current one
  68854. */
  68855. clone(): Quaternion;
  68856. /**
  68857. * Copy a quaternion to the current one
  68858. * @param other defines the other quaternion
  68859. * @returns the updated current quaternion
  68860. */
  68861. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68862. /**
  68863. * Updates the current quaternion with the given float coordinates
  68864. * @param x defines the x coordinate
  68865. * @param y defines the y coordinate
  68866. * @param z defines the z coordinate
  68867. * @param w defines the w coordinate
  68868. * @returns the updated current quaternion
  68869. */
  68870. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68871. /**
  68872. * Updates the current quaternion from the given float coordinates
  68873. * @param x defines the x coordinate
  68874. * @param y defines the y coordinate
  68875. * @param z defines the z coordinate
  68876. * @param w defines the w coordinate
  68877. * @returns the updated current quaternion
  68878. */
  68879. set(x: number, y: number, z: number, w: number): Quaternion;
  68880. /**
  68881. * Adds two quaternions
  68882. * @param other defines the second operand
  68883. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68884. */
  68885. add(other: DeepImmutable<Quaternion>): Quaternion;
  68886. /**
  68887. * Add a quaternion to the current one
  68888. * @param other defines the quaternion to add
  68889. * @returns the current quaternion
  68890. */
  68891. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68892. /**
  68893. * Subtract two quaternions
  68894. * @param other defines the second operand
  68895. * @returns a new quaternion as the subtraction result of the given one from the current one
  68896. */
  68897. subtract(other: Quaternion): Quaternion;
  68898. /**
  68899. * Multiplies the current quaternion by a scale factor
  68900. * @param value defines the scale factor
  68901. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68902. */
  68903. scale(value: number): Quaternion;
  68904. /**
  68905. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68906. * @param scale defines the scale factor
  68907. * @param result defines the Quaternion object where to store the result
  68908. * @returns the unmodified current quaternion
  68909. */
  68910. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68911. /**
  68912. * Multiplies in place the current quaternion by a scale factor
  68913. * @param value defines the scale factor
  68914. * @returns the current modified quaternion
  68915. */
  68916. scaleInPlace(value: number): Quaternion;
  68917. /**
  68918. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68919. * @param scale defines the scale factor
  68920. * @param result defines the Quaternion object where to store the result
  68921. * @returns the unmodified current quaternion
  68922. */
  68923. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68924. /**
  68925. * Multiplies two quaternions
  68926. * @param q1 defines the second operand
  68927. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68928. */
  68929. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68930. /**
  68931. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68932. * @param q1 defines the second operand
  68933. * @param result defines the target quaternion
  68934. * @returns the current quaternion
  68935. */
  68936. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68937. /**
  68938. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68939. * @param q1 defines the second operand
  68940. * @returns the currentupdated quaternion
  68941. */
  68942. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68943. /**
  68944. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68945. * @param ref defines the target quaternion
  68946. * @returns the current quaternion
  68947. */
  68948. conjugateToRef(ref: Quaternion): Quaternion;
  68949. /**
  68950. * Conjugates in place (1-q) the current quaternion
  68951. * @returns the current updated quaternion
  68952. */
  68953. conjugateInPlace(): Quaternion;
  68954. /**
  68955. * Conjugates in place (1-q) the current quaternion
  68956. * @returns a new quaternion
  68957. */
  68958. conjugate(): Quaternion;
  68959. /**
  68960. * Gets length of current quaternion
  68961. * @returns the quaternion length (float)
  68962. */
  68963. length(): number;
  68964. /**
  68965. * Normalize in place the current quaternion
  68966. * @returns the current updated quaternion
  68967. */
  68968. normalize(): Quaternion;
  68969. /**
  68970. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68971. * @param order is a reserved parameter and is ignore for now
  68972. * @returns a new Vector3 containing the Euler angles
  68973. */
  68974. toEulerAngles(order?: string): Vector3;
  68975. /**
  68976. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68977. * @param result defines the vector which will be filled with the Euler angles
  68978. * @param order is a reserved parameter and is ignore for now
  68979. * @returns the current unchanged quaternion
  68980. */
  68981. toEulerAnglesToRef(result: Vector3): Quaternion;
  68982. /**
  68983. * Updates the given rotation matrix with the current quaternion values
  68984. * @param result defines the target matrix
  68985. * @returns the current unchanged quaternion
  68986. */
  68987. toRotationMatrix(result: Matrix): Quaternion;
  68988. /**
  68989. * Updates the current quaternion from the given rotation matrix values
  68990. * @param matrix defines the source matrix
  68991. * @returns the current updated quaternion
  68992. */
  68993. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68994. /**
  68995. * Creates a new quaternion from a rotation matrix
  68996. * @param matrix defines the source matrix
  68997. * @returns a new quaternion created from the given rotation matrix values
  68998. */
  68999. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69000. /**
  69001. * Updates the given quaternion with the given rotation matrix values
  69002. * @param matrix defines the source matrix
  69003. * @param result defines the target quaternion
  69004. */
  69005. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69006. /**
  69007. * Returns the dot product (float) between the quaternions "left" and "right"
  69008. * @param left defines the left operand
  69009. * @param right defines the right operand
  69010. * @returns the dot product
  69011. */
  69012. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69013. /**
  69014. * Checks if the two quaternions are close to each other
  69015. * @param quat0 defines the first quaternion to check
  69016. * @param quat1 defines the second quaternion to check
  69017. * @returns true if the two quaternions are close to each other
  69018. */
  69019. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69020. /**
  69021. * Creates an empty quaternion
  69022. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69023. */
  69024. static Zero(): Quaternion;
  69025. /**
  69026. * Inverse a given quaternion
  69027. * @param q defines the source quaternion
  69028. * @returns a new quaternion as the inverted current quaternion
  69029. */
  69030. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69031. /**
  69032. * Inverse a given quaternion
  69033. * @param q defines the source quaternion
  69034. * @param result the quaternion the result will be stored in
  69035. * @returns the result quaternion
  69036. */
  69037. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69038. /**
  69039. * Creates an identity quaternion
  69040. * @returns the identity quaternion
  69041. */
  69042. static Identity(): Quaternion;
  69043. /**
  69044. * Gets a boolean indicating if the given quaternion is identity
  69045. * @param quaternion defines the quaternion to check
  69046. * @returns true if the quaternion is identity
  69047. */
  69048. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69049. /**
  69050. * Creates a quaternion from a rotation around an axis
  69051. * @param axis defines the axis to use
  69052. * @param angle defines the angle to use
  69053. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69054. */
  69055. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69056. /**
  69057. * Creates a rotation around an axis and stores it into the given quaternion
  69058. * @param axis defines the axis to use
  69059. * @param angle defines the angle to use
  69060. * @param result defines the target quaternion
  69061. * @returns the target quaternion
  69062. */
  69063. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69064. /**
  69065. * Creates a new quaternion from data stored into an array
  69066. * @param array defines the data source
  69067. * @param offset defines the offset in the source array where the data starts
  69068. * @returns a new quaternion
  69069. */
  69070. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69071. /**
  69072. * Create a quaternion from Euler rotation angles
  69073. * @param x Pitch
  69074. * @param y Yaw
  69075. * @param z Roll
  69076. * @returns the new Quaternion
  69077. */
  69078. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69079. /**
  69080. * Updates a quaternion from Euler rotation angles
  69081. * @param x Pitch
  69082. * @param y Yaw
  69083. * @param z Roll
  69084. * @param result the quaternion to store the result
  69085. * @returns the updated quaternion
  69086. */
  69087. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69088. /**
  69089. * Create a quaternion from Euler rotation vector
  69090. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69091. * @returns the new Quaternion
  69092. */
  69093. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69094. /**
  69095. * Updates a quaternion from Euler rotation vector
  69096. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69097. * @param result the quaternion to store the result
  69098. * @returns the updated quaternion
  69099. */
  69100. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69101. /**
  69102. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69103. * @param yaw defines the rotation around Y axis
  69104. * @param pitch defines the rotation around X axis
  69105. * @param roll defines the rotation around Z axis
  69106. * @returns the new quaternion
  69107. */
  69108. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69109. /**
  69110. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69111. * @param yaw defines the rotation around Y axis
  69112. * @param pitch defines the rotation around X axis
  69113. * @param roll defines the rotation around Z axis
  69114. * @param result defines the target quaternion
  69115. */
  69116. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69117. /**
  69118. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69119. * @param alpha defines the rotation around first axis
  69120. * @param beta defines the rotation around second axis
  69121. * @param gamma defines the rotation around third axis
  69122. * @returns the new quaternion
  69123. */
  69124. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69125. /**
  69126. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69127. * @param alpha defines the rotation around first axis
  69128. * @param beta defines the rotation around second axis
  69129. * @param gamma defines the rotation around third axis
  69130. * @param result defines the target quaternion
  69131. */
  69132. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69133. /**
  69134. * 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)
  69135. * @param axis1 defines the first axis
  69136. * @param axis2 defines the second axis
  69137. * @param axis3 defines the third axis
  69138. * @returns the new quaternion
  69139. */
  69140. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69141. /**
  69142. * 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
  69143. * @param axis1 defines the first axis
  69144. * @param axis2 defines the second axis
  69145. * @param axis3 defines the third axis
  69146. * @param ref defines the target quaternion
  69147. */
  69148. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69149. /**
  69150. * Interpolates between two quaternions
  69151. * @param left defines first quaternion
  69152. * @param right defines second quaternion
  69153. * @param amount defines the gradient to use
  69154. * @returns the new interpolated quaternion
  69155. */
  69156. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69157. /**
  69158. * Interpolates between two quaternions and stores it into a target quaternion
  69159. * @param left defines first quaternion
  69160. * @param right defines second quaternion
  69161. * @param amount defines the gradient to use
  69162. * @param result defines the target quaternion
  69163. */
  69164. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69165. /**
  69166. * Interpolate between two quaternions using Hermite interpolation
  69167. * @param value1 defines first quaternion
  69168. * @param tangent1 defines the incoming tangent
  69169. * @param value2 defines second quaternion
  69170. * @param tangent2 defines the outgoing tangent
  69171. * @param amount defines the target quaternion
  69172. * @returns the new interpolated quaternion
  69173. */
  69174. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69175. }
  69176. /**
  69177. * Class used to store matrix data (4x4)
  69178. */
  69179. export class Matrix {
  69180. private static _updateFlagSeed;
  69181. private static _identityReadOnly;
  69182. private _isIdentity;
  69183. private _isIdentityDirty;
  69184. private _isIdentity3x2;
  69185. private _isIdentity3x2Dirty;
  69186. /**
  69187. * Gets the update flag of the matrix which is an unique number for the matrix.
  69188. * It will be incremented every time the matrix data change.
  69189. * You can use it to speed the comparison between two versions of the same matrix.
  69190. */
  69191. updateFlag: number;
  69192. private readonly _m;
  69193. /**
  69194. * Gets the internal data of the matrix
  69195. */
  69196. readonly m: DeepImmutable<Float32Array>;
  69197. /** @hidden */
  69198. _markAsUpdated(): void;
  69199. /** @hidden */
  69200. private _updateIdentityStatus;
  69201. /**
  69202. * Creates an empty matrix (filled with zeros)
  69203. */
  69204. constructor();
  69205. /**
  69206. * Check if the current matrix is identity
  69207. * @returns true is the matrix is the identity matrix
  69208. */
  69209. isIdentity(): boolean;
  69210. /**
  69211. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69212. * @returns true is the matrix is the identity matrix
  69213. */
  69214. isIdentityAs3x2(): boolean;
  69215. /**
  69216. * Gets the determinant of the matrix
  69217. * @returns the matrix determinant
  69218. */
  69219. determinant(): number;
  69220. /**
  69221. * Returns the matrix as a Float32Array
  69222. * @returns the matrix underlying array
  69223. */
  69224. toArray(): DeepImmutable<Float32Array>;
  69225. /**
  69226. * Returns the matrix as a Float32Array
  69227. * @returns the matrix underlying array.
  69228. */
  69229. asArray(): DeepImmutable<Float32Array>;
  69230. /**
  69231. * Inverts the current matrix in place
  69232. * @returns the current inverted matrix
  69233. */
  69234. invert(): Matrix;
  69235. /**
  69236. * Sets all the matrix elements to zero
  69237. * @returns the current matrix
  69238. */
  69239. reset(): Matrix;
  69240. /**
  69241. * Adds the current matrix with a second one
  69242. * @param other defines the matrix to add
  69243. * @returns a new matrix as the addition of the current matrix and the given one
  69244. */
  69245. add(other: DeepImmutable<Matrix>): Matrix;
  69246. /**
  69247. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69248. * @param other defines the matrix to add
  69249. * @param result defines the target matrix
  69250. * @returns the current matrix
  69251. */
  69252. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69253. /**
  69254. * Adds in place the given matrix to the current matrix
  69255. * @param other defines the second operand
  69256. * @returns the current updated matrix
  69257. */
  69258. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69259. /**
  69260. * Sets the given matrix to the current inverted Matrix
  69261. * @param other defines the target matrix
  69262. * @returns the unmodified current matrix
  69263. */
  69264. invertToRef(other: Matrix): Matrix;
  69265. /**
  69266. * add a value at the specified position in the current Matrix
  69267. * @param index the index of the value within the matrix. between 0 and 15.
  69268. * @param value the value to be added
  69269. * @returns the current updated matrix
  69270. */
  69271. addAtIndex(index: number, value: number): Matrix;
  69272. /**
  69273. * mutiply the specified position in the current Matrix by a value
  69274. * @param index the index of the value within the matrix. between 0 and 15.
  69275. * @param value the value to be added
  69276. * @returns the current updated matrix
  69277. */
  69278. multiplyAtIndex(index: number, value: number): Matrix;
  69279. /**
  69280. * Inserts the translation vector (using 3 floats) in the current matrix
  69281. * @param x defines the 1st component of the translation
  69282. * @param y defines the 2nd component of the translation
  69283. * @param z defines the 3rd component of the translation
  69284. * @returns the current updated matrix
  69285. */
  69286. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69287. /**
  69288. * Adds the translation vector (using 3 floats) in the current matrix
  69289. * @param x defines the 1st component of the translation
  69290. * @param y defines the 2nd component of the translation
  69291. * @param z defines the 3rd component of the translation
  69292. * @returns the current updated matrix
  69293. */
  69294. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69295. /**
  69296. * Inserts the translation vector in the current matrix
  69297. * @param vector3 defines the translation to insert
  69298. * @returns the current updated matrix
  69299. */
  69300. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69301. /**
  69302. * Gets the translation value of the current matrix
  69303. * @returns a new Vector3 as the extracted translation from the matrix
  69304. */
  69305. getTranslation(): Vector3;
  69306. /**
  69307. * Fill a Vector3 with the extracted translation from the matrix
  69308. * @param result defines the Vector3 where to store the translation
  69309. * @returns the current matrix
  69310. */
  69311. getTranslationToRef(result: Vector3): Matrix;
  69312. /**
  69313. * Remove rotation and scaling part from the matrix
  69314. * @returns the updated matrix
  69315. */
  69316. removeRotationAndScaling(): Matrix;
  69317. /**
  69318. * Multiply two matrices
  69319. * @param other defines the second operand
  69320. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69321. */
  69322. multiply(other: DeepImmutable<Matrix>): Matrix;
  69323. /**
  69324. * Copy the current matrix from the given one
  69325. * @param other defines the source matrix
  69326. * @returns the current updated matrix
  69327. */
  69328. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69329. /**
  69330. * Populates the given array from the starting index with the current matrix values
  69331. * @param array defines the target array
  69332. * @param offset defines the offset in the target array where to start storing values
  69333. * @returns the current matrix
  69334. */
  69335. copyToArray(array: Float32Array, offset?: number): Matrix;
  69336. /**
  69337. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69338. * @param other defines the second operand
  69339. * @param result defines the matrix where to store the multiplication
  69340. * @returns the current matrix
  69341. */
  69342. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69343. /**
  69344. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69345. * @param other defines the second operand
  69346. * @param result defines the array where to store the multiplication
  69347. * @param offset defines the offset in the target array where to start storing values
  69348. * @returns the current matrix
  69349. */
  69350. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69351. /**
  69352. * Check equality between this matrix and a second one
  69353. * @param value defines the second matrix to compare
  69354. * @returns true is the current matrix and the given one values are strictly equal
  69355. */
  69356. equals(value: DeepImmutable<Matrix>): boolean;
  69357. /**
  69358. * Clone the current matrix
  69359. * @returns a new matrix from the current matrix
  69360. */
  69361. clone(): Matrix;
  69362. /**
  69363. * Returns the name of the current matrix class
  69364. * @returns the string "Matrix"
  69365. */
  69366. getClassName(): string;
  69367. /**
  69368. * Gets the hash code of the current matrix
  69369. * @returns the hash code
  69370. */
  69371. getHashCode(): number;
  69372. /**
  69373. * Decomposes the current Matrix into a translation, rotation and scaling components
  69374. * @param scale defines the scale vector3 given as a reference to update
  69375. * @param rotation defines the rotation quaternion given as a reference to update
  69376. * @param translation defines the translation vector3 given as a reference to update
  69377. * @returns true if operation was successful
  69378. */
  69379. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69380. /**
  69381. * Gets specific row of the matrix
  69382. * @param index defines the number of the row to get
  69383. * @returns the index-th row of the current matrix as a new Vector4
  69384. */
  69385. getRow(index: number): Nullable<Vector4>;
  69386. /**
  69387. * Sets the index-th row of the current matrix to the vector4 values
  69388. * @param index defines the number of the row to set
  69389. * @param row defines the target vector4
  69390. * @returns the updated current matrix
  69391. */
  69392. setRow(index: number, row: Vector4): Matrix;
  69393. /**
  69394. * Compute the transpose of the matrix
  69395. * @returns the new transposed matrix
  69396. */
  69397. transpose(): Matrix;
  69398. /**
  69399. * Compute the transpose of the matrix and store it in a given matrix
  69400. * @param result defines the target matrix
  69401. * @returns the current matrix
  69402. */
  69403. transposeToRef(result: Matrix): Matrix;
  69404. /**
  69405. * Sets the index-th row of the current matrix with the given 4 x float values
  69406. * @param index defines the row index
  69407. * @param x defines the x component to set
  69408. * @param y defines the y component to set
  69409. * @param z defines the z component to set
  69410. * @param w defines the w component to set
  69411. * @returns the updated current matrix
  69412. */
  69413. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69414. /**
  69415. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69416. * @param scale defines the scale factor
  69417. * @returns a new matrix
  69418. */
  69419. scale(scale: number): Matrix;
  69420. /**
  69421. * Scale the current matrix values by a factor to a given result matrix
  69422. * @param scale defines the scale factor
  69423. * @param result defines the matrix to store the result
  69424. * @returns the current matrix
  69425. */
  69426. scaleToRef(scale: number, result: Matrix): Matrix;
  69427. /**
  69428. * Scale the current matrix values by a factor and add the result to a given matrix
  69429. * @param scale defines the scale factor
  69430. * @param result defines the Matrix to store the result
  69431. * @returns the current matrix
  69432. */
  69433. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69434. /**
  69435. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69436. * @param ref matrix to store the result
  69437. */
  69438. toNormalMatrix(ref: Matrix): void;
  69439. /**
  69440. * Gets only rotation part of the current matrix
  69441. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69442. */
  69443. getRotationMatrix(): Matrix;
  69444. /**
  69445. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69446. * @param result defines the target matrix to store data to
  69447. * @returns the current matrix
  69448. */
  69449. getRotationMatrixToRef(result: Matrix): Matrix;
  69450. /**
  69451. * Toggles model matrix from being right handed to left handed in place and vice versa
  69452. */
  69453. toggleModelMatrixHandInPlace(): void;
  69454. /**
  69455. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69456. */
  69457. toggleProjectionMatrixHandInPlace(): void;
  69458. /**
  69459. * Creates a matrix from an array
  69460. * @param array defines the source array
  69461. * @param offset defines an offset in the source array
  69462. * @returns a new Matrix set from the starting index of the given array
  69463. */
  69464. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69465. /**
  69466. * Copy the content of an array into a given matrix
  69467. * @param array defines the source array
  69468. * @param offset defines an offset in the source array
  69469. * @param result defines the target matrix
  69470. */
  69471. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69472. /**
  69473. * Stores an array into a matrix after having multiplied each component by a given factor
  69474. * @param array defines the source array
  69475. * @param offset defines the offset in the source array
  69476. * @param scale defines the scaling factor
  69477. * @param result defines the target matrix
  69478. */
  69479. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69480. /**
  69481. * Gets an identity matrix that must not be updated
  69482. */
  69483. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69484. /**
  69485. * Stores a list of values (16) inside a given matrix
  69486. * @param initialM11 defines 1st value of 1st row
  69487. * @param initialM12 defines 2nd value of 1st row
  69488. * @param initialM13 defines 3rd value of 1st row
  69489. * @param initialM14 defines 4th value of 1st row
  69490. * @param initialM21 defines 1st value of 2nd row
  69491. * @param initialM22 defines 2nd value of 2nd row
  69492. * @param initialM23 defines 3rd value of 2nd row
  69493. * @param initialM24 defines 4th value of 2nd row
  69494. * @param initialM31 defines 1st value of 3rd row
  69495. * @param initialM32 defines 2nd value of 3rd row
  69496. * @param initialM33 defines 3rd value of 3rd row
  69497. * @param initialM34 defines 4th value of 3rd row
  69498. * @param initialM41 defines 1st value of 4th row
  69499. * @param initialM42 defines 2nd value of 4th row
  69500. * @param initialM43 defines 3rd value of 4th row
  69501. * @param initialM44 defines 4th value of 4th row
  69502. * @param result defines the target matrix
  69503. */
  69504. 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;
  69505. /**
  69506. * Creates new matrix from a list of values (16)
  69507. * @param initialM11 defines 1st value of 1st row
  69508. * @param initialM12 defines 2nd value of 1st row
  69509. * @param initialM13 defines 3rd value of 1st row
  69510. * @param initialM14 defines 4th value of 1st row
  69511. * @param initialM21 defines 1st value of 2nd row
  69512. * @param initialM22 defines 2nd value of 2nd row
  69513. * @param initialM23 defines 3rd value of 2nd row
  69514. * @param initialM24 defines 4th value of 2nd row
  69515. * @param initialM31 defines 1st value of 3rd row
  69516. * @param initialM32 defines 2nd value of 3rd row
  69517. * @param initialM33 defines 3rd value of 3rd row
  69518. * @param initialM34 defines 4th value of 3rd row
  69519. * @param initialM41 defines 1st value of 4th row
  69520. * @param initialM42 defines 2nd value of 4th row
  69521. * @param initialM43 defines 3rd value of 4th row
  69522. * @param initialM44 defines 4th value of 4th row
  69523. * @returns the new matrix
  69524. */
  69525. 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;
  69526. /**
  69527. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69528. * @param scale defines the scale vector3
  69529. * @param rotation defines the rotation quaternion
  69530. * @param translation defines the translation vector3
  69531. * @returns a new matrix
  69532. */
  69533. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69534. /**
  69535. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69536. * @param scale defines the scale vector3
  69537. * @param rotation defines the rotation quaternion
  69538. * @param translation defines the translation vector3
  69539. * @param result defines the target matrix
  69540. */
  69541. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69542. /**
  69543. * Creates a new identity matrix
  69544. * @returns a new identity matrix
  69545. */
  69546. static Identity(): Matrix;
  69547. /**
  69548. * Creates a new identity matrix and stores the result in a given matrix
  69549. * @param result defines the target matrix
  69550. */
  69551. static IdentityToRef(result: Matrix): void;
  69552. /**
  69553. * Creates a new zero matrix
  69554. * @returns a new zero matrix
  69555. */
  69556. static Zero(): Matrix;
  69557. /**
  69558. * Creates a new rotation matrix for "angle" radians around the X axis
  69559. * @param angle defines the angle (in radians) to use
  69560. * @return the new matrix
  69561. */
  69562. static RotationX(angle: number): Matrix;
  69563. /**
  69564. * Creates a new matrix as the invert of a given matrix
  69565. * @param source defines the source matrix
  69566. * @returns the new matrix
  69567. */
  69568. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69569. /**
  69570. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69571. * @param angle defines the angle (in radians) to use
  69572. * @param result defines the target matrix
  69573. */
  69574. static RotationXToRef(angle: number, result: Matrix): void;
  69575. /**
  69576. * Creates a new rotation matrix for "angle" radians around the Y axis
  69577. * @param angle defines the angle (in radians) to use
  69578. * @return the new matrix
  69579. */
  69580. static RotationY(angle: number): Matrix;
  69581. /**
  69582. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69583. * @param angle defines the angle (in radians) to use
  69584. * @param result defines the target matrix
  69585. */
  69586. static RotationYToRef(angle: number, result: Matrix): void;
  69587. /**
  69588. * Creates a new rotation matrix for "angle" radians around the Z axis
  69589. * @param angle defines the angle (in radians) to use
  69590. * @return the new matrix
  69591. */
  69592. static RotationZ(angle: number): Matrix;
  69593. /**
  69594. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69595. * @param angle defines the angle (in radians) to use
  69596. * @param result defines the target matrix
  69597. */
  69598. static RotationZToRef(angle: number, result: Matrix): void;
  69599. /**
  69600. * Creates a new rotation matrix for "angle" radians around the given axis
  69601. * @param axis defines the axis to use
  69602. * @param angle defines the angle (in radians) to use
  69603. * @return the new matrix
  69604. */
  69605. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69606. /**
  69607. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69608. * @param axis defines the axis to use
  69609. * @param angle defines the angle (in radians) to use
  69610. * @param result defines the target matrix
  69611. */
  69612. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69613. /**
  69614. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69615. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69616. * @param from defines the vector to align
  69617. * @param to defines the vector to align to
  69618. * @param result defines the target matrix
  69619. */
  69620. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69621. /**
  69622. * Creates a rotation matrix
  69623. * @param yaw defines the yaw angle in radians (Y axis)
  69624. * @param pitch defines the pitch angle in radians (X axis)
  69625. * @param roll defines the roll angle in radians (X axis)
  69626. * @returns the new rotation matrix
  69627. */
  69628. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69629. /**
  69630. * Creates a rotation matrix and stores it in a given matrix
  69631. * @param yaw defines the yaw angle in radians (Y axis)
  69632. * @param pitch defines the pitch angle in radians (X axis)
  69633. * @param roll defines the roll angle in radians (X axis)
  69634. * @param result defines the target matrix
  69635. */
  69636. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69637. /**
  69638. * Creates a scaling matrix
  69639. * @param x defines the scale factor on X axis
  69640. * @param y defines the scale factor on Y axis
  69641. * @param z defines the scale factor on Z axis
  69642. * @returns the new matrix
  69643. */
  69644. static Scaling(x: number, y: number, z: number): Matrix;
  69645. /**
  69646. * Creates a scaling matrix and stores it in a given matrix
  69647. * @param x defines the scale factor on X axis
  69648. * @param y defines the scale factor on Y axis
  69649. * @param z defines the scale factor on Z axis
  69650. * @param result defines the target matrix
  69651. */
  69652. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69653. /**
  69654. * Creates a translation matrix
  69655. * @param x defines the translation on X axis
  69656. * @param y defines the translation on Y axis
  69657. * @param z defines the translationon Z axis
  69658. * @returns the new matrix
  69659. */
  69660. static Translation(x: number, y: number, z: number): Matrix;
  69661. /**
  69662. * Creates a translation matrix and stores it in a given matrix
  69663. * @param x defines the translation on X axis
  69664. * @param y defines the translation on Y axis
  69665. * @param z defines the translationon Z axis
  69666. * @param result defines the target matrix
  69667. */
  69668. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69669. /**
  69670. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69671. * @param startValue defines the start value
  69672. * @param endValue defines the end value
  69673. * @param gradient defines the gradient factor
  69674. * @returns the new matrix
  69675. */
  69676. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69677. /**
  69678. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69679. * @param startValue defines the start value
  69680. * @param endValue defines the end value
  69681. * @param gradient defines the gradient factor
  69682. * @param result defines the Matrix object where to store data
  69683. */
  69684. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69685. /**
  69686. * Builds a new matrix whose values are computed by:
  69687. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69688. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69689. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69690. * @param startValue defines the first matrix
  69691. * @param endValue defines the second matrix
  69692. * @param gradient defines the gradient between the two matrices
  69693. * @returns the new matrix
  69694. */
  69695. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69696. /**
  69697. * Update a matrix to values which are computed by:
  69698. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69699. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69700. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69701. * @param startValue defines the first matrix
  69702. * @param endValue defines the second matrix
  69703. * @param gradient defines the gradient between the two matrices
  69704. * @param result defines the target matrix
  69705. */
  69706. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69707. /**
  69708. * 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"
  69709. * This function works in left handed mode
  69710. * @param eye defines the final position of the entity
  69711. * @param target defines where the entity should look at
  69712. * @param up defines the up vector for the entity
  69713. * @returns the new matrix
  69714. */
  69715. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69716. /**
  69717. * 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".
  69718. * This function works in left handed mode
  69719. * @param eye defines the final position of the entity
  69720. * @param target defines where the entity should look at
  69721. * @param up defines the up vector for the entity
  69722. * @param result defines the target matrix
  69723. */
  69724. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69725. /**
  69726. * 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"
  69727. * This function works in right handed mode
  69728. * @param eye defines the final position of the entity
  69729. * @param target defines where the entity should look at
  69730. * @param up defines the up vector for the entity
  69731. * @returns the new matrix
  69732. */
  69733. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69734. /**
  69735. * 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".
  69736. * This function works in right handed mode
  69737. * @param eye defines the final position of the entity
  69738. * @param target defines where the entity should look at
  69739. * @param up defines the up vector for the entity
  69740. * @param result defines the target matrix
  69741. */
  69742. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69743. /**
  69744. * Create a left-handed orthographic projection matrix
  69745. * @param width defines the viewport width
  69746. * @param height defines the viewport height
  69747. * @param znear defines the near clip plane
  69748. * @param zfar defines the far clip plane
  69749. * @returns a new matrix as a left-handed orthographic projection matrix
  69750. */
  69751. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69752. /**
  69753. * Store a left-handed orthographic projection to a given matrix
  69754. * @param width defines the viewport width
  69755. * @param height defines the viewport height
  69756. * @param znear defines the near clip plane
  69757. * @param zfar defines the far clip plane
  69758. * @param result defines the target matrix
  69759. */
  69760. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69761. /**
  69762. * Create a left-handed orthographic projection matrix
  69763. * @param left defines the viewport left coordinate
  69764. * @param right defines the viewport right coordinate
  69765. * @param bottom defines the viewport bottom coordinate
  69766. * @param top defines the viewport top coordinate
  69767. * @param znear defines the near clip plane
  69768. * @param zfar defines the far clip plane
  69769. * @returns a new matrix as a left-handed orthographic projection matrix
  69770. */
  69771. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69772. /**
  69773. * Stores a left-handed orthographic projection into a given matrix
  69774. * @param left defines the viewport left coordinate
  69775. * @param right defines the viewport right coordinate
  69776. * @param bottom defines the viewport bottom coordinate
  69777. * @param top defines the viewport top coordinate
  69778. * @param znear defines the near clip plane
  69779. * @param zfar defines the far clip plane
  69780. * @param result defines the target matrix
  69781. */
  69782. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69783. /**
  69784. * Creates a right-handed orthographic projection matrix
  69785. * @param left defines the viewport left coordinate
  69786. * @param right defines the viewport right coordinate
  69787. * @param bottom defines the viewport bottom coordinate
  69788. * @param top defines the viewport top coordinate
  69789. * @param znear defines the near clip plane
  69790. * @param zfar defines the far clip plane
  69791. * @returns a new matrix as a right-handed orthographic projection matrix
  69792. */
  69793. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69794. /**
  69795. * Stores a right-handed orthographic projection into a given matrix
  69796. * @param left defines the viewport left coordinate
  69797. * @param right defines the viewport right coordinate
  69798. * @param bottom defines the viewport bottom coordinate
  69799. * @param top defines the viewport top coordinate
  69800. * @param znear defines the near clip plane
  69801. * @param zfar defines the far clip plane
  69802. * @param result defines the target matrix
  69803. */
  69804. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69805. /**
  69806. * Creates a left-handed perspective projection matrix
  69807. * @param width defines the viewport width
  69808. * @param height defines the viewport height
  69809. * @param znear defines the near clip plane
  69810. * @param zfar defines the far clip plane
  69811. * @returns a new matrix as a left-handed perspective projection matrix
  69812. */
  69813. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69814. /**
  69815. * Creates a left-handed perspective projection matrix
  69816. * @param fov defines the horizontal field of view
  69817. * @param aspect defines the aspect ratio
  69818. * @param znear defines the near clip plane
  69819. * @param zfar defines the far clip plane
  69820. * @returns a new matrix as a left-handed perspective projection matrix
  69821. */
  69822. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69823. /**
  69824. * Stores a left-handed perspective projection into a given matrix
  69825. * @param fov defines the horizontal field of view
  69826. * @param aspect defines the aspect ratio
  69827. * @param znear defines the near clip plane
  69828. * @param zfar defines the far clip plane
  69829. * @param result defines the target matrix
  69830. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69831. */
  69832. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69833. /**
  69834. * Creates a right-handed perspective projection matrix
  69835. * @param fov defines the horizontal field of view
  69836. * @param aspect defines the aspect ratio
  69837. * @param znear defines the near clip plane
  69838. * @param zfar defines the far clip plane
  69839. * @returns a new matrix as a right-handed perspective projection matrix
  69840. */
  69841. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69842. /**
  69843. * Stores a right-handed perspective projection into a given matrix
  69844. * @param fov defines the horizontal field of view
  69845. * @param aspect defines the aspect ratio
  69846. * @param znear defines the near clip plane
  69847. * @param zfar defines the far clip plane
  69848. * @param result defines the target matrix
  69849. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69850. */
  69851. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69852. /**
  69853. * Stores a perspective projection for WebVR info a given matrix
  69854. * @param fov defines the field of view
  69855. * @param znear defines the near clip plane
  69856. * @param zfar defines the far clip plane
  69857. * @param result defines the target matrix
  69858. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69859. */
  69860. static PerspectiveFovWebVRToRef(fov: {
  69861. upDegrees: number;
  69862. downDegrees: number;
  69863. leftDegrees: number;
  69864. rightDegrees: number;
  69865. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69866. /**
  69867. * Computes a complete transformation matrix
  69868. * @param viewport defines the viewport to use
  69869. * @param world defines the world matrix
  69870. * @param view defines the view matrix
  69871. * @param projection defines the projection matrix
  69872. * @param zmin defines the near clip plane
  69873. * @param zmax defines the far clip plane
  69874. * @returns the transformation matrix
  69875. */
  69876. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69877. /**
  69878. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69879. * @param matrix defines the matrix to use
  69880. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69881. */
  69882. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69883. /**
  69884. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69885. * @param matrix defines the matrix to use
  69886. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69887. */
  69888. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69889. /**
  69890. * Compute the transpose of a given matrix
  69891. * @param matrix defines the matrix to transpose
  69892. * @returns the new matrix
  69893. */
  69894. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69895. /**
  69896. * Compute the transpose of a matrix and store it in a target matrix
  69897. * @param matrix defines the matrix to transpose
  69898. * @param result defines the target matrix
  69899. */
  69900. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69901. /**
  69902. * Computes a reflection matrix from a plane
  69903. * @param plane defines the reflection plane
  69904. * @returns a new matrix
  69905. */
  69906. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69907. /**
  69908. * Computes a reflection matrix from a plane
  69909. * @param plane defines the reflection plane
  69910. * @param result defines the target matrix
  69911. */
  69912. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69913. /**
  69914. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69915. * @param xaxis defines the value of the 1st axis
  69916. * @param yaxis defines the value of the 2nd axis
  69917. * @param zaxis defines the value of the 3rd axis
  69918. * @param result defines the target matrix
  69919. */
  69920. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69921. /**
  69922. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69923. * @param quat defines the quaternion to use
  69924. * @param result defines the target matrix
  69925. */
  69926. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69927. }
  69928. /**
  69929. * @hidden
  69930. */
  69931. export class TmpVectors {
  69932. static Vector2: Vector2[];
  69933. static Vector3: Vector3[];
  69934. static Vector4: Vector4[];
  69935. static Quaternion: Quaternion[];
  69936. static Matrix: Matrix[];
  69937. }
  69938. }
  69939. declare module BABYLON {
  69940. /** Defines the cross module used constants to avoid circular dependncies */
  69941. export class Constants {
  69942. /** Defines that alpha blending is disabled */
  69943. static readonly ALPHA_DISABLE: number;
  69944. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69945. static readonly ALPHA_ADD: number;
  69946. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69947. static readonly ALPHA_COMBINE: number;
  69948. /** Defines that alpha blending to DEST - SRC * DEST */
  69949. static readonly ALPHA_SUBTRACT: number;
  69950. /** Defines that alpha blending to SRC * DEST */
  69951. static readonly ALPHA_MULTIPLY: number;
  69952. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69953. static readonly ALPHA_MAXIMIZED: number;
  69954. /** Defines that alpha blending to SRC + DEST */
  69955. static readonly ALPHA_ONEONE: number;
  69956. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69957. static readonly ALPHA_PREMULTIPLIED: number;
  69958. /**
  69959. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69960. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69961. */
  69962. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69963. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69964. static readonly ALPHA_INTERPOLATE: number;
  69965. /**
  69966. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69967. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69968. */
  69969. static readonly ALPHA_SCREENMODE: number;
  69970. /**
  69971. * Defines that alpha blending to SRC + DST
  69972. * Alpha will be set to SRC ALPHA + DST ALPHA
  69973. */
  69974. static readonly ALPHA_ONEONE_ONEONE: number;
  69975. /**
  69976. * Defines that alpha blending to SRC * DST ALPHA + DST
  69977. * Alpha will be set to 0
  69978. */
  69979. static readonly ALPHA_ALPHATOCOLOR: number;
  69980. /**
  69981. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69982. */
  69983. static readonly ALPHA_REVERSEONEMINUS: number;
  69984. /**
  69985. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69986. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69987. */
  69988. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69989. /**
  69990. * Defines that alpha blending to SRC + DST
  69991. * Alpha will be set to SRC ALPHA
  69992. */
  69993. static readonly ALPHA_ONEONE_ONEZERO: number;
  69994. /** Defines that alpha blending equation a SUM */
  69995. static readonly ALPHA_EQUATION_ADD: number;
  69996. /** Defines that alpha blending equation a SUBSTRACTION */
  69997. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69998. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69999. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70000. /** Defines that alpha blending equation a MAX operation */
  70001. static readonly ALPHA_EQUATION_MAX: number;
  70002. /** Defines that alpha blending equation a MIN operation */
  70003. static readonly ALPHA_EQUATION_MIN: number;
  70004. /**
  70005. * Defines that alpha blending equation a DARKEN operation:
  70006. * It takes the min of the src and sums the alpha channels.
  70007. */
  70008. static readonly ALPHA_EQUATION_DARKEN: number;
  70009. /** Defines that the ressource is not delayed*/
  70010. static readonly DELAYLOADSTATE_NONE: number;
  70011. /** Defines that the ressource was successfully delay loaded */
  70012. static readonly DELAYLOADSTATE_LOADED: number;
  70013. /** Defines that the ressource is currently delay loading */
  70014. static readonly DELAYLOADSTATE_LOADING: number;
  70015. /** Defines that the ressource is delayed and has not started loading */
  70016. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70018. static readonly NEVER: number;
  70019. /** 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 */
  70020. static readonly ALWAYS: number;
  70021. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70022. static readonly LESS: number;
  70023. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70024. static readonly EQUAL: number;
  70025. /** 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 */
  70026. static readonly LEQUAL: number;
  70027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70028. static readonly GREATER: number;
  70029. /** 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 */
  70030. static readonly GEQUAL: number;
  70031. /** 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 */
  70032. static readonly NOTEQUAL: number;
  70033. /** Passed to stencilOperation to specify that stencil value must be kept */
  70034. static readonly KEEP: number;
  70035. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70036. static readonly REPLACE: number;
  70037. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70038. static readonly INCR: number;
  70039. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70040. static readonly DECR: number;
  70041. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70042. static readonly INVERT: number;
  70043. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70044. static readonly INCR_WRAP: number;
  70045. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70046. static readonly DECR_WRAP: number;
  70047. /** Texture is not repeating outside of 0..1 UVs */
  70048. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70049. /** Texture is repeating outside of 0..1 UVs */
  70050. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70051. /** Texture is repeating and mirrored */
  70052. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70053. /** ALPHA */
  70054. static readonly TEXTUREFORMAT_ALPHA: number;
  70055. /** LUMINANCE */
  70056. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70057. /** LUMINANCE_ALPHA */
  70058. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70059. /** RGB */
  70060. static readonly TEXTUREFORMAT_RGB: number;
  70061. /** RGBA */
  70062. static readonly TEXTUREFORMAT_RGBA: number;
  70063. /** RED */
  70064. static readonly TEXTUREFORMAT_RED: number;
  70065. /** RED (2nd reference) */
  70066. static readonly TEXTUREFORMAT_R: number;
  70067. /** RG */
  70068. static readonly TEXTUREFORMAT_RG: number;
  70069. /** RED_INTEGER */
  70070. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70071. /** RED_INTEGER (2nd reference) */
  70072. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70073. /** RG_INTEGER */
  70074. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70075. /** RGB_INTEGER */
  70076. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70077. /** RGBA_INTEGER */
  70078. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70079. /** UNSIGNED_BYTE */
  70080. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70081. /** UNSIGNED_BYTE (2nd reference) */
  70082. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70083. /** FLOAT */
  70084. static readonly TEXTURETYPE_FLOAT: number;
  70085. /** HALF_FLOAT */
  70086. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70087. /** BYTE */
  70088. static readonly TEXTURETYPE_BYTE: number;
  70089. /** SHORT */
  70090. static readonly TEXTURETYPE_SHORT: number;
  70091. /** UNSIGNED_SHORT */
  70092. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70093. /** INT */
  70094. static readonly TEXTURETYPE_INT: number;
  70095. /** UNSIGNED_INT */
  70096. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70097. /** UNSIGNED_SHORT_4_4_4_4 */
  70098. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70099. /** UNSIGNED_SHORT_5_5_5_1 */
  70100. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70101. /** UNSIGNED_SHORT_5_6_5 */
  70102. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70103. /** UNSIGNED_INT_2_10_10_10_REV */
  70104. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70105. /** UNSIGNED_INT_24_8 */
  70106. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70107. /** UNSIGNED_INT_10F_11F_11F_REV */
  70108. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70109. /** UNSIGNED_INT_5_9_9_9_REV */
  70110. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70111. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70112. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70113. /** nearest is mag = nearest and min = nearest and mip = linear */
  70114. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70115. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70116. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70117. /** Trilinear is mag = linear and min = linear and mip = linear */
  70118. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70119. /** nearest is mag = nearest and min = nearest and mip = linear */
  70120. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70122. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70123. /** Trilinear is mag = linear and min = linear and mip = linear */
  70124. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70125. /** mag = nearest and min = nearest and mip = nearest */
  70126. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70127. /** mag = nearest and min = linear and mip = nearest */
  70128. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70129. /** mag = nearest and min = linear and mip = linear */
  70130. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70131. /** mag = nearest and min = linear and mip = none */
  70132. static readonly TEXTURE_NEAREST_LINEAR: number;
  70133. /** mag = nearest and min = nearest and mip = none */
  70134. static readonly TEXTURE_NEAREST_NEAREST: number;
  70135. /** mag = linear and min = nearest and mip = nearest */
  70136. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70137. /** mag = linear and min = nearest and mip = linear */
  70138. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70139. /** mag = linear and min = linear and mip = none */
  70140. static readonly TEXTURE_LINEAR_LINEAR: number;
  70141. /** mag = linear and min = nearest and mip = none */
  70142. static readonly TEXTURE_LINEAR_NEAREST: number;
  70143. /** Explicit coordinates mode */
  70144. static readonly TEXTURE_EXPLICIT_MODE: number;
  70145. /** Spherical coordinates mode */
  70146. static readonly TEXTURE_SPHERICAL_MODE: number;
  70147. /** Planar coordinates mode */
  70148. static readonly TEXTURE_PLANAR_MODE: number;
  70149. /** Cubic coordinates mode */
  70150. static readonly TEXTURE_CUBIC_MODE: number;
  70151. /** Projection coordinates mode */
  70152. static readonly TEXTURE_PROJECTION_MODE: number;
  70153. /** Skybox coordinates mode */
  70154. static readonly TEXTURE_SKYBOX_MODE: number;
  70155. /** Inverse Cubic coordinates mode */
  70156. static readonly TEXTURE_INVCUBIC_MODE: number;
  70157. /** Equirectangular coordinates mode */
  70158. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70159. /** Equirectangular Fixed coordinates mode */
  70160. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70161. /** Equirectangular Fixed Mirrored coordinates mode */
  70162. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70163. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70164. static readonly SCALEMODE_FLOOR: number;
  70165. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70166. static readonly SCALEMODE_NEAREST: number;
  70167. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70168. static readonly SCALEMODE_CEILING: number;
  70169. /**
  70170. * The dirty texture flag value
  70171. */
  70172. static readonly MATERIAL_TextureDirtyFlag: number;
  70173. /**
  70174. * The dirty light flag value
  70175. */
  70176. static readonly MATERIAL_LightDirtyFlag: number;
  70177. /**
  70178. * The dirty fresnel flag value
  70179. */
  70180. static readonly MATERIAL_FresnelDirtyFlag: number;
  70181. /**
  70182. * The dirty attribute flag value
  70183. */
  70184. static readonly MATERIAL_AttributesDirtyFlag: number;
  70185. /**
  70186. * The dirty misc flag value
  70187. */
  70188. static readonly MATERIAL_MiscDirtyFlag: number;
  70189. /**
  70190. * The all dirty flag value
  70191. */
  70192. static readonly MATERIAL_AllDirtyFlag: number;
  70193. /**
  70194. * Returns the triangle fill mode
  70195. */
  70196. static readonly MATERIAL_TriangleFillMode: number;
  70197. /**
  70198. * Returns the wireframe mode
  70199. */
  70200. static readonly MATERIAL_WireFrameFillMode: number;
  70201. /**
  70202. * Returns the point fill mode
  70203. */
  70204. static readonly MATERIAL_PointFillMode: number;
  70205. /**
  70206. * Returns the point list draw mode
  70207. */
  70208. static readonly MATERIAL_PointListDrawMode: number;
  70209. /**
  70210. * Returns the line list draw mode
  70211. */
  70212. static readonly MATERIAL_LineListDrawMode: number;
  70213. /**
  70214. * Returns the line loop draw mode
  70215. */
  70216. static readonly MATERIAL_LineLoopDrawMode: number;
  70217. /**
  70218. * Returns the line strip draw mode
  70219. */
  70220. static readonly MATERIAL_LineStripDrawMode: number;
  70221. /**
  70222. * Returns the triangle strip draw mode
  70223. */
  70224. static readonly MATERIAL_TriangleStripDrawMode: number;
  70225. /**
  70226. * Returns the triangle fan draw mode
  70227. */
  70228. static readonly MATERIAL_TriangleFanDrawMode: number;
  70229. /**
  70230. * Stores the clock-wise side orientation
  70231. */
  70232. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70233. /**
  70234. * Stores the counter clock-wise side orientation
  70235. */
  70236. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70237. /**
  70238. * Nothing
  70239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70240. */
  70241. static readonly ACTION_NothingTrigger: number;
  70242. /**
  70243. * On pick
  70244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70245. */
  70246. static readonly ACTION_OnPickTrigger: number;
  70247. /**
  70248. * On left pick
  70249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70250. */
  70251. static readonly ACTION_OnLeftPickTrigger: number;
  70252. /**
  70253. * On right pick
  70254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70255. */
  70256. static readonly ACTION_OnRightPickTrigger: number;
  70257. /**
  70258. * On center pick
  70259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70260. */
  70261. static readonly ACTION_OnCenterPickTrigger: number;
  70262. /**
  70263. * On pick down
  70264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70265. */
  70266. static readonly ACTION_OnPickDownTrigger: number;
  70267. /**
  70268. * On double pick
  70269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70270. */
  70271. static readonly ACTION_OnDoublePickTrigger: number;
  70272. /**
  70273. * On pick up
  70274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70275. */
  70276. static readonly ACTION_OnPickUpTrigger: number;
  70277. /**
  70278. * On pick out.
  70279. * This trigger will only be raised if you also declared a OnPickDown
  70280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70281. */
  70282. static readonly ACTION_OnPickOutTrigger: number;
  70283. /**
  70284. * On long press
  70285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70286. */
  70287. static readonly ACTION_OnLongPressTrigger: number;
  70288. /**
  70289. * On pointer over
  70290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70291. */
  70292. static readonly ACTION_OnPointerOverTrigger: number;
  70293. /**
  70294. * On pointer out
  70295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70296. */
  70297. static readonly ACTION_OnPointerOutTrigger: number;
  70298. /**
  70299. * On every frame
  70300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70301. */
  70302. static readonly ACTION_OnEveryFrameTrigger: number;
  70303. /**
  70304. * On intersection enter
  70305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70306. */
  70307. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70308. /**
  70309. * On intersection exit
  70310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70311. */
  70312. static readonly ACTION_OnIntersectionExitTrigger: number;
  70313. /**
  70314. * On key down
  70315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70316. */
  70317. static readonly ACTION_OnKeyDownTrigger: number;
  70318. /**
  70319. * On key up
  70320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70321. */
  70322. static readonly ACTION_OnKeyUpTrigger: number;
  70323. /**
  70324. * Billboard mode will only apply to Y axis
  70325. */
  70326. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70327. /**
  70328. * Billboard mode will apply to all axes
  70329. */
  70330. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70331. /**
  70332. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70333. */
  70334. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70335. /**
  70336. * Gets or sets base Assets URL
  70337. */
  70338. static PARTICLES_BaseAssetsUrl: string;
  70339. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70340. * Test order :
  70341. * Is the bounding sphere outside the frustum ?
  70342. * If not, are the bounding box vertices outside the frustum ?
  70343. * It not, then the cullable object is in the frustum.
  70344. */
  70345. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70346. /** Culling strategy : Bounding Sphere Only.
  70347. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70348. * It's also less accurate than the standard because some not visible objects can still be selected.
  70349. * Test : is the bounding sphere outside the frustum ?
  70350. * If not, then the cullable object is in the frustum.
  70351. */
  70352. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70353. /** Culling strategy : Optimistic Inclusion.
  70354. * This in an inclusion test first, then the standard exclusion test.
  70355. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70356. * 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.
  70357. * Anyway, it's as accurate as the standard strategy.
  70358. * Test :
  70359. * Is the cullable object bounding sphere center in the frustum ?
  70360. * If not, apply the default culling strategy.
  70361. */
  70362. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70363. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70364. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70365. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70366. * 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.
  70367. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70368. * Test :
  70369. * Is the cullable object bounding sphere center in the frustum ?
  70370. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70371. */
  70372. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70373. /**
  70374. * No logging while loading
  70375. */
  70376. static readonly SCENELOADER_NO_LOGGING: number;
  70377. /**
  70378. * Minimal logging while loading
  70379. */
  70380. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70381. /**
  70382. * Summary logging while loading
  70383. */
  70384. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70385. /**
  70386. * Detailled logging while loading
  70387. */
  70388. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70389. }
  70390. }
  70391. declare module BABYLON {
  70392. /**
  70393. * Class used to store and describe the pipeline context associated with an effect
  70394. */
  70395. export interface IPipelineContext {
  70396. /**
  70397. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70398. */
  70399. isAsync: boolean;
  70400. /**
  70401. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70402. */
  70403. isReady: boolean;
  70404. /** @hidden */
  70405. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70406. }
  70407. }
  70408. declare module BABYLON {
  70409. /** @hidden */
  70410. export interface IShaderProcessor {
  70411. attributeProcessor?: (attribute: string) => string;
  70412. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70413. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70414. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70415. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70416. lineProcessor?: (line: string, isFragment: boolean) => string;
  70417. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70418. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70419. }
  70420. }
  70421. declare module BABYLON {
  70422. /** @hidden */
  70423. export interface ProcessingOptions {
  70424. defines: string[];
  70425. indexParameters: any;
  70426. isFragment: boolean;
  70427. shouldUseHighPrecisionShader: boolean;
  70428. supportsUniformBuffers: boolean;
  70429. shadersRepository: string;
  70430. includesShadersStore: {
  70431. [key: string]: string;
  70432. };
  70433. processor?: IShaderProcessor;
  70434. version: string;
  70435. platformName: string;
  70436. lookForClosingBracketForUniformBuffer?: boolean;
  70437. }
  70438. }
  70439. declare module BABYLON {
  70440. /**
  70441. * Helper to manipulate strings
  70442. */
  70443. export class StringTools {
  70444. /**
  70445. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70446. * @param str Source string
  70447. * @param suffix Suffix to search for in the source string
  70448. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70449. */
  70450. static EndsWith(str: string, suffix: string): boolean;
  70451. /**
  70452. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70453. * @param str Source string
  70454. * @param suffix Suffix to search for in the source string
  70455. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70456. */
  70457. static StartsWith(str: string, suffix: string): boolean;
  70458. }
  70459. }
  70460. declare module BABYLON {
  70461. /** @hidden */
  70462. export class ShaderCodeNode {
  70463. line: string;
  70464. children: ShaderCodeNode[];
  70465. additionalDefineKey?: string;
  70466. additionalDefineValue?: string;
  70467. isValid(preprocessors: {
  70468. [key: string]: string;
  70469. }): boolean;
  70470. process(preprocessors: {
  70471. [key: string]: string;
  70472. }, options: ProcessingOptions): string;
  70473. }
  70474. }
  70475. declare module BABYLON {
  70476. /** @hidden */
  70477. export class ShaderCodeCursor {
  70478. private _lines;
  70479. lineIndex: number;
  70480. readonly currentLine: string;
  70481. readonly canRead: boolean;
  70482. lines: string[];
  70483. }
  70484. }
  70485. declare module BABYLON {
  70486. /** @hidden */
  70487. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70488. process(preprocessors: {
  70489. [key: string]: string;
  70490. }, options: ProcessingOptions): string;
  70491. }
  70492. }
  70493. declare module BABYLON {
  70494. /** @hidden */
  70495. export class ShaderDefineExpression {
  70496. isTrue(preprocessors: {
  70497. [key: string]: string;
  70498. }): boolean;
  70499. }
  70500. }
  70501. declare module BABYLON {
  70502. /** @hidden */
  70503. export class ShaderCodeTestNode extends ShaderCodeNode {
  70504. testExpression: ShaderDefineExpression;
  70505. isValid(preprocessors: {
  70506. [key: string]: string;
  70507. }): boolean;
  70508. }
  70509. }
  70510. declare module BABYLON {
  70511. /** @hidden */
  70512. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70513. define: string;
  70514. not: boolean;
  70515. constructor(define: string, not?: boolean);
  70516. isTrue(preprocessors: {
  70517. [key: string]: string;
  70518. }): boolean;
  70519. }
  70520. }
  70521. declare module BABYLON {
  70522. /** @hidden */
  70523. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70524. leftOperand: ShaderDefineExpression;
  70525. rightOperand: ShaderDefineExpression;
  70526. isTrue(preprocessors: {
  70527. [key: string]: string;
  70528. }): boolean;
  70529. }
  70530. }
  70531. declare module BABYLON {
  70532. /** @hidden */
  70533. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70534. leftOperand: ShaderDefineExpression;
  70535. rightOperand: ShaderDefineExpression;
  70536. isTrue(preprocessors: {
  70537. [key: string]: string;
  70538. }): boolean;
  70539. }
  70540. }
  70541. declare module BABYLON {
  70542. /** @hidden */
  70543. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70544. define: string;
  70545. operand: string;
  70546. testValue: string;
  70547. constructor(define: string, operand: string, testValue: string);
  70548. isTrue(preprocessors: {
  70549. [key: string]: string;
  70550. }): boolean;
  70551. }
  70552. }
  70553. declare module BABYLON {
  70554. /**
  70555. * @ignore
  70556. * Application error to support additional information when loading a file
  70557. */
  70558. export class LoadFileError extends Error {
  70559. /** defines the optional web request */
  70560. request?: WebRequest | undefined;
  70561. private static _setPrototypeOf;
  70562. /**
  70563. * Creates a new LoadFileError
  70564. * @param message defines the message of the error
  70565. * @param request defines the optional web request
  70566. */
  70567. constructor(message: string,
  70568. /** defines the optional web request */
  70569. request?: WebRequest | undefined);
  70570. }
  70571. }
  70572. declare module BABYLON {
  70573. /**
  70574. * Class used to enable access to offline support
  70575. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70576. */
  70577. export interface IOfflineProvider {
  70578. /**
  70579. * Gets a boolean indicating if scene must be saved in the database
  70580. */
  70581. enableSceneOffline: boolean;
  70582. /**
  70583. * Gets a boolean indicating if textures must be saved in the database
  70584. */
  70585. enableTexturesOffline: boolean;
  70586. /**
  70587. * Open the offline support and make it available
  70588. * @param successCallback defines the callback to call on success
  70589. * @param errorCallback defines the callback to call on error
  70590. */
  70591. open(successCallback: () => void, errorCallback: () => void): void;
  70592. /**
  70593. * Loads an image from the offline support
  70594. * @param url defines the url to load from
  70595. * @param image defines the target DOM image
  70596. */
  70597. loadImage(url: string, image: HTMLImageElement): void;
  70598. /**
  70599. * Loads a file from offline support
  70600. * @param url defines the URL to load from
  70601. * @param sceneLoaded defines a callback to call on success
  70602. * @param progressCallBack defines a callback to call when progress changed
  70603. * @param errorCallback defines a callback to call on error
  70604. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70605. */
  70606. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70607. }
  70608. }
  70609. declare module BABYLON {
  70610. /**
  70611. * Class used to help managing file picking and drag'n'drop
  70612. * File Storage
  70613. */
  70614. export class FilesInputStore {
  70615. /**
  70616. * List of files ready to be loaded
  70617. */
  70618. static FilesToLoad: {
  70619. [key: string]: File;
  70620. };
  70621. }
  70622. }
  70623. declare module BABYLON {
  70624. /**
  70625. * Class used to define a retry strategy when error happens while loading assets
  70626. */
  70627. export class RetryStrategy {
  70628. /**
  70629. * Function used to defines an exponential back off strategy
  70630. * @param maxRetries defines the maximum number of retries (3 by default)
  70631. * @param baseInterval defines the interval between retries
  70632. * @returns the strategy function to use
  70633. */
  70634. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70635. }
  70636. }
  70637. declare module BABYLON {
  70638. /**
  70639. * @hidden
  70640. */
  70641. export class FileTools {
  70642. /**
  70643. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70644. */
  70645. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70646. /**
  70647. * Gets or sets the base URL to use to load assets
  70648. */
  70649. static BaseUrl: string;
  70650. /**
  70651. * Default behaviour for cors in the application.
  70652. * It can be a string if the expected behavior is identical in the entire app.
  70653. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70654. */
  70655. static CorsBehavior: string | ((url: string | string[]) => string);
  70656. /**
  70657. * Gets or sets a function used to pre-process url before using them to load assets
  70658. */
  70659. static PreprocessUrl: (url: string) => string;
  70660. /**
  70661. * Removes unwanted characters from an url
  70662. * @param url defines the url to clean
  70663. * @returns the cleaned url
  70664. */
  70665. private static _CleanUrl;
  70666. /**
  70667. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70668. * @param url define the url we are trying
  70669. * @param element define the dom element where to configure the cors policy
  70670. */
  70671. static SetCorsBehavior(url: string | string[], element: {
  70672. crossOrigin: string | null;
  70673. }): void;
  70674. /**
  70675. * Loads an image as an HTMLImageElement.
  70676. * @param input url string, ArrayBuffer, or Blob to load
  70677. * @param onLoad callback called when the image successfully loads
  70678. * @param onError callback called when the image fails to load
  70679. * @param offlineProvider offline provider for caching
  70680. * @returns the HTMLImageElement of the loaded image
  70681. */
  70682. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70683. /**
  70684. * Loads a file
  70685. * @param fileToLoad defines the file to load
  70686. * @param callback defines the callback to call when data is loaded
  70687. * @param progressCallBack defines the callback to call during loading process
  70688. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70689. * @returns a file request object
  70690. */
  70691. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70692. /**
  70693. * Loads a file
  70694. * @param url url string, ArrayBuffer, or Blob to load
  70695. * @param onSuccess callback called when the file successfully loads
  70696. * @param onProgress callback called while file is loading (if the server supports this mode)
  70697. * @param offlineProvider defines the offline provider for caching
  70698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70699. * @param onError callback called when the file fails to load
  70700. * @returns a file request object
  70701. */
  70702. 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;
  70703. /**
  70704. * Checks if the loaded document was accessed via `file:`-Protocol.
  70705. * @returns boolean
  70706. */
  70707. static IsFileURL(): boolean;
  70708. }
  70709. }
  70710. declare module BABYLON {
  70711. /** @hidden */
  70712. export class ShaderProcessor {
  70713. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70714. private static _ProcessPrecision;
  70715. private static _ExtractOperation;
  70716. private static _BuildSubExpression;
  70717. private static _BuildExpression;
  70718. private static _MoveCursorWithinIf;
  70719. private static _MoveCursor;
  70720. private static _EvaluatePreProcessors;
  70721. private static _PreparePreProcessors;
  70722. private static _ProcessShaderConversion;
  70723. private static _ProcessIncludes;
  70724. }
  70725. }
  70726. declare module BABYLON {
  70727. /**
  70728. * Class used to hold a RBG color
  70729. */
  70730. export class Color3 {
  70731. /**
  70732. * Defines the red component (between 0 and 1, default is 0)
  70733. */
  70734. r: number;
  70735. /**
  70736. * Defines the green component (between 0 and 1, default is 0)
  70737. */
  70738. g: number;
  70739. /**
  70740. * Defines the blue component (between 0 and 1, default is 0)
  70741. */
  70742. b: number;
  70743. /**
  70744. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70745. * @param r defines the red component (between 0 and 1, default is 0)
  70746. * @param g defines the green component (between 0 and 1, default is 0)
  70747. * @param b defines the blue component (between 0 and 1, default is 0)
  70748. */
  70749. constructor(
  70750. /**
  70751. * Defines the red component (between 0 and 1, default is 0)
  70752. */
  70753. r?: number,
  70754. /**
  70755. * Defines the green component (between 0 and 1, default is 0)
  70756. */
  70757. g?: number,
  70758. /**
  70759. * Defines the blue component (between 0 and 1, default is 0)
  70760. */
  70761. b?: number);
  70762. /**
  70763. * Creates a string with the Color3 current values
  70764. * @returns the string representation of the Color3 object
  70765. */
  70766. toString(): string;
  70767. /**
  70768. * Returns the string "Color3"
  70769. * @returns "Color3"
  70770. */
  70771. getClassName(): string;
  70772. /**
  70773. * Compute the Color3 hash code
  70774. * @returns an unique number that can be used to hash Color3 objects
  70775. */
  70776. getHashCode(): number;
  70777. /**
  70778. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70779. * @param array defines the array where to store the r,g,b components
  70780. * @param index defines an optional index in the target array to define where to start storing values
  70781. * @returns the current Color3 object
  70782. */
  70783. toArray(array: FloatArray, index?: number): Color3;
  70784. /**
  70785. * Returns a new Color4 object from the current Color3 and the given alpha
  70786. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70787. * @returns a new Color4 object
  70788. */
  70789. toColor4(alpha?: number): Color4;
  70790. /**
  70791. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70792. * @returns the new array
  70793. */
  70794. asArray(): number[];
  70795. /**
  70796. * Returns the luminance value
  70797. * @returns a float value
  70798. */
  70799. toLuminance(): number;
  70800. /**
  70801. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70802. * @param otherColor defines the second operand
  70803. * @returns the new Color3 object
  70804. */
  70805. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70806. /**
  70807. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70808. * @param otherColor defines the second operand
  70809. * @param result defines the Color3 object where to store the result
  70810. * @returns the current Color3
  70811. */
  70812. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70813. /**
  70814. * Determines equality between Color3 objects
  70815. * @param otherColor defines the second operand
  70816. * @returns true if the rgb values are equal to the given ones
  70817. */
  70818. equals(otherColor: DeepImmutable<Color3>): boolean;
  70819. /**
  70820. * Determines equality between the current Color3 object and a set of r,b,g values
  70821. * @param r defines the red component to check
  70822. * @param g defines the green component to check
  70823. * @param b defines the blue component to check
  70824. * @returns true if the rgb values are equal to the given ones
  70825. */
  70826. equalsFloats(r: number, g: number, b: number): boolean;
  70827. /**
  70828. * Multiplies in place each rgb value by scale
  70829. * @param scale defines the scaling factor
  70830. * @returns the updated Color3
  70831. */
  70832. scale(scale: number): Color3;
  70833. /**
  70834. * Multiplies the rgb values by scale and stores the result into "result"
  70835. * @param scale defines the scaling factor
  70836. * @param result defines the Color3 object where to store the result
  70837. * @returns the unmodified current Color3
  70838. */
  70839. scaleToRef(scale: number, result: Color3): Color3;
  70840. /**
  70841. * Scale the current Color3 values by a factor and add the result to a given Color3
  70842. * @param scale defines the scale factor
  70843. * @param result defines color to store the result into
  70844. * @returns the unmodified current Color3
  70845. */
  70846. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70847. /**
  70848. * Clamps the rgb values by the min and max values and stores the result into "result"
  70849. * @param min defines minimum clamping value (default is 0)
  70850. * @param max defines maximum clamping value (default is 1)
  70851. * @param result defines color to store the result into
  70852. * @returns the original Color3
  70853. */
  70854. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70855. /**
  70856. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70857. * @param otherColor defines the second operand
  70858. * @returns the new Color3
  70859. */
  70860. add(otherColor: DeepImmutable<Color3>): Color3;
  70861. /**
  70862. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70863. * @param otherColor defines the second operand
  70864. * @param result defines Color3 object to store the result into
  70865. * @returns the unmodified current Color3
  70866. */
  70867. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70868. /**
  70869. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70870. * @param otherColor defines the second operand
  70871. * @returns the new Color3
  70872. */
  70873. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70874. /**
  70875. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70876. * @param otherColor defines the second operand
  70877. * @param result defines Color3 object to store the result into
  70878. * @returns the unmodified current Color3
  70879. */
  70880. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70881. /**
  70882. * Copy the current object
  70883. * @returns a new Color3 copied the current one
  70884. */
  70885. clone(): Color3;
  70886. /**
  70887. * Copies the rgb values from the source in the current Color3
  70888. * @param source defines the source Color3 object
  70889. * @returns the updated Color3 object
  70890. */
  70891. copyFrom(source: DeepImmutable<Color3>): Color3;
  70892. /**
  70893. * Updates the Color3 rgb values from the given floats
  70894. * @param r defines the red component to read from
  70895. * @param g defines the green component to read from
  70896. * @param b defines the blue component to read from
  70897. * @returns the current Color3 object
  70898. */
  70899. copyFromFloats(r: number, g: number, b: number): Color3;
  70900. /**
  70901. * Updates the Color3 rgb values from the given floats
  70902. * @param r defines the red component to read from
  70903. * @param g defines the green component to read from
  70904. * @param b defines the blue component to read from
  70905. * @returns the current Color3 object
  70906. */
  70907. set(r: number, g: number, b: number): Color3;
  70908. /**
  70909. * Compute the Color3 hexadecimal code as a string
  70910. * @returns a string containing the hexadecimal representation of the Color3 object
  70911. */
  70912. toHexString(): string;
  70913. /**
  70914. * Computes a new Color3 converted from the current one to linear space
  70915. * @returns a new Color3 object
  70916. */
  70917. toLinearSpace(): Color3;
  70918. /**
  70919. * Converts current color in rgb space to HSV values
  70920. * @returns a new color3 representing the HSV values
  70921. */
  70922. toHSV(): Color3;
  70923. /**
  70924. * Converts current color in rgb space to HSV values
  70925. * @param result defines the Color3 where to store the HSV values
  70926. */
  70927. toHSVToRef(result: Color3): void;
  70928. /**
  70929. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70930. * @param convertedColor defines the Color3 object where to store the linear space version
  70931. * @returns the unmodified Color3
  70932. */
  70933. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70934. /**
  70935. * Computes a new Color3 converted from the current one to gamma space
  70936. * @returns a new Color3 object
  70937. */
  70938. toGammaSpace(): Color3;
  70939. /**
  70940. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70941. * @param convertedColor defines the Color3 object where to store the gamma space version
  70942. * @returns the unmodified Color3
  70943. */
  70944. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70945. private static _BlackReadOnly;
  70946. /**
  70947. * Convert Hue, saturation and value to a Color3 (RGB)
  70948. * @param hue defines the hue
  70949. * @param saturation defines the saturation
  70950. * @param value defines the value
  70951. * @param result defines the Color3 where to store the RGB values
  70952. */
  70953. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70954. /**
  70955. * Creates a new Color3 from the string containing valid hexadecimal values
  70956. * @param hex defines a string containing valid hexadecimal values
  70957. * @returns a new Color3 object
  70958. */
  70959. static FromHexString(hex: string): Color3;
  70960. /**
  70961. * Creates a new Color3 from the starting index of the given array
  70962. * @param array defines the source array
  70963. * @param offset defines an offset in the source array
  70964. * @returns a new Color3 object
  70965. */
  70966. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70967. /**
  70968. * Creates a new Color3 from integer values (< 256)
  70969. * @param r defines the red component to read from (value between 0 and 255)
  70970. * @param g defines the green component to read from (value between 0 and 255)
  70971. * @param b defines the blue component to read from (value between 0 and 255)
  70972. * @returns a new Color3 object
  70973. */
  70974. static FromInts(r: number, g: number, b: number): Color3;
  70975. /**
  70976. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70977. * @param start defines the start Color3 value
  70978. * @param end defines the end Color3 value
  70979. * @param amount defines the gradient value between start and end
  70980. * @returns a new Color3 object
  70981. */
  70982. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70983. /**
  70984. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70985. * @param left defines the start value
  70986. * @param right defines the end value
  70987. * @param amount defines the gradient factor
  70988. * @param result defines the Color3 object where to store the result
  70989. */
  70990. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70991. /**
  70992. * Returns a Color3 value containing a red color
  70993. * @returns a new Color3 object
  70994. */
  70995. static Red(): Color3;
  70996. /**
  70997. * Returns a Color3 value containing a green color
  70998. * @returns a new Color3 object
  70999. */
  71000. static Green(): Color3;
  71001. /**
  71002. * Returns a Color3 value containing a blue color
  71003. * @returns a new Color3 object
  71004. */
  71005. static Blue(): Color3;
  71006. /**
  71007. * Returns a Color3 value containing a black color
  71008. * @returns a new Color3 object
  71009. */
  71010. static Black(): Color3;
  71011. /**
  71012. * Gets a Color3 value containing a black color that must not be updated
  71013. */
  71014. static readonly BlackReadOnly: DeepImmutable<Color3>;
  71015. /**
  71016. * Returns a Color3 value containing a white color
  71017. * @returns a new Color3 object
  71018. */
  71019. static White(): Color3;
  71020. /**
  71021. * Returns a Color3 value containing a purple color
  71022. * @returns a new Color3 object
  71023. */
  71024. static Purple(): Color3;
  71025. /**
  71026. * Returns a Color3 value containing a magenta color
  71027. * @returns a new Color3 object
  71028. */
  71029. static Magenta(): Color3;
  71030. /**
  71031. * Returns a Color3 value containing a yellow color
  71032. * @returns a new Color3 object
  71033. */
  71034. static Yellow(): Color3;
  71035. /**
  71036. * Returns a Color3 value containing a gray color
  71037. * @returns a new Color3 object
  71038. */
  71039. static Gray(): Color3;
  71040. /**
  71041. * Returns a Color3 value containing a teal color
  71042. * @returns a new Color3 object
  71043. */
  71044. static Teal(): Color3;
  71045. /**
  71046. * Returns a Color3 value containing a random color
  71047. * @returns a new Color3 object
  71048. */
  71049. static Random(): Color3;
  71050. }
  71051. /**
  71052. * Class used to hold a RBGA color
  71053. */
  71054. export class Color4 {
  71055. /**
  71056. * Defines the red component (between 0 and 1, default is 0)
  71057. */
  71058. r: number;
  71059. /**
  71060. * Defines the green component (between 0 and 1, default is 0)
  71061. */
  71062. g: number;
  71063. /**
  71064. * Defines the blue component (between 0 and 1, default is 0)
  71065. */
  71066. b: number;
  71067. /**
  71068. * Defines the alpha component (between 0 and 1, default is 1)
  71069. */
  71070. a: number;
  71071. /**
  71072. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  71073. * @param r defines the red component (between 0 and 1, default is 0)
  71074. * @param g defines the green component (between 0 and 1, default is 0)
  71075. * @param b defines the blue component (between 0 and 1, default is 0)
  71076. * @param a defines the alpha component (between 0 and 1, default is 1)
  71077. */
  71078. constructor(
  71079. /**
  71080. * Defines the red component (between 0 and 1, default is 0)
  71081. */
  71082. r?: number,
  71083. /**
  71084. * Defines the green component (between 0 and 1, default is 0)
  71085. */
  71086. g?: number,
  71087. /**
  71088. * Defines the blue component (between 0 and 1, default is 0)
  71089. */
  71090. b?: number,
  71091. /**
  71092. * Defines the alpha component (between 0 and 1, default is 1)
  71093. */
  71094. a?: number);
  71095. /**
  71096. * Adds in place the given Color4 values to the current Color4 object
  71097. * @param right defines the second operand
  71098. * @returns the current updated Color4 object
  71099. */
  71100. addInPlace(right: DeepImmutable<Color4>): Color4;
  71101. /**
  71102. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  71103. * @returns the new array
  71104. */
  71105. asArray(): number[];
  71106. /**
  71107. * Stores from the starting index in the given array the Color4 successive values
  71108. * @param array defines the array where to store the r,g,b components
  71109. * @param index defines an optional index in the target array to define where to start storing values
  71110. * @returns the current Color4 object
  71111. */
  71112. toArray(array: number[], index?: number): Color4;
  71113. /**
  71114. * Determines equality between Color4 objects
  71115. * @param otherColor defines the second operand
  71116. * @returns true if the rgba values are equal to the given ones
  71117. */
  71118. equals(otherColor: DeepImmutable<Color4>): boolean;
  71119. /**
  71120. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  71121. * @param right defines the second operand
  71122. * @returns a new Color4 object
  71123. */
  71124. add(right: DeepImmutable<Color4>): Color4;
  71125. /**
  71126. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71127. * @param right defines the second operand
  71128. * @returns a new Color4 object
  71129. */
  71130. subtract(right: DeepImmutable<Color4>): Color4;
  71131. /**
  71132. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71133. * @param right defines the second operand
  71134. * @param result defines the Color4 object where to store the result
  71135. * @returns the current Color4 object
  71136. */
  71137. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  71138. /**
  71139. * Creates a new Color4 with the current Color4 values multiplied by scale
  71140. * @param scale defines the scaling factor to apply
  71141. * @returns a new Color4 object
  71142. */
  71143. scale(scale: number): Color4;
  71144. /**
  71145. * Multiplies the current Color4 values by scale and stores the result in "result"
  71146. * @param scale defines the scaling factor to apply
  71147. * @param result defines the Color4 object where to store the result
  71148. * @returns the current unmodified Color4
  71149. */
  71150. scaleToRef(scale: number, result: Color4): Color4;
  71151. /**
  71152. * Scale the current Color4 values by a factor and add the result to a given Color4
  71153. * @param scale defines the scale factor
  71154. * @param result defines the Color4 object where to store the result
  71155. * @returns the unmodified current Color4
  71156. */
  71157. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71158. /**
  71159. * Clamps the rgb values by the min and max values and stores the result into "result"
  71160. * @param min defines minimum clamping value (default is 0)
  71161. * @param max defines maximum clamping value (default is 1)
  71162. * @param result defines color to store the result into.
  71163. * @returns the cuurent Color4
  71164. */
  71165. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71166. /**
  71167. * Multipy an Color4 value by another and return a new Color4 object
  71168. * @param color defines the Color4 value to multiply by
  71169. * @returns a new Color4 object
  71170. */
  71171. multiply(color: Color4): Color4;
  71172. /**
  71173. * Multipy a Color4 value by another and push the result in a reference value
  71174. * @param color defines the Color4 value to multiply by
  71175. * @param result defines the Color4 to fill the result in
  71176. * @returns the result Color4
  71177. */
  71178. multiplyToRef(color: Color4, result: Color4): Color4;
  71179. /**
  71180. * Creates a string with the Color4 current values
  71181. * @returns the string representation of the Color4 object
  71182. */
  71183. toString(): string;
  71184. /**
  71185. * Returns the string "Color4"
  71186. * @returns "Color4"
  71187. */
  71188. getClassName(): string;
  71189. /**
  71190. * Compute the Color4 hash code
  71191. * @returns an unique number that can be used to hash Color4 objects
  71192. */
  71193. getHashCode(): number;
  71194. /**
  71195. * Creates a new Color4 copied from the current one
  71196. * @returns a new Color4 object
  71197. */
  71198. clone(): Color4;
  71199. /**
  71200. * Copies the given Color4 values into the current one
  71201. * @param source defines the source Color4 object
  71202. * @returns the current updated Color4 object
  71203. */
  71204. copyFrom(source: Color4): Color4;
  71205. /**
  71206. * Copies the given float values into the current one
  71207. * @param r defines the red component to read from
  71208. * @param g defines the green component to read from
  71209. * @param b defines the blue component to read from
  71210. * @param a defines the alpha component to read from
  71211. * @returns the current updated Color4 object
  71212. */
  71213. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71214. /**
  71215. * Copies the given float values into the current one
  71216. * @param r defines the red component to read from
  71217. * @param g defines the green component to read from
  71218. * @param b defines the blue component to read from
  71219. * @param a defines the alpha component to read from
  71220. * @returns the current updated Color4 object
  71221. */
  71222. set(r: number, g: number, b: number, a: number): Color4;
  71223. /**
  71224. * Compute the Color4 hexadecimal code as a string
  71225. * @returns a string containing the hexadecimal representation of the Color4 object
  71226. */
  71227. toHexString(): string;
  71228. /**
  71229. * Computes a new Color4 converted from the current one to linear space
  71230. * @returns a new Color4 object
  71231. */
  71232. toLinearSpace(): Color4;
  71233. /**
  71234. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71235. * @param convertedColor defines the Color4 object where to store the linear space version
  71236. * @returns the unmodified Color4
  71237. */
  71238. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71239. /**
  71240. * Computes a new Color4 converted from the current one to gamma space
  71241. * @returns a new Color4 object
  71242. */
  71243. toGammaSpace(): Color4;
  71244. /**
  71245. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71246. * @param convertedColor defines the Color4 object where to store the gamma space version
  71247. * @returns the unmodified Color4
  71248. */
  71249. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71250. /**
  71251. * Creates a new Color4 from the string containing valid hexadecimal values
  71252. * @param hex defines a string containing valid hexadecimal values
  71253. * @returns a new Color4 object
  71254. */
  71255. static FromHexString(hex: string): Color4;
  71256. /**
  71257. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71258. * @param left defines the start value
  71259. * @param right defines the end value
  71260. * @param amount defines the gradient factor
  71261. * @returns a new Color4 object
  71262. */
  71263. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71264. /**
  71265. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71266. * @param left defines the start value
  71267. * @param right defines the end value
  71268. * @param amount defines the gradient factor
  71269. * @param result defines the Color4 object where to store data
  71270. */
  71271. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71272. /**
  71273. * Creates a new Color4 from a Color3 and an alpha value
  71274. * @param color3 defines the source Color3 to read from
  71275. * @param alpha defines the alpha component (1.0 by default)
  71276. * @returns a new Color4 object
  71277. */
  71278. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71279. /**
  71280. * Creates a new Color4 from the starting index element of the given array
  71281. * @param array defines the source array to read from
  71282. * @param offset defines the offset in the source array
  71283. * @returns a new Color4 object
  71284. */
  71285. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71286. /**
  71287. * Creates a new Color3 from integer values (< 256)
  71288. * @param r defines the red component to read from (value between 0 and 255)
  71289. * @param g defines the green component to read from (value between 0 and 255)
  71290. * @param b defines the blue component to read from (value between 0 and 255)
  71291. * @param a defines the alpha component to read from (value between 0 and 255)
  71292. * @returns a new Color3 object
  71293. */
  71294. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71295. /**
  71296. * Check the content of a given array and convert it to an array containing RGBA data
  71297. * If the original array was already containing count * 4 values then it is returned directly
  71298. * @param colors defines the array to check
  71299. * @param count defines the number of RGBA data to expect
  71300. * @returns an array containing count * 4 values (RGBA)
  71301. */
  71302. static CheckColors4(colors: number[], count: number): number[];
  71303. }
  71304. /**
  71305. * @hidden
  71306. */
  71307. export class TmpColors {
  71308. static Color3: Color3[];
  71309. static Color4: Color4[];
  71310. }
  71311. }
  71312. declare module BABYLON {
  71313. /**
  71314. * Class representing spherical harmonics coefficients to the 3rd degree
  71315. */
  71316. export class SphericalHarmonics {
  71317. /**
  71318. * Defines whether or not the harmonics have been prescaled for rendering.
  71319. */
  71320. preScaled: boolean;
  71321. /**
  71322. * The l0,0 coefficients of the spherical harmonics
  71323. */
  71324. l00: Vector3;
  71325. /**
  71326. * The l1,-1 coefficients of the spherical harmonics
  71327. */
  71328. l1_1: Vector3;
  71329. /**
  71330. * The l1,0 coefficients of the spherical harmonics
  71331. */
  71332. l10: Vector3;
  71333. /**
  71334. * The l1,1 coefficients of the spherical harmonics
  71335. */
  71336. l11: Vector3;
  71337. /**
  71338. * The l2,-2 coefficients of the spherical harmonics
  71339. */
  71340. l2_2: Vector3;
  71341. /**
  71342. * The l2,-1 coefficients of the spherical harmonics
  71343. */
  71344. l2_1: Vector3;
  71345. /**
  71346. * The l2,0 coefficients of the spherical harmonics
  71347. */
  71348. l20: Vector3;
  71349. /**
  71350. * The l2,1 coefficients of the spherical harmonics
  71351. */
  71352. l21: Vector3;
  71353. /**
  71354. * The l2,2 coefficients of the spherical harmonics
  71355. */
  71356. l22: Vector3;
  71357. /**
  71358. * Adds a light to the spherical harmonics
  71359. * @param direction the direction of the light
  71360. * @param color the color of the light
  71361. * @param deltaSolidAngle the delta solid angle of the light
  71362. */
  71363. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71364. /**
  71365. * Scales the spherical harmonics by the given amount
  71366. * @param scale the amount to scale
  71367. */
  71368. scaleInPlace(scale: number): void;
  71369. /**
  71370. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71371. *
  71372. * ```
  71373. * E_lm = A_l * L_lm
  71374. * ```
  71375. *
  71376. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71377. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71378. * the scaling factors are given in equation 9.
  71379. */
  71380. convertIncidentRadianceToIrradiance(): void;
  71381. /**
  71382. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71383. *
  71384. * ```
  71385. * L = (1/pi) * E * rho
  71386. * ```
  71387. *
  71388. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71389. */
  71390. convertIrradianceToLambertianRadiance(): void;
  71391. /**
  71392. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71393. * required operations at run time.
  71394. *
  71395. * This is simply done by scaling back the SH with Ylm constants parameter.
  71396. * The trigonometric part being applied by the shader at run time.
  71397. */
  71398. preScaleForRendering(): void;
  71399. /**
  71400. * Constructs a spherical harmonics from an array.
  71401. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71402. * @returns the spherical harmonics
  71403. */
  71404. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71405. /**
  71406. * Gets the spherical harmonics from polynomial
  71407. * @param polynomial the spherical polynomial
  71408. * @returns the spherical harmonics
  71409. */
  71410. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71411. }
  71412. /**
  71413. * Class representing spherical polynomial coefficients to the 3rd degree
  71414. */
  71415. export class SphericalPolynomial {
  71416. private _harmonics;
  71417. /**
  71418. * The spherical harmonics used to create the polynomials.
  71419. */
  71420. readonly preScaledHarmonics: SphericalHarmonics;
  71421. /**
  71422. * The x coefficients of the spherical polynomial
  71423. */
  71424. x: Vector3;
  71425. /**
  71426. * The y coefficients of the spherical polynomial
  71427. */
  71428. y: Vector3;
  71429. /**
  71430. * The z coefficients of the spherical polynomial
  71431. */
  71432. z: Vector3;
  71433. /**
  71434. * The xx coefficients of the spherical polynomial
  71435. */
  71436. xx: Vector3;
  71437. /**
  71438. * The yy coefficients of the spherical polynomial
  71439. */
  71440. yy: Vector3;
  71441. /**
  71442. * The zz coefficients of the spherical polynomial
  71443. */
  71444. zz: Vector3;
  71445. /**
  71446. * The xy coefficients of the spherical polynomial
  71447. */
  71448. xy: Vector3;
  71449. /**
  71450. * The yz coefficients of the spherical polynomial
  71451. */
  71452. yz: Vector3;
  71453. /**
  71454. * The zx coefficients of the spherical polynomial
  71455. */
  71456. zx: Vector3;
  71457. /**
  71458. * Adds an ambient color to the spherical polynomial
  71459. * @param color the color to add
  71460. */
  71461. addAmbient(color: Color3): void;
  71462. /**
  71463. * Scales the spherical polynomial by the given amount
  71464. * @param scale the amount to scale
  71465. */
  71466. scaleInPlace(scale: number): void;
  71467. /**
  71468. * Gets the spherical polynomial from harmonics
  71469. * @param harmonics the spherical harmonics
  71470. * @returns the spherical polynomial
  71471. */
  71472. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71473. /**
  71474. * Constructs a spherical polynomial from an array.
  71475. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71476. * @returns the spherical polynomial
  71477. */
  71478. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71479. }
  71480. }
  71481. declare module BABYLON {
  71482. /**
  71483. * Define options used to create a render target texture
  71484. */
  71485. export class RenderTargetCreationOptions {
  71486. /**
  71487. * Specifies is mipmaps must be generated
  71488. */
  71489. generateMipMaps?: boolean;
  71490. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71491. generateDepthBuffer?: boolean;
  71492. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71493. generateStencilBuffer?: boolean;
  71494. /** Defines texture type (int by default) */
  71495. type?: number;
  71496. /** Defines sampling mode (trilinear by default) */
  71497. samplingMode?: number;
  71498. /** Defines format (RGBA by default) */
  71499. format?: number;
  71500. }
  71501. }
  71502. declare module BABYLON {
  71503. /**
  71504. * @hidden
  71505. **/
  71506. export class _AlphaState {
  71507. private _isAlphaBlendDirty;
  71508. private _isBlendFunctionParametersDirty;
  71509. private _isBlendEquationParametersDirty;
  71510. private _isBlendConstantsDirty;
  71511. private _alphaBlend;
  71512. private _blendFunctionParameters;
  71513. private _blendEquationParameters;
  71514. private _blendConstants;
  71515. /**
  71516. * Initializes the state.
  71517. */
  71518. constructor();
  71519. readonly isDirty: boolean;
  71520. alphaBlend: boolean;
  71521. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71522. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71523. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71524. reset(): void;
  71525. apply(gl: WebGLRenderingContext): void;
  71526. }
  71527. }
  71528. declare module BABYLON {
  71529. /**
  71530. * @hidden
  71531. **/
  71532. export class _DepthCullingState {
  71533. private _isDepthTestDirty;
  71534. private _isDepthMaskDirty;
  71535. private _isDepthFuncDirty;
  71536. private _isCullFaceDirty;
  71537. private _isCullDirty;
  71538. private _isZOffsetDirty;
  71539. private _isFrontFaceDirty;
  71540. private _depthTest;
  71541. private _depthMask;
  71542. private _depthFunc;
  71543. private _cull;
  71544. private _cullFace;
  71545. private _zOffset;
  71546. private _frontFace;
  71547. /**
  71548. * Initializes the state.
  71549. */
  71550. constructor();
  71551. readonly isDirty: boolean;
  71552. zOffset: number;
  71553. cullFace: Nullable<number>;
  71554. cull: Nullable<boolean>;
  71555. depthFunc: Nullable<number>;
  71556. depthMask: boolean;
  71557. depthTest: boolean;
  71558. frontFace: Nullable<number>;
  71559. reset(): void;
  71560. apply(gl: WebGLRenderingContext): void;
  71561. }
  71562. }
  71563. declare module BABYLON {
  71564. /**
  71565. * @hidden
  71566. **/
  71567. export class _StencilState {
  71568. /** 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 */
  71569. static readonly ALWAYS: number;
  71570. /** Passed to stencilOperation to specify that stencil value must be kept */
  71571. static readonly KEEP: number;
  71572. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71573. static readonly REPLACE: number;
  71574. private _isStencilTestDirty;
  71575. private _isStencilMaskDirty;
  71576. private _isStencilFuncDirty;
  71577. private _isStencilOpDirty;
  71578. private _stencilTest;
  71579. private _stencilMask;
  71580. private _stencilFunc;
  71581. private _stencilFuncRef;
  71582. private _stencilFuncMask;
  71583. private _stencilOpStencilFail;
  71584. private _stencilOpDepthFail;
  71585. private _stencilOpStencilDepthPass;
  71586. readonly isDirty: boolean;
  71587. stencilFunc: number;
  71588. stencilFuncRef: number;
  71589. stencilFuncMask: number;
  71590. stencilOpStencilFail: number;
  71591. stencilOpDepthFail: number;
  71592. stencilOpStencilDepthPass: number;
  71593. stencilMask: number;
  71594. stencilTest: boolean;
  71595. constructor();
  71596. reset(): void;
  71597. apply(gl: WebGLRenderingContext): void;
  71598. }
  71599. }
  71600. declare module BABYLON {
  71601. /**
  71602. * @hidden
  71603. **/
  71604. export class _TimeToken {
  71605. _startTimeQuery: Nullable<WebGLQuery>;
  71606. _endTimeQuery: Nullable<WebGLQuery>;
  71607. _timeElapsedQuery: Nullable<WebGLQuery>;
  71608. _timeElapsedQueryEnded: boolean;
  71609. }
  71610. }
  71611. declare module BABYLON {
  71612. /**
  71613. * Class used to evalaute queries containing `and` and `or` operators
  71614. */
  71615. export class AndOrNotEvaluator {
  71616. /**
  71617. * Evaluate a query
  71618. * @param query defines the query to evaluate
  71619. * @param evaluateCallback defines the callback used to filter result
  71620. * @returns true if the query matches
  71621. */
  71622. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71623. private static _HandleParenthesisContent;
  71624. private static _SimplifyNegation;
  71625. }
  71626. }
  71627. declare module BABYLON {
  71628. /**
  71629. * Class used to store custom tags
  71630. */
  71631. export class Tags {
  71632. /**
  71633. * Adds support for tags on the given object
  71634. * @param obj defines the object to use
  71635. */
  71636. static EnableFor(obj: any): void;
  71637. /**
  71638. * Removes tags support
  71639. * @param obj defines the object to use
  71640. */
  71641. static DisableFor(obj: any): void;
  71642. /**
  71643. * Gets a boolean indicating if the given object has tags
  71644. * @param obj defines the object to use
  71645. * @returns a boolean
  71646. */
  71647. static HasTags(obj: any): boolean;
  71648. /**
  71649. * Gets the tags available on a given object
  71650. * @param obj defines the object to use
  71651. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71652. * @returns the tags
  71653. */
  71654. static GetTags(obj: any, asString?: boolean): any;
  71655. /**
  71656. * Adds tags to an object
  71657. * @param obj defines the object to use
  71658. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71659. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71660. */
  71661. static AddTagsTo(obj: any, tagsString: string): void;
  71662. /**
  71663. * @hidden
  71664. */
  71665. static _AddTagTo(obj: any, tag: string): void;
  71666. /**
  71667. * Removes specific tags from a specific object
  71668. * @param obj defines the object to use
  71669. * @param tagsString defines the tags to remove
  71670. */
  71671. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71672. /**
  71673. * @hidden
  71674. */
  71675. static _RemoveTagFrom(obj: any, tag: string): void;
  71676. /**
  71677. * Defines if tags hosted on an object match a given query
  71678. * @param obj defines the object to use
  71679. * @param tagsQuery defines the tag query
  71680. * @returns a boolean
  71681. */
  71682. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * Defines potential orientation for back face culling
  71688. */
  71689. export enum Orientation {
  71690. /**
  71691. * Clockwise
  71692. */
  71693. CW = 0,
  71694. /** Counter clockwise */
  71695. CCW = 1
  71696. }
  71697. /** Class used to represent a Bezier curve */
  71698. export class BezierCurve {
  71699. /**
  71700. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71701. * @param t defines the time
  71702. * @param x1 defines the left coordinate on X axis
  71703. * @param y1 defines the left coordinate on Y axis
  71704. * @param x2 defines the right coordinate on X axis
  71705. * @param y2 defines the right coordinate on Y axis
  71706. * @returns the interpolated value
  71707. */
  71708. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71709. }
  71710. /**
  71711. * Defines angle representation
  71712. */
  71713. export class Angle {
  71714. private _radians;
  71715. /**
  71716. * Creates an Angle object of "radians" radians (float).
  71717. * @param radians the angle in radians
  71718. */
  71719. constructor(radians: number);
  71720. /**
  71721. * Get value in degrees
  71722. * @returns the Angle value in degrees (float)
  71723. */
  71724. degrees(): number;
  71725. /**
  71726. * Get value in radians
  71727. * @returns the Angle value in radians (float)
  71728. */
  71729. radians(): number;
  71730. /**
  71731. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71732. * @param a defines first vector
  71733. * @param b defines second vector
  71734. * @returns a new Angle
  71735. */
  71736. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71737. /**
  71738. * Gets a new Angle object from the given float in radians
  71739. * @param radians defines the angle value in radians
  71740. * @returns a new Angle
  71741. */
  71742. static FromRadians(radians: number): Angle;
  71743. /**
  71744. * Gets a new Angle object from the given float in degrees
  71745. * @param degrees defines the angle value in degrees
  71746. * @returns a new Angle
  71747. */
  71748. static FromDegrees(degrees: number): Angle;
  71749. }
  71750. /**
  71751. * This represents an arc in a 2d space.
  71752. */
  71753. export class Arc2 {
  71754. /** Defines the start point of the arc */
  71755. startPoint: Vector2;
  71756. /** Defines the mid point of the arc */
  71757. midPoint: Vector2;
  71758. /** Defines the end point of the arc */
  71759. endPoint: Vector2;
  71760. /**
  71761. * Defines the center point of the arc.
  71762. */
  71763. centerPoint: Vector2;
  71764. /**
  71765. * Defines the radius of the arc.
  71766. */
  71767. radius: number;
  71768. /**
  71769. * Defines the angle of the arc (from mid point to end point).
  71770. */
  71771. angle: Angle;
  71772. /**
  71773. * Defines the start angle of the arc (from start point to middle point).
  71774. */
  71775. startAngle: Angle;
  71776. /**
  71777. * Defines the orientation of the arc (clock wise/counter clock wise).
  71778. */
  71779. orientation: Orientation;
  71780. /**
  71781. * Creates an Arc object from the three given points : start, middle and end.
  71782. * @param startPoint Defines the start point of the arc
  71783. * @param midPoint Defines the midlle point of the arc
  71784. * @param endPoint Defines the end point of the arc
  71785. */
  71786. constructor(
  71787. /** Defines the start point of the arc */
  71788. startPoint: Vector2,
  71789. /** Defines the mid point of the arc */
  71790. midPoint: Vector2,
  71791. /** Defines the end point of the arc */
  71792. endPoint: Vector2);
  71793. }
  71794. /**
  71795. * Represents a 2D path made up of multiple 2D points
  71796. */
  71797. export class Path2 {
  71798. private _points;
  71799. private _length;
  71800. /**
  71801. * If the path start and end point are the same
  71802. */
  71803. closed: boolean;
  71804. /**
  71805. * Creates a Path2 object from the starting 2D coordinates x and y.
  71806. * @param x the starting points x value
  71807. * @param y the starting points y value
  71808. */
  71809. constructor(x: number, y: number);
  71810. /**
  71811. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71812. * @param x the added points x value
  71813. * @param y the added points y value
  71814. * @returns the updated Path2.
  71815. */
  71816. addLineTo(x: number, y: number): Path2;
  71817. /**
  71818. * 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.
  71819. * @param midX middle point x value
  71820. * @param midY middle point y value
  71821. * @param endX end point x value
  71822. * @param endY end point y value
  71823. * @param numberOfSegments (default: 36)
  71824. * @returns the updated Path2.
  71825. */
  71826. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71827. /**
  71828. * Closes the Path2.
  71829. * @returns the Path2.
  71830. */
  71831. close(): Path2;
  71832. /**
  71833. * Gets the sum of the distance between each sequential point in the path
  71834. * @returns the Path2 total length (float).
  71835. */
  71836. length(): number;
  71837. /**
  71838. * Gets the points which construct the path
  71839. * @returns the Path2 internal array of points.
  71840. */
  71841. getPoints(): Vector2[];
  71842. /**
  71843. * Retreives the point at the distance aways from the starting point
  71844. * @param normalizedLengthPosition the length along the path to retreive the point from
  71845. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71846. */
  71847. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71848. /**
  71849. * Creates a new path starting from an x and y position
  71850. * @param x starting x value
  71851. * @param y starting y value
  71852. * @returns a new Path2 starting at the coordinates (x, y).
  71853. */
  71854. static StartingAt(x: number, y: number): Path2;
  71855. }
  71856. /**
  71857. * Represents a 3D path made up of multiple 3D points
  71858. */
  71859. export class Path3D {
  71860. /**
  71861. * an array of Vector3, the curve axis of the Path3D
  71862. */
  71863. path: Vector3[];
  71864. private _curve;
  71865. private _distances;
  71866. private _tangents;
  71867. private _normals;
  71868. private _binormals;
  71869. private _raw;
  71870. /**
  71871. * new Path3D(path, normal, raw)
  71872. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71873. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71874. * @param path an array of Vector3, the curve axis of the Path3D
  71875. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71876. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71877. */
  71878. constructor(
  71879. /**
  71880. * an array of Vector3, the curve axis of the Path3D
  71881. */
  71882. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71883. /**
  71884. * Returns the Path3D array of successive Vector3 designing its curve.
  71885. * @returns the Path3D array of successive Vector3 designing its curve.
  71886. */
  71887. getCurve(): Vector3[];
  71888. /**
  71889. * Returns an array populated with tangent vectors on each Path3D curve point.
  71890. * @returns an array populated with tangent vectors on each Path3D curve point.
  71891. */
  71892. getTangents(): Vector3[];
  71893. /**
  71894. * Returns an array populated with normal vectors on each Path3D curve point.
  71895. * @returns an array populated with normal vectors on each Path3D curve point.
  71896. */
  71897. getNormals(): Vector3[];
  71898. /**
  71899. * Returns an array populated with binormal vectors on each Path3D curve point.
  71900. * @returns an array populated with binormal vectors on each Path3D curve point.
  71901. */
  71902. getBinormals(): Vector3[];
  71903. /**
  71904. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71905. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71906. */
  71907. getDistances(): number[];
  71908. /**
  71909. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71910. * @param path path which all values are copied into the curves points
  71911. * @param firstNormal which should be projected onto the curve
  71912. * @returns the same object updated.
  71913. */
  71914. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71915. private _compute;
  71916. private _getFirstNonNullVector;
  71917. private _getLastNonNullVector;
  71918. private _normalVector;
  71919. }
  71920. /**
  71921. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71922. * A Curve3 is designed from a series of successive Vector3.
  71923. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71924. */
  71925. export class Curve3 {
  71926. private _points;
  71927. private _length;
  71928. /**
  71929. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71930. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71931. * @param v1 (Vector3) the control point
  71932. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71933. * @param nbPoints (integer) the wanted number of points in the curve
  71934. * @returns the created Curve3
  71935. */
  71936. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71937. /**
  71938. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71939. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71940. * @param v1 (Vector3) the first control point
  71941. * @param v2 (Vector3) the second control point
  71942. * @param v3 (Vector3) the end point of the Cubic Bezier
  71943. * @param nbPoints (integer) the wanted number of points in the curve
  71944. * @returns the created Curve3
  71945. */
  71946. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71947. /**
  71948. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71949. * @param p1 (Vector3) the origin point of the Hermite Spline
  71950. * @param t1 (Vector3) the tangent vector at the origin point
  71951. * @param p2 (Vector3) the end point of the Hermite Spline
  71952. * @param t2 (Vector3) the tangent vector at the end point
  71953. * @param nbPoints (integer) the wanted number of points in the curve
  71954. * @returns the created Curve3
  71955. */
  71956. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71957. /**
  71958. * Returns a Curve3 object along a CatmullRom Spline curve :
  71959. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71960. * @param nbPoints (integer) the wanted number of points between each curve control points
  71961. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71962. * @returns the created Curve3
  71963. */
  71964. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71965. /**
  71966. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71967. * A Curve3 is designed from a series of successive Vector3.
  71968. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71969. * @param points points which make up the curve
  71970. */
  71971. constructor(points: Vector3[]);
  71972. /**
  71973. * @returns the Curve3 stored array of successive Vector3
  71974. */
  71975. getPoints(): Vector3[];
  71976. /**
  71977. * @returns the computed length (float) of the curve.
  71978. */
  71979. length(): number;
  71980. /**
  71981. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71982. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71983. * curveA and curveB keep unchanged.
  71984. * @param curve the curve to continue from this curve
  71985. * @returns the newly constructed curve
  71986. */
  71987. continue(curve: DeepImmutable<Curve3>): Curve3;
  71988. private _computeLength;
  71989. }
  71990. }
  71991. declare module BABYLON {
  71992. /**
  71993. * This represents the main contract an easing function should follow.
  71994. * Easing functions are used throughout the animation system.
  71995. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71996. */
  71997. export interface IEasingFunction {
  71998. /**
  71999. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72000. * of the easing function.
  72001. * The link below provides some of the most common examples of easing functions.
  72002. * @see https://easings.net/
  72003. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72004. * @returns the corresponding value on the curve defined by the easing function
  72005. */
  72006. ease(gradient: number): number;
  72007. }
  72008. /**
  72009. * Base class used for every default easing function.
  72010. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72011. */
  72012. export class EasingFunction implements IEasingFunction {
  72013. /**
  72014. * Interpolation follows the mathematical formula associated with the easing function.
  72015. */
  72016. static readonly EASINGMODE_EASEIN: number;
  72017. /**
  72018. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72019. */
  72020. static readonly EASINGMODE_EASEOUT: number;
  72021. /**
  72022. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72023. */
  72024. static readonly EASINGMODE_EASEINOUT: number;
  72025. private _easingMode;
  72026. /**
  72027. * Sets the easing mode of the current function.
  72028. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72029. */
  72030. setEasingMode(easingMode: number): void;
  72031. /**
  72032. * Gets the current easing mode.
  72033. * @returns the easing mode
  72034. */
  72035. getEasingMode(): number;
  72036. /**
  72037. * @hidden
  72038. */
  72039. easeInCore(gradient: number): number;
  72040. /**
  72041. * Given an input gradient between 0 and 1, this returns the corresponding value
  72042. * of the easing function.
  72043. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72044. * @returns the corresponding value on the curve defined by the easing function
  72045. */
  72046. ease(gradient: number): number;
  72047. }
  72048. /**
  72049. * Easing function with a circle shape (see link below).
  72050. * @see https://easings.net/#easeInCirc
  72051. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72052. */
  72053. export class CircleEase extends EasingFunction implements IEasingFunction {
  72054. /** @hidden */
  72055. easeInCore(gradient: number): number;
  72056. }
  72057. /**
  72058. * Easing function with a ease back shape (see link below).
  72059. * @see https://easings.net/#easeInBack
  72060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72061. */
  72062. export class BackEase extends EasingFunction implements IEasingFunction {
  72063. /** Defines the amplitude of the function */
  72064. amplitude: number;
  72065. /**
  72066. * Instantiates a back ease easing
  72067. * @see https://easings.net/#easeInBack
  72068. * @param amplitude Defines the amplitude of the function
  72069. */
  72070. constructor(
  72071. /** Defines the amplitude of the function */
  72072. amplitude?: number);
  72073. /** @hidden */
  72074. easeInCore(gradient: number): number;
  72075. }
  72076. /**
  72077. * Easing function with a bouncing shape (see link below).
  72078. * @see https://easings.net/#easeInBounce
  72079. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72080. */
  72081. export class BounceEase extends EasingFunction implements IEasingFunction {
  72082. /** Defines the number of bounces */
  72083. bounces: number;
  72084. /** Defines the amplitude of the bounce */
  72085. bounciness: number;
  72086. /**
  72087. * Instantiates a bounce easing
  72088. * @see https://easings.net/#easeInBounce
  72089. * @param bounces Defines the number of bounces
  72090. * @param bounciness Defines the amplitude of the bounce
  72091. */
  72092. constructor(
  72093. /** Defines the number of bounces */
  72094. bounces?: number,
  72095. /** Defines the amplitude of the bounce */
  72096. bounciness?: number);
  72097. /** @hidden */
  72098. easeInCore(gradient: number): number;
  72099. }
  72100. /**
  72101. * Easing function with a power of 3 shape (see link below).
  72102. * @see https://easings.net/#easeInCubic
  72103. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72104. */
  72105. export class CubicEase extends EasingFunction implements IEasingFunction {
  72106. /** @hidden */
  72107. easeInCore(gradient: number): number;
  72108. }
  72109. /**
  72110. * Easing function with an elastic shape (see link below).
  72111. * @see https://easings.net/#easeInElastic
  72112. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72113. */
  72114. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72115. /** Defines the number of oscillations*/
  72116. oscillations: number;
  72117. /** Defines the amplitude of the oscillations*/
  72118. springiness: number;
  72119. /**
  72120. * Instantiates an elastic easing function
  72121. * @see https://easings.net/#easeInElastic
  72122. * @param oscillations Defines the number of oscillations
  72123. * @param springiness Defines the amplitude of the oscillations
  72124. */
  72125. constructor(
  72126. /** Defines the number of oscillations*/
  72127. oscillations?: number,
  72128. /** Defines the amplitude of the oscillations*/
  72129. springiness?: number);
  72130. /** @hidden */
  72131. easeInCore(gradient: number): number;
  72132. }
  72133. /**
  72134. * Easing function with an exponential shape (see link below).
  72135. * @see https://easings.net/#easeInExpo
  72136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72137. */
  72138. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72139. /** Defines the exponent of the function */
  72140. exponent: number;
  72141. /**
  72142. * Instantiates an exponential easing function
  72143. * @see https://easings.net/#easeInExpo
  72144. * @param exponent Defines the exponent of the function
  72145. */
  72146. constructor(
  72147. /** Defines the exponent of the function */
  72148. exponent?: number);
  72149. /** @hidden */
  72150. easeInCore(gradient: number): number;
  72151. }
  72152. /**
  72153. * Easing function with a power shape (see link below).
  72154. * @see https://easings.net/#easeInQuad
  72155. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72156. */
  72157. export class PowerEase extends EasingFunction implements IEasingFunction {
  72158. /** Defines the power of the function */
  72159. power: number;
  72160. /**
  72161. * Instantiates an power base easing function
  72162. * @see https://easings.net/#easeInQuad
  72163. * @param power Defines the power of the function
  72164. */
  72165. constructor(
  72166. /** Defines the power of the function */
  72167. power?: number);
  72168. /** @hidden */
  72169. easeInCore(gradient: number): number;
  72170. }
  72171. /**
  72172. * Easing function with a power of 2 shape (see link below).
  72173. * @see https://easings.net/#easeInQuad
  72174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72175. */
  72176. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72177. /** @hidden */
  72178. easeInCore(gradient: number): number;
  72179. }
  72180. /**
  72181. * Easing function with a power of 4 shape (see link below).
  72182. * @see https://easings.net/#easeInQuart
  72183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72184. */
  72185. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72186. /** @hidden */
  72187. easeInCore(gradient: number): number;
  72188. }
  72189. /**
  72190. * Easing function with a power of 5 shape (see link below).
  72191. * @see https://easings.net/#easeInQuint
  72192. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72193. */
  72194. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72195. /** @hidden */
  72196. easeInCore(gradient: number): number;
  72197. }
  72198. /**
  72199. * Easing function with a sin shape (see link below).
  72200. * @see https://easings.net/#easeInSine
  72201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72202. */
  72203. export class SineEase extends EasingFunction implements IEasingFunction {
  72204. /** @hidden */
  72205. easeInCore(gradient: number): number;
  72206. }
  72207. /**
  72208. * Easing function with a bezier shape (see link below).
  72209. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72211. */
  72212. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72213. /** Defines the x component of the start tangent in the bezier curve */
  72214. x1: number;
  72215. /** Defines the y component of the start tangent in the bezier curve */
  72216. y1: number;
  72217. /** Defines the x component of the end tangent in the bezier curve */
  72218. x2: number;
  72219. /** Defines the y component of the end tangent in the bezier curve */
  72220. y2: number;
  72221. /**
  72222. * Instantiates a bezier function
  72223. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72224. * @param x1 Defines the x component of the start tangent in the bezier curve
  72225. * @param y1 Defines the y component of the start tangent in the bezier curve
  72226. * @param x2 Defines the x component of the end tangent in the bezier curve
  72227. * @param y2 Defines the y component of the end tangent in the bezier curve
  72228. */
  72229. constructor(
  72230. /** Defines the x component of the start tangent in the bezier curve */
  72231. x1?: number,
  72232. /** Defines the y component of the start tangent in the bezier curve */
  72233. y1?: number,
  72234. /** Defines the x component of the end tangent in the bezier curve */
  72235. x2?: number,
  72236. /** Defines the y component of the end tangent in the bezier curve */
  72237. y2?: number);
  72238. /** @hidden */
  72239. easeInCore(gradient: number): number;
  72240. }
  72241. }
  72242. declare module BABYLON {
  72243. /**
  72244. * Defines an interface which represents an animation key frame
  72245. */
  72246. export interface IAnimationKey {
  72247. /**
  72248. * Frame of the key frame
  72249. */
  72250. frame: number;
  72251. /**
  72252. * Value at the specifies key frame
  72253. */
  72254. value: any;
  72255. /**
  72256. * The input tangent for the cubic hermite spline
  72257. */
  72258. inTangent?: any;
  72259. /**
  72260. * The output tangent for the cubic hermite spline
  72261. */
  72262. outTangent?: any;
  72263. /**
  72264. * The animation interpolation type
  72265. */
  72266. interpolation?: AnimationKeyInterpolation;
  72267. }
  72268. /**
  72269. * Enum for the animation key frame interpolation type
  72270. */
  72271. export enum AnimationKeyInterpolation {
  72272. /**
  72273. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72274. */
  72275. STEP = 1
  72276. }
  72277. }
  72278. declare module BABYLON {
  72279. /**
  72280. * Represents the range of an animation
  72281. */
  72282. export class AnimationRange {
  72283. /**The name of the animation range**/
  72284. name: string;
  72285. /**The starting frame of the animation */
  72286. from: number;
  72287. /**The ending frame of the animation*/
  72288. to: number;
  72289. /**
  72290. * Initializes the range of an animation
  72291. * @param name The name of the animation range
  72292. * @param from The starting frame of the animation
  72293. * @param to The ending frame of the animation
  72294. */
  72295. constructor(
  72296. /**The name of the animation range**/
  72297. name: string,
  72298. /**The starting frame of the animation */
  72299. from: number,
  72300. /**The ending frame of the animation*/
  72301. to: number);
  72302. /**
  72303. * Makes a copy of the animation range
  72304. * @returns A copy of the animation range
  72305. */
  72306. clone(): AnimationRange;
  72307. }
  72308. }
  72309. declare module BABYLON {
  72310. /**
  72311. * Composed of a frame, and an action function
  72312. */
  72313. export class AnimationEvent {
  72314. /** The frame for which the event is triggered **/
  72315. frame: number;
  72316. /** The event to perform when triggered **/
  72317. action: (currentFrame: number) => void;
  72318. /** Specifies if the event should be triggered only once**/
  72319. onlyOnce?: boolean | undefined;
  72320. /**
  72321. * Specifies if the animation event is done
  72322. */
  72323. isDone: boolean;
  72324. /**
  72325. * Initializes the animation event
  72326. * @param frame The frame for which the event is triggered
  72327. * @param action The event to perform when triggered
  72328. * @param onlyOnce Specifies if the event should be triggered only once
  72329. */
  72330. constructor(
  72331. /** The frame for which the event is triggered **/
  72332. frame: number,
  72333. /** The event to perform when triggered **/
  72334. action: (currentFrame: number) => void,
  72335. /** Specifies if the event should be triggered only once**/
  72336. onlyOnce?: boolean | undefined);
  72337. /** @hidden */
  72338. _clone(): AnimationEvent;
  72339. }
  72340. }
  72341. declare module BABYLON {
  72342. /**
  72343. * Interface used to define a behavior
  72344. */
  72345. export interface Behavior<T> {
  72346. /** gets or sets behavior's name */
  72347. name: string;
  72348. /**
  72349. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72350. */
  72351. init(): void;
  72352. /**
  72353. * Called when the behavior is attached to a target
  72354. * @param target defines the target where the behavior is attached to
  72355. */
  72356. attach(target: T): void;
  72357. /**
  72358. * Called when the behavior is detached from its target
  72359. */
  72360. detach(): void;
  72361. }
  72362. /**
  72363. * Interface implemented by classes supporting behaviors
  72364. */
  72365. export interface IBehaviorAware<T> {
  72366. /**
  72367. * Attach a behavior
  72368. * @param behavior defines the behavior to attach
  72369. * @returns the current host
  72370. */
  72371. addBehavior(behavior: Behavior<T>): T;
  72372. /**
  72373. * Remove a behavior from the current object
  72374. * @param behavior defines the behavior to detach
  72375. * @returns the current host
  72376. */
  72377. removeBehavior(behavior: Behavior<T>): T;
  72378. /**
  72379. * Gets a behavior using its name to search
  72380. * @param name defines the name to search
  72381. * @returns the behavior or null if not found
  72382. */
  72383. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72384. }
  72385. }
  72386. declare module BABYLON {
  72387. /**
  72388. * Defines an array and its length.
  72389. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72390. */
  72391. export interface ISmartArrayLike<T> {
  72392. /**
  72393. * The data of the array.
  72394. */
  72395. data: Array<T>;
  72396. /**
  72397. * The active length of the array.
  72398. */
  72399. length: number;
  72400. }
  72401. /**
  72402. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72403. */
  72404. export class SmartArray<T> implements ISmartArrayLike<T> {
  72405. /**
  72406. * The full set of data from the array.
  72407. */
  72408. data: Array<T>;
  72409. /**
  72410. * The active length of the array.
  72411. */
  72412. length: number;
  72413. protected _id: number;
  72414. /**
  72415. * Instantiates a Smart Array.
  72416. * @param capacity defines the default capacity of the array.
  72417. */
  72418. constructor(capacity: number);
  72419. /**
  72420. * Pushes a value at the end of the active data.
  72421. * @param value defines the object to push in the array.
  72422. */
  72423. push(value: T): void;
  72424. /**
  72425. * Iterates over the active data and apply the lambda to them.
  72426. * @param func defines the action to apply on each value.
  72427. */
  72428. forEach(func: (content: T) => void): void;
  72429. /**
  72430. * Sorts the full sets of data.
  72431. * @param compareFn defines the comparison function to apply.
  72432. */
  72433. sort(compareFn: (a: T, b: T) => number): void;
  72434. /**
  72435. * Resets the active data to an empty array.
  72436. */
  72437. reset(): void;
  72438. /**
  72439. * Releases all the data from the array as well as the array.
  72440. */
  72441. dispose(): void;
  72442. /**
  72443. * Concats the active data with a given array.
  72444. * @param array defines the data to concatenate with.
  72445. */
  72446. concat(array: any): void;
  72447. /**
  72448. * Returns the position of a value in the active data.
  72449. * @param value defines the value to find the index for
  72450. * @returns the index if found in the active data otherwise -1
  72451. */
  72452. indexOf(value: T): number;
  72453. /**
  72454. * Returns whether an element is part of the active data.
  72455. * @param value defines the value to look for
  72456. * @returns true if found in the active data otherwise false
  72457. */
  72458. contains(value: T): boolean;
  72459. private static _GlobalId;
  72460. }
  72461. /**
  72462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72463. * The data in this array can only be present once
  72464. */
  72465. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72466. private _duplicateId;
  72467. /**
  72468. * Pushes a value at the end of the active data.
  72469. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72470. * @param value defines the object to push in the array.
  72471. */
  72472. push(value: T): void;
  72473. /**
  72474. * Pushes a value at the end of the active data.
  72475. * If the data is already present, it won t be added again
  72476. * @param value defines the object to push in the array.
  72477. * @returns true if added false if it was already present
  72478. */
  72479. pushNoDuplicate(value: T): boolean;
  72480. /**
  72481. * Resets the active data to an empty array.
  72482. */
  72483. reset(): void;
  72484. /**
  72485. * Concats the active data with a given array.
  72486. * This ensures no dupplicate will be present in the result.
  72487. * @param array defines the data to concatenate with.
  72488. */
  72489. concatWithNoDuplicate(array: any): void;
  72490. }
  72491. }
  72492. declare module BABYLON {
  72493. /**
  72494. * @ignore
  72495. * This is a list of all the different input types that are available in the application.
  72496. * Fo instance: ArcRotateCameraGamepadInput...
  72497. */
  72498. export var CameraInputTypes: {};
  72499. /**
  72500. * This is the contract to implement in order to create a new input class.
  72501. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72502. */
  72503. export interface ICameraInput<TCamera extends Camera> {
  72504. /**
  72505. * Defines the camera the input is attached to.
  72506. */
  72507. camera: Nullable<TCamera>;
  72508. /**
  72509. * Gets the class name of the current intput.
  72510. * @returns the class name
  72511. */
  72512. getClassName(): string;
  72513. /**
  72514. * Get the friendly name associated with the input class.
  72515. * @returns the input friendly name
  72516. */
  72517. getSimpleName(): string;
  72518. /**
  72519. * Attach the input controls to a specific dom element to get the input from.
  72520. * @param element Defines the element the controls should be listened from
  72521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72522. */
  72523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72524. /**
  72525. * Detach the current controls from the specified dom element.
  72526. * @param element Defines the element to stop listening the inputs from
  72527. */
  72528. detachControl(element: Nullable<HTMLElement>): void;
  72529. /**
  72530. * Update the current camera state depending on the inputs that have been used this frame.
  72531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72532. */
  72533. checkInputs?: () => void;
  72534. }
  72535. /**
  72536. * Represents a map of input types to input instance or input index to input instance.
  72537. */
  72538. export interface CameraInputsMap<TCamera extends Camera> {
  72539. /**
  72540. * Accessor to the input by input type.
  72541. */
  72542. [name: string]: ICameraInput<TCamera>;
  72543. /**
  72544. * Accessor to the input by input index.
  72545. */
  72546. [idx: number]: ICameraInput<TCamera>;
  72547. }
  72548. /**
  72549. * This represents the input manager used within a camera.
  72550. * It helps dealing with all the different kind of input attached to a camera.
  72551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72552. */
  72553. export class CameraInputsManager<TCamera extends Camera> {
  72554. /**
  72555. * Defines the list of inputs attahed to the camera.
  72556. */
  72557. attached: CameraInputsMap<TCamera>;
  72558. /**
  72559. * Defines the dom element the camera is collecting inputs from.
  72560. * This is null if the controls have not been attached.
  72561. */
  72562. attachedElement: Nullable<HTMLElement>;
  72563. /**
  72564. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72565. */
  72566. noPreventDefault: boolean;
  72567. /**
  72568. * Defined the camera the input manager belongs to.
  72569. */
  72570. camera: TCamera;
  72571. /**
  72572. * Update the current camera state depending on the inputs that have been used this frame.
  72573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72574. */
  72575. checkInputs: () => void;
  72576. /**
  72577. * Instantiate a new Camera Input Manager.
  72578. * @param camera Defines the camera the input manager blongs to
  72579. */
  72580. constructor(camera: TCamera);
  72581. /**
  72582. * Add an input method to a camera
  72583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72584. * @param input camera input method
  72585. */
  72586. add(input: ICameraInput<TCamera>): void;
  72587. /**
  72588. * Remove a specific input method from a camera
  72589. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72590. * @param inputToRemove camera input method
  72591. */
  72592. remove(inputToRemove: ICameraInput<TCamera>): void;
  72593. /**
  72594. * Remove a specific input type from a camera
  72595. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72596. * @param inputType the type of the input to remove
  72597. */
  72598. removeByType(inputType: string): void;
  72599. private _addCheckInputs;
  72600. /**
  72601. * Attach the input controls to the currently attached dom element to listen the events from.
  72602. * @param input Defines the input to attach
  72603. */
  72604. attachInput(input: ICameraInput<TCamera>): void;
  72605. /**
  72606. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72607. * @param element Defines the dom element to collect the events from
  72608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72609. */
  72610. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72611. /**
  72612. * Detach the current manager inputs controls from a specific dom element.
  72613. * @param element Defines the dom element to collect the events from
  72614. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72615. */
  72616. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72617. /**
  72618. * Rebuild the dynamic inputCheck function from the current list of
  72619. * defined inputs in the manager.
  72620. */
  72621. rebuildInputCheck(): void;
  72622. /**
  72623. * Remove all attached input methods from a camera
  72624. */
  72625. clear(): void;
  72626. /**
  72627. * Serialize the current input manager attached to a camera.
  72628. * This ensures than once parsed,
  72629. * the input associated to the camera will be identical to the current ones
  72630. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72631. */
  72632. serialize(serializedCamera: any): void;
  72633. /**
  72634. * Parses an input manager serialized JSON to restore the previous list of inputs
  72635. * and states associated to a camera.
  72636. * @param parsedCamera Defines the JSON to parse
  72637. */
  72638. parse(parsedCamera: any): void;
  72639. }
  72640. }
  72641. declare module BABYLON {
  72642. /**
  72643. * @hidden
  72644. */
  72645. export class IntersectionInfo {
  72646. bu: Nullable<number>;
  72647. bv: Nullable<number>;
  72648. distance: number;
  72649. faceId: number;
  72650. subMeshId: number;
  72651. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72652. }
  72653. }
  72654. declare module BABYLON {
  72655. /**
  72656. * Represens a plane by the equation ax + by + cz + d = 0
  72657. */
  72658. export class Plane {
  72659. private static _TmpMatrix;
  72660. /**
  72661. * Normal of the plane (a,b,c)
  72662. */
  72663. normal: Vector3;
  72664. /**
  72665. * d component of the plane
  72666. */
  72667. d: number;
  72668. /**
  72669. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72670. * @param a a component of the plane
  72671. * @param b b component of the plane
  72672. * @param c c component of the plane
  72673. * @param d d component of the plane
  72674. */
  72675. constructor(a: number, b: number, c: number, d: number);
  72676. /**
  72677. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72678. */
  72679. asArray(): number[];
  72680. /**
  72681. * @returns a new plane copied from the current Plane.
  72682. */
  72683. clone(): Plane;
  72684. /**
  72685. * @returns the string "Plane".
  72686. */
  72687. getClassName(): string;
  72688. /**
  72689. * @returns the Plane hash code.
  72690. */
  72691. getHashCode(): number;
  72692. /**
  72693. * Normalize the current Plane in place.
  72694. * @returns the updated Plane.
  72695. */
  72696. normalize(): Plane;
  72697. /**
  72698. * Applies a transformation the plane and returns the result
  72699. * @param transformation the transformation matrix to be applied to the plane
  72700. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72701. */
  72702. transform(transformation: DeepImmutable<Matrix>): Plane;
  72703. /**
  72704. * Calcualtte the dot product between the point and the plane normal
  72705. * @param point point to calculate the dot product with
  72706. * @returns the dot product (float) of the point coordinates and the plane normal.
  72707. */
  72708. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72709. /**
  72710. * Updates the current Plane from the plane defined by the three given points.
  72711. * @param point1 one of the points used to contruct the plane
  72712. * @param point2 one of the points used to contruct the plane
  72713. * @param point3 one of the points used to contruct the plane
  72714. * @returns the updated Plane.
  72715. */
  72716. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72717. /**
  72718. * Checks if the plane is facing a given direction
  72719. * @param direction the direction to check if the plane is facing
  72720. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72721. * @returns True is the vector "direction" is the same side than the plane normal.
  72722. */
  72723. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72724. /**
  72725. * Calculates the distance to a point
  72726. * @param point point to calculate distance to
  72727. * @returns the signed distance (float) from the given point to the Plane.
  72728. */
  72729. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72730. /**
  72731. * Creates a plane from an array
  72732. * @param array the array to create a plane from
  72733. * @returns a new Plane from the given array.
  72734. */
  72735. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72736. /**
  72737. * Creates a plane from three points
  72738. * @param point1 point used to create the plane
  72739. * @param point2 point used to create the plane
  72740. * @param point3 point used to create the plane
  72741. * @returns a new Plane defined by the three given points.
  72742. */
  72743. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72744. /**
  72745. * Creates a plane from an origin point and a normal
  72746. * @param origin origin of the plane to be constructed
  72747. * @param normal normal of the plane to be constructed
  72748. * @returns a new Plane the normal vector to this plane at the given origin point.
  72749. * Note : the vector "normal" is updated because normalized.
  72750. */
  72751. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72752. /**
  72753. * Calculates the distance from a plane and a point
  72754. * @param origin origin of the plane to be constructed
  72755. * @param normal normal of the plane to be constructed
  72756. * @param point point to calculate distance to
  72757. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72758. */
  72759. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72760. }
  72761. }
  72762. declare module BABYLON {
  72763. /**
  72764. * Class used to store bounding sphere information
  72765. */
  72766. export class BoundingSphere {
  72767. /**
  72768. * Gets the center of the bounding sphere in local space
  72769. */
  72770. readonly center: Vector3;
  72771. /**
  72772. * Radius of the bounding sphere in local space
  72773. */
  72774. radius: number;
  72775. /**
  72776. * Gets the center of the bounding sphere in world space
  72777. */
  72778. readonly centerWorld: Vector3;
  72779. /**
  72780. * Radius of the bounding sphere in world space
  72781. */
  72782. radiusWorld: number;
  72783. /**
  72784. * Gets the minimum vector in local space
  72785. */
  72786. readonly minimum: Vector3;
  72787. /**
  72788. * Gets the maximum vector in local space
  72789. */
  72790. readonly maximum: Vector3;
  72791. private _worldMatrix;
  72792. private static readonly TmpVector3;
  72793. /**
  72794. * Creates a new bounding sphere
  72795. * @param min defines the minimum vector (in local space)
  72796. * @param max defines the maximum vector (in local space)
  72797. * @param worldMatrix defines the new world matrix
  72798. */
  72799. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72800. /**
  72801. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72802. * @param min defines the new minimum vector (in local space)
  72803. * @param max defines the new maximum vector (in local space)
  72804. * @param worldMatrix defines the new world matrix
  72805. */
  72806. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72807. /**
  72808. * Scale the current bounding sphere by applying a scale factor
  72809. * @param factor defines the scale factor to apply
  72810. * @returns the current bounding box
  72811. */
  72812. scale(factor: number): BoundingSphere;
  72813. /**
  72814. * Gets the world matrix of the bounding box
  72815. * @returns a matrix
  72816. */
  72817. getWorldMatrix(): DeepImmutable<Matrix>;
  72818. /** @hidden */
  72819. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72820. /**
  72821. * Tests if the bounding sphere is intersecting the frustum planes
  72822. * @param frustumPlanes defines the frustum planes to test
  72823. * @returns true if there is an intersection
  72824. */
  72825. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72826. /**
  72827. * Tests if the bounding sphere center is in between the frustum planes.
  72828. * Used for optimistic fast inclusion.
  72829. * @param frustumPlanes defines the frustum planes to test
  72830. * @returns true if the sphere center is in between the frustum planes
  72831. */
  72832. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72833. /**
  72834. * Tests if a point is inside the bounding sphere
  72835. * @param point defines the point to test
  72836. * @returns true if the point is inside the bounding sphere
  72837. */
  72838. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72839. /**
  72840. * Checks if two sphere intersct
  72841. * @param sphere0 sphere 0
  72842. * @param sphere1 sphere 1
  72843. * @returns true if the speres intersect
  72844. */
  72845. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72846. }
  72847. }
  72848. declare module BABYLON {
  72849. /**
  72850. * Class used to store bounding box information
  72851. */
  72852. export class BoundingBox implements ICullable {
  72853. /**
  72854. * Gets the 8 vectors representing the bounding box in local space
  72855. */
  72856. readonly vectors: Vector3[];
  72857. /**
  72858. * Gets the center of the bounding box in local space
  72859. */
  72860. readonly center: Vector3;
  72861. /**
  72862. * Gets the center of the bounding box in world space
  72863. */
  72864. readonly centerWorld: Vector3;
  72865. /**
  72866. * Gets the extend size in local space
  72867. */
  72868. readonly extendSize: Vector3;
  72869. /**
  72870. * Gets the extend size in world space
  72871. */
  72872. readonly extendSizeWorld: Vector3;
  72873. /**
  72874. * Gets the OBB (object bounding box) directions
  72875. */
  72876. readonly directions: Vector3[];
  72877. /**
  72878. * Gets the 8 vectors representing the bounding box in world space
  72879. */
  72880. readonly vectorsWorld: Vector3[];
  72881. /**
  72882. * Gets the minimum vector in world space
  72883. */
  72884. readonly minimumWorld: Vector3;
  72885. /**
  72886. * Gets the maximum vector in world space
  72887. */
  72888. readonly maximumWorld: Vector3;
  72889. /**
  72890. * Gets the minimum vector in local space
  72891. */
  72892. readonly minimum: Vector3;
  72893. /**
  72894. * Gets the maximum vector in local space
  72895. */
  72896. readonly maximum: Vector3;
  72897. private _worldMatrix;
  72898. private static readonly TmpVector3;
  72899. /**
  72900. * @hidden
  72901. */
  72902. _tag: number;
  72903. /**
  72904. * Creates a new bounding box
  72905. * @param min defines the minimum vector (in local space)
  72906. * @param max defines the maximum vector (in local space)
  72907. * @param worldMatrix defines the new world matrix
  72908. */
  72909. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72910. /**
  72911. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72912. * @param min defines the new minimum vector (in local space)
  72913. * @param max defines the new maximum vector (in local space)
  72914. * @param worldMatrix defines the new world matrix
  72915. */
  72916. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72917. /**
  72918. * Scale the current bounding box by applying a scale factor
  72919. * @param factor defines the scale factor to apply
  72920. * @returns the current bounding box
  72921. */
  72922. scale(factor: number): BoundingBox;
  72923. /**
  72924. * Gets the world matrix of the bounding box
  72925. * @returns a matrix
  72926. */
  72927. getWorldMatrix(): DeepImmutable<Matrix>;
  72928. /** @hidden */
  72929. _update(world: DeepImmutable<Matrix>): void;
  72930. /**
  72931. * Tests if the bounding box is intersecting the frustum planes
  72932. * @param frustumPlanes defines the frustum planes to test
  72933. * @returns true if there is an intersection
  72934. */
  72935. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72936. /**
  72937. * Tests if the bounding box is entirely inside the frustum planes
  72938. * @param frustumPlanes defines the frustum planes to test
  72939. * @returns true if there is an inclusion
  72940. */
  72941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72942. /**
  72943. * Tests if a point is inside the bounding box
  72944. * @param point defines the point to test
  72945. * @returns true if the point is inside the bounding box
  72946. */
  72947. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72948. /**
  72949. * Tests if the bounding box intersects with a bounding sphere
  72950. * @param sphere defines the sphere to test
  72951. * @returns true if there is an intersection
  72952. */
  72953. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72954. /**
  72955. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72956. * @param min defines the min vector to use
  72957. * @param max defines the max vector to use
  72958. * @returns true if there is an intersection
  72959. */
  72960. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72961. /**
  72962. * Tests if two bounding boxes are intersections
  72963. * @param box0 defines the first box to test
  72964. * @param box1 defines the second box to test
  72965. * @returns true if there is an intersection
  72966. */
  72967. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72968. /**
  72969. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72970. * @param minPoint defines the minimum vector of the bounding box
  72971. * @param maxPoint defines the maximum vector of the bounding box
  72972. * @param sphereCenter defines the sphere center
  72973. * @param sphereRadius defines the sphere radius
  72974. * @returns true if there is an intersection
  72975. */
  72976. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72977. /**
  72978. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72979. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72980. * @param frustumPlanes defines the frustum planes to test
  72981. * @return true if there is an inclusion
  72982. */
  72983. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72984. /**
  72985. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72986. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72987. * @param frustumPlanes defines the frustum planes to test
  72988. * @return true if there is an intersection
  72989. */
  72990. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72991. }
  72992. }
  72993. declare module BABYLON {
  72994. /** @hidden */
  72995. export class Collider {
  72996. /** Define if a collision was found */
  72997. collisionFound: boolean;
  72998. /**
  72999. * Define last intersection point in local space
  73000. */
  73001. intersectionPoint: Vector3;
  73002. /**
  73003. * Define last collided mesh
  73004. */
  73005. collidedMesh: Nullable<AbstractMesh>;
  73006. private _collisionPoint;
  73007. private _planeIntersectionPoint;
  73008. private _tempVector;
  73009. private _tempVector2;
  73010. private _tempVector3;
  73011. private _tempVector4;
  73012. private _edge;
  73013. private _baseToVertex;
  73014. private _destinationPoint;
  73015. private _slidePlaneNormal;
  73016. private _displacementVector;
  73017. /** @hidden */
  73018. _radius: Vector3;
  73019. /** @hidden */
  73020. _retry: number;
  73021. private _velocity;
  73022. private _basePoint;
  73023. private _epsilon;
  73024. /** @hidden */
  73025. _velocityWorldLength: number;
  73026. /** @hidden */
  73027. _basePointWorld: Vector3;
  73028. private _velocityWorld;
  73029. private _normalizedVelocity;
  73030. /** @hidden */
  73031. _initialVelocity: Vector3;
  73032. /** @hidden */
  73033. _initialPosition: Vector3;
  73034. private _nearestDistance;
  73035. private _collisionMask;
  73036. collisionMask: number;
  73037. /**
  73038. * Gets the plane normal used to compute the sliding response (in local space)
  73039. */
  73040. readonly slidePlaneNormal: Vector3;
  73041. /** @hidden */
  73042. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73043. /** @hidden */
  73044. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73045. /** @hidden */
  73046. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73047. /** @hidden */
  73048. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73049. /** @hidden */
  73050. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73051. /** @hidden */
  73052. _getResponse(pos: Vector3, vel: Vector3): void;
  73053. }
  73054. }
  73055. declare module BABYLON {
  73056. /**
  73057. * Interface for cullable objects
  73058. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73059. */
  73060. export interface ICullable {
  73061. /**
  73062. * Checks if the object or part of the object is in the frustum
  73063. * @param frustumPlanes Camera near/planes
  73064. * @returns true if the object is in frustum otherwise false
  73065. */
  73066. isInFrustum(frustumPlanes: Plane[]): boolean;
  73067. /**
  73068. * Checks if a cullable object (mesh...) is in the camera frustum
  73069. * Unlike isInFrustum this cheks the full bounding box
  73070. * @param frustumPlanes Camera near/planes
  73071. * @returns true if the object is in frustum otherwise false
  73072. */
  73073. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73074. }
  73075. /**
  73076. * Info for a bounding data of a mesh
  73077. */
  73078. export class BoundingInfo implements ICullable {
  73079. /**
  73080. * Bounding box for the mesh
  73081. */
  73082. readonly boundingBox: BoundingBox;
  73083. /**
  73084. * Bounding sphere for the mesh
  73085. */
  73086. readonly boundingSphere: BoundingSphere;
  73087. private _isLocked;
  73088. private static readonly TmpVector3;
  73089. /**
  73090. * Constructs bounding info
  73091. * @param minimum min vector of the bounding box/sphere
  73092. * @param maximum max vector of the bounding box/sphere
  73093. * @param worldMatrix defines the new world matrix
  73094. */
  73095. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73096. /**
  73097. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73098. * @param min defines the new minimum vector (in local space)
  73099. * @param max defines the new maximum vector (in local space)
  73100. * @param worldMatrix defines the new world matrix
  73101. */
  73102. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73103. /**
  73104. * min vector of the bounding box/sphere
  73105. */
  73106. readonly minimum: Vector3;
  73107. /**
  73108. * max vector of the bounding box/sphere
  73109. */
  73110. readonly maximum: Vector3;
  73111. /**
  73112. * If the info is locked and won't be updated to avoid perf overhead
  73113. */
  73114. isLocked: boolean;
  73115. /**
  73116. * Updates the bounding sphere and box
  73117. * @param world world matrix to be used to update
  73118. */
  73119. update(world: DeepImmutable<Matrix>): void;
  73120. /**
  73121. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73122. * @param center New center of the bounding info
  73123. * @param extend New extend of the bounding info
  73124. * @returns the current bounding info
  73125. */
  73126. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73127. /**
  73128. * Scale the current bounding info by applying a scale factor
  73129. * @param factor defines the scale factor to apply
  73130. * @returns the current bounding info
  73131. */
  73132. scale(factor: number): BoundingInfo;
  73133. /**
  73134. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73135. * @param frustumPlanes defines the frustum to test
  73136. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73137. * @returns true if the bounding info is in the frustum planes
  73138. */
  73139. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73140. /**
  73141. * Gets the world distance between the min and max points of the bounding box
  73142. */
  73143. readonly diagonalLength: number;
  73144. /**
  73145. * Checks if a cullable object (mesh...) is in the camera frustum
  73146. * Unlike isInFrustum this cheks the full bounding box
  73147. * @param frustumPlanes Camera near/planes
  73148. * @returns true if the object is in frustum otherwise false
  73149. */
  73150. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73151. /** @hidden */
  73152. _checkCollision(collider: Collider): boolean;
  73153. /**
  73154. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73155. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73156. * @param point the point to check intersection with
  73157. * @returns if the point intersects
  73158. */
  73159. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73160. /**
  73161. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73162. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73163. * @param boundingInfo the bounding info to check intersection with
  73164. * @param precise if the intersection should be done using OBB
  73165. * @returns if the bounding info intersects
  73166. */
  73167. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73168. }
  73169. }
  73170. declare module BABYLON {
  73171. /**
  73172. * Extracts minimum and maximum values from a list of indexed positions
  73173. * @param positions defines the positions to use
  73174. * @param indices defines the indices to the positions
  73175. * @param indexStart defines the start index
  73176. * @param indexCount defines the end index
  73177. * @param bias defines bias value to add to the result
  73178. * @return minimum and maximum values
  73179. */
  73180. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73181. minimum: Vector3;
  73182. maximum: Vector3;
  73183. };
  73184. /**
  73185. * Extracts minimum and maximum values from a list of positions
  73186. * @param positions defines the positions to use
  73187. * @param start defines the start index in the positions array
  73188. * @param count defines the number of positions to handle
  73189. * @param bias defines bias value to add to the result
  73190. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73191. * @return minimum and maximum values
  73192. */
  73193. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73194. minimum: Vector3;
  73195. maximum: Vector3;
  73196. };
  73197. }
  73198. declare module BABYLON {
  73199. /**
  73200. * Enum that determines the text-wrapping mode to use.
  73201. */
  73202. export enum InspectableType {
  73203. /**
  73204. * Checkbox for booleans
  73205. */
  73206. Checkbox = 0,
  73207. /**
  73208. * Sliders for numbers
  73209. */
  73210. Slider = 1,
  73211. /**
  73212. * Vector3
  73213. */
  73214. Vector3 = 2,
  73215. /**
  73216. * Quaternions
  73217. */
  73218. Quaternion = 3,
  73219. /**
  73220. * Color3
  73221. */
  73222. Color3 = 4,
  73223. /**
  73224. * String
  73225. */
  73226. String = 5
  73227. }
  73228. /**
  73229. * Interface used to define custom inspectable properties.
  73230. * This interface is used by the inspector to display custom property grids
  73231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73232. */
  73233. export interface IInspectable {
  73234. /**
  73235. * Gets the label to display
  73236. */
  73237. label: string;
  73238. /**
  73239. * Gets the name of the property to edit
  73240. */
  73241. propertyName: string;
  73242. /**
  73243. * Gets the type of the editor to use
  73244. */
  73245. type: InspectableType;
  73246. /**
  73247. * Gets the minimum value of the property when using in "slider" mode
  73248. */
  73249. min?: number;
  73250. /**
  73251. * Gets the maximum value of the property when using in "slider" mode
  73252. */
  73253. max?: number;
  73254. /**
  73255. * Gets the setp to use when using in "slider" mode
  73256. */
  73257. step?: number;
  73258. }
  73259. }
  73260. declare module BABYLON {
  73261. /**
  73262. * Class used to provide helper for timing
  73263. */
  73264. export class TimingTools {
  73265. /**
  73266. * Polyfill for setImmediate
  73267. * @param action defines the action to execute after the current execution block
  73268. */
  73269. static SetImmediate(action: () => void): void;
  73270. }
  73271. }
  73272. declare module BABYLON {
  73273. /**
  73274. * Class used to enable instatition of objects by class name
  73275. */
  73276. export class InstantiationTools {
  73277. /**
  73278. * Use this object to register external classes like custom textures or material
  73279. * to allow the laoders to instantiate them
  73280. */
  73281. static RegisteredExternalClasses: {
  73282. [key: string]: Object;
  73283. };
  73284. /**
  73285. * Tries to instantiate a new object from a given class name
  73286. * @param className defines the class name to instantiate
  73287. * @returns the new object or null if the system was not able to do the instantiation
  73288. */
  73289. static Instantiate(className: string): any;
  73290. }
  73291. }
  73292. declare module BABYLON {
  73293. /**
  73294. * This represents the required contract to create a new type of texture loader.
  73295. */
  73296. export interface IInternalTextureLoader {
  73297. /**
  73298. * Defines wether the loader supports cascade loading the different faces.
  73299. */
  73300. supportCascades: boolean;
  73301. /**
  73302. * This returns if the loader support the current file information.
  73303. * @param extension defines the file extension of the file being loaded
  73304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73305. * @param fallback defines the fallback internal texture if any
  73306. * @param isBase64 defines whether the texture is encoded as a base64
  73307. * @param isBuffer defines whether the texture data are stored as a buffer
  73308. * @returns true if the loader can load the specified file
  73309. */
  73310. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73311. /**
  73312. * Transform the url before loading if required.
  73313. * @param rootUrl the url of the texture
  73314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73315. * @returns the transformed texture
  73316. */
  73317. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73318. /**
  73319. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73320. * @param rootUrl the url of the texture
  73321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73322. * @returns the fallback texture
  73323. */
  73324. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73325. /**
  73326. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73327. * @param data contains the texture data
  73328. * @param texture defines the BabylonJS internal texture
  73329. * @param createPolynomials will be true if polynomials have been requested
  73330. * @param onLoad defines the callback to trigger once the texture is ready
  73331. * @param onError defines the callback to trigger in case of error
  73332. */
  73333. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73334. /**
  73335. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73336. * @param data contains the texture data
  73337. * @param texture defines the BabylonJS internal texture
  73338. * @param callback defines the method to call once ready to upload
  73339. */
  73340. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73341. }
  73342. }
  73343. declare module BABYLON {
  73344. interface Engine {
  73345. /**
  73346. * Creates a depth stencil cube texture.
  73347. * This is only available in WebGL 2.
  73348. * @param size The size of face edge in the cube texture.
  73349. * @param options The options defining the cube texture.
  73350. * @returns The cube texture
  73351. */
  73352. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73353. /**
  73354. * Creates a cube texture
  73355. * @param rootUrl defines the url where the files to load is located
  73356. * @param scene defines the current scene
  73357. * @param files defines the list of files to load (1 per face)
  73358. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73359. * @param onLoad defines an optional callback raised when the texture is loaded
  73360. * @param onError defines an optional callback raised if there is an issue to load the texture
  73361. * @param format defines the format of the data
  73362. * @param forcedExtension defines the extension to use to pick the right loader
  73363. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73364. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73365. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73366. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73367. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73368. * @returns the cube texture as an InternalTexture
  73369. */
  73370. 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;
  73371. /**
  73372. * Creates a cube texture
  73373. * @param rootUrl defines the url where the files to load is located
  73374. * @param scene defines the current scene
  73375. * @param files defines the list of files to load (1 per face)
  73376. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73377. * @param onLoad defines an optional callback raised when the texture is loaded
  73378. * @param onError defines an optional callback raised if there is an issue to load the texture
  73379. * @param format defines the format of the data
  73380. * @param forcedExtension defines the extension to use to pick the right loader
  73381. * @returns the cube texture as an InternalTexture
  73382. */
  73383. 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;
  73384. /**
  73385. * Creates a cube texture
  73386. * @param rootUrl defines the url where the files to load is located
  73387. * @param scene defines the current scene
  73388. * @param files defines the list of files to load (1 per face)
  73389. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73390. * @param onLoad defines an optional callback raised when the texture is loaded
  73391. * @param onError defines an optional callback raised if there is an issue to load the texture
  73392. * @param format defines the format of the data
  73393. * @param forcedExtension defines the extension to use to pick the right loader
  73394. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73395. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73396. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73397. * @returns the cube texture as an InternalTexture
  73398. */
  73399. 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;
  73400. /** @hidden */
  73401. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73402. /** @hidden */
  73403. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73404. /** @hidden */
  73405. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73406. /** @hidden */
  73407. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73408. }
  73409. }
  73410. declare module BABYLON {
  73411. /**
  73412. * Class for creating a cube texture
  73413. */
  73414. export class CubeTexture extends BaseTexture {
  73415. private _delayedOnLoad;
  73416. /**
  73417. * The url of the texture
  73418. */
  73419. url: string;
  73420. /**
  73421. * Gets or sets the center of the bounding box associated with the cube texture.
  73422. * It must define where the camera used to render the texture was set
  73423. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73424. */
  73425. boundingBoxPosition: Vector3;
  73426. private _boundingBoxSize;
  73427. /**
  73428. * Gets or sets the size of the bounding box associated with the cube texture
  73429. * When defined, the cubemap will switch to local mode
  73430. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73431. * @example https://www.babylonjs-playground.com/#RNASML
  73432. */
  73433. /**
  73434. * Returns the bounding box size
  73435. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73436. */
  73437. boundingBoxSize: Vector3;
  73438. protected _rotationY: number;
  73439. /**
  73440. * Sets texture matrix rotation angle around Y axis in radians.
  73441. */
  73442. /**
  73443. * Gets texture matrix rotation angle around Y axis radians.
  73444. */
  73445. rotationY: number;
  73446. /**
  73447. * Are mip maps generated for this texture or not.
  73448. */
  73449. readonly noMipmap: boolean;
  73450. private _noMipmap;
  73451. private _files;
  73452. private _extensions;
  73453. private _textureMatrix;
  73454. private _format;
  73455. private _createPolynomials;
  73456. /** @hidden */
  73457. _prefiltered: boolean;
  73458. /**
  73459. * Creates a cube texture from an array of image urls
  73460. * @param files defines an array of image urls
  73461. * @param scene defines the hosting scene
  73462. * @param noMipmap specifies if mip maps are not used
  73463. * @returns a cube texture
  73464. */
  73465. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73466. /**
  73467. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73468. * @param url defines the url of the prefiltered texture
  73469. * @param scene defines the scene the texture is attached to
  73470. * @param forcedExtension defines the extension of the file if different from the url
  73471. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73472. * @return the prefiltered texture
  73473. */
  73474. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73475. /**
  73476. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73477. * as prefiltered data.
  73478. * @param rootUrl defines the url of the texture or the root name of the six images
  73479. * @param scene defines the scene the texture is attached to
  73480. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73481. * @param noMipmap defines if mipmaps should be created or not
  73482. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73483. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73484. * @param onError defines a callback triggered in case of error during load
  73485. * @param format defines the internal format to use for the texture once loaded
  73486. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73487. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73488. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73489. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73490. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73491. * @return the cube texture
  73492. */
  73493. 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);
  73494. /**
  73495. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73496. */
  73497. readonly isPrefiltered: boolean;
  73498. /**
  73499. * Get the current class name of the texture useful for serialization or dynamic coding.
  73500. * @returns "CubeTexture"
  73501. */
  73502. getClassName(): string;
  73503. /**
  73504. * Update the url (and optional buffer) of this texture if url was null during construction.
  73505. * @param url the url of the texture
  73506. * @param forcedExtension defines the extension to use
  73507. * @param onLoad callback called when the texture is loaded (defaults to null)
  73508. */
  73509. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73510. /**
  73511. * Delays loading of the cube texture
  73512. * @param forcedExtension defines the extension to use
  73513. */
  73514. delayLoad(forcedExtension?: string): void;
  73515. /**
  73516. * Returns the reflection texture matrix
  73517. * @returns the reflection texture matrix
  73518. */
  73519. getReflectionTextureMatrix(): Matrix;
  73520. /**
  73521. * Sets the reflection texture matrix
  73522. * @param value Reflection texture matrix
  73523. */
  73524. setReflectionTextureMatrix(value: Matrix): void;
  73525. /**
  73526. * Parses text to create a cube texture
  73527. * @param parsedTexture define the serialized text to read from
  73528. * @param scene defines the hosting scene
  73529. * @param rootUrl defines the root url of the cube texture
  73530. * @returns a cube texture
  73531. */
  73532. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73533. /**
  73534. * Makes a clone, or deep copy, of the cube texture
  73535. * @returns a new cube texture
  73536. */
  73537. clone(): CubeTexture;
  73538. }
  73539. }
  73540. declare module BABYLON {
  73541. /**
  73542. * Manages the defines for the Material
  73543. */
  73544. export class MaterialDefines {
  73545. /** @hidden */
  73546. protected _keys: string[];
  73547. private _isDirty;
  73548. /** @hidden */
  73549. _renderId: number;
  73550. /** @hidden */
  73551. _areLightsDirty: boolean;
  73552. /** @hidden */
  73553. _areLightsDisposed: boolean;
  73554. /** @hidden */
  73555. _areAttributesDirty: boolean;
  73556. /** @hidden */
  73557. _areTexturesDirty: boolean;
  73558. /** @hidden */
  73559. _areFresnelDirty: boolean;
  73560. /** @hidden */
  73561. _areMiscDirty: boolean;
  73562. /** @hidden */
  73563. _areImageProcessingDirty: boolean;
  73564. /** @hidden */
  73565. _normals: boolean;
  73566. /** @hidden */
  73567. _uvs: boolean;
  73568. /** @hidden */
  73569. _needNormals: boolean;
  73570. /** @hidden */
  73571. _needUVs: boolean;
  73572. [id: string]: any;
  73573. /**
  73574. * Specifies if the material needs to be re-calculated
  73575. */
  73576. readonly isDirty: boolean;
  73577. /**
  73578. * Marks the material to indicate that it has been re-calculated
  73579. */
  73580. markAsProcessed(): void;
  73581. /**
  73582. * Marks the material to indicate that it needs to be re-calculated
  73583. */
  73584. markAsUnprocessed(): void;
  73585. /**
  73586. * Marks the material to indicate all of its defines need to be re-calculated
  73587. */
  73588. markAllAsDirty(): void;
  73589. /**
  73590. * Marks the material to indicate that image processing needs to be re-calculated
  73591. */
  73592. markAsImageProcessingDirty(): void;
  73593. /**
  73594. * Marks the material to indicate the lights need to be re-calculated
  73595. * @param disposed Defines whether the light is dirty due to dispose or not
  73596. */
  73597. markAsLightDirty(disposed?: boolean): void;
  73598. /**
  73599. * Marks the attribute state as changed
  73600. */
  73601. markAsAttributesDirty(): void;
  73602. /**
  73603. * Marks the texture state as changed
  73604. */
  73605. markAsTexturesDirty(): void;
  73606. /**
  73607. * Marks the fresnel state as changed
  73608. */
  73609. markAsFresnelDirty(): void;
  73610. /**
  73611. * Marks the misc state as changed
  73612. */
  73613. markAsMiscDirty(): void;
  73614. /**
  73615. * Rebuilds the material defines
  73616. */
  73617. rebuild(): void;
  73618. /**
  73619. * Specifies if two material defines are equal
  73620. * @param other - A material define instance to compare to
  73621. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73622. */
  73623. isEqual(other: MaterialDefines): boolean;
  73624. /**
  73625. * Clones this instance's defines to another instance
  73626. * @param other - material defines to clone values to
  73627. */
  73628. cloneTo(other: MaterialDefines): void;
  73629. /**
  73630. * Resets the material define values
  73631. */
  73632. reset(): void;
  73633. /**
  73634. * Converts the material define values to a string
  73635. * @returns - String of material define information
  73636. */
  73637. toString(): string;
  73638. }
  73639. }
  73640. declare module BABYLON {
  73641. /**
  73642. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73643. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73644. * 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;
  73645. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73646. */
  73647. export class ColorCurves {
  73648. private _dirty;
  73649. private _tempColor;
  73650. private _globalCurve;
  73651. private _highlightsCurve;
  73652. private _midtonesCurve;
  73653. private _shadowsCurve;
  73654. private _positiveCurve;
  73655. private _negativeCurve;
  73656. private _globalHue;
  73657. private _globalDensity;
  73658. private _globalSaturation;
  73659. private _globalExposure;
  73660. /**
  73661. * Gets the global Hue value.
  73662. * 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).
  73663. */
  73664. /**
  73665. * Sets the global Hue value.
  73666. * 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).
  73667. */
  73668. globalHue: number;
  73669. /**
  73670. * Gets the global Density value.
  73671. * 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.
  73672. * Values less than zero provide a filter of opposite hue.
  73673. */
  73674. /**
  73675. * Sets the global Density value.
  73676. * 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.
  73677. * Values less than zero provide a filter of opposite hue.
  73678. */
  73679. globalDensity: number;
  73680. /**
  73681. * Gets the global Saturation value.
  73682. * 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.
  73683. */
  73684. /**
  73685. * Sets the global Saturation value.
  73686. * 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.
  73687. */
  73688. globalSaturation: number;
  73689. /**
  73690. * Gets the global Exposure value.
  73691. * 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.
  73692. */
  73693. /**
  73694. * Sets the global Exposure value.
  73695. * 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.
  73696. */
  73697. globalExposure: number;
  73698. private _highlightsHue;
  73699. private _highlightsDensity;
  73700. private _highlightsSaturation;
  73701. private _highlightsExposure;
  73702. /**
  73703. * Gets the highlights Hue value.
  73704. * 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).
  73705. */
  73706. /**
  73707. * Sets the highlights Hue value.
  73708. * 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).
  73709. */
  73710. highlightsHue: number;
  73711. /**
  73712. * Gets the highlights Density value.
  73713. * 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.
  73714. * Values less than zero provide a filter of opposite hue.
  73715. */
  73716. /**
  73717. * Sets the highlights Density value.
  73718. * 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.
  73719. * Values less than zero provide a filter of opposite hue.
  73720. */
  73721. highlightsDensity: number;
  73722. /**
  73723. * Gets the highlights Saturation value.
  73724. * 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.
  73725. */
  73726. /**
  73727. * Sets the highlights Saturation value.
  73728. * 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.
  73729. */
  73730. highlightsSaturation: number;
  73731. /**
  73732. * Gets the highlights Exposure value.
  73733. * 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.
  73734. */
  73735. /**
  73736. * Sets the highlights Exposure value.
  73737. * 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.
  73738. */
  73739. highlightsExposure: number;
  73740. private _midtonesHue;
  73741. private _midtonesDensity;
  73742. private _midtonesSaturation;
  73743. private _midtonesExposure;
  73744. /**
  73745. * Gets the midtones Hue value.
  73746. * 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).
  73747. */
  73748. /**
  73749. * Sets the midtones Hue value.
  73750. * 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).
  73751. */
  73752. midtonesHue: number;
  73753. /**
  73754. * Gets the midtones Density value.
  73755. * 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.
  73756. * Values less than zero provide a filter of opposite hue.
  73757. */
  73758. /**
  73759. * Sets the midtones Density value.
  73760. * 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.
  73761. * Values less than zero provide a filter of opposite hue.
  73762. */
  73763. midtonesDensity: number;
  73764. /**
  73765. * Gets the midtones Saturation value.
  73766. * 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.
  73767. */
  73768. /**
  73769. * Sets the midtones Saturation value.
  73770. * 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.
  73771. */
  73772. midtonesSaturation: number;
  73773. /**
  73774. * Gets the midtones Exposure value.
  73775. * 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.
  73776. */
  73777. /**
  73778. * Sets the midtones Exposure value.
  73779. * 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.
  73780. */
  73781. midtonesExposure: number;
  73782. private _shadowsHue;
  73783. private _shadowsDensity;
  73784. private _shadowsSaturation;
  73785. private _shadowsExposure;
  73786. /**
  73787. * Gets the shadows Hue value.
  73788. * 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).
  73789. */
  73790. /**
  73791. * Sets the shadows Hue value.
  73792. * 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).
  73793. */
  73794. shadowsHue: number;
  73795. /**
  73796. * Gets the shadows Density value.
  73797. * 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.
  73798. * Values less than zero provide a filter of opposite hue.
  73799. */
  73800. /**
  73801. * Sets the shadows Density value.
  73802. * 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.
  73803. * Values less than zero provide a filter of opposite hue.
  73804. */
  73805. shadowsDensity: number;
  73806. /**
  73807. * Gets the shadows Saturation value.
  73808. * 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.
  73809. */
  73810. /**
  73811. * Sets the shadows Saturation value.
  73812. * 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.
  73813. */
  73814. shadowsSaturation: number;
  73815. /**
  73816. * Gets the shadows Exposure value.
  73817. * 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.
  73818. */
  73819. /**
  73820. * Sets the shadows Exposure value.
  73821. * 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.
  73822. */
  73823. shadowsExposure: number;
  73824. /**
  73825. * Returns the class name
  73826. * @returns The class name
  73827. */
  73828. getClassName(): string;
  73829. /**
  73830. * Binds the color curves to the shader.
  73831. * @param colorCurves The color curve to bind
  73832. * @param effect The effect to bind to
  73833. * @param positiveUniform The positive uniform shader parameter
  73834. * @param neutralUniform The neutral uniform shader parameter
  73835. * @param negativeUniform The negative uniform shader parameter
  73836. */
  73837. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73838. /**
  73839. * Prepare the list of uniforms associated with the ColorCurves effects.
  73840. * @param uniformsList The list of uniforms used in the effect
  73841. */
  73842. static PrepareUniforms(uniformsList: string[]): void;
  73843. /**
  73844. * Returns color grading data based on a hue, density, saturation and exposure value.
  73845. * @param filterHue The hue of the color filter.
  73846. * @param filterDensity The density of the color filter.
  73847. * @param saturation The saturation.
  73848. * @param exposure The exposure.
  73849. * @param result The result data container.
  73850. */
  73851. private getColorGradingDataToRef;
  73852. /**
  73853. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73854. * @param value The input slider value in range [-100,100].
  73855. * @returns Adjusted value.
  73856. */
  73857. private static applyColorGradingSliderNonlinear;
  73858. /**
  73859. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73860. * @param hue The hue (H) input.
  73861. * @param saturation The saturation (S) input.
  73862. * @param brightness The brightness (B) input.
  73863. * @result An RGBA color represented as Vector4.
  73864. */
  73865. private static fromHSBToRef;
  73866. /**
  73867. * Returns a value clamped between min and max
  73868. * @param value The value to clamp
  73869. * @param min The minimum of value
  73870. * @param max The maximum of value
  73871. * @returns The clamped value.
  73872. */
  73873. private static clamp;
  73874. /**
  73875. * Clones the current color curve instance.
  73876. * @return The cloned curves
  73877. */
  73878. clone(): ColorCurves;
  73879. /**
  73880. * Serializes the current color curve instance to a json representation.
  73881. * @return a JSON representation
  73882. */
  73883. serialize(): any;
  73884. /**
  73885. * Parses the color curve from a json representation.
  73886. * @param source the JSON source to parse
  73887. * @return The parsed curves
  73888. */
  73889. static Parse(source: any): ColorCurves;
  73890. }
  73891. }
  73892. declare module BABYLON {
  73893. /**
  73894. * Interface to follow in your material defines to integrate easily the
  73895. * Image proccessing functions.
  73896. * @hidden
  73897. */
  73898. export interface IImageProcessingConfigurationDefines {
  73899. IMAGEPROCESSING: boolean;
  73900. VIGNETTE: boolean;
  73901. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73902. VIGNETTEBLENDMODEOPAQUE: boolean;
  73903. TONEMAPPING: boolean;
  73904. TONEMAPPING_ACES: boolean;
  73905. CONTRAST: boolean;
  73906. EXPOSURE: boolean;
  73907. COLORCURVES: boolean;
  73908. COLORGRADING: boolean;
  73909. COLORGRADING3D: boolean;
  73910. SAMPLER3DGREENDEPTH: boolean;
  73911. SAMPLER3DBGRMAP: boolean;
  73912. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73913. }
  73914. /**
  73915. * @hidden
  73916. */
  73917. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73918. IMAGEPROCESSING: boolean;
  73919. VIGNETTE: boolean;
  73920. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73921. VIGNETTEBLENDMODEOPAQUE: boolean;
  73922. TONEMAPPING: boolean;
  73923. TONEMAPPING_ACES: boolean;
  73924. CONTRAST: boolean;
  73925. COLORCURVES: boolean;
  73926. COLORGRADING: boolean;
  73927. COLORGRADING3D: boolean;
  73928. SAMPLER3DGREENDEPTH: boolean;
  73929. SAMPLER3DBGRMAP: boolean;
  73930. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73931. EXPOSURE: boolean;
  73932. constructor();
  73933. }
  73934. /**
  73935. * This groups together the common properties used for image processing either in direct forward pass
  73936. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73937. * or not.
  73938. */
  73939. export class ImageProcessingConfiguration {
  73940. /**
  73941. * Default tone mapping applied in BabylonJS.
  73942. */
  73943. static readonly TONEMAPPING_STANDARD: number;
  73944. /**
  73945. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73946. * to other engines rendering to increase portability.
  73947. */
  73948. static readonly TONEMAPPING_ACES: number;
  73949. /**
  73950. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73951. */
  73952. colorCurves: Nullable<ColorCurves>;
  73953. private _colorCurvesEnabled;
  73954. /**
  73955. * Gets wether the color curves effect is enabled.
  73956. */
  73957. /**
  73958. * Sets wether the color curves effect is enabled.
  73959. */
  73960. colorCurvesEnabled: boolean;
  73961. private _colorGradingTexture;
  73962. /**
  73963. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73964. */
  73965. /**
  73966. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73967. */
  73968. colorGradingTexture: Nullable<BaseTexture>;
  73969. private _colorGradingEnabled;
  73970. /**
  73971. * Gets wether the color grading effect is enabled.
  73972. */
  73973. /**
  73974. * Sets wether the color grading effect is enabled.
  73975. */
  73976. colorGradingEnabled: boolean;
  73977. private _colorGradingWithGreenDepth;
  73978. /**
  73979. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73980. */
  73981. /**
  73982. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73983. */
  73984. colorGradingWithGreenDepth: boolean;
  73985. private _colorGradingBGR;
  73986. /**
  73987. * Gets wether the color grading texture contains BGR values.
  73988. */
  73989. /**
  73990. * Sets wether the color grading texture contains BGR values.
  73991. */
  73992. colorGradingBGR: boolean;
  73993. /** @hidden */
  73994. _exposure: number;
  73995. /**
  73996. * Gets the Exposure used in the effect.
  73997. */
  73998. /**
  73999. * Sets the Exposure used in the effect.
  74000. */
  74001. exposure: number;
  74002. private _toneMappingEnabled;
  74003. /**
  74004. * Gets wether the tone mapping effect is enabled.
  74005. */
  74006. /**
  74007. * Sets wether the tone mapping effect is enabled.
  74008. */
  74009. toneMappingEnabled: boolean;
  74010. private _toneMappingType;
  74011. /**
  74012. * Gets the type of tone mapping effect.
  74013. */
  74014. /**
  74015. * Sets the type of tone mapping effect used in BabylonJS.
  74016. */
  74017. toneMappingType: number;
  74018. protected _contrast: number;
  74019. /**
  74020. * Gets the contrast used in the effect.
  74021. */
  74022. /**
  74023. * Sets the contrast used in the effect.
  74024. */
  74025. contrast: number;
  74026. /**
  74027. * Vignette stretch size.
  74028. */
  74029. vignetteStretch: number;
  74030. /**
  74031. * Vignette centre X Offset.
  74032. */
  74033. vignetteCentreX: number;
  74034. /**
  74035. * Vignette centre Y Offset.
  74036. */
  74037. vignetteCentreY: number;
  74038. /**
  74039. * Vignette weight or intensity of the vignette effect.
  74040. */
  74041. vignetteWeight: number;
  74042. /**
  74043. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74044. * if vignetteEnabled is set to true.
  74045. */
  74046. vignetteColor: Color4;
  74047. /**
  74048. * Camera field of view used by the Vignette effect.
  74049. */
  74050. vignetteCameraFov: number;
  74051. private _vignetteBlendMode;
  74052. /**
  74053. * Gets the vignette blend mode allowing different kind of effect.
  74054. */
  74055. /**
  74056. * Sets the vignette blend mode allowing different kind of effect.
  74057. */
  74058. vignetteBlendMode: number;
  74059. private _vignetteEnabled;
  74060. /**
  74061. * Gets wether the vignette effect is enabled.
  74062. */
  74063. /**
  74064. * Sets wether the vignette effect is enabled.
  74065. */
  74066. vignetteEnabled: boolean;
  74067. private _applyByPostProcess;
  74068. /**
  74069. * Gets wether the image processing is applied through a post process or not.
  74070. */
  74071. /**
  74072. * Sets wether the image processing is applied through a post process or not.
  74073. */
  74074. applyByPostProcess: boolean;
  74075. private _isEnabled;
  74076. /**
  74077. * Gets wether the image processing is enabled or not.
  74078. */
  74079. /**
  74080. * Sets wether the image processing is enabled or not.
  74081. */
  74082. isEnabled: boolean;
  74083. /**
  74084. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74085. */
  74086. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74087. /**
  74088. * Method called each time the image processing information changes requires to recompile the effect.
  74089. */
  74090. protected _updateParameters(): void;
  74091. /**
  74092. * Gets the current class name.
  74093. * @return "ImageProcessingConfiguration"
  74094. */
  74095. getClassName(): string;
  74096. /**
  74097. * Prepare the list of uniforms associated with the Image Processing effects.
  74098. * @param uniforms The list of uniforms used in the effect
  74099. * @param defines the list of defines currently in use
  74100. */
  74101. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74102. /**
  74103. * Prepare the list of samplers associated with the Image Processing effects.
  74104. * @param samplersList The list of uniforms used in the effect
  74105. * @param defines the list of defines currently in use
  74106. */
  74107. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74108. /**
  74109. * Prepare the list of defines associated to the shader.
  74110. * @param defines the list of defines to complete
  74111. * @param forPostProcess Define if we are currently in post process mode or not
  74112. */
  74113. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74114. /**
  74115. * Returns true if all the image processing information are ready.
  74116. * @returns True if ready, otherwise, false
  74117. */
  74118. isReady(): boolean;
  74119. /**
  74120. * Binds the image processing to the shader.
  74121. * @param effect The effect to bind to
  74122. * @param aspectRatio Define the current aspect ratio of the effect
  74123. */
  74124. bind(effect: Effect, aspectRatio?: number): void;
  74125. /**
  74126. * Clones the current image processing instance.
  74127. * @return The cloned image processing
  74128. */
  74129. clone(): ImageProcessingConfiguration;
  74130. /**
  74131. * Serializes the current image processing instance to a json representation.
  74132. * @return a JSON representation
  74133. */
  74134. serialize(): any;
  74135. /**
  74136. * Parses the image processing from a json representation.
  74137. * @param source the JSON source to parse
  74138. * @return The parsed image processing
  74139. */
  74140. static Parse(source: any): ImageProcessingConfiguration;
  74141. private static _VIGNETTEMODE_MULTIPLY;
  74142. private static _VIGNETTEMODE_OPAQUE;
  74143. /**
  74144. * Used to apply the vignette as a mix with the pixel color.
  74145. */
  74146. static readonly VIGNETTEMODE_MULTIPLY: number;
  74147. /**
  74148. * Used to apply the vignette as a replacement of the pixel color.
  74149. */
  74150. static readonly VIGNETTEMODE_OPAQUE: number;
  74151. }
  74152. }
  74153. declare module BABYLON {
  74154. /** @hidden */
  74155. export var postprocessVertexShader: {
  74156. name: string;
  74157. shader: string;
  74158. };
  74159. }
  74160. declare module BABYLON {
  74161. /** Defines supported spaces */
  74162. export enum Space {
  74163. /** Local (object) space */
  74164. LOCAL = 0,
  74165. /** World space */
  74166. WORLD = 1,
  74167. /** Bone space */
  74168. BONE = 2
  74169. }
  74170. /** Defines the 3 main axes */
  74171. export class Axis {
  74172. /** X axis */
  74173. static X: Vector3;
  74174. /** Y axis */
  74175. static Y: Vector3;
  74176. /** Z axis */
  74177. static Z: Vector3;
  74178. }
  74179. }
  74180. declare module BABYLON {
  74181. /**
  74182. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74183. * This is the base of the follow, arc rotate cameras and Free camera
  74184. * @see http://doc.babylonjs.com/features/cameras
  74185. */
  74186. export class TargetCamera extends Camera {
  74187. private static _RigCamTransformMatrix;
  74188. private static _TargetTransformMatrix;
  74189. private static _TargetFocalPoint;
  74190. /**
  74191. * Define the current direction the camera is moving to
  74192. */
  74193. cameraDirection: Vector3;
  74194. /**
  74195. * Define the current rotation the camera is rotating to
  74196. */
  74197. cameraRotation: Vector2;
  74198. /**
  74199. * When set, the up vector of the camera will be updated by the rotation of the camera
  74200. */
  74201. updateUpVectorFromRotation: boolean;
  74202. private _tmpQuaternion;
  74203. /**
  74204. * Define the current rotation of the camera
  74205. */
  74206. rotation: Vector3;
  74207. /**
  74208. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74209. */
  74210. rotationQuaternion: Quaternion;
  74211. /**
  74212. * Define the current speed of the camera
  74213. */
  74214. speed: number;
  74215. /**
  74216. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74217. * around all axis.
  74218. */
  74219. noRotationConstraint: boolean;
  74220. /**
  74221. * Define the current target of the camera as an object or a position.
  74222. */
  74223. lockedTarget: any;
  74224. /** @hidden */
  74225. _currentTarget: Vector3;
  74226. /** @hidden */
  74227. _initialFocalDistance: number;
  74228. /** @hidden */
  74229. _viewMatrix: Matrix;
  74230. /** @hidden */
  74231. _camMatrix: Matrix;
  74232. /** @hidden */
  74233. _cameraTransformMatrix: Matrix;
  74234. /** @hidden */
  74235. _cameraRotationMatrix: Matrix;
  74236. /** @hidden */
  74237. _referencePoint: Vector3;
  74238. /** @hidden */
  74239. _transformedReferencePoint: Vector3;
  74240. protected _globalCurrentTarget: Vector3;
  74241. protected _globalCurrentUpVector: Vector3;
  74242. /** @hidden */
  74243. _reset: () => void;
  74244. private _defaultUp;
  74245. /**
  74246. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74247. * This is the base of the follow, arc rotate cameras and Free camera
  74248. * @see http://doc.babylonjs.com/features/cameras
  74249. * @param name Defines the name of the camera in the scene
  74250. * @param position Defines the start position of the camera in the scene
  74251. * @param scene Defines the scene the camera belongs to
  74252. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74253. */
  74254. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74255. /**
  74256. * Gets the position in front of the camera at a given distance.
  74257. * @param distance The distance from the camera we want the position to be
  74258. * @returns the position
  74259. */
  74260. getFrontPosition(distance: number): Vector3;
  74261. /** @hidden */
  74262. _getLockedTargetPosition(): Nullable<Vector3>;
  74263. private _storedPosition;
  74264. private _storedRotation;
  74265. private _storedRotationQuaternion;
  74266. /**
  74267. * Store current camera state of the camera (fov, position, rotation, etc..)
  74268. * @returns the camera
  74269. */
  74270. storeState(): Camera;
  74271. /**
  74272. * Restored camera state. You must call storeState() first
  74273. * @returns whether it was successful or not
  74274. * @hidden
  74275. */
  74276. _restoreStateValues(): boolean;
  74277. /** @hidden */
  74278. _initCache(): void;
  74279. /** @hidden */
  74280. _updateCache(ignoreParentClass?: boolean): void;
  74281. /** @hidden */
  74282. _isSynchronizedViewMatrix(): boolean;
  74283. /** @hidden */
  74284. _computeLocalCameraSpeed(): number;
  74285. /**
  74286. * Defines the target the camera should look at.
  74287. * @param target Defines the new target as a Vector or a mesh
  74288. */
  74289. setTarget(target: Vector3): void;
  74290. /**
  74291. * Return the current target position of the camera. This value is expressed in local space.
  74292. * @returns the target position
  74293. */
  74294. getTarget(): Vector3;
  74295. /** @hidden */
  74296. _decideIfNeedsToMove(): boolean;
  74297. /** @hidden */
  74298. _updatePosition(): void;
  74299. /** @hidden */
  74300. _checkInputs(): void;
  74301. protected _updateCameraRotationMatrix(): void;
  74302. /**
  74303. * 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)
  74304. * @returns the current camera
  74305. */
  74306. private _rotateUpVectorWithCameraRotationMatrix;
  74307. private _cachedRotationZ;
  74308. private _cachedQuaternionRotationZ;
  74309. /** @hidden */
  74310. _getViewMatrix(): Matrix;
  74311. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74312. /**
  74313. * @hidden
  74314. */
  74315. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74316. /**
  74317. * @hidden
  74318. */
  74319. _updateRigCameras(): void;
  74320. private _getRigCamPositionAndTarget;
  74321. /**
  74322. * Gets the current object class name.
  74323. * @return the class name
  74324. */
  74325. getClassName(): string;
  74326. }
  74327. }
  74328. declare module BABYLON {
  74329. /**
  74330. * Gather the list of keyboard event types as constants.
  74331. */
  74332. export class KeyboardEventTypes {
  74333. /**
  74334. * The keydown event is fired when a key becomes active (pressed).
  74335. */
  74336. static readonly KEYDOWN: number;
  74337. /**
  74338. * The keyup event is fired when a key has been released.
  74339. */
  74340. static readonly KEYUP: number;
  74341. }
  74342. /**
  74343. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74344. */
  74345. export class KeyboardInfo {
  74346. /**
  74347. * Defines the type of event (KeyboardEventTypes)
  74348. */
  74349. type: number;
  74350. /**
  74351. * Defines the related dom event
  74352. */
  74353. event: KeyboardEvent;
  74354. /**
  74355. * Instantiates a new keyboard info.
  74356. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74357. * @param type Defines the type of event (KeyboardEventTypes)
  74358. * @param event Defines the related dom event
  74359. */
  74360. constructor(
  74361. /**
  74362. * Defines the type of event (KeyboardEventTypes)
  74363. */
  74364. type: number,
  74365. /**
  74366. * Defines the related dom event
  74367. */
  74368. event: KeyboardEvent);
  74369. }
  74370. /**
  74371. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74372. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74373. */
  74374. export class KeyboardInfoPre extends KeyboardInfo {
  74375. /**
  74376. * Defines the type of event (KeyboardEventTypes)
  74377. */
  74378. type: number;
  74379. /**
  74380. * Defines the related dom event
  74381. */
  74382. event: KeyboardEvent;
  74383. /**
  74384. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74385. */
  74386. skipOnPointerObservable: boolean;
  74387. /**
  74388. * Instantiates a new keyboard pre info.
  74389. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74390. * @param type Defines the type of event (KeyboardEventTypes)
  74391. * @param event Defines the related dom event
  74392. */
  74393. constructor(
  74394. /**
  74395. * Defines the type of event (KeyboardEventTypes)
  74396. */
  74397. type: number,
  74398. /**
  74399. * Defines the related dom event
  74400. */
  74401. event: KeyboardEvent);
  74402. }
  74403. }
  74404. declare module BABYLON {
  74405. /**
  74406. * Manage the keyboard inputs to control the movement of a free camera.
  74407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74408. */
  74409. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74410. /**
  74411. * Defines the camera the input is attached to.
  74412. */
  74413. camera: FreeCamera;
  74414. /**
  74415. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74416. */
  74417. keysUp: number[];
  74418. /**
  74419. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74420. */
  74421. keysDown: number[];
  74422. /**
  74423. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74424. */
  74425. keysLeft: number[];
  74426. /**
  74427. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74428. */
  74429. keysRight: number[];
  74430. private _keys;
  74431. private _onCanvasBlurObserver;
  74432. private _onKeyboardObserver;
  74433. private _engine;
  74434. private _scene;
  74435. /**
  74436. * Attach the input controls to a specific dom element to get the input from.
  74437. * @param element Defines the element the controls should be listened from
  74438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74439. */
  74440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74441. /**
  74442. * Detach the current controls from the specified dom element.
  74443. * @param element Defines the element to stop listening the inputs from
  74444. */
  74445. detachControl(element: Nullable<HTMLElement>): void;
  74446. /**
  74447. * Update the current camera state depending on the inputs that have been used this frame.
  74448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74449. */
  74450. checkInputs(): void;
  74451. /**
  74452. * Gets the class name of the current intput.
  74453. * @returns the class name
  74454. */
  74455. getClassName(): string;
  74456. /** @hidden */
  74457. _onLostFocus(): void;
  74458. /**
  74459. * Get the friendly name associated with the input class.
  74460. * @returns the input friendly name
  74461. */
  74462. getSimpleName(): string;
  74463. }
  74464. }
  74465. declare module BABYLON {
  74466. /**
  74467. * Interface describing all the common properties and methods a shadow light needs to implement.
  74468. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74469. * as well as binding the different shadow properties to the effects.
  74470. */
  74471. export interface IShadowLight extends Light {
  74472. /**
  74473. * The light id in the scene (used in scene.findLighById for instance)
  74474. */
  74475. id: string;
  74476. /**
  74477. * The position the shdow will be casted from.
  74478. */
  74479. position: Vector3;
  74480. /**
  74481. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74482. */
  74483. direction: Vector3;
  74484. /**
  74485. * The transformed position. Position of the light in world space taking parenting in account.
  74486. */
  74487. transformedPosition: Vector3;
  74488. /**
  74489. * The transformed direction. Direction of the light in world space taking parenting in account.
  74490. */
  74491. transformedDirection: Vector3;
  74492. /**
  74493. * The friendly name of the light in the scene.
  74494. */
  74495. name: string;
  74496. /**
  74497. * Defines the shadow projection clipping minimum z value.
  74498. */
  74499. shadowMinZ: number;
  74500. /**
  74501. * Defines the shadow projection clipping maximum z value.
  74502. */
  74503. shadowMaxZ: number;
  74504. /**
  74505. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74506. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74507. */
  74508. computeTransformedInformation(): boolean;
  74509. /**
  74510. * Gets the scene the light belongs to.
  74511. * @returns The scene
  74512. */
  74513. getScene(): Scene;
  74514. /**
  74515. * Callback defining a custom Projection Matrix Builder.
  74516. * This can be used to override the default projection matrix computation.
  74517. */
  74518. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74519. /**
  74520. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74521. * @param matrix The materix to updated with the projection information
  74522. * @param viewMatrix The transform matrix of the light
  74523. * @param renderList The list of mesh to render in the map
  74524. * @returns The current light
  74525. */
  74526. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74527. /**
  74528. * Gets the current depth scale used in ESM.
  74529. * @returns The scale
  74530. */
  74531. getDepthScale(): number;
  74532. /**
  74533. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74534. * @returns true if a cube texture needs to be use
  74535. */
  74536. needCube(): boolean;
  74537. /**
  74538. * Detects if the projection matrix requires to be recomputed this frame.
  74539. * @returns true if it requires to be recomputed otherwise, false.
  74540. */
  74541. needProjectionMatrixCompute(): boolean;
  74542. /**
  74543. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74544. */
  74545. forceProjectionMatrixCompute(): void;
  74546. /**
  74547. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74548. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74549. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74550. */
  74551. getShadowDirection(faceIndex?: number): Vector3;
  74552. /**
  74553. * Gets the minZ used for shadow according to both the scene and the light.
  74554. * @param activeCamera The camera we are returning the min for
  74555. * @returns the depth min z
  74556. */
  74557. getDepthMinZ(activeCamera: Camera): number;
  74558. /**
  74559. * Gets the maxZ used for shadow according to both the scene and the light.
  74560. * @param activeCamera The camera we are returning the max for
  74561. * @returns the depth max z
  74562. */
  74563. getDepthMaxZ(activeCamera: Camera): number;
  74564. }
  74565. /**
  74566. * Base implementation IShadowLight
  74567. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74568. */
  74569. export abstract class ShadowLight extends Light implements IShadowLight {
  74570. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74571. protected _position: Vector3;
  74572. protected _setPosition(value: Vector3): void;
  74573. /**
  74574. * Sets the position the shadow will be casted from. Also use as the light position for both
  74575. * point and spot lights.
  74576. */
  74577. /**
  74578. * Sets the position the shadow will be casted from. Also use as the light position for both
  74579. * point and spot lights.
  74580. */
  74581. position: Vector3;
  74582. protected _direction: Vector3;
  74583. protected _setDirection(value: Vector3): void;
  74584. /**
  74585. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74586. * Also use as the light direction on spot and directional lights.
  74587. */
  74588. /**
  74589. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74590. * Also use as the light direction on spot and directional lights.
  74591. */
  74592. direction: Vector3;
  74593. private _shadowMinZ;
  74594. /**
  74595. * Gets the shadow projection clipping minimum z value.
  74596. */
  74597. /**
  74598. * Sets the shadow projection clipping minimum z value.
  74599. */
  74600. shadowMinZ: number;
  74601. private _shadowMaxZ;
  74602. /**
  74603. * Sets the shadow projection clipping maximum z value.
  74604. */
  74605. /**
  74606. * Gets the shadow projection clipping maximum z value.
  74607. */
  74608. shadowMaxZ: number;
  74609. /**
  74610. * Callback defining a custom Projection Matrix Builder.
  74611. * This can be used to override the default projection matrix computation.
  74612. */
  74613. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74614. /**
  74615. * The transformed position. Position of the light in world space taking parenting in account.
  74616. */
  74617. transformedPosition: Vector3;
  74618. /**
  74619. * The transformed direction. Direction of the light in world space taking parenting in account.
  74620. */
  74621. transformedDirection: Vector3;
  74622. private _needProjectionMatrixCompute;
  74623. /**
  74624. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74625. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74626. */
  74627. computeTransformedInformation(): boolean;
  74628. /**
  74629. * Return the depth scale used for the shadow map.
  74630. * @returns the depth scale.
  74631. */
  74632. getDepthScale(): number;
  74633. /**
  74634. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74635. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74636. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74637. */
  74638. getShadowDirection(faceIndex?: number): Vector3;
  74639. /**
  74640. * Returns the ShadowLight absolute position in the World.
  74641. * @returns the position vector in world space
  74642. */
  74643. getAbsolutePosition(): Vector3;
  74644. /**
  74645. * Sets the ShadowLight direction toward the passed target.
  74646. * @param target The point to target in local space
  74647. * @returns the updated ShadowLight direction
  74648. */
  74649. setDirectionToTarget(target: Vector3): Vector3;
  74650. /**
  74651. * Returns the light rotation in euler definition.
  74652. * @returns the x y z rotation in local space.
  74653. */
  74654. getRotation(): Vector3;
  74655. /**
  74656. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74657. * @returns true if a cube texture needs to be use
  74658. */
  74659. needCube(): boolean;
  74660. /**
  74661. * Detects if the projection matrix requires to be recomputed this frame.
  74662. * @returns true if it requires to be recomputed otherwise, false.
  74663. */
  74664. needProjectionMatrixCompute(): boolean;
  74665. /**
  74666. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74667. */
  74668. forceProjectionMatrixCompute(): void;
  74669. /** @hidden */
  74670. _initCache(): void;
  74671. /** @hidden */
  74672. _isSynchronized(): boolean;
  74673. /**
  74674. * Computes the world matrix of the node
  74675. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74676. * @returns the world matrix
  74677. */
  74678. computeWorldMatrix(force?: boolean): Matrix;
  74679. /**
  74680. * Gets the minZ used for shadow according to both the scene and the light.
  74681. * @param activeCamera The camera we are returning the min for
  74682. * @returns the depth min z
  74683. */
  74684. getDepthMinZ(activeCamera: Camera): number;
  74685. /**
  74686. * Gets the maxZ used for shadow according to both the scene and the light.
  74687. * @param activeCamera The camera we are returning the max for
  74688. * @returns the depth max z
  74689. */
  74690. getDepthMaxZ(activeCamera: Camera): number;
  74691. /**
  74692. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74693. * @param matrix The materix to updated with the projection information
  74694. * @param viewMatrix The transform matrix of the light
  74695. * @param renderList The list of mesh to render in the map
  74696. * @returns The current light
  74697. */
  74698. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74699. }
  74700. }
  74701. declare module BABYLON {
  74702. /**
  74703. * "Static Class" containing the most commonly used helper while dealing with material for
  74704. * rendering purpose.
  74705. *
  74706. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74707. *
  74708. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74709. */
  74710. export class MaterialHelper {
  74711. /**
  74712. * Bind the current view position to an effect.
  74713. * @param effect The effect to be bound
  74714. * @param scene The scene the eyes position is used from
  74715. */
  74716. static BindEyePosition(effect: Effect, scene: Scene): void;
  74717. /**
  74718. * Helps preparing the defines values about the UVs in used in the effect.
  74719. * UVs are shared as much as we can accross channels in the shaders.
  74720. * @param texture The texture we are preparing the UVs for
  74721. * @param defines The defines to update
  74722. * @param key The channel key "diffuse", "specular"... used in the shader
  74723. */
  74724. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74725. /**
  74726. * Binds a texture matrix value to its corrsponding uniform
  74727. * @param texture The texture to bind the matrix for
  74728. * @param uniformBuffer The uniform buffer receivin the data
  74729. * @param key The channel key "diffuse", "specular"... used in the shader
  74730. */
  74731. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74732. /**
  74733. * Gets the current status of the fog (should it be enabled?)
  74734. * @param mesh defines the mesh to evaluate for fog support
  74735. * @param scene defines the hosting scene
  74736. * @returns true if fog must be enabled
  74737. */
  74738. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74739. /**
  74740. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74741. * @param mesh defines the current mesh
  74742. * @param scene defines the current scene
  74743. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74744. * @param pointsCloud defines if point cloud rendering has to be turned on
  74745. * @param fogEnabled defines if fog has to be turned on
  74746. * @param alphaTest defines if alpha testing has to be turned on
  74747. * @param defines defines the current list of defines
  74748. */
  74749. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74750. /**
  74751. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74752. * @param scene defines the current scene
  74753. * @param engine defines the current engine
  74754. * @param defines specifies the list of active defines
  74755. * @param useInstances defines if instances have to be turned on
  74756. * @param useClipPlane defines if clip plane have to be turned on
  74757. */
  74758. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74759. /**
  74760. * Prepares the defines for bones
  74761. * @param mesh The mesh containing the geometry data we will draw
  74762. * @param defines The defines to update
  74763. */
  74764. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74765. /**
  74766. * Prepares the defines for morph targets
  74767. * @param mesh The mesh containing the geometry data we will draw
  74768. * @param defines The defines to update
  74769. */
  74770. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74771. /**
  74772. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74773. * @param mesh The mesh containing the geometry data we will draw
  74774. * @param defines The defines to update
  74775. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74776. * @param useBones Precise whether bones should be used or not (override mesh info)
  74777. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74778. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74779. * @returns false if defines are considered not dirty and have not been checked
  74780. */
  74781. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74782. /**
  74783. * Prepares the defines related to multiview
  74784. * @param scene The scene we are intending to draw
  74785. * @param defines The defines to update
  74786. */
  74787. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74788. /**
  74789. * Prepares the defines related to the light information passed in parameter
  74790. * @param scene The scene we are intending to draw
  74791. * @param mesh The mesh the effect is compiling for
  74792. * @param light The light the effect is compiling for
  74793. * @param lightIndex The index of the light
  74794. * @param defines The defines to update
  74795. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74796. * @param state Defines the current state regarding what is needed (normals, etc...)
  74797. */
  74798. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74799. needNormals: boolean;
  74800. needRebuild: boolean;
  74801. shadowEnabled: boolean;
  74802. specularEnabled: boolean;
  74803. lightmapMode: boolean;
  74804. }): void;
  74805. /**
  74806. * Prepares the defines related to the light information passed in parameter
  74807. * @param scene The scene we are intending to draw
  74808. * @param mesh The mesh the effect is compiling for
  74809. * @param defines The defines to update
  74810. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74811. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74812. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74813. * @returns true if normals will be required for the rest of the effect
  74814. */
  74815. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74816. /**
  74817. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74818. * @param lightIndex defines the light index
  74819. * @param uniformsList The uniform list
  74820. * @param samplersList The sampler list
  74821. * @param projectedLightTexture defines if projected texture must be used
  74822. * @param uniformBuffersList defines an optional list of uniform buffers
  74823. */
  74824. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74825. /**
  74826. * Prepares the uniforms and samplers list to be used in the effect
  74827. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74828. * @param samplersList The sampler list
  74829. * @param defines The defines helping in the list generation
  74830. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74831. */
  74832. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74833. /**
  74834. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74835. * @param defines The defines to update while falling back
  74836. * @param fallbacks The authorized effect fallbacks
  74837. * @param maxSimultaneousLights The maximum number of lights allowed
  74838. * @param rank the current rank of the Effect
  74839. * @returns The newly affected rank
  74840. */
  74841. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74842. private static _TmpMorphInfluencers;
  74843. /**
  74844. * Prepares the list of attributes required for morph targets according to the effect defines.
  74845. * @param attribs The current list of supported attribs
  74846. * @param mesh The mesh to prepare the morph targets attributes for
  74847. * @param influencers The number of influencers
  74848. */
  74849. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74850. /**
  74851. * Prepares the list of attributes required for morph targets according to the effect defines.
  74852. * @param attribs The current list of supported attribs
  74853. * @param mesh The mesh to prepare the morph targets attributes for
  74854. * @param defines The current Defines of the effect
  74855. */
  74856. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74857. /**
  74858. * Prepares the list of attributes required for bones according to the effect defines.
  74859. * @param attribs The current list of supported attribs
  74860. * @param mesh The mesh to prepare the bones attributes for
  74861. * @param defines The current Defines of the effect
  74862. * @param fallbacks The current efffect fallback strategy
  74863. */
  74864. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74865. /**
  74866. * Check and prepare the list of attributes required for instances according to the effect defines.
  74867. * @param attribs The current list of supported attribs
  74868. * @param defines The current MaterialDefines of the effect
  74869. */
  74870. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74871. /**
  74872. * Add the list of attributes required for instances to the attribs array.
  74873. * @param attribs The current list of supported attribs
  74874. */
  74875. static PushAttributesForInstances(attribs: string[]): void;
  74876. /**
  74877. * Binds the light shadow information to the effect for the given mesh.
  74878. * @param light The light containing the generator
  74879. * @param scene The scene the lights belongs to
  74880. * @param mesh The mesh we are binding the information to render
  74881. * @param lightIndex The light index in the effect used to render the mesh
  74882. * @param effect The effect we are binding the data to
  74883. */
  74884. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74885. /**
  74886. * Binds the light information to the effect.
  74887. * @param light The light containing the generator
  74888. * @param effect The effect we are binding the data to
  74889. * @param lightIndex The light index in the effect used to render
  74890. */
  74891. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74892. /**
  74893. * Binds the lights information from the scene to the effect for the given mesh.
  74894. * @param light Light to bind
  74895. * @param lightIndex Light index
  74896. * @param scene The scene where the light belongs to
  74897. * @param mesh The mesh we are binding the information to render
  74898. * @param effect The effect we are binding the data to
  74899. * @param useSpecular Defines if specular is supported
  74900. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74901. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74902. */
  74903. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74904. /**
  74905. * Binds the lights information from the scene to the effect for the given mesh.
  74906. * @param scene The scene the lights belongs to
  74907. * @param mesh The mesh we are binding the information to render
  74908. * @param effect The effect we are binding the data to
  74909. * @param defines The generated defines for the effect
  74910. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74911. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74912. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74913. */
  74914. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74915. private static _tempFogColor;
  74916. /**
  74917. * Binds the fog information from the scene to the effect for the given mesh.
  74918. * @param scene The scene the lights belongs to
  74919. * @param mesh The mesh we are binding the information to render
  74920. * @param effect The effect we are binding the data to
  74921. * @param linearSpace Defines if the fog effect is applied in linear space
  74922. */
  74923. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74924. /**
  74925. * Binds the bones information from the mesh to the effect.
  74926. * @param mesh The mesh we are binding the information to render
  74927. * @param effect The effect we are binding the data to
  74928. */
  74929. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74930. /**
  74931. * Binds the morph targets information from the mesh to the effect.
  74932. * @param abstractMesh The mesh we are binding the information to render
  74933. * @param effect The effect we are binding the data to
  74934. */
  74935. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74936. /**
  74937. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74938. * @param defines The generated defines used in the effect
  74939. * @param effect The effect we are binding the data to
  74940. * @param scene The scene we are willing to render with logarithmic scale for
  74941. */
  74942. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74943. /**
  74944. * Binds the clip plane information from the scene to the effect.
  74945. * @param scene The scene the clip plane information are extracted from
  74946. * @param effect The effect we are binding the data to
  74947. */
  74948. static BindClipPlane(effect: Effect, scene: Scene): void;
  74949. }
  74950. }
  74951. declare module BABYLON {
  74952. /** @hidden */
  74953. export var packingFunctions: {
  74954. name: string;
  74955. shader: string;
  74956. };
  74957. }
  74958. declare module BABYLON {
  74959. /** @hidden */
  74960. export var shadowMapPixelShader: {
  74961. name: string;
  74962. shader: string;
  74963. };
  74964. }
  74965. declare module BABYLON {
  74966. /** @hidden */
  74967. export var bonesDeclaration: {
  74968. name: string;
  74969. shader: string;
  74970. };
  74971. }
  74972. declare module BABYLON {
  74973. /** @hidden */
  74974. export var morphTargetsVertexGlobalDeclaration: {
  74975. name: string;
  74976. shader: string;
  74977. };
  74978. }
  74979. declare module BABYLON {
  74980. /** @hidden */
  74981. export var morphTargetsVertexDeclaration: {
  74982. name: string;
  74983. shader: string;
  74984. };
  74985. }
  74986. declare module BABYLON {
  74987. /** @hidden */
  74988. export var instancesDeclaration: {
  74989. name: string;
  74990. shader: string;
  74991. };
  74992. }
  74993. declare module BABYLON {
  74994. /** @hidden */
  74995. export var helperFunctions: {
  74996. name: string;
  74997. shader: string;
  74998. };
  74999. }
  75000. declare module BABYLON {
  75001. /** @hidden */
  75002. export var morphTargetsVertex: {
  75003. name: string;
  75004. shader: string;
  75005. };
  75006. }
  75007. declare module BABYLON {
  75008. /** @hidden */
  75009. export var instancesVertex: {
  75010. name: string;
  75011. shader: string;
  75012. };
  75013. }
  75014. declare module BABYLON {
  75015. /** @hidden */
  75016. export var bonesVertex: {
  75017. name: string;
  75018. shader: string;
  75019. };
  75020. }
  75021. declare module BABYLON {
  75022. /** @hidden */
  75023. export var shadowMapVertexShader: {
  75024. name: string;
  75025. shader: string;
  75026. };
  75027. }
  75028. declare module BABYLON {
  75029. /** @hidden */
  75030. export var depthBoxBlurPixelShader: {
  75031. name: string;
  75032. shader: string;
  75033. };
  75034. }
  75035. declare module BABYLON {
  75036. /**
  75037. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75038. */
  75039. export interface ICustomShaderOptions {
  75040. /**
  75041. * Gets or sets the custom shader name to use
  75042. */
  75043. shaderName: string;
  75044. /**
  75045. * The list of attribute names used in the shader
  75046. */
  75047. attributes?: string[];
  75048. /**
  75049. * The list of unifrom names used in the shader
  75050. */
  75051. uniforms?: string[];
  75052. /**
  75053. * The list of sampler names used in the shader
  75054. */
  75055. samplers?: string[];
  75056. /**
  75057. * The list of defines used in the shader
  75058. */
  75059. defines?: string[];
  75060. }
  75061. /**
  75062. * Interface to implement to create a shadow generator compatible with BJS.
  75063. */
  75064. export interface IShadowGenerator {
  75065. /**
  75066. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75067. * @returns The render target texture if present otherwise, null
  75068. */
  75069. getShadowMap(): Nullable<RenderTargetTexture>;
  75070. /**
  75071. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75072. * @returns The render target texture if the shadow map is present otherwise, null
  75073. */
  75074. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75075. /**
  75076. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75077. * @param subMesh The submesh we want to render in the shadow map
  75078. * @param useInstances Defines wether will draw in the map using instances
  75079. * @returns true if ready otherwise, false
  75080. */
  75081. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75082. /**
  75083. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75084. * @param defines Defines of the material we want to update
  75085. * @param lightIndex Index of the light in the enabled light list of the material
  75086. */
  75087. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75088. /**
  75089. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75090. * defined in the generator but impacting the effect).
  75091. * It implies the unifroms available on the materials are the standard BJS ones.
  75092. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75093. * @param effect The effect we are binfing the information for
  75094. */
  75095. bindShadowLight(lightIndex: string, effect: Effect): void;
  75096. /**
  75097. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75098. * (eq to shadow prjection matrix * light transform matrix)
  75099. * @returns The transform matrix used to create the shadow map
  75100. */
  75101. getTransformMatrix(): Matrix;
  75102. /**
  75103. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75104. * Cube and 2D textures for instance.
  75105. */
  75106. recreateShadowMap(): void;
  75107. /**
  75108. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75109. * @param onCompiled Callback triggered at the and of the effects compilation
  75110. * @param options Sets of optional options forcing the compilation with different modes
  75111. */
  75112. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75113. useInstances: boolean;
  75114. }>): void;
  75115. /**
  75116. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75117. * @param options Sets of optional options forcing the compilation with different modes
  75118. * @returns A promise that resolves when the compilation completes
  75119. */
  75120. forceCompilationAsync(options?: Partial<{
  75121. useInstances: boolean;
  75122. }>): Promise<void>;
  75123. /**
  75124. * Serializes the shadow generator setup to a json object.
  75125. * @returns The serialized JSON object
  75126. */
  75127. serialize(): any;
  75128. /**
  75129. * Disposes the Shadow map and related Textures and effects.
  75130. */
  75131. dispose(): void;
  75132. }
  75133. /**
  75134. * Default implementation IShadowGenerator.
  75135. * This is the main object responsible of generating shadows in the framework.
  75136. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75137. */
  75138. export class ShadowGenerator implements IShadowGenerator {
  75139. /**
  75140. * Shadow generator mode None: no filtering applied.
  75141. */
  75142. static readonly FILTER_NONE: number;
  75143. /**
  75144. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75145. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75146. */
  75147. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75148. /**
  75149. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75150. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75151. */
  75152. static readonly FILTER_POISSONSAMPLING: number;
  75153. /**
  75154. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75155. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75156. */
  75157. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75158. /**
  75159. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75160. * edge artifacts on steep falloff.
  75161. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75162. */
  75163. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75164. /**
  75165. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75166. * edge artifacts on steep falloff.
  75167. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75168. */
  75169. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75170. /**
  75171. * Shadow generator mode PCF: Percentage Closer Filtering
  75172. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75173. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75174. */
  75175. static readonly FILTER_PCF: number;
  75176. /**
  75177. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75178. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75179. * Contact Hardening
  75180. */
  75181. static readonly FILTER_PCSS: number;
  75182. /**
  75183. * Reserved for PCF and PCSS
  75184. * Highest Quality.
  75185. *
  75186. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75187. *
  75188. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75189. */
  75190. static readonly QUALITY_HIGH: number;
  75191. /**
  75192. * Reserved for PCF and PCSS
  75193. * Good tradeoff for quality/perf cross devices
  75194. *
  75195. * Execute PCF on a 3*3 kernel.
  75196. *
  75197. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75198. */
  75199. static readonly QUALITY_MEDIUM: number;
  75200. /**
  75201. * Reserved for PCF and PCSS
  75202. * The lowest quality but the fastest.
  75203. *
  75204. * Execute PCF on a 1*1 kernel.
  75205. *
  75206. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75207. */
  75208. static readonly QUALITY_LOW: number;
  75209. /** Gets or sets the custom shader name to use */
  75210. customShaderOptions: ICustomShaderOptions;
  75211. /**
  75212. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75213. */
  75214. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75215. /**
  75216. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75217. */
  75218. onAfterShadowMapRenderObservable: Observable<Effect>;
  75219. /**
  75220. * Observable triggered before a mesh is rendered in the shadow map.
  75221. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75222. */
  75223. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75224. /**
  75225. * Observable triggered after a mesh is rendered in the shadow map.
  75226. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75227. */
  75228. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75229. private _bias;
  75230. /**
  75231. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75232. */
  75233. /**
  75234. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75235. */
  75236. bias: number;
  75237. private _normalBias;
  75238. /**
  75239. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75240. */
  75241. /**
  75242. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75243. */
  75244. normalBias: number;
  75245. private _blurBoxOffset;
  75246. /**
  75247. * Gets the blur box offset: offset applied during the blur pass.
  75248. * Only useful if useKernelBlur = false
  75249. */
  75250. /**
  75251. * Sets the blur box offset: offset applied during the blur pass.
  75252. * Only useful if useKernelBlur = false
  75253. */
  75254. blurBoxOffset: number;
  75255. private _blurScale;
  75256. /**
  75257. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75258. * 2 means half of the size.
  75259. */
  75260. /**
  75261. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75262. * 2 means half of the size.
  75263. */
  75264. blurScale: number;
  75265. private _blurKernel;
  75266. /**
  75267. * Gets the blur kernel: kernel size of the blur pass.
  75268. * Only useful if useKernelBlur = true
  75269. */
  75270. /**
  75271. * Sets the blur kernel: kernel size of the blur pass.
  75272. * Only useful if useKernelBlur = true
  75273. */
  75274. blurKernel: number;
  75275. private _useKernelBlur;
  75276. /**
  75277. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75278. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75279. */
  75280. /**
  75281. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75282. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75283. */
  75284. useKernelBlur: boolean;
  75285. private _depthScale;
  75286. /**
  75287. * Gets the depth scale used in ESM mode.
  75288. */
  75289. /**
  75290. * Sets the depth scale used in ESM mode.
  75291. * This can override the scale stored on the light.
  75292. */
  75293. depthScale: number;
  75294. private _filter;
  75295. /**
  75296. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75297. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75298. */
  75299. /**
  75300. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75301. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75302. */
  75303. filter: number;
  75304. /**
  75305. * Gets if the current filter is set to Poisson Sampling.
  75306. */
  75307. /**
  75308. * Sets the current filter to Poisson Sampling.
  75309. */
  75310. usePoissonSampling: boolean;
  75311. /**
  75312. * Gets if the current filter is set to ESM.
  75313. */
  75314. /**
  75315. * Sets the current filter is to ESM.
  75316. */
  75317. useExponentialShadowMap: boolean;
  75318. /**
  75319. * Gets if the current filter is set to filtered ESM.
  75320. */
  75321. /**
  75322. * Gets if the current filter is set to filtered ESM.
  75323. */
  75324. useBlurExponentialShadowMap: boolean;
  75325. /**
  75326. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75327. * exponential to prevent steep falloff artifacts).
  75328. */
  75329. /**
  75330. * Sets the current filter to "close ESM" (using the inverse of the
  75331. * exponential to prevent steep falloff artifacts).
  75332. */
  75333. useCloseExponentialShadowMap: boolean;
  75334. /**
  75335. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75336. * exponential to prevent steep falloff artifacts).
  75337. */
  75338. /**
  75339. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75340. * exponential to prevent steep falloff artifacts).
  75341. */
  75342. useBlurCloseExponentialShadowMap: boolean;
  75343. /**
  75344. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75345. */
  75346. /**
  75347. * Sets the current filter to "PCF" (percentage closer filtering).
  75348. */
  75349. usePercentageCloserFiltering: boolean;
  75350. private _filteringQuality;
  75351. /**
  75352. * Gets the PCF or PCSS Quality.
  75353. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75354. */
  75355. /**
  75356. * Sets the PCF or PCSS Quality.
  75357. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75358. */
  75359. filteringQuality: number;
  75360. /**
  75361. * Gets if the current filter is set to "PCSS" (contact hardening).
  75362. */
  75363. /**
  75364. * Sets the current filter to "PCSS" (contact hardening).
  75365. */
  75366. useContactHardeningShadow: boolean;
  75367. private _contactHardeningLightSizeUVRatio;
  75368. /**
  75369. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75370. * Using a ratio helps keeping shape stability independently of the map size.
  75371. *
  75372. * It does not account for the light projection as it was having too much
  75373. * instability during the light setup or during light position changes.
  75374. *
  75375. * Only valid if useContactHardeningShadow is true.
  75376. */
  75377. /**
  75378. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75379. * Using a ratio helps keeping shape stability independently of the map size.
  75380. *
  75381. * It does not account for the light projection as it was having too much
  75382. * instability during the light setup or during light position changes.
  75383. *
  75384. * Only valid if useContactHardeningShadow is true.
  75385. */
  75386. contactHardeningLightSizeUVRatio: number;
  75387. private _darkness;
  75388. /** Gets or sets the actual darkness of a shadow */
  75389. darkness: number;
  75390. /**
  75391. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75392. * 0 means strongest and 1 would means no shadow.
  75393. * @returns the darkness.
  75394. */
  75395. getDarkness(): number;
  75396. /**
  75397. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75398. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75399. * @returns the shadow generator allowing fluent coding.
  75400. */
  75401. setDarkness(darkness: number): ShadowGenerator;
  75402. private _transparencyShadow;
  75403. /** Gets or sets the ability to have transparent shadow */
  75404. transparencyShadow: boolean;
  75405. /**
  75406. * Sets the ability to have transparent shadow (boolean).
  75407. * @param transparent True if transparent else False
  75408. * @returns the shadow generator allowing fluent coding
  75409. */
  75410. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75411. private _shadowMap;
  75412. private _shadowMap2;
  75413. /**
  75414. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75415. * @returns The render target texture if present otherwise, null
  75416. */
  75417. getShadowMap(): Nullable<RenderTargetTexture>;
  75418. /**
  75419. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75420. * @returns The render target texture if the shadow map is present otherwise, null
  75421. */
  75422. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75423. /**
  75424. * Gets the class name of that object
  75425. * @returns "ShadowGenerator"
  75426. */
  75427. getClassName(): string;
  75428. /**
  75429. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75430. * @param mesh Mesh to add
  75431. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75432. * @returns the Shadow Generator itself
  75433. */
  75434. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75435. /**
  75436. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75437. * @param mesh Mesh to remove
  75438. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75439. * @returns the Shadow Generator itself
  75440. */
  75441. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75442. /**
  75443. * Controls the extent to which the shadows fade out at the edge of the frustum
  75444. * Used only by directionals and spots
  75445. */
  75446. frustumEdgeFalloff: number;
  75447. private _light;
  75448. /**
  75449. * Returns the associated light object.
  75450. * @returns the light generating the shadow
  75451. */
  75452. getLight(): IShadowLight;
  75453. /**
  75454. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75455. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75456. * It might on the other hand introduce peter panning.
  75457. */
  75458. forceBackFacesOnly: boolean;
  75459. private _scene;
  75460. private _lightDirection;
  75461. private _effect;
  75462. private _viewMatrix;
  75463. private _projectionMatrix;
  75464. private _transformMatrix;
  75465. private _cachedPosition;
  75466. private _cachedDirection;
  75467. private _cachedDefines;
  75468. private _currentRenderID;
  75469. private _boxBlurPostprocess;
  75470. private _kernelBlurXPostprocess;
  75471. private _kernelBlurYPostprocess;
  75472. private _blurPostProcesses;
  75473. private _mapSize;
  75474. private _currentFaceIndex;
  75475. private _currentFaceIndexCache;
  75476. private _textureType;
  75477. private _defaultTextureMatrix;
  75478. /** @hidden */
  75479. static _SceneComponentInitialization: (scene: Scene) => void;
  75480. /**
  75481. * Creates a ShadowGenerator object.
  75482. * A ShadowGenerator is the required tool to use the shadows.
  75483. * Each light casting shadows needs to use its own ShadowGenerator.
  75484. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75485. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75486. * @param light The light object generating the shadows.
  75487. * @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.
  75488. */
  75489. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75490. private _initializeGenerator;
  75491. private _initializeShadowMap;
  75492. private _initializeBlurRTTAndPostProcesses;
  75493. private _renderForShadowMap;
  75494. private _renderSubMeshForShadowMap;
  75495. private _applyFilterValues;
  75496. /**
  75497. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75498. * @param onCompiled Callback triggered at the and of the effects compilation
  75499. * @param options Sets of optional options forcing the compilation with different modes
  75500. */
  75501. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75502. useInstances: boolean;
  75503. }>): void;
  75504. /**
  75505. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75506. * @param options Sets of optional options forcing the compilation with different modes
  75507. * @returns A promise that resolves when the compilation completes
  75508. */
  75509. forceCompilationAsync(options?: Partial<{
  75510. useInstances: boolean;
  75511. }>): Promise<void>;
  75512. /**
  75513. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75514. * @param subMesh The submesh we want to render in the shadow map
  75515. * @param useInstances Defines wether will draw in the map using instances
  75516. * @returns true if ready otherwise, false
  75517. */
  75518. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75519. /**
  75520. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75521. * @param defines Defines of the material we want to update
  75522. * @param lightIndex Index of the light in the enabled light list of the material
  75523. */
  75524. prepareDefines(defines: any, lightIndex: number): void;
  75525. /**
  75526. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75527. * defined in the generator but impacting the effect).
  75528. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75529. * @param effect The effect we are binfing the information for
  75530. */
  75531. bindShadowLight(lightIndex: string, effect: Effect): void;
  75532. /**
  75533. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75534. * (eq to shadow prjection matrix * light transform matrix)
  75535. * @returns The transform matrix used to create the shadow map
  75536. */
  75537. getTransformMatrix(): Matrix;
  75538. /**
  75539. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75540. * Cube and 2D textures for instance.
  75541. */
  75542. recreateShadowMap(): void;
  75543. private _disposeBlurPostProcesses;
  75544. private _disposeRTTandPostProcesses;
  75545. /**
  75546. * Disposes the ShadowGenerator.
  75547. * Returns nothing.
  75548. */
  75549. dispose(): void;
  75550. /**
  75551. * Serializes the shadow generator setup to a json object.
  75552. * @returns The serialized JSON object
  75553. */
  75554. serialize(): any;
  75555. /**
  75556. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75557. * @param parsedShadowGenerator The JSON object to parse
  75558. * @param scene The scene to create the shadow map for
  75559. * @returns The parsed shadow generator
  75560. */
  75561. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75562. }
  75563. }
  75564. declare module BABYLON {
  75565. /**
  75566. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75567. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75568. * 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.
  75569. */
  75570. export abstract class Light extends Node {
  75571. /**
  75572. * Falloff Default: light is falling off following the material specification:
  75573. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75574. */
  75575. static readonly FALLOFF_DEFAULT: number;
  75576. /**
  75577. * Falloff Physical: light is falling off following the inverse squared distance law.
  75578. */
  75579. static readonly FALLOFF_PHYSICAL: number;
  75580. /**
  75581. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75582. * to enhance interoperability with other engines.
  75583. */
  75584. static readonly FALLOFF_GLTF: number;
  75585. /**
  75586. * Falloff Standard: light is falling off like in the standard material
  75587. * to enhance interoperability with other materials.
  75588. */
  75589. static readonly FALLOFF_STANDARD: number;
  75590. /**
  75591. * If every light affecting the material is in this lightmapMode,
  75592. * material.lightmapTexture adds or multiplies
  75593. * (depends on material.useLightmapAsShadowmap)
  75594. * after every other light calculations.
  75595. */
  75596. static readonly LIGHTMAP_DEFAULT: number;
  75597. /**
  75598. * material.lightmapTexture as only diffuse lighting from this light
  75599. * adds only specular lighting from this light
  75600. * adds dynamic shadows
  75601. */
  75602. static readonly LIGHTMAP_SPECULAR: number;
  75603. /**
  75604. * material.lightmapTexture as only lighting
  75605. * no light calculation from this light
  75606. * only adds dynamic shadows from this light
  75607. */
  75608. static readonly LIGHTMAP_SHADOWSONLY: number;
  75609. /**
  75610. * Each light type uses the default quantity according to its type:
  75611. * point/spot lights use luminous intensity
  75612. * directional lights use illuminance
  75613. */
  75614. static readonly INTENSITYMODE_AUTOMATIC: number;
  75615. /**
  75616. * lumen (lm)
  75617. */
  75618. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75619. /**
  75620. * candela (lm/sr)
  75621. */
  75622. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75623. /**
  75624. * lux (lm/m^2)
  75625. */
  75626. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75627. /**
  75628. * nit (cd/m^2)
  75629. */
  75630. static readonly INTENSITYMODE_LUMINANCE: number;
  75631. /**
  75632. * Light type const id of the point light.
  75633. */
  75634. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75635. /**
  75636. * Light type const id of the directional light.
  75637. */
  75638. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75639. /**
  75640. * Light type const id of the spot light.
  75641. */
  75642. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75643. /**
  75644. * Light type const id of the hemispheric light.
  75645. */
  75646. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75647. /**
  75648. * Diffuse gives the basic color to an object.
  75649. */
  75650. diffuse: Color3;
  75651. /**
  75652. * Specular produces a highlight color on an object.
  75653. * Note: This is note affecting PBR materials.
  75654. */
  75655. specular: Color3;
  75656. /**
  75657. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75658. * falling off base on range or angle.
  75659. * This can be set to any values in Light.FALLOFF_x.
  75660. *
  75661. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75662. * other types of materials.
  75663. */
  75664. falloffType: number;
  75665. /**
  75666. * Strength of the light.
  75667. * Note: By default it is define in the framework own unit.
  75668. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75669. */
  75670. intensity: number;
  75671. private _range;
  75672. protected _inverseSquaredRange: number;
  75673. /**
  75674. * Defines how far from the source the light is impacting in scene units.
  75675. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75676. */
  75677. /**
  75678. * Defines how far from the source the light is impacting in scene units.
  75679. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75680. */
  75681. range: number;
  75682. /**
  75683. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75684. * of light.
  75685. */
  75686. private _photometricScale;
  75687. private _intensityMode;
  75688. /**
  75689. * Gets the photometric scale used to interpret the intensity.
  75690. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75691. */
  75692. /**
  75693. * Sets the photometric scale used to interpret the intensity.
  75694. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75695. */
  75696. intensityMode: number;
  75697. private _radius;
  75698. /**
  75699. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75700. */
  75701. /**
  75702. * sets the light radius used by PBR Materials to simulate soft area lights.
  75703. */
  75704. radius: number;
  75705. private _renderPriority;
  75706. /**
  75707. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75708. * exceeding the number allowed of the materials.
  75709. */
  75710. renderPriority: number;
  75711. private _shadowEnabled;
  75712. /**
  75713. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75714. * the current shadow generator.
  75715. */
  75716. /**
  75717. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75718. * the current shadow generator.
  75719. */
  75720. shadowEnabled: boolean;
  75721. private _includedOnlyMeshes;
  75722. /**
  75723. * Gets the only meshes impacted by this light.
  75724. */
  75725. /**
  75726. * Sets the only meshes impacted by this light.
  75727. */
  75728. includedOnlyMeshes: AbstractMesh[];
  75729. private _excludedMeshes;
  75730. /**
  75731. * Gets the meshes not impacted by this light.
  75732. */
  75733. /**
  75734. * Sets the meshes not impacted by this light.
  75735. */
  75736. excludedMeshes: AbstractMesh[];
  75737. private _excludeWithLayerMask;
  75738. /**
  75739. * Gets the layer id use to find what meshes are not impacted by the light.
  75740. * Inactive if 0
  75741. */
  75742. /**
  75743. * Sets the layer id use to find what meshes are not impacted by the light.
  75744. * Inactive if 0
  75745. */
  75746. excludeWithLayerMask: number;
  75747. private _includeOnlyWithLayerMask;
  75748. /**
  75749. * Gets the layer id use to find what meshes are impacted by the light.
  75750. * Inactive if 0
  75751. */
  75752. /**
  75753. * Sets the layer id use to find what meshes are impacted by the light.
  75754. * Inactive if 0
  75755. */
  75756. includeOnlyWithLayerMask: number;
  75757. private _lightmapMode;
  75758. /**
  75759. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75760. */
  75761. /**
  75762. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75763. */
  75764. lightmapMode: number;
  75765. /**
  75766. * Shadow generator associted to the light.
  75767. * @hidden Internal use only.
  75768. */
  75769. _shadowGenerator: Nullable<IShadowGenerator>;
  75770. /**
  75771. * @hidden Internal use only.
  75772. */
  75773. _excludedMeshesIds: string[];
  75774. /**
  75775. * @hidden Internal use only.
  75776. */
  75777. _includedOnlyMeshesIds: string[];
  75778. /**
  75779. * The current light unifom buffer.
  75780. * @hidden Internal use only.
  75781. */
  75782. _uniformBuffer: UniformBuffer;
  75783. /**
  75784. * Creates a Light object in the scene.
  75785. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75786. * @param name The firendly name of the light
  75787. * @param scene The scene the light belongs too
  75788. */
  75789. constructor(name: string, scene: Scene);
  75790. protected abstract _buildUniformLayout(): void;
  75791. /**
  75792. * Sets the passed Effect "effect" with the Light information.
  75793. * @param effect The effect to update
  75794. * @param lightIndex The index of the light in the effect to update
  75795. * @returns The light
  75796. */
  75797. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75798. /**
  75799. * Sets the passed Effect "effect" with the Light information.
  75800. * @param effect The effect to update
  75801. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75802. * @returns The light
  75803. */
  75804. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75805. /**
  75806. * Returns the string "Light".
  75807. * @returns the class name
  75808. */
  75809. getClassName(): string;
  75810. /** @hidden */
  75811. readonly _isLight: boolean;
  75812. /**
  75813. * Converts the light information to a readable string for debug purpose.
  75814. * @param fullDetails Supports for multiple levels of logging within scene loading
  75815. * @returns the human readable light info
  75816. */
  75817. toString(fullDetails?: boolean): string;
  75818. /** @hidden */
  75819. protected _syncParentEnabledState(): void;
  75820. /**
  75821. * Set the enabled state of this node.
  75822. * @param value - the new enabled state
  75823. */
  75824. setEnabled(value: boolean): void;
  75825. /**
  75826. * Returns the Light associated shadow generator if any.
  75827. * @return the associated shadow generator.
  75828. */
  75829. getShadowGenerator(): Nullable<IShadowGenerator>;
  75830. /**
  75831. * Returns a Vector3, the absolute light position in the World.
  75832. * @returns the world space position of the light
  75833. */
  75834. getAbsolutePosition(): Vector3;
  75835. /**
  75836. * Specifies if the light will affect the passed mesh.
  75837. * @param mesh The mesh to test against the light
  75838. * @return true the mesh is affected otherwise, false.
  75839. */
  75840. canAffectMesh(mesh: AbstractMesh): boolean;
  75841. /**
  75842. * Sort function to order lights for rendering.
  75843. * @param a First Light object to compare to second.
  75844. * @param b Second Light object to compare first.
  75845. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75846. */
  75847. static CompareLightsPriority(a: Light, b: Light): number;
  75848. /**
  75849. * Releases resources associated with this node.
  75850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75852. */
  75853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75854. /**
  75855. * Returns the light type ID (integer).
  75856. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75857. */
  75858. getTypeID(): number;
  75859. /**
  75860. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75861. * @returns the scaled intensity in intensity mode unit
  75862. */
  75863. getScaledIntensity(): number;
  75864. /**
  75865. * Returns a new Light object, named "name", from the current one.
  75866. * @param name The name of the cloned light
  75867. * @returns the new created light
  75868. */
  75869. clone(name: string): Nullable<Light>;
  75870. /**
  75871. * Serializes the current light into a Serialization object.
  75872. * @returns the serialized object.
  75873. */
  75874. serialize(): any;
  75875. /**
  75876. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75877. * This new light is named "name" and added to the passed scene.
  75878. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75879. * @param name The friendly name of the light
  75880. * @param scene The scene the new light will belong to
  75881. * @returns the constructor function
  75882. */
  75883. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75884. /**
  75885. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75886. * @param parsedLight The JSON representation of the light
  75887. * @param scene The scene to create the parsed light in
  75888. * @returns the created light after parsing
  75889. */
  75890. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75891. private _hookArrayForExcluded;
  75892. private _hookArrayForIncludedOnly;
  75893. private _resyncMeshes;
  75894. /**
  75895. * Forces the meshes to update their light related information in their rendering used effects
  75896. * @hidden Internal Use Only
  75897. */
  75898. _markMeshesAsLightDirty(): void;
  75899. /**
  75900. * Recomputes the cached photometric scale if needed.
  75901. */
  75902. private _computePhotometricScale;
  75903. /**
  75904. * Returns the Photometric Scale according to the light type and intensity mode.
  75905. */
  75906. private _getPhotometricScale;
  75907. /**
  75908. * Reorder the light in the scene according to their defined priority.
  75909. * @hidden Internal Use Only
  75910. */
  75911. _reorderLightsInScene(): void;
  75912. /**
  75913. * Prepares the list of defines specific to the light type.
  75914. * @param defines the list of defines
  75915. * @param lightIndex defines the index of the light for the effect
  75916. */
  75917. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75918. }
  75919. }
  75920. declare module BABYLON {
  75921. /**
  75922. * Interface used to define Action
  75923. */
  75924. export interface IAction {
  75925. /**
  75926. * Trigger for the action
  75927. */
  75928. trigger: number;
  75929. /** Options of the trigger */
  75930. triggerOptions: any;
  75931. /**
  75932. * Gets the trigger parameters
  75933. * @returns the trigger parameters
  75934. */
  75935. getTriggerParameter(): any;
  75936. /**
  75937. * Internal only - executes current action event
  75938. * @hidden
  75939. */
  75940. _executeCurrent(evt?: ActionEvent): void;
  75941. /**
  75942. * Serialize placeholder for child classes
  75943. * @param parent of child
  75944. * @returns the serialized object
  75945. */
  75946. serialize(parent: any): any;
  75947. /**
  75948. * Internal only
  75949. * @hidden
  75950. */
  75951. _prepare(): void;
  75952. /**
  75953. * Internal only - manager for action
  75954. * @hidden
  75955. */
  75956. _actionManager: AbstractActionManager;
  75957. /**
  75958. * Adds action to chain of actions, may be a DoNothingAction
  75959. * @param action defines the next action to execute
  75960. * @returns The action passed in
  75961. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75962. */
  75963. then(action: IAction): IAction;
  75964. }
  75965. /**
  75966. * The action to be carried out following a trigger
  75967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75968. */
  75969. export class Action implements IAction {
  75970. /** the trigger, with or without parameters, for the action */
  75971. triggerOptions: any;
  75972. /**
  75973. * Trigger for the action
  75974. */
  75975. trigger: number;
  75976. /**
  75977. * Internal only - manager for action
  75978. * @hidden
  75979. */
  75980. _actionManager: ActionManager;
  75981. private _nextActiveAction;
  75982. private _child;
  75983. private _condition?;
  75984. private _triggerParameter;
  75985. /**
  75986. * An event triggered prior to action being executed.
  75987. */
  75988. onBeforeExecuteObservable: Observable<Action>;
  75989. /**
  75990. * Creates a new Action
  75991. * @param triggerOptions the trigger, with or without parameters, for the action
  75992. * @param condition an optional determinant of action
  75993. */
  75994. constructor(
  75995. /** the trigger, with or without parameters, for the action */
  75996. triggerOptions: any, condition?: Condition);
  75997. /**
  75998. * Internal only
  75999. * @hidden
  76000. */
  76001. _prepare(): void;
  76002. /**
  76003. * Gets the trigger parameters
  76004. * @returns the trigger parameters
  76005. */
  76006. getTriggerParameter(): any;
  76007. /**
  76008. * Internal only - executes current action event
  76009. * @hidden
  76010. */
  76011. _executeCurrent(evt?: ActionEvent): void;
  76012. /**
  76013. * Execute placeholder for child classes
  76014. * @param evt optional action event
  76015. */
  76016. execute(evt?: ActionEvent): void;
  76017. /**
  76018. * Skips to next active action
  76019. */
  76020. skipToNextActiveAction(): void;
  76021. /**
  76022. * Adds action to chain of actions, may be a DoNothingAction
  76023. * @param action defines the next action to execute
  76024. * @returns The action passed in
  76025. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76026. */
  76027. then(action: Action): Action;
  76028. /**
  76029. * Internal only
  76030. * @hidden
  76031. */
  76032. _getProperty(propertyPath: string): string;
  76033. /**
  76034. * Internal only
  76035. * @hidden
  76036. */
  76037. _getEffectiveTarget(target: any, propertyPath: string): any;
  76038. /**
  76039. * Serialize placeholder for child classes
  76040. * @param parent of child
  76041. * @returns the serialized object
  76042. */
  76043. serialize(parent: any): any;
  76044. /**
  76045. * Internal only called by serialize
  76046. * @hidden
  76047. */
  76048. protected _serialize(serializedAction: any, parent?: any): any;
  76049. /**
  76050. * Internal only
  76051. * @hidden
  76052. */
  76053. static _SerializeValueAsString: (value: any) => string;
  76054. /**
  76055. * Internal only
  76056. * @hidden
  76057. */
  76058. static _GetTargetProperty: (target: Node | Scene) => {
  76059. name: string;
  76060. targetType: string;
  76061. value: string;
  76062. };
  76063. }
  76064. }
  76065. declare module BABYLON {
  76066. /**
  76067. * A Condition applied to an Action
  76068. */
  76069. export class Condition {
  76070. /**
  76071. * Internal only - manager for action
  76072. * @hidden
  76073. */
  76074. _actionManager: ActionManager;
  76075. /**
  76076. * Internal only
  76077. * @hidden
  76078. */
  76079. _evaluationId: number;
  76080. /**
  76081. * Internal only
  76082. * @hidden
  76083. */
  76084. _currentResult: boolean;
  76085. /**
  76086. * Creates a new Condition
  76087. * @param actionManager the manager of the action the condition is applied to
  76088. */
  76089. constructor(actionManager: ActionManager);
  76090. /**
  76091. * Check if the current condition is valid
  76092. * @returns a boolean
  76093. */
  76094. isValid(): boolean;
  76095. /**
  76096. * Internal only
  76097. * @hidden
  76098. */
  76099. _getProperty(propertyPath: string): string;
  76100. /**
  76101. * Internal only
  76102. * @hidden
  76103. */
  76104. _getEffectiveTarget(target: any, propertyPath: string): any;
  76105. /**
  76106. * Serialize placeholder for child classes
  76107. * @returns the serialized object
  76108. */
  76109. serialize(): any;
  76110. /**
  76111. * Internal only
  76112. * @hidden
  76113. */
  76114. protected _serialize(serializedCondition: any): any;
  76115. }
  76116. /**
  76117. * Defines specific conditional operators as extensions of Condition
  76118. */
  76119. export class ValueCondition extends Condition {
  76120. /** path to specify the property of the target the conditional operator uses */
  76121. propertyPath: string;
  76122. /** the value compared by the conditional operator against the current value of the property */
  76123. value: any;
  76124. /** the conditional operator, default ValueCondition.IsEqual */
  76125. operator: number;
  76126. /**
  76127. * Internal only
  76128. * @hidden
  76129. */
  76130. private static _IsEqual;
  76131. /**
  76132. * Internal only
  76133. * @hidden
  76134. */
  76135. private static _IsDifferent;
  76136. /**
  76137. * Internal only
  76138. * @hidden
  76139. */
  76140. private static _IsGreater;
  76141. /**
  76142. * Internal only
  76143. * @hidden
  76144. */
  76145. private static _IsLesser;
  76146. /**
  76147. * returns the number for IsEqual
  76148. */
  76149. static readonly IsEqual: number;
  76150. /**
  76151. * Returns the number for IsDifferent
  76152. */
  76153. static readonly IsDifferent: number;
  76154. /**
  76155. * Returns the number for IsGreater
  76156. */
  76157. static readonly IsGreater: number;
  76158. /**
  76159. * Returns the number for IsLesser
  76160. */
  76161. static readonly IsLesser: number;
  76162. /**
  76163. * Internal only The action manager for the condition
  76164. * @hidden
  76165. */
  76166. _actionManager: ActionManager;
  76167. /**
  76168. * Internal only
  76169. * @hidden
  76170. */
  76171. private _target;
  76172. /**
  76173. * Internal only
  76174. * @hidden
  76175. */
  76176. private _effectiveTarget;
  76177. /**
  76178. * Internal only
  76179. * @hidden
  76180. */
  76181. private _property;
  76182. /**
  76183. * Creates a new ValueCondition
  76184. * @param actionManager manager for the action the condition applies to
  76185. * @param target for the action
  76186. * @param propertyPath path to specify the property of the target the conditional operator uses
  76187. * @param value the value compared by the conditional operator against the current value of the property
  76188. * @param operator the conditional operator, default ValueCondition.IsEqual
  76189. */
  76190. constructor(actionManager: ActionManager, target: any,
  76191. /** path to specify the property of the target the conditional operator uses */
  76192. propertyPath: string,
  76193. /** the value compared by the conditional operator against the current value of the property */
  76194. value: any,
  76195. /** the conditional operator, default ValueCondition.IsEqual */
  76196. operator?: number);
  76197. /**
  76198. * Compares the given value with the property value for the specified conditional operator
  76199. * @returns the result of the comparison
  76200. */
  76201. isValid(): boolean;
  76202. /**
  76203. * Serialize the ValueCondition into a JSON compatible object
  76204. * @returns serialization object
  76205. */
  76206. serialize(): any;
  76207. /**
  76208. * Gets the name of the conditional operator for the ValueCondition
  76209. * @param operator the conditional operator
  76210. * @returns the name
  76211. */
  76212. static GetOperatorName(operator: number): string;
  76213. }
  76214. /**
  76215. * Defines a predicate condition as an extension of Condition
  76216. */
  76217. export class PredicateCondition extends Condition {
  76218. /** defines the predicate function used to validate the condition */
  76219. predicate: () => boolean;
  76220. /**
  76221. * Internal only - manager for action
  76222. * @hidden
  76223. */
  76224. _actionManager: ActionManager;
  76225. /**
  76226. * Creates a new PredicateCondition
  76227. * @param actionManager manager for the action the condition applies to
  76228. * @param predicate defines the predicate function used to validate the condition
  76229. */
  76230. constructor(actionManager: ActionManager,
  76231. /** defines the predicate function used to validate the condition */
  76232. predicate: () => boolean);
  76233. /**
  76234. * @returns the validity of the predicate condition
  76235. */
  76236. isValid(): boolean;
  76237. }
  76238. /**
  76239. * Defines a state condition as an extension of Condition
  76240. */
  76241. export class StateCondition extends Condition {
  76242. /** Value to compare with target state */
  76243. value: string;
  76244. /**
  76245. * Internal only - manager for action
  76246. * @hidden
  76247. */
  76248. _actionManager: ActionManager;
  76249. /**
  76250. * Internal only
  76251. * @hidden
  76252. */
  76253. private _target;
  76254. /**
  76255. * Creates a new StateCondition
  76256. * @param actionManager manager for the action the condition applies to
  76257. * @param target of the condition
  76258. * @param value to compare with target state
  76259. */
  76260. constructor(actionManager: ActionManager, target: any,
  76261. /** Value to compare with target state */
  76262. value: string);
  76263. /**
  76264. * Gets a boolean indicating if the current condition is met
  76265. * @returns the validity of the state
  76266. */
  76267. isValid(): boolean;
  76268. /**
  76269. * Serialize the StateCondition into a JSON compatible object
  76270. * @returns serialization object
  76271. */
  76272. serialize(): any;
  76273. }
  76274. }
  76275. declare module BABYLON {
  76276. /**
  76277. * This defines an action responsible to toggle a boolean once triggered.
  76278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76279. */
  76280. export class SwitchBooleanAction extends Action {
  76281. /**
  76282. * The path to the boolean property in the target object
  76283. */
  76284. propertyPath: string;
  76285. private _target;
  76286. private _effectiveTarget;
  76287. private _property;
  76288. /**
  76289. * Instantiate the action
  76290. * @param triggerOptions defines the trigger options
  76291. * @param target defines the object containing the boolean
  76292. * @param propertyPath defines the path to the boolean property in the target object
  76293. * @param condition defines the trigger related conditions
  76294. */
  76295. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76296. /** @hidden */
  76297. _prepare(): void;
  76298. /**
  76299. * Execute the action toggle the boolean value.
  76300. */
  76301. execute(): void;
  76302. /**
  76303. * Serializes the actions and its related information.
  76304. * @param parent defines the object to serialize in
  76305. * @returns the serialized object
  76306. */
  76307. serialize(parent: any): any;
  76308. }
  76309. /**
  76310. * This defines an action responsible to set a the state field of the target
  76311. * to a desired value once triggered.
  76312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76313. */
  76314. export class SetStateAction extends Action {
  76315. /**
  76316. * The value to store in the state field.
  76317. */
  76318. value: string;
  76319. private _target;
  76320. /**
  76321. * Instantiate the action
  76322. * @param triggerOptions defines the trigger options
  76323. * @param target defines the object containing the state property
  76324. * @param value defines the value to store in the state field
  76325. * @param condition defines the trigger related conditions
  76326. */
  76327. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76328. /**
  76329. * Execute the action and store the value on the target state property.
  76330. */
  76331. execute(): void;
  76332. /**
  76333. * Serializes the actions and its related information.
  76334. * @param parent defines the object to serialize in
  76335. * @returns the serialized object
  76336. */
  76337. serialize(parent: any): any;
  76338. }
  76339. /**
  76340. * This defines an action responsible to set a property of the target
  76341. * to a desired value once triggered.
  76342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76343. */
  76344. export class SetValueAction extends Action {
  76345. /**
  76346. * The path of the property to set in the target.
  76347. */
  76348. propertyPath: string;
  76349. /**
  76350. * The value to set in the property
  76351. */
  76352. value: any;
  76353. private _target;
  76354. private _effectiveTarget;
  76355. private _property;
  76356. /**
  76357. * Instantiate the action
  76358. * @param triggerOptions defines the trigger options
  76359. * @param target defines the object containing the property
  76360. * @param propertyPath defines the path of the property to set in the target
  76361. * @param value defines the value to set in the property
  76362. * @param condition defines the trigger related conditions
  76363. */
  76364. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76365. /** @hidden */
  76366. _prepare(): void;
  76367. /**
  76368. * Execute the action and set the targetted property to the desired value.
  76369. */
  76370. execute(): void;
  76371. /**
  76372. * Serializes the actions and its related information.
  76373. * @param parent defines the object to serialize in
  76374. * @returns the serialized object
  76375. */
  76376. serialize(parent: any): any;
  76377. }
  76378. /**
  76379. * This defines an action responsible to increment the target value
  76380. * to a desired value once triggered.
  76381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76382. */
  76383. export class IncrementValueAction extends Action {
  76384. /**
  76385. * The path of the property to increment in the target.
  76386. */
  76387. propertyPath: string;
  76388. /**
  76389. * The value we should increment the property by.
  76390. */
  76391. value: any;
  76392. private _target;
  76393. private _effectiveTarget;
  76394. private _property;
  76395. /**
  76396. * Instantiate the action
  76397. * @param triggerOptions defines the trigger options
  76398. * @param target defines the object containing the property
  76399. * @param propertyPath defines the path of the property to increment in the target
  76400. * @param value defines the value value we should increment the property by
  76401. * @param condition defines the trigger related conditions
  76402. */
  76403. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76404. /** @hidden */
  76405. _prepare(): void;
  76406. /**
  76407. * Execute the action and increment the target of the value amount.
  76408. */
  76409. execute(): void;
  76410. /**
  76411. * Serializes the actions and its related information.
  76412. * @param parent defines the object to serialize in
  76413. * @returns the serialized object
  76414. */
  76415. serialize(parent: any): any;
  76416. }
  76417. /**
  76418. * This defines an action responsible to start an animation once triggered.
  76419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76420. */
  76421. export class PlayAnimationAction extends Action {
  76422. /**
  76423. * Where the animation should start (animation frame)
  76424. */
  76425. from: number;
  76426. /**
  76427. * Where the animation should stop (animation frame)
  76428. */
  76429. to: number;
  76430. /**
  76431. * Define if the animation should loop or stop after the first play.
  76432. */
  76433. loop?: boolean;
  76434. private _target;
  76435. /**
  76436. * Instantiate the action
  76437. * @param triggerOptions defines the trigger options
  76438. * @param target defines the target animation or animation name
  76439. * @param from defines from where the animation should start (animation frame)
  76440. * @param end defines where the animation should stop (animation frame)
  76441. * @param loop defines if the animation should loop or stop after the first play
  76442. * @param condition defines the trigger related conditions
  76443. */
  76444. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76445. /** @hidden */
  76446. _prepare(): void;
  76447. /**
  76448. * Execute the action and play the animation.
  76449. */
  76450. execute(): void;
  76451. /**
  76452. * Serializes the actions and its related information.
  76453. * @param parent defines the object to serialize in
  76454. * @returns the serialized object
  76455. */
  76456. serialize(parent: any): any;
  76457. }
  76458. /**
  76459. * This defines an action responsible to stop an animation once triggered.
  76460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76461. */
  76462. export class StopAnimationAction extends Action {
  76463. private _target;
  76464. /**
  76465. * Instantiate the action
  76466. * @param triggerOptions defines the trigger options
  76467. * @param target defines the target animation or animation name
  76468. * @param condition defines the trigger related conditions
  76469. */
  76470. constructor(triggerOptions: any, target: any, condition?: Condition);
  76471. /** @hidden */
  76472. _prepare(): void;
  76473. /**
  76474. * Execute the action and stop the animation.
  76475. */
  76476. execute(): void;
  76477. /**
  76478. * Serializes the actions and its related information.
  76479. * @param parent defines the object to serialize in
  76480. * @returns the serialized object
  76481. */
  76482. serialize(parent: any): any;
  76483. }
  76484. /**
  76485. * This defines an action responsible that does nothing once triggered.
  76486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76487. */
  76488. export class DoNothingAction extends Action {
  76489. /**
  76490. * Instantiate the action
  76491. * @param triggerOptions defines the trigger options
  76492. * @param condition defines the trigger related conditions
  76493. */
  76494. constructor(triggerOptions?: any, condition?: Condition);
  76495. /**
  76496. * Execute the action and do nothing.
  76497. */
  76498. execute(): void;
  76499. /**
  76500. * Serializes the actions and its related information.
  76501. * @param parent defines the object to serialize in
  76502. * @returns the serialized object
  76503. */
  76504. serialize(parent: any): any;
  76505. }
  76506. /**
  76507. * This defines an action responsible to trigger several actions once triggered.
  76508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76509. */
  76510. export class CombineAction extends Action {
  76511. /**
  76512. * The list of aggregated animations to run.
  76513. */
  76514. children: Action[];
  76515. /**
  76516. * Instantiate the action
  76517. * @param triggerOptions defines the trigger options
  76518. * @param children defines the list of aggregated animations to run
  76519. * @param condition defines the trigger related conditions
  76520. */
  76521. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76522. /** @hidden */
  76523. _prepare(): void;
  76524. /**
  76525. * Execute the action and executes all the aggregated actions.
  76526. */
  76527. execute(evt: ActionEvent): void;
  76528. /**
  76529. * Serializes the actions and its related information.
  76530. * @param parent defines the object to serialize in
  76531. * @returns the serialized object
  76532. */
  76533. serialize(parent: any): any;
  76534. }
  76535. /**
  76536. * This defines an action responsible to run code (external event) once triggered.
  76537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76538. */
  76539. export class ExecuteCodeAction extends Action {
  76540. /**
  76541. * The callback function to run.
  76542. */
  76543. func: (evt: ActionEvent) => void;
  76544. /**
  76545. * Instantiate the action
  76546. * @param triggerOptions defines the trigger options
  76547. * @param func defines the callback function to run
  76548. * @param condition defines the trigger related conditions
  76549. */
  76550. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76551. /**
  76552. * Execute the action and run the attached code.
  76553. */
  76554. execute(evt: ActionEvent): void;
  76555. }
  76556. /**
  76557. * This defines an action responsible to set the parent property of the target once triggered.
  76558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76559. */
  76560. export class SetParentAction extends Action {
  76561. private _parent;
  76562. private _target;
  76563. /**
  76564. * Instantiate the action
  76565. * @param triggerOptions defines the trigger options
  76566. * @param target defines the target containing the parent property
  76567. * @param parent defines from where the animation should start (animation frame)
  76568. * @param condition defines the trigger related conditions
  76569. */
  76570. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76571. /** @hidden */
  76572. _prepare(): void;
  76573. /**
  76574. * Execute the action and set the parent property.
  76575. */
  76576. execute(): void;
  76577. /**
  76578. * Serializes the actions and its related information.
  76579. * @param parent defines the object to serialize in
  76580. * @returns the serialized object
  76581. */
  76582. serialize(parent: any): any;
  76583. }
  76584. }
  76585. declare module BABYLON {
  76586. /**
  76587. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76588. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76590. */
  76591. export class ActionManager extends AbstractActionManager {
  76592. /**
  76593. * Nothing
  76594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76595. */
  76596. static readonly NothingTrigger: number;
  76597. /**
  76598. * On pick
  76599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76600. */
  76601. static readonly OnPickTrigger: number;
  76602. /**
  76603. * On left pick
  76604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76605. */
  76606. static readonly OnLeftPickTrigger: number;
  76607. /**
  76608. * On right pick
  76609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76610. */
  76611. static readonly OnRightPickTrigger: number;
  76612. /**
  76613. * On center pick
  76614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76615. */
  76616. static readonly OnCenterPickTrigger: number;
  76617. /**
  76618. * On pick down
  76619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76620. */
  76621. static readonly OnPickDownTrigger: number;
  76622. /**
  76623. * On double pick
  76624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76625. */
  76626. static readonly OnDoublePickTrigger: number;
  76627. /**
  76628. * On pick up
  76629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76630. */
  76631. static readonly OnPickUpTrigger: number;
  76632. /**
  76633. * On pick out.
  76634. * This trigger will only be raised if you also declared a OnPickDown
  76635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76636. */
  76637. static readonly OnPickOutTrigger: number;
  76638. /**
  76639. * On long press
  76640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76641. */
  76642. static readonly OnLongPressTrigger: number;
  76643. /**
  76644. * On pointer over
  76645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76646. */
  76647. static readonly OnPointerOverTrigger: number;
  76648. /**
  76649. * On pointer out
  76650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76651. */
  76652. static readonly OnPointerOutTrigger: number;
  76653. /**
  76654. * On every frame
  76655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76656. */
  76657. static readonly OnEveryFrameTrigger: number;
  76658. /**
  76659. * On intersection enter
  76660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76661. */
  76662. static readonly OnIntersectionEnterTrigger: number;
  76663. /**
  76664. * On intersection exit
  76665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76666. */
  76667. static readonly OnIntersectionExitTrigger: number;
  76668. /**
  76669. * On key down
  76670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76671. */
  76672. static readonly OnKeyDownTrigger: number;
  76673. /**
  76674. * On key up
  76675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76676. */
  76677. static readonly OnKeyUpTrigger: number;
  76678. private _scene;
  76679. /**
  76680. * Creates a new action manager
  76681. * @param scene defines the hosting scene
  76682. */
  76683. constructor(scene: Scene);
  76684. /**
  76685. * Releases all associated resources
  76686. */
  76687. dispose(): void;
  76688. /**
  76689. * Gets hosting scene
  76690. * @returns the hosting scene
  76691. */
  76692. getScene(): Scene;
  76693. /**
  76694. * Does this action manager handles actions of any of the given triggers
  76695. * @param triggers defines the triggers to be tested
  76696. * @return a boolean indicating whether one (or more) of the triggers is handled
  76697. */
  76698. hasSpecificTriggers(triggers: number[]): boolean;
  76699. /**
  76700. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76701. * speed.
  76702. * @param triggerA defines the trigger to be tested
  76703. * @param triggerB defines the trigger to be tested
  76704. * @return a boolean indicating whether one (or more) of the triggers is handled
  76705. */
  76706. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76707. /**
  76708. * Does this action manager handles actions of a given trigger
  76709. * @param trigger defines the trigger to be tested
  76710. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76711. * @return whether the trigger is handled
  76712. */
  76713. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76714. /**
  76715. * Does this action manager has pointer triggers
  76716. */
  76717. readonly hasPointerTriggers: boolean;
  76718. /**
  76719. * Does this action manager has pick triggers
  76720. */
  76721. readonly hasPickTriggers: boolean;
  76722. /**
  76723. * Registers an action to this action manager
  76724. * @param action defines the action to be registered
  76725. * @return the action amended (prepared) after registration
  76726. */
  76727. registerAction(action: IAction): Nullable<IAction>;
  76728. /**
  76729. * Unregisters an action to this action manager
  76730. * @param action defines the action to be unregistered
  76731. * @return a boolean indicating whether the action has been unregistered
  76732. */
  76733. unregisterAction(action: IAction): Boolean;
  76734. /**
  76735. * Process a specific trigger
  76736. * @param trigger defines the trigger to process
  76737. * @param evt defines the event details to be processed
  76738. */
  76739. processTrigger(trigger: number, evt?: IActionEvent): void;
  76740. /** @hidden */
  76741. _getEffectiveTarget(target: any, propertyPath: string): any;
  76742. /** @hidden */
  76743. _getProperty(propertyPath: string): string;
  76744. /**
  76745. * Serialize this manager to a JSON object
  76746. * @param name defines the property name to store this manager
  76747. * @returns a JSON representation of this manager
  76748. */
  76749. serialize(name: string): any;
  76750. /**
  76751. * Creates a new ActionManager from a JSON data
  76752. * @param parsedActions defines the JSON data to read from
  76753. * @param object defines the hosting mesh
  76754. * @param scene defines the hosting scene
  76755. */
  76756. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76757. /**
  76758. * Get a trigger name by index
  76759. * @param trigger defines the trigger index
  76760. * @returns a trigger name
  76761. */
  76762. static GetTriggerName(trigger: number): string;
  76763. }
  76764. }
  76765. declare module BABYLON {
  76766. /**
  76767. * Class representing a ray with position and direction
  76768. */
  76769. export class Ray {
  76770. /** origin point */
  76771. origin: Vector3;
  76772. /** direction */
  76773. direction: Vector3;
  76774. /** length of the ray */
  76775. length: number;
  76776. private static readonly TmpVector3;
  76777. private _tmpRay;
  76778. /**
  76779. * Creates a new ray
  76780. * @param origin origin point
  76781. * @param direction direction
  76782. * @param length length of the ray
  76783. */
  76784. constructor(
  76785. /** origin point */
  76786. origin: Vector3,
  76787. /** direction */
  76788. direction: Vector3,
  76789. /** length of the ray */
  76790. length?: number);
  76791. /**
  76792. * Checks if the ray intersects a box
  76793. * @param minimum bound of the box
  76794. * @param maximum bound of the box
  76795. * @param intersectionTreshold extra extend to be added to the box in all direction
  76796. * @returns if the box was hit
  76797. */
  76798. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76799. /**
  76800. * Checks if the ray intersects a box
  76801. * @param box the bounding box to check
  76802. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76803. * @returns if the box was hit
  76804. */
  76805. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76806. /**
  76807. * If the ray hits a sphere
  76808. * @param sphere the bounding sphere to check
  76809. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76810. * @returns true if it hits the sphere
  76811. */
  76812. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76813. /**
  76814. * If the ray hits a triange
  76815. * @param vertex0 triangle vertex
  76816. * @param vertex1 triangle vertex
  76817. * @param vertex2 triangle vertex
  76818. * @returns intersection information if hit
  76819. */
  76820. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76821. /**
  76822. * Checks if ray intersects a plane
  76823. * @param plane the plane to check
  76824. * @returns the distance away it was hit
  76825. */
  76826. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76827. /**
  76828. * Calculate the intercept of a ray on a given axis
  76829. * @param axis to check 'x' | 'y' | 'z'
  76830. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76831. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76832. */
  76833. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76834. /**
  76835. * Checks if ray intersects a mesh
  76836. * @param mesh the mesh to check
  76837. * @param fastCheck if only the bounding box should checked
  76838. * @returns picking info of the intersecton
  76839. */
  76840. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76841. /**
  76842. * Checks if ray intersects a mesh
  76843. * @param meshes the meshes to check
  76844. * @param fastCheck if only the bounding box should checked
  76845. * @param results array to store result in
  76846. * @returns Array of picking infos
  76847. */
  76848. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76849. private _comparePickingInfo;
  76850. private static smallnum;
  76851. private static rayl;
  76852. /**
  76853. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76854. * @param sega the first point of the segment to test the intersection against
  76855. * @param segb the second point of the segment to test the intersection against
  76856. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76857. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76858. */
  76859. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76860. /**
  76861. * Update the ray from viewport position
  76862. * @param x position
  76863. * @param y y position
  76864. * @param viewportWidth viewport width
  76865. * @param viewportHeight viewport height
  76866. * @param world world matrix
  76867. * @param view view matrix
  76868. * @param projection projection matrix
  76869. * @returns this ray updated
  76870. */
  76871. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76872. /**
  76873. * Creates a ray with origin and direction of 0,0,0
  76874. * @returns the new ray
  76875. */
  76876. static Zero(): Ray;
  76877. /**
  76878. * Creates a new ray from screen space and viewport
  76879. * @param x position
  76880. * @param y y position
  76881. * @param viewportWidth viewport width
  76882. * @param viewportHeight viewport height
  76883. * @param world world matrix
  76884. * @param view view matrix
  76885. * @param projection projection matrix
  76886. * @returns new ray
  76887. */
  76888. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76889. /**
  76890. * 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
  76891. * transformed to the given world matrix.
  76892. * @param origin The origin point
  76893. * @param end The end point
  76894. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76895. * @returns the new ray
  76896. */
  76897. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76898. /**
  76899. * Transforms a ray by a matrix
  76900. * @param ray ray to transform
  76901. * @param matrix matrix to apply
  76902. * @returns the resulting new ray
  76903. */
  76904. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76905. /**
  76906. * Transforms a ray by a matrix
  76907. * @param ray ray to transform
  76908. * @param matrix matrix to apply
  76909. * @param result ray to store result in
  76910. */
  76911. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76912. /**
  76913. * Unproject a ray from screen space to object space
  76914. * @param sourceX defines the screen space x coordinate to use
  76915. * @param sourceY defines the screen space y coordinate to use
  76916. * @param viewportWidth defines the current width of the viewport
  76917. * @param viewportHeight defines the current height of the viewport
  76918. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76919. * @param view defines the view matrix to use
  76920. * @param projection defines the projection matrix to use
  76921. */
  76922. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76923. }
  76924. /**
  76925. * Type used to define predicate used to select faces when a mesh intersection is detected
  76926. */
  76927. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76928. interface Scene {
  76929. /** @hidden */
  76930. _tempPickingRay: Nullable<Ray>;
  76931. /** @hidden */
  76932. _cachedRayForTransform: Ray;
  76933. /** @hidden */
  76934. _pickWithRayInverseMatrix: Matrix;
  76935. /** @hidden */
  76936. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76937. /** @hidden */
  76938. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76939. }
  76940. }
  76941. declare module BABYLON {
  76942. /**
  76943. * Groups all the scene component constants in one place to ease maintenance.
  76944. * @hidden
  76945. */
  76946. export class SceneComponentConstants {
  76947. static readonly NAME_EFFECTLAYER: string;
  76948. static readonly NAME_LAYER: string;
  76949. static readonly NAME_LENSFLARESYSTEM: string;
  76950. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76951. static readonly NAME_PARTICLESYSTEM: string;
  76952. static readonly NAME_GAMEPAD: string;
  76953. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76954. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76955. static readonly NAME_DEPTHRENDERER: string;
  76956. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76957. static readonly NAME_SPRITE: string;
  76958. static readonly NAME_OUTLINERENDERER: string;
  76959. static readonly NAME_PROCEDURALTEXTURE: string;
  76960. static readonly NAME_SHADOWGENERATOR: string;
  76961. static readonly NAME_OCTREE: string;
  76962. static readonly NAME_PHYSICSENGINE: string;
  76963. static readonly NAME_AUDIO: string;
  76964. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76965. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76966. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76967. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76968. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76969. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76970. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76971. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76972. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76973. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76974. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76975. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76976. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76977. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76978. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76979. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76980. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76981. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76982. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76983. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76984. static readonly STEP_AFTERRENDER_AUDIO: number;
  76985. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76986. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76987. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76988. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76989. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76990. static readonly STEP_POINTERMOVE_SPRITE: number;
  76991. static readonly STEP_POINTERDOWN_SPRITE: number;
  76992. static readonly STEP_POINTERUP_SPRITE: number;
  76993. }
  76994. /**
  76995. * This represents a scene component.
  76996. *
  76997. * This is used to decouple the dependency the scene is having on the different workloads like
  76998. * layers, post processes...
  76999. */
  77000. export interface ISceneComponent {
  77001. /**
  77002. * The name of the component. Each component must have a unique name.
  77003. */
  77004. name: string;
  77005. /**
  77006. * The scene the component belongs to.
  77007. */
  77008. scene: Scene;
  77009. /**
  77010. * Register the component to one instance of a scene.
  77011. */
  77012. register(): void;
  77013. /**
  77014. * Rebuilds the elements related to this component in case of
  77015. * context lost for instance.
  77016. */
  77017. rebuild(): void;
  77018. /**
  77019. * Disposes the component and the associated ressources.
  77020. */
  77021. dispose(): void;
  77022. }
  77023. /**
  77024. * This represents a SERIALIZABLE scene component.
  77025. *
  77026. * This extends Scene Component to add Serialization methods on top.
  77027. */
  77028. export interface ISceneSerializableComponent extends ISceneComponent {
  77029. /**
  77030. * Adds all the elements from the container to the scene
  77031. * @param container the container holding the elements
  77032. */
  77033. addFromContainer(container: AbstractScene): void;
  77034. /**
  77035. * Removes all the elements in the container from the scene
  77036. * @param container contains the elements to remove
  77037. * @param dispose if the removed element should be disposed (default: false)
  77038. */
  77039. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77040. /**
  77041. * Serializes the component data to the specified json object
  77042. * @param serializationObject The object to serialize to
  77043. */
  77044. serialize(serializationObject: any): void;
  77045. }
  77046. /**
  77047. * Strong typing of a Mesh related stage step action
  77048. */
  77049. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77050. /**
  77051. * Strong typing of a Evaluate Sub Mesh related stage step action
  77052. */
  77053. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77054. /**
  77055. * Strong typing of a Active Mesh related stage step action
  77056. */
  77057. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77058. /**
  77059. * Strong typing of a Camera related stage step action
  77060. */
  77061. export type CameraStageAction = (camera: Camera) => void;
  77062. /**
  77063. * Strong typing of a Camera Frame buffer related stage step action
  77064. */
  77065. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77066. /**
  77067. * Strong typing of a Render Target related stage step action
  77068. */
  77069. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77070. /**
  77071. * Strong typing of a RenderingGroup related stage step action
  77072. */
  77073. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77074. /**
  77075. * Strong typing of a Mesh Render related stage step action
  77076. */
  77077. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77078. /**
  77079. * Strong typing of a simple stage step action
  77080. */
  77081. export type SimpleStageAction = () => void;
  77082. /**
  77083. * Strong typing of a render target action.
  77084. */
  77085. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77086. /**
  77087. * Strong typing of a pointer move action.
  77088. */
  77089. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77090. /**
  77091. * Strong typing of a pointer up/down action.
  77092. */
  77093. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77094. /**
  77095. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77096. * @hidden
  77097. */
  77098. export class Stage<T extends Function> extends Array<{
  77099. index: number;
  77100. component: ISceneComponent;
  77101. action: T;
  77102. }> {
  77103. /**
  77104. * Hide ctor from the rest of the world.
  77105. * @param items The items to add.
  77106. */
  77107. private constructor();
  77108. /**
  77109. * Creates a new Stage.
  77110. * @returns A new instance of a Stage
  77111. */
  77112. static Create<T extends Function>(): Stage<T>;
  77113. /**
  77114. * Registers a step in an ordered way in the targeted stage.
  77115. * @param index Defines the position to register the step in
  77116. * @param component Defines the component attached to the step
  77117. * @param action Defines the action to launch during the step
  77118. */
  77119. registerStep(index: number, component: ISceneComponent, action: T): void;
  77120. /**
  77121. * Clears all the steps from the stage.
  77122. */
  77123. clear(): void;
  77124. }
  77125. }
  77126. declare module BABYLON {
  77127. interface Scene {
  77128. /** @hidden */
  77129. _pointerOverSprite: Nullable<Sprite>;
  77130. /** @hidden */
  77131. _pickedDownSprite: Nullable<Sprite>;
  77132. /** @hidden */
  77133. _tempSpritePickingRay: Nullable<Ray>;
  77134. /**
  77135. * All of the sprite managers added to this scene
  77136. * @see http://doc.babylonjs.com/babylon101/sprites
  77137. */
  77138. spriteManagers: Array<ISpriteManager>;
  77139. /**
  77140. * An event triggered when sprites rendering is about to start
  77141. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77142. */
  77143. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77144. /**
  77145. * An event triggered when sprites rendering is done
  77146. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77147. */
  77148. onAfterSpritesRenderingObservable: Observable<Scene>;
  77149. /** @hidden */
  77150. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77151. /** Launch a ray to try to pick a sprite in the scene
  77152. * @param x position on screen
  77153. * @param y position on screen
  77154. * @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
  77155. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77156. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77157. * @returns a PickingInfo
  77158. */
  77159. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77160. /** Use the given ray to pick a sprite in the scene
  77161. * @param ray The ray (in world space) to use to pick meshes
  77162. * @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
  77163. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77164. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77165. * @returns a PickingInfo
  77166. */
  77167. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77168. /** @hidden */
  77169. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77170. /** Launch a ray to try to pick sprites in the scene
  77171. * @param x position on screen
  77172. * @param y position on screen
  77173. * @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
  77174. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77175. * @returns a PickingInfo array
  77176. */
  77177. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77178. /** Use the given ray to pick sprites in the scene
  77179. * @param ray The ray (in world space) to use to pick meshes
  77180. * @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
  77181. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77182. * @returns a PickingInfo array
  77183. */
  77184. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77185. /**
  77186. * Force the sprite under the pointer
  77187. * @param sprite defines the sprite to use
  77188. */
  77189. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77190. /**
  77191. * Gets the sprite under the pointer
  77192. * @returns a Sprite or null if no sprite is under the pointer
  77193. */
  77194. getPointerOverSprite(): Nullable<Sprite>;
  77195. }
  77196. /**
  77197. * Defines the sprite scene component responsible to manage sprites
  77198. * in a given scene.
  77199. */
  77200. export class SpriteSceneComponent implements ISceneComponent {
  77201. /**
  77202. * The component name helpfull to identify the component in the list of scene components.
  77203. */
  77204. readonly name: string;
  77205. /**
  77206. * The scene the component belongs to.
  77207. */
  77208. scene: Scene;
  77209. /** @hidden */
  77210. private _spritePredicate;
  77211. /**
  77212. * Creates a new instance of the component for the given scene
  77213. * @param scene Defines the scene to register the component in
  77214. */
  77215. constructor(scene: Scene);
  77216. /**
  77217. * Registers the component in a given scene
  77218. */
  77219. register(): void;
  77220. /**
  77221. * Rebuilds the elements related to this component in case of
  77222. * context lost for instance.
  77223. */
  77224. rebuild(): void;
  77225. /**
  77226. * Disposes the component and the associated ressources.
  77227. */
  77228. dispose(): void;
  77229. private _pickSpriteButKeepRay;
  77230. private _pointerMove;
  77231. private _pointerDown;
  77232. private _pointerUp;
  77233. }
  77234. }
  77235. declare module BABYLON {
  77236. /** @hidden */
  77237. export var fogFragmentDeclaration: {
  77238. name: string;
  77239. shader: string;
  77240. };
  77241. }
  77242. declare module BABYLON {
  77243. /** @hidden */
  77244. export var fogFragment: {
  77245. name: string;
  77246. shader: string;
  77247. };
  77248. }
  77249. declare module BABYLON {
  77250. /** @hidden */
  77251. export var spritesPixelShader: {
  77252. name: string;
  77253. shader: string;
  77254. };
  77255. }
  77256. declare module BABYLON {
  77257. /** @hidden */
  77258. export var fogVertexDeclaration: {
  77259. name: string;
  77260. shader: string;
  77261. };
  77262. }
  77263. declare module BABYLON {
  77264. /** @hidden */
  77265. export var spritesVertexShader: {
  77266. name: string;
  77267. shader: string;
  77268. };
  77269. }
  77270. declare module BABYLON {
  77271. /**
  77272. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77273. */
  77274. export interface ISpriteManager extends IDisposable {
  77275. /**
  77276. * Restricts the camera to viewing objects with the same layerMask.
  77277. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77278. */
  77279. layerMask: number;
  77280. /**
  77281. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77282. */
  77283. isPickable: boolean;
  77284. /**
  77285. * Specifies the rendering group id for this mesh (0 by default)
  77286. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77287. */
  77288. renderingGroupId: number;
  77289. /**
  77290. * Defines the list of sprites managed by the manager.
  77291. */
  77292. sprites: Array<Sprite>;
  77293. /**
  77294. * Tests the intersection of a sprite with a specific ray.
  77295. * @param ray The ray we are sending to test the collision
  77296. * @param camera The camera space we are sending rays in
  77297. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77298. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77299. * @returns picking info or null.
  77300. */
  77301. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77302. /**
  77303. * Intersects the sprites with a ray
  77304. * @param ray defines the ray to intersect with
  77305. * @param camera defines the current active camera
  77306. * @param predicate defines a predicate used to select candidate sprites
  77307. * @returns null if no hit or a PickingInfo array
  77308. */
  77309. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77310. /**
  77311. * Renders the list of sprites on screen.
  77312. */
  77313. render(): void;
  77314. }
  77315. /**
  77316. * Class used to manage multiple sprites on the same spritesheet
  77317. * @see http://doc.babylonjs.com/babylon101/sprites
  77318. */
  77319. export class SpriteManager implements ISpriteManager {
  77320. /** defines the manager's name */
  77321. name: string;
  77322. /** Gets the list of sprites */
  77323. sprites: Sprite[];
  77324. /** Gets or sets the rendering group id (0 by default) */
  77325. renderingGroupId: number;
  77326. /** Gets or sets camera layer mask */
  77327. layerMask: number;
  77328. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77329. fogEnabled: boolean;
  77330. /** Gets or sets a boolean indicating if the sprites are pickable */
  77331. isPickable: boolean;
  77332. /** Defines the default width of a cell in the spritesheet */
  77333. cellWidth: number;
  77334. /** Defines the default height of a cell in the spritesheet */
  77335. cellHeight: number;
  77336. /** Associative array from JSON sprite data file */
  77337. private _cellData;
  77338. /** Array of sprite names from JSON sprite data file */
  77339. private _spriteMap;
  77340. /** True when packed cell data from JSON file is ready*/
  77341. private _packedAndReady;
  77342. /**
  77343. * An event triggered when the manager is disposed.
  77344. */
  77345. onDisposeObservable: Observable<SpriteManager>;
  77346. private _onDisposeObserver;
  77347. /**
  77348. * Callback called when the manager is disposed
  77349. */
  77350. onDispose: () => void;
  77351. private _capacity;
  77352. private _fromPacked;
  77353. private _spriteTexture;
  77354. private _epsilon;
  77355. private _scene;
  77356. private _vertexData;
  77357. private _buffer;
  77358. private _vertexBuffers;
  77359. private _indexBuffer;
  77360. private _effectBase;
  77361. private _effectFog;
  77362. /**
  77363. * Gets or sets the spritesheet texture
  77364. */
  77365. texture: Texture;
  77366. /**
  77367. * Creates a new sprite manager
  77368. * @param name defines the manager's name
  77369. * @param imgUrl defines the sprite sheet url
  77370. * @param capacity defines the maximum allowed number of sprites
  77371. * @param cellSize defines the size of a sprite cell
  77372. * @param scene defines the hosting scene
  77373. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77374. * @param samplingMode defines the smapling mode to use with spritesheet
  77375. * @param fromPacked set to false; do not alter
  77376. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77377. */
  77378. constructor(
  77379. /** defines the manager's name */
  77380. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77381. private _makePacked;
  77382. private _appendSpriteVertex;
  77383. /**
  77384. * Intersects the sprites with a ray
  77385. * @param ray defines the ray to intersect with
  77386. * @param camera defines the current active camera
  77387. * @param predicate defines a predicate used to select candidate sprites
  77388. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77389. * @returns null if no hit or a PickingInfo
  77390. */
  77391. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77392. /**
  77393. * Intersects the sprites with a ray
  77394. * @param ray defines the ray to intersect with
  77395. * @param camera defines the current active camera
  77396. * @param predicate defines a predicate used to select candidate sprites
  77397. * @returns null if no hit or a PickingInfo array
  77398. */
  77399. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77400. /**
  77401. * Render all child sprites
  77402. */
  77403. render(): void;
  77404. /**
  77405. * Release associated resources
  77406. */
  77407. dispose(): void;
  77408. }
  77409. }
  77410. declare module BABYLON {
  77411. /**
  77412. * Class used to represent a sprite
  77413. * @see http://doc.babylonjs.com/babylon101/sprites
  77414. */
  77415. export class Sprite {
  77416. /** defines the name */
  77417. name: string;
  77418. /** Gets or sets the current world position */
  77419. position: Vector3;
  77420. /** Gets or sets the main color */
  77421. color: Color4;
  77422. /** Gets or sets the width */
  77423. width: number;
  77424. /** Gets or sets the height */
  77425. height: number;
  77426. /** Gets or sets rotation angle */
  77427. angle: number;
  77428. /** Gets or sets the cell index in the sprite sheet */
  77429. cellIndex: number;
  77430. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77431. cellRef: string;
  77432. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77433. invertU: number;
  77434. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77435. invertV: number;
  77436. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77437. disposeWhenFinishedAnimating: boolean;
  77438. /** Gets the list of attached animations */
  77439. animations: Animation[];
  77440. /** Gets or sets a boolean indicating if the sprite can be picked */
  77441. isPickable: boolean;
  77442. /**
  77443. * Gets or sets the associated action manager
  77444. */
  77445. actionManager: Nullable<ActionManager>;
  77446. private _animationStarted;
  77447. private _loopAnimation;
  77448. private _fromIndex;
  77449. private _toIndex;
  77450. private _delay;
  77451. private _direction;
  77452. private _manager;
  77453. private _time;
  77454. private _onAnimationEnd;
  77455. /**
  77456. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77457. */
  77458. isVisible: boolean;
  77459. /**
  77460. * Gets or sets the sprite size
  77461. */
  77462. size: number;
  77463. /**
  77464. * Creates a new Sprite
  77465. * @param name defines the name
  77466. * @param manager defines the manager
  77467. */
  77468. constructor(
  77469. /** defines the name */
  77470. name: string, manager: ISpriteManager);
  77471. /**
  77472. * Starts an animation
  77473. * @param from defines the initial key
  77474. * @param to defines the end key
  77475. * @param loop defines if the animation must loop
  77476. * @param delay defines the start delay (in ms)
  77477. * @param onAnimationEnd defines a callback to call when animation ends
  77478. */
  77479. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77480. /** Stops current animation (if any) */
  77481. stopAnimation(): void;
  77482. /** @hidden */
  77483. _animate(deltaTime: number): void;
  77484. /** Release associated resources */
  77485. dispose(): void;
  77486. }
  77487. }
  77488. declare module BABYLON {
  77489. /**
  77490. * Information about the result of picking within a scene
  77491. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77492. */
  77493. export class PickingInfo {
  77494. /** @hidden */
  77495. _pickingUnavailable: boolean;
  77496. /**
  77497. * If the pick collided with an object
  77498. */
  77499. hit: boolean;
  77500. /**
  77501. * Distance away where the pick collided
  77502. */
  77503. distance: number;
  77504. /**
  77505. * The location of pick collision
  77506. */
  77507. pickedPoint: Nullable<Vector3>;
  77508. /**
  77509. * The mesh corresponding the the pick collision
  77510. */
  77511. pickedMesh: Nullable<AbstractMesh>;
  77512. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77513. bu: number;
  77514. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77515. bv: number;
  77516. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77517. faceId: number;
  77518. /** Id of the the submesh that was picked */
  77519. subMeshId: number;
  77520. /** If a sprite was picked, this will be the sprite the pick collided with */
  77521. pickedSprite: Nullable<Sprite>;
  77522. /**
  77523. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77524. */
  77525. originMesh: Nullable<AbstractMesh>;
  77526. /**
  77527. * The ray that was used to perform the picking.
  77528. */
  77529. ray: Nullable<Ray>;
  77530. /**
  77531. * Gets the normal correspodning to the face the pick collided with
  77532. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77533. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77534. * @returns The normal correspodning to the face the pick collided with
  77535. */
  77536. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77537. /**
  77538. * Gets the texture coordinates of where the pick occured
  77539. * @returns the vector containing the coordnates of the texture
  77540. */
  77541. getTextureCoordinates(): Nullable<Vector2>;
  77542. }
  77543. }
  77544. declare module BABYLON {
  77545. /**
  77546. * Gather the list of pointer event types as constants.
  77547. */
  77548. export class PointerEventTypes {
  77549. /**
  77550. * 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.
  77551. */
  77552. static readonly POINTERDOWN: number;
  77553. /**
  77554. * The pointerup event is fired when a pointer is no longer active.
  77555. */
  77556. static readonly POINTERUP: number;
  77557. /**
  77558. * The pointermove event is fired when a pointer changes coordinates.
  77559. */
  77560. static readonly POINTERMOVE: number;
  77561. /**
  77562. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77563. */
  77564. static readonly POINTERWHEEL: number;
  77565. /**
  77566. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77567. */
  77568. static readonly POINTERPICK: number;
  77569. /**
  77570. * The pointertap event is fired when a the object has been touched and released without drag.
  77571. */
  77572. static readonly POINTERTAP: number;
  77573. /**
  77574. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77575. */
  77576. static readonly POINTERDOUBLETAP: number;
  77577. }
  77578. /**
  77579. * Base class of pointer info types.
  77580. */
  77581. export class PointerInfoBase {
  77582. /**
  77583. * Defines the type of event (PointerEventTypes)
  77584. */
  77585. type: number;
  77586. /**
  77587. * Defines the related dom event
  77588. */
  77589. event: PointerEvent | MouseWheelEvent;
  77590. /**
  77591. * Instantiates the base class of pointers info.
  77592. * @param type Defines the type of event (PointerEventTypes)
  77593. * @param event Defines the related dom event
  77594. */
  77595. constructor(
  77596. /**
  77597. * Defines the type of event (PointerEventTypes)
  77598. */
  77599. type: number,
  77600. /**
  77601. * Defines the related dom event
  77602. */
  77603. event: PointerEvent | MouseWheelEvent);
  77604. }
  77605. /**
  77606. * This class is used to store pointer related info for the onPrePointerObservable event.
  77607. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77608. */
  77609. export class PointerInfoPre extends PointerInfoBase {
  77610. /**
  77611. * Ray from a pointer if availible (eg. 6dof controller)
  77612. */
  77613. ray: Nullable<Ray>;
  77614. /**
  77615. * Defines the local position of the pointer on the canvas.
  77616. */
  77617. localPosition: Vector2;
  77618. /**
  77619. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77620. */
  77621. skipOnPointerObservable: boolean;
  77622. /**
  77623. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77624. * @param type Defines the type of event (PointerEventTypes)
  77625. * @param event Defines the related dom event
  77626. * @param localX Defines the local x coordinates of the pointer when the event occured
  77627. * @param localY Defines the local y coordinates of the pointer when the event occured
  77628. */
  77629. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77630. }
  77631. /**
  77632. * This type contains all the data related to a pointer event in Babylon.js.
  77633. * 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.
  77634. */
  77635. export class PointerInfo extends PointerInfoBase {
  77636. /**
  77637. * Defines the picking info associated to the info (if any)\
  77638. */
  77639. pickInfo: Nullable<PickingInfo>;
  77640. /**
  77641. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77642. * @param type Defines the type of event (PointerEventTypes)
  77643. * @param event Defines the related dom event
  77644. * @param pickInfo Defines the picking info associated to the info (if any)\
  77645. */
  77646. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77647. /**
  77648. * Defines the picking info associated to the info (if any)\
  77649. */
  77650. pickInfo: Nullable<PickingInfo>);
  77651. }
  77652. /**
  77653. * Data relating to a touch event on the screen.
  77654. */
  77655. export interface PointerTouch {
  77656. /**
  77657. * X coordinate of touch.
  77658. */
  77659. x: number;
  77660. /**
  77661. * Y coordinate of touch.
  77662. */
  77663. y: number;
  77664. /**
  77665. * Id of touch. Unique for each finger.
  77666. */
  77667. pointerId: number;
  77668. /**
  77669. * Event type passed from DOM.
  77670. */
  77671. type: any;
  77672. }
  77673. }
  77674. declare module BABYLON {
  77675. /**
  77676. * Manage the mouse inputs to control the movement of a free camera.
  77677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77678. */
  77679. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77680. /**
  77681. * Define if touch is enabled in the mouse input
  77682. */
  77683. touchEnabled: boolean;
  77684. /**
  77685. * Defines the camera the input is attached to.
  77686. */
  77687. camera: FreeCamera;
  77688. /**
  77689. * Defines the buttons associated with the input to handle camera move.
  77690. */
  77691. buttons: number[];
  77692. /**
  77693. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77694. */
  77695. angularSensibility: number;
  77696. private _pointerInput;
  77697. private _onMouseMove;
  77698. private _observer;
  77699. private previousPosition;
  77700. /**
  77701. * Observable for when a pointer move event occurs containing the move offset
  77702. */
  77703. onPointerMovedObservable: Observable<{
  77704. offsetX: number;
  77705. offsetY: number;
  77706. }>;
  77707. /**
  77708. * @hidden
  77709. * If the camera should be rotated automatically based on pointer movement
  77710. */
  77711. _allowCameraRotation: boolean;
  77712. /**
  77713. * Manage the mouse inputs to control the movement of a free camera.
  77714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77715. * @param touchEnabled Defines if touch is enabled or not
  77716. */
  77717. constructor(
  77718. /**
  77719. * Define if touch is enabled in the mouse input
  77720. */
  77721. touchEnabled?: boolean);
  77722. /**
  77723. * Attach the input controls to a specific dom element to get the input from.
  77724. * @param element Defines the element the controls should be listened from
  77725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77726. */
  77727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77728. /**
  77729. * Called on JS contextmenu event.
  77730. * Override this method to provide functionality.
  77731. */
  77732. protected onContextMenu(evt: PointerEvent): void;
  77733. /**
  77734. * Detach the current controls from the specified dom element.
  77735. * @param element Defines the element to stop listening the inputs from
  77736. */
  77737. detachControl(element: Nullable<HTMLElement>): void;
  77738. /**
  77739. * Gets the class name of the current intput.
  77740. * @returns the class name
  77741. */
  77742. getClassName(): string;
  77743. /**
  77744. * Get the friendly name associated with the input class.
  77745. * @returns the input friendly name
  77746. */
  77747. getSimpleName(): string;
  77748. }
  77749. }
  77750. declare module BABYLON {
  77751. /**
  77752. * Manage the touch inputs to control the movement of a free camera.
  77753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77754. */
  77755. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77756. /**
  77757. * Defines the camera the input is attached to.
  77758. */
  77759. camera: FreeCamera;
  77760. /**
  77761. * Defines the touch sensibility for rotation.
  77762. * The higher the faster.
  77763. */
  77764. touchAngularSensibility: number;
  77765. /**
  77766. * Defines the touch sensibility for move.
  77767. * The higher the faster.
  77768. */
  77769. touchMoveSensibility: number;
  77770. private _offsetX;
  77771. private _offsetY;
  77772. private _pointerPressed;
  77773. private _pointerInput;
  77774. private _observer;
  77775. private _onLostFocus;
  77776. /**
  77777. * Attach the input controls to a specific dom element to get the input from.
  77778. * @param element Defines the element the controls should be listened from
  77779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77780. */
  77781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77782. /**
  77783. * Detach the current controls from the specified dom element.
  77784. * @param element Defines the element to stop listening the inputs from
  77785. */
  77786. detachControl(element: Nullable<HTMLElement>): void;
  77787. /**
  77788. * Update the current camera state depending on the inputs that have been used this frame.
  77789. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77790. */
  77791. checkInputs(): void;
  77792. /**
  77793. * Gets the class name of the current intput.
  77794. * @returns the class name
  77795. */
  77796. getClassName(): string;
  77797. /**
  77798. * Get the friendly name associated with the input class.
  77799. * @returns the input friendly name
  77800. */
  77801. getSimpleName(): string;
  77802. }
  77803. }
  77804. declare module BABYLON {
  77805. /**
  77806. * Default Inputs manager for the FreeCamera.
  77807. * It groups all the default supported inputs for ease of use.
  77808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77809. */
  77810. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77811. /**
  77812. * @hidden
  77813. */
  77814. _mouseInput: Nullable<FreeCameraMouseInput>;
  77815. /**
  77816. * Instantiates a new FreeCameraInputsManager.
  77817. * @param camera Defines the camera the inputs belong to
  77818. */
  77819. constructor(camera: FreeCamera);
  77820. /**
  77821. * Add keyboard input support to the input manager.
  77822. * @returns the current input manager
  77823. */
  77824. addKeyboard(): FreeCameraInputsManager;
  77825. /**
  77826. * Add mouse input support to the input manager.
  77827. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77828. * @returns the current input manager
  77829. */
  77830. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77831. /**
  77832. * Removes the mouse input support from the manager
  77833. * @returns the current input manager
  77834. */
  77835. removeMouse(): FreeCameraInputsManager;
  77836. /**
  77837. * Add touch input support to the input manager.
  77838. * @returns the current input manager
  77839. */
  77840. addTouch(): FreeCameraInputsManager;
  77841. /**
  77842. * Remove all attached input methods from a camera
  77843. */
  77844. clear(): void;
  77845. }
  77846. }
  77847. declare module BABYLON {
  77848. /**
  77849. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77850. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77852. */
  77853. export class FreeCamera extends TargetCamera {
  77854. /**
  77855. * Define the collision ellipsoid of the camera.
  77856. * This is helpful to simulate a camera body like the player body around the camera
  77857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77858. */
  77859. ellipsoid: Vector3;
  77860. /**
  77861. * Define an offset for the position of the ellipsoid around the camera.
  77862. * This can be helpful to determine the center of the body near the gravity center of the body
  77863. * instead of its head.
  77864. */
  77865. ellipsoidOffset: Vector3;
  77866. /**
  77867. * Enable or disable collisions of the camera with the rest of the scene objects.
  77868. */
  77869. checkCollisions: boolean;
  77870. /**
  77871. * Enable or disable gravity on the camera.
  77872. */
  77873. applyGravity: boolean;
  77874. /**
  77875. * Define the input manager associated to the camera.
  77876. */
  77877. inputs: FreeCameraInputsManager;
  77878. /**
  77879. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77880. * Higher values reduce sensitivity.
  77881. */
  77882. /**
  77883. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77884. * Higher values reduce sensitivity.
  77885. */
  77886. angularSensibility: number;
  77887. /**
  77888. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77889. */
  77890. keysUp: number[];
  77891. /**
  77892. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77893. */
  77894. keysDown: number[];
  77895. /**
  77896. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77897. */
  77898. keysLeft: number[];
  77899. /**
  77900. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77901. */
  77902. keysRight: number[];
  77903. /**
  77904. * Event raised when the camera collide with a mesh in the scene.
  77905. */
  77906. onCollide: (collidedMesh: AbstractMesh) => void;
  77907. private _collider;
  77908. private _needMoveForGravity;
  77909. private _oldPosition;
  77910. private _diffPosition;
  77911. private _newPosition;
  77912. /** @hidden */
  77913. _localDirection: Vector3;
  77914. /** @hidden */
  77915. _transformedDirection: Vector3;
  77916. /**
  77917. * Instantiates a Free Camera.
  77918. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77919. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77921. * @param name Define the name of the camera in the scene
  77922. * @param position Define the start position of the camera in the scene
  77923. * @param scene Define the scene the camera belongs to
  77924. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77925. */
  77926. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77927. /**
  77928. * Attached controls to the current camera.
  77929. * @param element Defines the element the controls should be listened from
  77930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77931. */
  77932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77933. /**
  77934. * Detach the current controls from the camera.
  77935. * The camera will stop reacting to inputs.
  77936. * @param element Defines the element to stop listening the inputs from
  77937. */
  77938. detachControl(element: HTMLElement): void;
  77939. private _collisionMask;
  77940. /**
  77941. * Define a collision mask to limit the list of object the camera can collide with
  77942. */
  77943. collisionMask: number;
  77944. /** @hidden */
  77945. _collideWithWorld(displacement: Vector3): void;
  77946. private _onCollisionPositionChange;
  77947. /** @hidden */
  77948. _checkInputs(): void;
  77949. /** @hidden */
  77950. _decideIfNeedsToMove(): boolean;
  77951. /** @hidden */
  77952. _updatePosition(): void;
  77953. /**
  77954. * Destroy the camera and release the current resources hold by it.
  77955. */
  77956. dispose(): void;
  77957. /**
  77958. * Gets the current object class name.
  77959. * @return the class name
  77960. */
  77961. getClassName(): string;
  77962. }
  77963. }
  77964. declare module BABYLON {
  77965. /**
  77966. * Represents a gamepad control stick position
  77967. */
  77968. export class StickValues {
  77969. /**
  77970. * The x component of the control stick
  77971. */
  77972. x: number;
  77973. /**
  77974. * The y component of the control stick
  77975. */
  77976. y: number;
  77977. /**
  77978. * Initializes the gamepad x and y control stick values
  77979. * @param x The x component of the gamepad control stick value
  77980. * @param y The y component of the gamepad control stick value
  77981. */
  77982. constructor(
  77983. /**
  77984. * The x component of the control stick
  77985. */
  77986. x: number,
  77987. /**
  77988. * The y component of the control stick
  77989. */
  77990. y: number);
  77991. }
  77992. /**
  77993. * An interface which manages callbacks for gamepad button changes
  77994. */
  77995. export interface GamepadButtonChanges {
  77996. /**
  77997. * Called when a gamepad has been changed
  77998. */
  77999. changed: boolean;
  78000. /**
  78001. * Called when a gamepad press event has been triggered
  78002. */
  78003. pressChanged: boolean;
  78004. /**
  78005. * Called when a touch event has been triggered
  78006. */
  78007. touchChanged: boolean;
  78008. /**
  78009. * Called when a value has changed
  78010. */
  78011. valueChanged: boolean;
  78012. }
  78013. /**
  78014. * Represents a gamepad
  78015. */
  78016. export class Gamepad {
  78017. /**
  78018. * The id of the gamepad
  78019. */
  78020. id: string;
  78021. /**
  78022. * The index of the gamepad
  78023. */
  78024. index: number;
  78025. /**
  78026. * The browser gamepad
  78027. */
  78028. browserGamepad: any;
  78029. /**
  78030. * Specifies what type of gamepad this represents
  78031. */
  78032. type: number;
  78033. private _leftStick;
  78034. private _rightStick;
  78035. /** @hidden */
  78036. _isConnected: boolean;
  78037. private _leftStickAxisX;
  78038. private _leftStickAxisY;
  78039. private _rightStickAxisX;
  78040. private _rightStickAxisY;
  78041. /**
  78042. * Triggered when the left control stick has been changed
  78043. */
  78044. private _onleftstickchanged;
  78045. /**
  78046. * Triggered when the right control stick has been changed
  78047. */
  78048. private _onrightstickchanged;
  78049. /**
  78050. * Represents a gamepad controller
  78051. */
  78052. static GAMEPAD: number;
  78053. /**
  78054. * Represents a generic controller
  78055. */
  78056. static GENERIC: number;
  78057. /**
  78058. * Represents an XBox controller
  78059. */
  78060. static XBOX: number;
  78061. /**
  78062. * Represents a pose-enabled controller
  78063. */
  78064. static POSE_ENABLED: number;
  78065. /**
  78066. * Represents an Dual Shock controller
  78067. */
  78068. static DUALSHOCK: number;
  78069. /**
  78070. * Specifies whether the left control stick should be Y-inverted
  78071. */
  78072. protected _invertLeftStickY: boolean;
  78073. /**
  78074. * Specifies if the gamepad has been connected
  78075. */
  78076. readonly isConnected: boolean;
  78077. /**
  78078. * Initializes the gamepad
  78079. * @param id The id of the gamepad
  78080. * @param index The index of the gamepad
  78081. * @param browserGamepad The browser gamepad
  78082. * @param leftStickX The x component of the left joystick
  78083. * @param leftStickY The y component of the left joystick
  78084. * @param rightStickX The x component of the right joystick
  78085. * @param rightStickY The y component of the right joystick
  78086. */
  78087. constructor(
  78088. /**
  78089. * The id of the gamepad
  78090. */
  78091. id: string,
  78092. /**
  78093. * The index of the gamepad
  78094. */
  78095. index: number,
  78096. /**
  78097. * The browser gamepad
  78098. */
  78099. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78100. /**
  78101. * Callback triggered when the left joystick has changed
  78102. * @param callback
  78103. */
  78104. onleftstickchanged(callback: (values: StickValues) => void): void;
  78105. /**
  78106. * Callback triggered when the right joystick has changed
  78107. * @param callback
  78108. */
  78109. onrightstickchanged(callback: (values: StickValues) => void): void;
  78110. /**
  78111. * Gets the left joystick
  78112. */
  78113. /**
  78114. * Sets the left joystick values
  78115. */
  78116. leftStick: StickValues;
  78117. /**
  78118. * Gets the right joystick
  78119. */
  78120. /**
  78121. * Sets the right joystick value
  78122. */
  78123. rightStick: StickValues;
  78124. /**
  78125. * Updates the gamepad joystick positions
  78126. */
  78127. update(): void;
  78128. /**
  78129. * Disposes the gamepad
  78130. */
  78131. dispose(): void;
  78132. }
  78133. /**
  78134. * Represents a generic gamepad
  78135. */
  78136. export class GenericPad extends Gamepad {
  78137. private _buttons;
  78138. private _onbuttondown;
  78139. private _onbuttonup;
  78140. /**
  78141. * Observable triggered when a button has been pressed
  78142. */
  78143. onButtonDownObservable: Observable<number>;
  78144. /**
  78145. * Observable triggered when a button has been released
  78146. */
  78147. onButtonUpObservable: Observable<number>;
  78148. /**
  78149. * Callback triggered when a button has been pressed
  78150. * @param callback Called when a button has been pressed
  78151. */
  78152. onbuttondown(callback: (buttonPressed: number) => void): void;
  78153. /**
  78154. * Callback triggered when a button has been released
  78155. * @param callback Called when a button has been released
  78156. */
  78157. onbuttonup(callback: (buttonReleased: number) => void): void;
  78158. /**
  78159. * Initializes the generic gamepad
  78160. * @param id The id of the generic gamepad
  78161. * @param index The index of the generic gamepad
  78162. * @param browserGamepad The browser gamepad
  78163. */
  78164. constructor(id: string, index: number, browserGamepad: any);
  78165. private _setButtonValue;
  78166. /**
  78167. * Updates the generic gamepad
  78168. */
  78169. update(): void;
  78170. /**
  78171. * Disposes the generic gamepad
  78172. */
  78173. dispose(): void;
  78174. }
  78175. }
  78176. declare module BABYLON {
  78177. interface Engine {
  78178. /**
  78179. * Creates a raw texture
  78180. * @param data defines the data to store in the texture
  78181. * @param width defines the width of the texture
  78182. * @param height defines the height of the texture
  78183. * @param format defines the format of the data
  78184. * @param generateMipMaps defines if the engine should generate the mip levels
  78185. * @param invertY defines if data must be stored with Y axis inverted
  78186. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78187. * @param compression defines the compression used (null by default)
  78188. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78189. * @returns the raw texture inside an InternalTexture
  78190. */
  78191. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78192. /**
  78193. * Update a raw texture
  78194. * @param texture defines the texture to update
  78195. * @param data defines the data to store in the texture
  78196. * @param format defines the format of the data
  78197. * @param invertY defines if data must be stored with Y axis inverted
  78198. */
  78199. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78200. /**
  78201. * Update a raw texture
  78202. * @param texture defines the texture to update
  78203. * @param data defines the data to store in the texture
  78204. * @param format defines the format of the data
  78205. * @param invertY defines if data must be stored with Y axis inverted
  78206. * @param compression defines the compression used (null by default)
  78207. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78208. */
  78209. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78210. /**
  78211. * Creates a new raw cube texture
  78212. * @param data defines the array of data to use to create each face
  78213. * @param size defines the size of the textures
  78214. * @param format defines the format of the data
  78215. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78216. * @param generateMipMaps defines if the engine should generate the mip levels
  78217. * @param invertY defines if data must be stored with Y axis inverted
  78218. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78219. * @param compression defines the compression used (null by default)
  78220. * @returns the cube texture as an InternalTexture
  78221. */
  78222. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78223. /**
  78224. * Update a raw cube texture
  78225. * @param texture defines the texture to udpdate
  78226. * @param data defines the data to store
  78227. * @param format defines the data format
  78228. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78229. * @param invertY defines if data must be stored with Y axis inverted
  78230. */
  78231. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78232. /**
  78233. * Update a raw cube texture
  78234. * @param texture defines the texture to udpdate
  78235. * @param data defines the data to store
  78236. * @param format defines the data format
  78237. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78238. * @param invertY defines if data must be stored with Y axis inverted
  78239. * @param compression defines the compression used (null by default)
  78240. */
  78241. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78242. /**
  78243. * Update a raw cube texture
  78244. * @param texture defines the texture to udpdate
  78245. * @param data defines the data to store
  78246. * @param format defines the data format
  78247. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78248. * @param invertY defines if data must be stored with Y axis inverted
  78249. * @param compression defines the compression used (null by default)
  78250. * @param level defines which level of the texture to update
  78251. */
  78252. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78253. /**
  78254. * Creates a new raw cube texture from a specified url
  78255. * @param url defines the url where the data is located
  78256. * @param scene defines the current scene
  78257. * @param size defines the size of the textures
  78258. * @param format defines the format of the data
  78259. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78260. * @param noMipmap defines if the engine should avoid generating the mip levels
  78261. * @param callback defines a callback used to extract texture data from loaded data
  78262. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78263. * @param onLoad defines a callback called when texture is loaded
  78264. * @param onError defines a callback called if there is an error
  78265. * @returns the cube texture as an InternalTexture
  78266. */
  78267. 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;
  78268. /**
  78269. * Creates a new raw cube texture from a specified url
  78270. * @param url defines the url where the data is located
  78271. * @param scene defines the current scene
  78272. * @param size defines the size of the textures
  78273. * @param format defines the format of the data
  78274. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78275. * @param noMipmap defines if the engine should avoid generating the mip levels
  78276. * @param callback defines a callback used to extract texture data from loaded data
  78277. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78278. * @param onLoad defines a callback called when texture is loaded
  78279. * @param onError defines a callback called if there is an error
  78280. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78281. * @param invertY defines if data must be stored with Y axis inverted
  78282. * @returns the cube texture as an InternalTexture
  78283. */
  78284. 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;
  78285. /**
  78286. * Creates a new raw 3D texture
  78287. * @param data defines the data used to create the texture
  78288. * @param width defines the width of the texture
  78289. * @param height defines the height of the texture
  78290. * @param depth defines the depth of the texture
  78291. * @param format defines the format of the texture
  78292. * @param generateMipMaps defines if the engine must generate mip levels
  78293. * @param invertY defines if data must be stored with Y axis inverted
  78294. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78295. * @param compression defines the compressed used (can be null)
  78296. * @param textureType defines the compressed used (can be null)
  78297. * @returns a new raw 3D texture (stored in an InternalTexture)
  78298. */
  78299. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78300. /**
  78301. * Update a raw 3D texture
  78302. * @param texture defines the texture to update
  78303. * @param data defines the data to store
  78304. * @param format defines the data format
  78305. * @param invertY defines if data must be stored with Y axis inverted
  78306. */
  78307. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78308. /**
  78309. * Update a raw 3D texture
  78310. * @param texture defines the texture to update
  78311. * @param data defines the data to store
  78312. * @param format defines the data format
  78313. * @param invertY defines if data must be stored with Y axis inverted
  78314. * @param compression defines the used compression (can be null)
  78315. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78316. */
  78317. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78318. }
  78319. }
  78320. declare module BABYLON {
  78321. /**
  78322. * Raw texture can help creating a texture directly from an array of data.
  78323. * This can be super useful if you either get the data from an uncompressed source or
  78324. * if you wish to create your texture pixel by pixel.
  78325. */
  78326. export class RawTexture extends Texture {
  78327. /**
  78328. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78329. */
  78330. format: number;
  78331. private _engine;
  78332. /**
  78333. * Instantiates a new RawTexture.
  78334. * Raw texture can help creating a texture directly from an array of data.
  78335. * This can be super useful if you either get the data from an uncompressed source or
  78336. * if you wish to create your texture pixel by pixel.
  78337. * @param data define the array of data to use to create the texture
  78338. * @param width define the width of the texture
  78339. * @param height define the height of the texture
  78340. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78341. * @param scene define the scene the texture belongs to
  78342. * @param generateMipMaps define whether mip maps should be generated or not
  78343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78345. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78346. */
  78347. constructor(data: ArrayBufferView, width: number, height: number,
  78348. /**
  78349. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78350. */
  78351. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78352. /**
  78353. * Updates the texture underlying data.
  78354. * @param data Define the new data of the texture
  78355. */
  78356. update(data: ArrayBufferView): void;
  78357. /**
  78358. * Creates a luminance texture from some data.
  78359. * @param data Define the texture data
  78360. * @param width Define the width of the texture
  78361. * @param height Define the height of the texture
  78362. * @param scene Define the scene the texture belongs to
  78363. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78364. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78365. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78366. * @returns the luminance texture
  78367. */
  78368. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78369. /**
  78370. * Creates a luminance alpha texture from some data.
  78371. * @param data Define the texture data
  78372. * @param width Define the width of the texture
  78373. * @param height Define the height of the texture
  78374. * @param scene Define the scene the texture belongs to
  78375. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78376. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78377. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78378. * @returns the luminance alpha texture
  78379. */
  78380. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78381. /**
  78382. * Creates an alpha texture from some data.
  78383. * @param data Define the texture data
  78384. * @param width Define the width of the texture
  78385. * @param height Define the height of the texture
  78386. * @param scene Define the scene the texture belongs to
  78387. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78388. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78389. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78390. * @returns the alpha texture
  78391. */
  78392. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78393. /**
  78394. * Creates a RGB texture from some data.
  78395. * @param data Define the texture data
  78396. * @param width Define the width of the texture
  78397. * @param height Define the height of the texture
  78398. * @param scene Define the scene the texture belongs to
  78399. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78400. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78401. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78402. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78403. * @returns the RGB alpha texture
  78404. */
  78405. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78406. /**
  78407. * Creates a RGBA texture from some data.
  78408. * @param data Define the texture data
  78409. * @param width Define the width of the texture
  78410. * @param height Define the height of the texture
  78411. * @param scene Define the scene the texture belongs to
  78412. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78413. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78414. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78415. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78416. * @returns the RGBA texture
  78417. */
  78418. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78419. /**
  78420. * Creates a R texture from some data.
  78421. * @param data Define the texture data
  78422. * @param width Define the width of the texture
  78423. * @param height Define the height of the texture
  78424. * @param scene Define the scene the texture belongs to
  78425. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78426. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78427. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78428. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78429. * @returns the R texture
  78430. */
  78431. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78432. }
  78433. }
  78434. declare module BABYLON {
  78435. /**
  78436. * Interface for the size containing width and height
  78437. */
  78438. export interface ISize {
  78439. /**
  78440. * Width
  78441. */
  78442. width: number;
  78443. /**
  78444. * Heighht
  78445. */
  78446. height: number;
  78447. }
  78448. /**
  78449. * Size containing widht and height
  78450. */
  78451. export class Size implements ISize {
  78452. /**
  78453. * Width
  78454. */
  78455. width: number;
  78456. /**
  78457. * Height
  78458. */
  78459. height: number;
  78460. /**
  78461. * Creates a Size object from the given width and height (floats).
  78462. * @param width width of the new size
  78463. * @param height height of the new size
  78464. */
  78465. constructor(width: number, height: number);
  78466. /**
  78467. * Returns a string with the Size width and height
  78468. * @returns a string with the Size width and height
  78469. */
  78470. toString(): string;
  78471. /**
  78472. * "Size"
  78473. * @returns the string "Size"
  78474. */
  78475. getClassName(): string;
  78476. /**
  78477. * Returns the Size hash code.
  78478. * @returns a hash code for a unique width and height
  78479. */
  78480. getHashCode(): number;
  78481. /**
  78482. * Updates the current size from the given one.
  78483. * @param src the given size
  78484. */
  78485. copyFrom(src: Size): void;
  78486. /**
  78487. * Updates in place the current Size from the given floats.
  78488. * @param width width of the new size
  78489. * @param height height of the new size
  78490. * @returns the updated Size.
  78491. */
  78492. copyFromFloats(width: number, height: number): Size;
  78493. /**
  78494. * Updates in place the current Size from the given floats.
  78495. * @param width width to set
  78496. * @param height height to set
  78497. * @returns the updated Size.
  78498. */
  78499. set(width: number, height: number): Size;
  78500. /**
  78501. * Multiplies the width and height by numbers
  78502. * @param w factor to multiple the width by
  78503. * @param h factor to multiple the height by
  78504. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78505. */
  78506. multiplyByFloats(w: number, h: number): Size;
  78507. /**
  78508. * Clones the size
  78509. * @returns a new Size copied from the given one.
  78510. */
  78511. clone(): Size;
  78512. /**
  78513. * True if the current Size and the given one width and height are strictly equal.
  78514. * @param other the other size to compare against
  78515. * @returns True if the current Size and the given one width and height are strictly equal.
  78516. */
  78517. equals(other: Size): boolean;
  78518. /**
  78519. * The surface of the Size : width * height (float).
  78520. */
  78521. readonly surface: number;
  78522. /**
  78523. * Create a new size of zero
  78524. * @returns a new Size set to (0.0, 0.0)
  78525. */
  78526. static Zero(): Size;
  78527. /**
  78528. * Sums the width and height of two sizes
  78529. * @param otherSize size to add to this size
  78530. * @returns a new Size set as the addition result of the current Size and the given one.
  78531. */
  78532. add(otherSize: Size): Size;
  78533. /**
  78534. * Subtracts the width and height of two
  78535. * @param otherSize size to subtract to this size
  78536. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78537. */
  78538. subtract(otherSize: Size): Size;
  78539. /**
  78540. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78541. * @param start starting size to lerp between
  78542. * @param end end size to lerp between
  78543. * @param amount amount to lerp between the start and end values
  78544. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78545. */
  78546. static Lerp(start: Size, end: Size, amount: number): Size;
  78547. }
  78548. }
  78549. declare module BABYLON {
  78550. /**
  78551. * Defines a runtime animation
  78552. */
  78553. export class RuntimeAnimation {
  78554. private _events;
  78555. /**
  78556. * The current frame of the runtime animation
  78557. */
  78558. private _currentFrame;
  78559. /**
  78560. * The animation used by the runtime animation
  78561. */
  78562. private _animation;
  78563. /**
  78564. * The target of the runtime animation
  78565. */
  78566. private _target;
  78567. /**
  78568. * The initiating animatable
  78569. */
  78570. private _host;
  78571. /**
  78572. * The original value of the runtime animation
  78573. */
  78574. private _originalValue;
  78575. /**
  78576. * The original blend value of the runtime animation
  78577. */
  78578. private _originalBlendValue;
  78579. /**
  78580. * The offsets cache of the runtime animation
  78581. */
  78582. private _offsetsCache;
  78583. /**
  78584. * The high limits cache of the runtime animation
  78585. */
  78586. private _highLimitsCache;
  78587. /**
  78588. * Specifies if the runtime animation has been stopped
  78589. */
  78590. private _stopped;
  78591. /**
  78592. * The blending factor of the runtime animation
  78593. */
  78594. private _blendingFactor;
  78595. /**
  78596. * The BabylonJS scene
  78597. */
  78598. private _scene;
  78599. /**
  78600. * The current value of the runtime animation
  78601. */
  78602. private _currentValue;
  78603. /** @hidden */
  78604. _animationState: _IAnimationState;
  78605. /**
  78606. * The active target of the runtime animation
  78607. */
  78608. private _activeTargets;
  78609. private _currentActiveTarget;
  78610. private _directTarget;
  78611. /**
  78612. * The target path of the runtime animation
  78613. */
  78614. private _targetPath;
  78615. /**
  78616. * The weight of the runtime animation
  78617. */
  78618. private _weight;
  78619. /**
  78620. * The ratio offset of the runtime animation
  78621. */
  78622. private _ratioOffset;
  78623. /**
  78624. * The previous delay of the runtime animation
  78625. */
  78626. private _previousDelay;
  78627. /**
  78628. * The previous ratio of the runtime animation
  78629. */
  78630. private _previousRatio;
  78631. private _enableBlending;
  78632. private _keys;
  78633. private _minFrame;
  78634. private _maxFrame;
  78635. private _minValue;
  78636. private _maxValue;
  78637. private _targetIsArray;
  78638. /**
  78639. * Gets the current frame of the runtime animation
  78640. */
  78641. readonly currentFrame: number;
  78642. /**
  78643. * Gets the weight of the runtime animation
  78644. */
  78645. readonly weight: number;
  78646. /**
  78647. * Gets the current value of the runtime animation
  78648. */
  78649. readonly currentValue: any;
  78650. /**
  78651. * Gets the target path of the runtime animation
  78652. */
  78653. readonly targetPath: string;
  78654. /**
  78655. * Gets the actual target of the runtime animation
  78656. */
  78657. readonly target: any;
  78658. /** @hidden */
  78659. _onLoop: () => void;
  78660. /**
  78661. * Create a new RuntimeAnimation object
  78662. * @param target defines the target of the animation
  78663. * @param animation defines the source animation object
  78664. * @param scene defines the hosting scene
  78665. * @param host defines the initiating Animatable
  78666. */
  78667. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78668. private _preparePath;
  78669. /**
  78670. * Gets the animation from the runtime animation
  78671. */
  78672. readonly animation: Animation;
  78673. /**
  78674. * Resets the runtime animation to the beginning
  78675. * @param restoreOriginal defines whether to restore the target property to the original value
  78676. */
  78677. reset(restoreOriginal?: boolean): void;
  78678. /**
  78679. * Specifies if the runtime animation is stopped
  78680. * @returns Boolean specifying if the runtime animation is stopped
  78681. */
  78682. isStopped(): boolean;
  78683. /**
  78684. * Disposes of the runtime animation
  78685. */
  78686. dispose(): void;
  78687. /**
  78688. * Apply the interpolated value to the target
  78689. * @param currentValue defines the value computed by the animation
  78690. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78691. */
  78692. setValue(currentValue: any, weight: number): void;
  78693. private _getOriginalValues;
  78694. private _setValue;
  78695. /**
  78696. * Gets the loop pmode of the runtime animation
  78697. * @returns Loop Mode
  78698. */
  78699. private _getCorrectLoopMode;
  78700. /**
  78701. * Move the current animation to a given frame
  78702. * @param frame defines the frame to move to
  78703. */
  78704. goToFrame(frame: number): void;
  78705. /**
  78706. * @hidden Internal use only
  78707. */
  78708. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78709. /**
  78710. * Execute the current animation
  78711. * @param delay defines the delay to add to the current frame
  78712. * @param from defines the lower bound of the animation range
  78713. * @param to defines the upper bound of the animation range
  78714. * @param loop defines if the current animation must loop
  78715. * @param speedRatio defines the current speed ratio
  78716. * @param weight defines the weight of the animation (default is -1 so no weight)
  78717. * @param onLoop optional callback called when animation loops
  78718. * @returns a boolean indicating if the animation is running
  78719. */
  78720. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78721. }
  78722. }
  78723. declare module BABYLON {
  78724. /**
  78725. * Class used to store an actual running animation
  78726. */
  78727. export class Animatable {
  78728. /** defines the target object */
  78729. target: any;
  78730. /** defines the starting frame number (default is 0) */
  78731. fromFrame: number;
  78732. /** defines the ending frame number (default is 100) */
  78733. toFrame: number;
  78734. /** defines if the animation must loop (default is false) */
  78735. loopAnimation: boolean;
  78736. /** defines a callback to call when animation ends if it is not looping */
  78737. onAnimationEnd?: (() => void) | null | undefined;
  78738. /** defines a callback to call when animation loops */
  78739. onAnimationLoop?: (() => void) | null | undefined;
  78740. private _localDelayOffset;
  78741. private _pausedDelay;
  78742. private _runtimeAnimations;
  78743. private _paused;
  78744. private _scene;
  78745. private _speedRatio;
  78746. private _weight;
  78747. private _syncRoot;
  78748. /**
  78749. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78750. * This will only apply for non looping animation (default is true)
  78751. */
  78752. disposeOnEnd: boolean;
  78753. /**
  78754. * Gets a boolean indicating if the animation has started
  78755. */
  78756. animationStarted: boolean;
  78757. /**
  78758. * Observer raised when the animation ends
  78759. */
  78760. onAnimationEndObservable: Observable<Animatable>;
  78761. /**
  78762. * Observer raised when the animation loops
  78763. */
  78764. onAnimationLoopObservable: Observable<Animatable>;
  78765. /**
  78766. * Gets the root Animatable used to synchronize and normalize animations
  78767. */
  78768. readonly syncRoot: Nullable<Animatable>;
  78769. /**
  78770. * Gets the current frame of the first RuntimeAnimation
  78771. * Used to synchronize Animatables
  78772. */
  78773. readonly masterFrame: number;
  78774. /**
  78775. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78776. */
  78777. weight: number;
  78778. /**
  78779. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78780. */
  78781. speedRatio: number;
  78782. /**
  78783. * Creates a new Animatable
  78784. * @param scene defines the hosting scene
  78785. * @param target defines the target object
  78786. * @param fromFrame defines the starting frame number (default is 0)
  78787. * @param toFrame defines the ending frame number (default is 100)
  78788. * @param loopAnimation defines if the animation must loop (default is false)
  78789. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78790. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78791. * @param animations defines a group of animation to add to the new Animatable
  78792. * @param onAnimationLoop defines a callback to call when animation loops
  78793. */
  78794. constructor(scene: Scene,
  78795. /** defines the target object */
  78796. target: any,
  78797. /** defines the starting frame number (default is 0) */
  78798. fromFrame?: number,
  78799. /** defines the ending frame number (default is 100) */
  78800. toFrame?: number,
  78801. /** defines if the animation must loop (default is false) */
  78802. loopAnimation?: boolean, speedRatio?: number,
  78803. /** defines a callback to call when animation ends if it is not looping */
  78804. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78805. /** defines a callback to call when animation loops */
  78806. onAnimationLoop?: (() => void) | null | undefined);
  78807. /**
  78808. * Synchronize and normalize current Animatable with a source Animatable
  78809. * This is useful when using animation weights and when animations are not of the same length
  78810. * @param root defines the root Animatable to synchronize with
  78811. * @returns the current Animatable
  78812. */
  78813. syncWith(root: Animatable): Animatable;
  78814. /**
  78815. * Gets the list of runtime animations
  78816. * @returns an array of RuntimeAnimation
  78817. */
  78818. getAnimations(): RuntimeAnimation[];
  78819. /**
  78820. * Adds more animations to the current animatable
  78821. * @param target defines the target of the animations
  78822. * @param animations defines the new animations to add
  78823. */
  78824. appendAnimations(target: any, animations: Animation[]): void;
  78825. /**
  78826. * Gets the source animation for a specific property
  78827. * @param property defines the propertyu to look for
  78828. * @returns null or the source animation for the given property
  78829. */
  78830. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78831. /**
  78832. * Gets the runtime animation for a specific property
  78833. * @param property defines the propertyu to look for
  78834. * @returns null or the runtime animation for the given property
  78835. */
  78836. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78837. /**
  78838. * Resets the animatable to its original state
  78839. */
  78840. reset(): void;
  78841. /**
  78842. * Allows the animatable to blend with current running animations
  78843. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78844. * @param blendingSpeed defines the blending speed to use
  78845. */
  78846. enableBlending(blendingSpeed: number): void;
  78847. /**
  78848. * Disable animation blending
  78849. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78850. */
  78851. disableBlending(): void;
  78852. /**
  78853. * Jump directly to a given frame
  78854. * @param frame defines the frame to jump to
  78855. */
  78856. goToFrame(frame: number): void;
  78857. /**
  78858. * Pause the animation
  78859. */
  78860. pause(): void;
  78861. /**
  78862. * Restart the animation
  78863. */
  78864. restart(): void;
  78865. private _raiseOnAnimationEnd;
  78866. /**
  78867. * Stop and delete the current animation
  78868. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78869. * @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)
  78870. */
  78871. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78872. /**
  78873. * Wait asynchronously for the animation to end
  78874. * @returns a promise which will be fullfilled when the animation ends
  78875. */
  78876. waitAsync(): Promise<Animatable>;
  78877. /** @hidden */
  78878. _animate(delay: number): boolean;
  78879. }
  78880. interface Scene {
  78881. /** @hidden */
  78882. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78883. /** @hidden */
  78884. _processLateAnimationBindingsForMatrices(holder: {
  78885. totalWeight: number;
  78886. animations: RuntimeAnimation[];
  78887. originalValue: Matrix;
  78888. }): any;
  78889. /** @hidden */
  78890. _processLateAnimationBindingsForQuaternions(holder: {
  78891. totalWeight: number;
  78892. animations: RuntimeAnimation[];
  78893. originalValue: Quaternion;
  78894. }, refQuaternion: Quaternion): Quaternion;
  78895. /** @hidden */
  78896. _processLateAnimationBindings(): void;
  78897. /**
  78898. * Will start the animation sequence of a given target
  78899. * @param target defines the target
  78900. * @param from defines from which frame should animation start
  78901. * @param to defines until which frame should animation run.
  78902. * @param weight defines the weight to apply to the animation (1.0 by default)
  78903. * @param loop defines if the animation loops
  78904. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78905. * @param onAnimationEnd defines the function to be executed when the animation ends
  78906. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78907. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78908. * @param onAnimationLoop defines the callback to call when an animation loops
  78909. * @returns the animatable object created for this animation
  78910. */
  78911. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78912. /**
  78913. * Will start the animation sequence of a given target
  78914. * @param target defines the target
  78915. * @param from defines from which frame should animation start
  78916. * @param to defines until which frame should animation run.
  78917. * @param loop defines if the animation loops
  78918. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78919. * @param onAnimationEnd defines the function to be executed when the animation ends
  78920. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78921. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78922. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78923. * @param onAnimationLoop defines the callback to call when an animation loops
  78924. * @returns the animatable object created for this animation
  78925. */
  78926. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78927. /**
  78928. * Will start the animation sequence of a given target and its hierarchy
  78929. * @param target defines the target
  78930. * @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.
  78931. * @param from defines from which frame should animation start
  78932. * @param to defines until which frame should animation run.
  78933. * @param loop defines if the animation loops
  78934. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78935. * @param onAnimationEnd defines the function to be executed when the animation ends
  78936. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78937. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78938. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78939. * @param onAnimationLoop defines the callback to call when an animation loops
  78940. * @returns the list of created animatables
  78941. */
  78942. 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[];
  78943. /**
  78944. * Begin a new animation on a given node
  78945. * @param target defines the target where the animation will take place
  78946. * @param animations defines the list of animations to start
  78947. * @param from defines the initial value
  78948. * @param to defines the final value
  78949. * @param loop defines if you want animation to loop (off by default)
  78950. * @param speedRatio defines the speed ratio to apply to all animations
  78951. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78952. * @param onAnimationLoop defines the callback to call when an animation loops
  78953. * @returns the list of created animatables
  78954. */
  78955. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78956. /**
  78957. * Begin a new animation on a given node and its hierarchy
  78958. * @param target defines the root node where the animation will take place
  78959. * @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.
  78960. * @param animations defines the list of animations to start
  78961. * @param from defines the initial value
  78962. * @param to defines the final value
  78963. * @param loop defines if you want animation to loop (off by default)
  78964. * @param speedRatio defines the speed ratio to apply to all animations
  78965. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78966. * @param onAnimationLoop defines the callback to call when an animation loops
  78967. * @returns the list of animatables created for all nodes
  78968. */
  78969. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78970. /**
  78971. * Gets the animatable associated with a specific target
  78972. * @param target defines the target of the animatable
  78973. * @returns the required animatable if found
  78974. */
  78975. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78976. /**
  78977. * Gets all animatables associated with a given target
  78978. * @param target defines the target to look animatables for
  78979. * @returns an array of Animatables
  78980. */
  78981. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78982. /**
  78983. * Stops and removes all animations that have been applied to the scene
  78984. */
  78985. stopAllAnimations(): void;
  78986. }
  78987. interface Bone {
  78988. /**
  78989. * Copy an animation range from another bone
  78990. * @param source defines the source bone
  78991. * @param rangeName defines the range name to copy
  78992. * @param frameOffset defines the frame offset
  78993. * @param rescaleAsRequired defines if rescaling must be applied if required
  78994. * @param skelDimensionsRatio defines the scaling ratio
  78995. * @returns true if operation was successful
  78996. */
  78997. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78998. }
  78999. }
  79000. declare module BABYLON {
  79001. /**
  79002. * Class used to override all child animations of a given target
  79003. */
  79004. export class AnimationPropertiesOverride {
  79005. /**
  79006. * Gets or sets a value indicating if animation blending must be used
  79007. */
  79008. enableBlending: boolean;
  79009. /**
  79010. * Gets or sets the blending speed to use when enableBlending is true
  79011. */
  79012. blendingSpeed: number;
  79013. /**
  79014. * Gets or sets the default loop mode to use
  79015. */
  79016. loopMode: number;
  79017. }
  79018. }
  79019. declare module BABYLON {
  79020. /**
  79021. * Class used to handle skinning animations
  79022. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79023. */
  79024. export class Skeleton implements IAnimatable {
  79025. /** defines the skeleton name */
  79026. name: string;
  79027. /** defines the skeleton Id */
  79028. id: string;
  79029. /**
  79030. * Defines the list of child bones
  79031. */
  79032. bones: Bone[];
  79033. /**
  79034. * Defines an estimate of the dimension of the skeleton at rest
  79035. */
  79036. dimensionsAtRest: Vector3;
  79037. /**
  79038. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79039. */
  79040. needInitialSkinMatrix: boolean;
  79041. /**
  79042. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79043. */
  79044. overrideMesh: Nullable<AbstractMesh>;
  79045. /**
  79046. * Gets the list of animations attached to this skeleton
  79047. */
  79048. animations: Array<Animation>;
  79049. private _scene;
  79050. private _isDirty;
  79051. private _transformMatrices;
  79052. private _transformMatrixTexture;
  79053. private _meshesWithPoseMatrix;
  79054. private _animatables;
  79055. private _identity;
  79056. private _synchronizedWithMesh;
  79057. private _ranges;
  79058. private _lastAbsoluteTransformsUpdateId;
  79059. private _canUseTextureForBones;
  79060. private _uniqueId;
  79061. /** @hidden */
  79062. _numBonesWithLinkedTransformNode: number;
  79063. /** @hidden */
  79064. _hasWaitingData: Nullable<boolean>;
  79065. /**
  79066. * Specifies if the skeleton should be serialized
  79067. */
  79068. doNotSerialize: boolean;
  79069. private _useTextureToStoreBoneMatrices;
  79070. /**
  79071. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79072. * Please note that this option is not available if the hardware does not support it
  79073. */
  79074. useTextureToStoreBoneMatrices: boolean;
  79075. private _animationPropertiesOverride;
  79076. /**
  79077. * Gets or sets the animation properties override
  79078. */
  79079. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79080. /**
  79081. * List of inspectable custom properties (used by the Inspector)
  79082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79083. */
  79084. inspectableCustomProperties: IInspectable[];
  79085. /**
  79086. * An observable triggered before computing the skeleton's matrices
  79087. */
  79088. onBeforeComputeObservable: Observable<Skeleton>;
  79089. /**
  79090. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79091. */
  79092. readonly isUsingTextureForMatrices: boolean;
  79093. /**
  79094. * Gets the unique ID of this skeleton
  79095. */
  79096. readonly uniqueId: number;
  79097. /**
  79098. * Creates a new skeleton
  79099. * @param name defines the skeleton name
  79100. * @param id defines the skeleton Id
  79101. * @param scene defines the hosting scene
  79102. */
  79103. constructor(
  79104. /** defines the skeleton name */
  79105. name: string,
  79106. /** defines the skeleton Id */
  79107. id: string, scene: Scene);
  79108. /**
  79109. * Gets the current object class name.
  79110. * @return the class name
  79111. */
  79112. getClassName(): string;
  79113. /**
  79114. * Returns an array containing the root bones
  79115. * @returns an array containing the root bones
  79116. */
  79117. getChildren(): Array<Bone>;
  79118. /**
  79119. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79120. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79121. * @returns a Float32Array containing matrices data
  79122. */
  79123. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79124. /**
  79125. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79126. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79127. * @returns a raw texture containing the data
  79128. */
  79129. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79130. /**
  79131. * Gets the current hosting scene
  79132. * @returns a scene object
  79133. */
  79134. getScene(): Scene;
  79135. /**
  79136. * Gets a string representing the current skeleton data
  79137. * @param fullDetails defines a boolean indicating if we want a verbose version
  79138. * @returns a string representing the current skeleton data
  79139. */
  79140. toString(fullDetails?: boolean): string;
  79141. /**
  79142. * Get bone's index searching by name
  79143. * @param name defines bone's name to search for
  79144. * @return the indice of the bone. Returns -1 if not found
  79145. */
  79146. getBoneIndexByName(name: string): number;
  79147. /**
  79148. * Creater a new animation range
  79149. * @param name defines the name of the range
  79150. * @param from defines the start key
  79151. * @param to defines the end key
  79152. */
  79153. createAnimationRange(name: string, from: number, to: number): void;
  79154. /**
  79155. * Delete a specific animation range
  79156. * @param name defines the name of the range
  79157. * @param deleteFrames defines if frames must be removed as well
  79158. */
  79159. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79160. /**
  79161. * Gets a specific animation range
  79162. * @param name defines the name of the range to look for
  79163. * @returns the requested animation range or null if not found
  79164. */
  79165. getAnimationRange(name: string): Nullable<AnimationRange>;
  79166. /**
  79167. * Gets the list of all animation ranges defined on this skeleton
  79168. * @returns an array
  79169. */
  79170. getAnimationRanges(): Nullable<AnimationRange>[];
  79171. /**
  79172. * Copy animation range from a source skeleton.
  79173. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79174. * @param source defines the source skeleton
  79175. * @param name defines the name of the range to copy
  79176. * @param rescaleAsRequired defines if rescaling must be applied if required
  79177. * @returns true if operation was successful
  79178. */
  79179. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79180. /**
  79181. * Forces the skeleton to go to rest pose
  79182. */
  79183. returnToRest(): void;
  79184. private _getHighestAnimationFrame;
  79185. /**
  79186. * Begin a specific animation range
  79187. * @param name defines the name of the range to start
  79188. * @param loop defines if looping must be turned on (false by default)
  79189. * @param speedRatio defines the speed ratio to apply (1 by default)
  79190. * @param onAnimationEnd defines a callback which will be called when animation will end
  79191. * @returns a new animatable
  79192. */
  79193. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79194. /** @hidden */
  79195. _markAsDirty(): void;
  79196. /** @hidden */
  79197. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79198. /** @hidden */
  79199. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79200. private _computeTransformMatrices;
  79201. /**
  79202. * Build all resources required to render a skeleton
  79203. */
  79204. prepare(): void;
  79205. /**
  79206. * Gets the list of animatables currently running for this skeleton
  79207. * @returns an array of animatables
  79208. */
  79209. getAnimatables(): IAnimatable[];
  79210. /**
  79211. * Clone the current skeleton
  79212. * @param name defines the name of the new skeleton
  79213. * @param id defines the id of the new skeleton
  79214. * @returns the new skeleton
  79215. */
  79216. clone(name: string, id: string): Skeleton;
  79217. /**
  79218. * Enable animation blending for this skeleton
  79219. * @param blendingSpeed defines the blending speed to apply
  79220. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79221. */
  79222. enableBlending(blendingSpeed?: number): void;
  79223. /**
  79224. * Releases all resources associated with the current skeleton
  79225. */
  79226. dispose(): void;
  79227. /**
  79228. * Serialize the skeleton in a JSON object
  79229. * @returns a JSON object
  79230. */
  79231. serialize(): any;
  79232. /**
  79233. * Creates a new skeleton from serialized data
  79234. * @param parsedSkeleton defines the serialized data
  79235. * @param scene defines the hosting scene
  79236. * @returns a new skeleton
  79237. */
  79238. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79239. /**
  79240. * Compute all node absolute transforms
  79241. * @param forceUpdate defines if computation must be done even if cache is up to date
  79242. */
  79243. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79244. /**
  79245. * Gets the root pose matrix
  79246. * @returns a matrix
  79247. */
  79248. getPoseMatrix(): Nullable<Matrix>;
  79249. /**
  79250. * Sorts bones per internal index
  79251. */
  79252. sortBones(): void;
  79253. private _sortBones;
  79254. }
  79255. }
  79256. declare module BABYLON {
  79257. /**
  79258. * Class used to store bone information
  79259. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79260. */
  79261. export class Bone extends Node {
  79262. /**
  79263. * defines the bone name
  79264. */
  79265. name: string;
  79266. private static _tmpVecs;
  79267. private static _tmpQuat;
  79268. private static _tmpMats;
  79269. /**
  79270. * Gets the list of child bones
  79271. */
  79272. children: Bone[];
  79273. /** Gets the animations associated with this bone */
  79274. animations: Animation[];
  79275. /**
  79276. * Gets or sets bone length
  79277. */
  79278. length: number;
  79279. /**
  79280. * @hidden Internal only
  79281. * Set this value to map this bone to a different index in the transform matrices
  79282. * Set this value to -1 to exclude the bone from the transform matrices
  79283. */
  79284. _index: Nullable<number>;
  79285. private _skeleton;
  79286. private _localMatrix;
  79287. private _restPose;
  79288. private _baseMatrix;
  79289. private _absoluteTransform;
  79290. private _invertedAbsoluteTransform;
  79291. private _parent;
  79292. private _scalingDeterminant;
  79293. private _worldTransform;
  79294. private _localScaling;
  79295. private _localRotation;
  79296. private _localPosition;
  79297. private _needToDecompose;
  79298. private _needToCompose;
  79299. /** @hidden */
  79300. _linkedTransformNode: Nullable<TransformNode>;
  79301. /** @hidden */
  79302. _waitingTransformNodeId: Nullable<string>;
  79303. /** @hidden */
  79304. /** @hidden */
  79305. _matrix: Matrix;
  79306. /**
  79307. * Create a new bone
  79308. * @param name defines the bone name
  79309. * @param skeleton defines the parent skeleton
  79310. * @param parentBone defines the parent (can be null if the bone is the root)
  79311. * @param localMatrix defines the local matrix
  79312. * @param restPose defines the rest pose matrix
  79313. * @param baseMatrix defines the base matrix
  79314. * @param index defines index of the bone in the hiearchy
  79315. */
  79316. constructor(
  79317. /**
  79318. * defines the bone name
  79319. */
  79320. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79321. /**
  79322. * Gets the current object class name.
  79323. * @return the class name
  79324. */
  79325. getClassName(): string;
  79326. /**
  79327. * Gets the parent skeleton
  79328. * @returns a skeleton
  79329. */
  79330. getSkeleton(): Skeleton;
  79331. /**
  79332. * Gets parent bone
  79333. * @returns a bone or null if the bone is the root of the bone hierarchy
  79334. */
  79335. getParent(): Nullable<Bone>;
  79336. /**
  79337. * Returns an array containing the root bones
  79338. * @returns an array containing the root bones
  79339. */
  79340. getChildren(): Array<Bone>;
  79341. /**
  79342. * Sets the parent bone
  79343. * @param parent defines the parent (can be null if the bone is the root)
  79344. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79345. */
  79346. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79347. /**
  79348. * Gets the local matrix
  79349. * @returns a matrix
  79350. */
  79351. getLocalMatrix(): Matrix;
  79352. /**
  79353. * Gets the base matrix (initial matrix which remains unchanged)
  79354. * @returns a matrix
  79355. */
  79356. getBaseMatrix(): Matrix;
  79357. /**
  79358. * Gets the rest pose matrix
  79359. * @returns a matrix
  79360. */
  79361. getRestPose(): Matrix;
  79362. /**
  79363. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79364. */
  79365. getWorldMatrix(): Matrix;
  79366. /**
  79367. * Sets the local matrix to rest pose matrix
  79368. */
  79369. returnToRest(): void;
  79370. /**
  79371. * Gets the inverse of the absolute transform matrix.
  79372. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79373. * @returns a matrix
  79374. */
  79375. getInvertedAbsoluteTransform(): Matrix;
  79376. /**
  79377. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79378. * @returns a matrix
  79379. */
  79380. getAbsoluteTransform(): Matrix;
  79381. /**
  79382. * Links with the given transform node.
  79383. * The local matrix of this bone is copied from the transform node every frame.
  79384. * @param transformNode defines the transform node to link to
  79385. */
  79386. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79387. /**
  79388. * Gets the node used to drive the bone's transformation
  79389. * @returns a transform node or null
  79390. */
  79391. getTransformNode(): Nullable<TransformNode>;
  79392. /** Gets or sets current position (in local space) */
  79393. position: Vector3;
  79394. /** Gets or sets current rotation (in local space) */
  79395. rotation: Vector3;
  79396. /** Gets or sets current rotation quaternion (in local space) */
  79397. rotationQuaternion: Quaternion;
  79398. /** Gets or sets current scaling (in local space) */
  79399. scaling: Vector3;
  79400. /**
  79401. * Gets the animation properties override
  79402. */
  79403. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79404. private _decompose;
  79405. private _compose;
  79406. /**
  79407. * Update the base and local matrices
  79408. * @param matrix defines the new base or local matrix
  79409. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79410. * @param updateLocalMatrix defines if the local matrix should be updated
  79411. */
  79412. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79413. /** @hidden */
  79414. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79415. /**
  79416. * Flag the bone as dirty (Forcing it to update everything)
  79417. */
  79418. markAsDirty(): void;
  79419. /** @hidden */
  79420. _markAsDirtyAndCompose(): void;
  79421. private _markAsDirtyAndDecompose;
  79422. /**
  79423. * Translate the bone in local or world space
  79424. * @param vec The amount to translate the bone
  79425. * @param space The space that the translation is in
  79426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79427. */
  79428. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79429. /**
  79430. * Set the postion of the bone in local or world space
  79431. * @param position The position to set the bone
  79432. * @param space The space that the position is in
  79433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79434. */
  79435. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79436. /**
  79437. * Set the absolute position of the bone (world space)
  79438. * @param position The position to set the bone
  79439. * @param mesh The mesh that this bone is attached to
  79440. */
  79441. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79442. /**
  79443. * Scale the bone on the x, y and z axes (in local space)
  79444. * @param x The amount to scale the bone on the x axis
  79445. * @param y The amount to scale the bone on the y axis
  79446. * @param z The amount to scale the bone on the z axis
  79447. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79448. */
  79449. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79450. /**
  79451. * Set the bone scaling in local space
  79452. * @param scale defines the scaling vector
  79453. */
  79454. setScale(scale: Vector3): void;
  79455. /**
  79456. * Gets the current scaling in local space
  79457. * @returns the current scaling vector
  79458. */
  79459. getScale(): Vector3;
  79460. /**
  79461. * Gets the current scaling in local space and stores it in a target vector
  79462. * @param result defines the target vector
  79463. */
  79464. getScaleToRef(result: Vector3): void;
  79465. /**
  79466. * Set the yaw, pitch, and roll of the bone in local or world space
  79467. * @param yaw The rotation of the bone on the y axis
  79468. * @param pitch The rotation of the bone on the x axis
  79469. * @param roll The rotation of the bone on the z axis
  79470. * @param space The space that the axes of rotation are in
  79471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79472. */
  79473. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79474. /**
  79475. * Add a rotation to the bone on an axis in local or world space
  79476. * @param axis The axis to rotate the bone on
  79477. * @param amount The amount to rotate the bone
  79478. * @param space The space that the axis is in
  79479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79480. */
  79481. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79482. /**
  79483. * Set the rotation of the bone to a particular axis angle in local or world space
  79484. * @param axis The axis to rotate the bone on
  79485. * @param angle The angle that the bone should be rotated to
  79486. * @param space The space that the axis is in
  79487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79488. */
  79489. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79490. /**
  79491. * Set the euler rotation of the bone in local of world space
  79492. * @param rotation The euler rotation that the bone should be set to
  79493. * @param space The space that the rotation is in
  79494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79495. */
  79496. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79497. /**
  79498. * Set the quaternion rotation of the bone in local of world space
  79499. * @param quat The quaternion rotation that the bone should be set to
  79500. * @param space The space that the rotation is in
  79501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79502. */
  79503. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79504. /**
  79505. * Set the rotation matrix of the bone in local of world space
  79506. * @param rotMat The rotation matrix that the bone should be set to
  79507. * @param space The space that the rotation is in
  79508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79509. */
  79510. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79511. private _rotateWithMatrix;
  79512. private _getNegativeRotationToRef;
  79513. /**
  79514. * Get the position of the bone in local or world space
  79515. * @param space The space that the returned position is in
  79516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79517. * @returns The position of the bone
  79518. */
  79519. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79520. /**
  79521. * Copy the position of the bone to a vector3 in local or world space
  79522. * @param space The space that the returned position is in
  79523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79524. * @param result The vector3 to copy the position to
  79525. */
  79526. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79527. /**
  79528. * Get the absolute position of the bone (world space)
  79529. * @param mesh The mesh that this bone is attached to
  79530. * @returns The absolute position of the bone
  79531. */
  79532. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79533. /**
  79534. * Copy the absolute position of the bone (world space) to the result param
  79535. * @param mesh The mesh that this bone is attached to
  79536. * @param result The vector3 to copy the absolute position to
  79537. */
  79538. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79539. /**
  79540. * Compute the absolute transforms of this bone and its children
  79541. */
  79542. computeAbsoluteTransforms(): void;
  79543. /**
  79544. * Get the world direction from an axis that is in the local space of the bone
  79545. * @param localAxis The local direction that is used to compute the world direction
  79546. * @param mesh The mesh that this bone is attached to
  79547. * @returns The world direction
  79548. */
  79549. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79550. /**
  79551. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79552. * @param localAxis The local direction that is used to compute the world direction
  79553. * @param mesh The mesh that this bone is attached to
  79554. * @param result The vector3 that the world direction will be copied to
  79555. */
  79556. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79557. /**
  79558. * Get the euler rotation of the bone in local or world space
  79559. * @param space The space that the rotation should be in
  79560. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79561. * @returns The euler rotation
  79562. */
  79563. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79564. /**
  79565. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79566. * @param space The space that the rotation should be in
  79567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79568. * @param result The vector3 that the rotation should be copied to
  79569. */
  79570. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79571. /**
  79572. * Get the quaternion rotation of the bone in either local or world space
  79573. * @param space The space that the rotation should be in
  79574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79575. * @returns The quaternion rotation
  79576. */
  79577. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79578. /**
  79579. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79580. * @param space The space that the rotation should be in
  79581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79582. * @param result The quaternion that the rotation should be copied to
  79583. */
  79584. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79585. /**
  79586. * Get the rotation matrix of the bone in local or world space
  79587. * @param space The space that the rotation should be in
  79588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79589. * @returns The rotation matrix
  79590. */
  79591. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79592. /**
  79593. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79594. * @param space The space that the rotation should be in
  79595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79596. * @param result The quaternion that the rotation should be copied to
  79597. */
  79598. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79599. /**
  79600. * Get the world position of a point that is in the local space of the bone
  79601. * @param position The local position
  79602. * @param mesh The mesh that this bone is attached to
  79603. * @returns The world position
  79604. */
  79605. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79606. /**
  79607. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79608. * @param position The local position
  79609. * @param mesh The mesh that this bone is attached to
  79610. * @param result The vector3 that the world position should be copied to
  79611. */
  79612. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79613. /**
  79614. * Get the local position of a point that is in world space
  79615. * @param position The world position
  79616. * @param mesh The mesh that this bone is attached to
  79617. * @returns The local position
  79618. */
  79619. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79620. /**
  79621. * Get the local position of a point that is in world space and copy it to the result param
  79622. * @param position The world position
  79623. * @param mesh The mesh that this bone is attached to
  79624. * @param result The vector3 that the local position should be copied to
  79625. */
  79626. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79627. }
  79628. }
  79629. declare module BABYLON {
  79630. /**
  79631. * 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.
  79632. * @see https://doc.babylonjs.com/how_to/transformnode
  79633. */
  79634. export class TransformNode extends Node {
  79635. /**
  79636. * Object will not rotate to face the camera
  79637. */
  79638. static BILLBOARDMODE_NONE: number;
  79639. /**
  79640. * Object will rotate to face the camera but only on the x axis
  79641. */
  79642. static BILLBOARDMODE_X: number;
  79643. /**
  79644. * Object will rotate to face the camera but only on the y axis
  79645. */
  79646. static BILLBOARDMODE_Y: number;
  79647. /**
  79648. * Object will rotate to face the camera but only on the z axis
  79649. */
  79650. static BILLBOARDMODE_Z: number;
  79651. /**
  79652. * Object will rotate to face the camera
  79653. */
  79654. static BILLBOARDMODE_ALL: number;
  79655. /**
  79656. * Object will rotate to face the camera's position instead of orientation
  79657. */
  79658. static BILLBOARDMODE_USE_POSITION: number;
  79659. private _forward;
  79660. private _forwardInverted;
  79661. private _up;
  79662. private _right;
  79663. private _rightInverted;
  79664. private _position;
  79665. private _rotation;
  79666. private _rotationQuaternion;
  79667. protected _scaling: Vector3;
  79668. protected _isDirty: boolean;
  79669. private _transformToBoneReferal;
  79670. private _isAbsoluteSynced;
  79671. private _billboardMode;
  79672. /**
  79673. * Gets or sets the billboard mode. Default is 0.
  79674. *
  79675. * | Value | Type | Description |
  79676. * | --- | --- | --- |
  79677. * | 0 | BILLBOARDMODE_NONE | |
  79678. * | 1 | BILLBOARDMODE_X | |
  79679. * | 2 | BILLBOARDMODE_Y | |
  79680. * | 4 | BILLBOARDMODE_Z | |
  79681. * | 7 | BILLBOARDMODE_ALL | |
  79682. *
  79683. */
  79684. billboardMode: number;
  79685. private _preserveParentRotationForBillboard;
  79686. /**
  79687. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79688. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79689. */
  79690. preserveParentRotationForBillboard: boolean;
  79691. /**
  79692. * 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
  79693. */
  79694. scalingDeterminant: number;
  79695. private _infiniteDistance;
  79696. /**
  79697. * Gets or sets the distance of the object to max, often used by skybox
  79698. */
  79699. infiniteDistance: boolean;
  79700. /**
  79701. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79702. * By default the system will update normals to compensate
  79703. */
  79704. ignoreNonUniformScaling: boolean;
  79705. /**
  79706. * 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
  79707. */
  79708. reIntegrateRotationIntoRotationQuaternion: boolean;
  79709. /** @hidden */
  79710. _poseMatrix: Nullable<Matrix>;
  79711. /** @hidden */
  79712. _localMatrix: Matrix;
  79713. private _usePivotMatrix;
  79714. private _absolutePosition;
  79715. private _absoluteScaling;
  79716. private _absoluteRotationQuaternion;
  79717. private _pivotMatrix;
  79718. private _pivotMatrixInverse;
  79719. protected _postMultiplyPivotMatrix: boolean;
  79720. protected _isWorldMatrixFrozen: boolean;
  79721. /** @hidden */
  79722. _indexInSceneTransformNodesArray: number;
  79723. /**
  79724. * An event triggered after the world matrix is updated
  79725. */
  79726. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79727. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79728. /**
  79729. * Gets a string identifying the name of the class
  79730. * @returns "TransformNode" string
  79731. */
  79732. getClassName(): string;
  79733. /**
  79734. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79735. */
  79736. position: Vector3;
  79737. /**
  79738. * 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)).
  79739. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79740. */
  79741. rotation: Vector3;
  79742. /**
  79743. * 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)).
  79744. */
  79745. scaling: Vector3;
  79746. /**
  79747. * 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).
  79748. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79749. */
  79750. rotationQuaternion: Nullable<Quaternion>;
  79751. /**
  79752. * The forward direction of that transform in world space.
  79753. */
  79754. readonly forward: Vector3;
  79755. /**
  79756. * The up direction of that transform in world space.
  79757. */
  79758. readonly up: Vector3;
  79759. /**
  79760. * The right direction of that transform in world space.
  79761. */
  79762. readonly right: Vector3;
  79763. /**
  79764. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79765. * @param matrix the matrix to copy the pose from
  79766. * @returns this TransformNode.
  79767. */
  79768. updatePoseMatrix(matrix: Matrix): TransformNode;
  79769. /**
  79770. * Returns the mesh Pose matrix.
  79771. * @returns the pose matrix
  79772. */
  79773. getPoseMatrix(): Matrix;
  79774. /** @hidden */
  79775. _isSynchronized(): boolean;
  79776. /** @hidden */
  79777. _initCache(): void;
  79778. /**
  79779. * Flag the transform node as dirty (Forcing it to update everything)
  79780. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79781. * @returns this transform node
  79782. */
  79783. markAsDirty(property: string): TransformNode;
  79784. /**
  79785. * Returns the current mesh absolute position.
  79786. * Returns a Vector3.
  79787. */
  79788. readonly absolutePosition: Vector3;
  79789. /**
  79790. * Returns the current mesh absolute scaling.
  79791. * Returns a Vector3.
  79792. */
  79793. readonly absoluteScaling: Vector3;
  79794. /**
  79795. * Returns the current mesh absolute rotation.
  79796. * Returns a Quaternion.
  79797. */
  79798. readonly absoluteRotationQuaternion: Quaternion;
  79799. /**
  79800. * Sets a new matrix to apply before all other transformation
  79801. * @param matrix defines the transform matrix
  79802. * @returns the current TransformNode
  79803. */
  79804. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79805. /**
  79806. * Sets a new pivot matrix to the current node
  79807. * @param matrix defines the new pivot matrix to use
  79808. * @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
  79809. * @returns the current TransformNode
  79810. */
  79811. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79812. /**
  79813. * Returns the mesh pivot matrix.
  79814. * Default : Identity.
  79815. * @returns the matrix
  79816. */
  79817. getPivotMatrix(): Matrix;
  79818. /**
  79819. * Instantiate (when possible) or clone that node with its hierarchy
  79820. * @param newParent defines the new parent to use for the instance (or clone)
  79821. * @returns an instance (or a clone) of the current node with its hiearchy
  79822. */
  79823. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79824. /**
  79825. * Prevents the World matrix to be computed any longer
  79826. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79827. * @returns the TransformNode.
  79828. */
  79829. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79830. /**
  79831. * Allows back the World matrix computation.
  79832. * @returns the TransformNode.
  79833. */
  79834. unfreezeWorldMatrix(): this;
  79835. /**
  79836. * True if the World matrix has been frozen.
  79837. */
  79838. readonly isWorldMatrixFrozen: boolean;
  79839. /**
  79840. * Retuns the mesh absolute position in the World.
  79841. * @returns a Vector3.
  79842. */
  79843. getAbsolutePosition(): Vector3;
  79844. /**
  79845. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79846. * @param absolutePosition the absolute position to set
  79847. * @returns the TransformNode.
  79848. */
  79849. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79850. /**
  79851. * Sets the mesh position in its local space.
  79852. * @param vector3 the position to set in localspace
  79853. * @returns the TransformNode.
  79854. */
  79855. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79856. /**
  79857. * Returns the mesh position in the local space from the current World matrix values.
  79858. * @returns a new Vector3.
  79859. */
  79860. getPositionExpressedInLocalSpace(): Vector3;
  79861. /**
  79862. * Translates the mesh along the passed Vector3 in its local space.
  79863. * @param vector3 the distance to translate in localspace
  79864. * @returns the TransformNode.
  79865. */
  79866. locallyTranslate(vector3: Vector3): TransformNode;
  79867. private static _lookAtVectorCache;
  79868. /**
  79869. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79870. * @param targetPoint the position (must be in same space as current mesh) to look at
  79871. * @param yawCor optional yaw (y-axis) correction in radians
  79872. * @param pitchCor optional pitch (x-axis) correction in radians
  79873. * @param rollCor optional roll (z-axis) correction in radians
  79874. * @param space the choosen space of the target
  79875. * @returns the TransformNode.
  79876. */
  79877. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79878. /**
  79879. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79880. * This Vector3 is expressed in the World space.
  79881. * @param localAxis axis to rotate
  79882. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79883. */
  79884. getDirection(localAxis: Vector3): Vector3;
  79885. /**
  79886. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79887. * localAxis is expressed in the mesh local space.
  79888. * result is computed in the Wordl space from the mesh World matrix.
  79889. * @param localAxis axis to rotate
  79890. * @param result the resulting transformnode
  79891. * @returns this TransformNode.
  79892. */
  79893. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79894. /**
  79895. * Sets this transform node rotation to the given local axis.
  79896. * @param localAxis the axis in local space
  79897. * @param yawCor optional yaw (y-axis) correction in radians
  79898. * @param pitchCor optional pitch (x-axis) correction in radians
  79899. * @param rollCor optional roll (z-axis) correction in radians
  79900. * @returns this TransformNode
  79901. */
  79902. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79903. /**
  79904. * Sets a new pivot point to the current node
  79905. * @param point defines the new pivot point to use
  79906. * @param space defines if the point is in world or local space (local by default)
  79907. * @returns the current TransformNode
  79908. */
  79909. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79910. /**
  79911. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79912. * @returns the pivot point
  79913. */
  79914. getPivotPoint(): Vector3;
  79915. /**
  79916. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79917. * @param result the vector3 to store the result
  79918. * @returns this TransformNode.
  79919. */
  79920. getPivotPointToRef(result: Vector3): TransformNode;
  79921. /**
  79922. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79923. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79924. */
  79925. getAbsolutePivotPoint(): Vector3;
  79926. /**
  79927. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79928. * @param result vector3 to store the result
  79929. * @returns this TransformNode.
  79930. */
  79931. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79932. /**
  79933. * Defines the passed node as the parent of the current node.
  79934. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79935. * @see https://doc.babylonjs.com/how_to/parenting
  79936. * @param node the node ot set as the parent
  79937. * @returns this TransformNode.
  79938. */
  79939. setParent(node: Nullable<Node>): TransformNode;
  79940. private _nonUniformScaling;
  79941. /**
  79942. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79943. */
  79944. readonly nonUniformScaling: boolean;
  79945. /** @hidden */
  79946. _updateNonUniformScalingState(value: boolean): boolean;
  79947. /**
  79948. * Attach the current TransformNode to another TransformNode associated with a bone
  79949. * @param bone Bone affecting the TransformNode
  79950. * @param affectedTransformNode TransformNode associated with the bone
  79951. * @returns this object
  79952. */
  79953. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79954. /**
  79955. * Detach the transform node if its associated with a bone
  79956. * @returns this object
  79957. */
  79958. detachFromBone(): TransformNode;
  79959. private static _rotationAxisCache;
  79960. /**
  79961. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79962. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79963. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79964. * The passed axis is also normalized.
  79965. * @param axis the axis to rotate around
  79966. * @param amount the amount to rotate in radians
  79967. * @param space Space to rotate in (Default: local)
  79968. * @returns the TransformNode.
  79969. */
  79970. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79971. /**
  79972. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79973. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79974. * The passed axis is also normalized. .
  79975. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79976. * @param point the point to rotate around
  79977. * @param axis the axis to rotate around
  79978. * @param amount the amount to rotate in radians
  79979. * @returns the TransformNode
  79980. */
  79981. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79982. /**
  79983. * Translates the mesh along the axis vector for the passed distance in the given space.
  79984. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79985. * @param axis the axis to translate in
  79986. * @param distance the distance to translate
  79987. * @param space Space to rotate in (Default: local)
  79988. * @returns the TransformNode.
  79989. */
  79990. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79991. /**
  79992. * Adds a rotation step to the mesh current rotation.
  79993. * x, y, z are Euler angles expressed in radians.
  79994. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79995. * This means this rotation is made in the mesh local space only.
  79996. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79997. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79998. * ```javascript
  79999. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80000. * ```
  80001. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80002. * 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.
  80003. * @param x Rotation to add
  80004. * @param y Rotation to add
  80005. * @param z Rotation to add
  80006. * @returns the TransformNode.
  80007. */
  80008. addRotation(x: number, y: number, z: number): TransformNode;
  80009. /**
  80010. * @hidden
  80011. */
  80012. protected _getEffectiveParent(): Nullable<Node>;
  80013. /**
  80014. * Computes the world matrix of the node
  80015. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80016. * @returns the world matrix
  80017. */
  80018. computeWorldMatrix(force?: boolean): Matrix;
  80019. protected _afterComputeWorldMatrix(): void;
  80020. /**
  80021. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80022. * @param func callback function to add
  80023. *
  80024. * @returns the TransformNode.
  80025. */
  80026. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80027. /**
  80028. * Removes a registered callback function.
  80029. * @param func callback function to remove
  80030. * @returns the TransformNode.
  80031. */
  80032. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80033. /**
  80034. * Gets the position of the current mesh in camera space
  80035. * @param camera defines the camera to use
  80036. * @returns a position
  80037. */
  80038. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80039. /**
  80040. * Returns the distance from the mesh to the active camera
  80041. * @param camera defines the camera to use
  80042. * @returns the distance
  80043. */
  80044. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80045. /**
  80046. * Clone the current transform node
  80047. * @param name Name of the new clone
  80048. * @param newParent New parent for the clone
  80049. * @param doNotCloneChildren Do not clone children hierarchy
  80050. * @returns the new transform node
  80051. */
  80052. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80053. /**
  80054. * Serializes the objects information.
  80055. * @param currentSerializationObject defines the object to serialize in
  80056. * @returns the serialized object
  80057. */
  80058. serialize(currentSerializationObject?: any): any;
  80059. /**
  80060. * Returns a new TransformNode object parsed from the source provided.
  80061. * @param parsedTransformNode is the source.
  80062. * @param scene the scne the object belongs to
  80063. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80064. * @returns a new TransformNode object parsed from the source provided.
  80065. */
  80066. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80067. /**
  80068. * Get all child-transformNodes of this node
  80069. * @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
  80070. * @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
  80071. * @returns an array of TransformNode
  80072. */
  80073. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80074. /**
  80075. * Releases resources associated with this transform node.
  80076. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80077. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80078. */
  80079. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80080. /**
  80081. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80082. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80083. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80084. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80085. * @returns the current mesh
  80086. */
  80087. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80088. private _syncAbsoluteScalingAndRotation;
  80089. }
  80090. }
  80091. declare module BABYLON {
  80092. /**
  80093. * Defines the types of pose enabled controllers that are supported
  80094. */
  80095. export enum PoseEnabledControllerType {
  80096. /**
  80097. * HTC Vive
  80098. */
  80099. VIVE = 0,
  80100. /**
  80101. * Oculus Rift
  80102. */
  80103. OCULUS = 1,
  80104. /**
  80105. * Windows mixed reality
  80106. */
  80107. WINDOWS = 2,
  80108. /**
  80109. * Samsung gear VR
  80110. */
  80111. GEAR_VR = 3,
  80112. /**
  80113. * Google Daydream
  80114. */
  80115. DAYDREAM = 4,
  80116. /**
  80117. * Generic
  80118. */
  80119. GENERIC = 5
  80120. }
  80121. /**
  80122. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80123. */
  80124. export interface MutableGamepadButton {
  80125. /**
  80126. * Value of the button/trigger
  80127. */
  80128. value: number;
  80129. /**
  80130. * If the button/trigger is currently touched
  80131. */
  80132. touched: boolean;
  80133. /**
  80134. * If the button/trigger is currently pressed
  80135. */
  80136. pressed: boolean;
  80137. }
  80138. /**
  80139. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80140. * @hidden
  80141. */
  80142. export interface ExtendedGamepadButton extends GamepadButton {
  80143. /**
  80144. * If the button/trigger is currently pressed
  80145. */
  80146. readonly pressed: boolean;
  80147. /**
  80148. * If the button/trigger is currently touched
  80149. */
  80150. readonly touched: boolean;
  80151. /**
  80152. * Value of the button/trigger
  80153. */
  80154. readonly value: number;
  80155. }
  80156. /** @hidden */
  80157. export interface _GamePadFactory {
  80158. /**
  80159. * Returns wether or not the current gamepad can be created for this type of controller.
  80160. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80161. * @returns true if it can be created, otherwise false
  80162. */
  80163. canCreate(gamepadInfo: any): boolean;
  80164. /**
  80165. * Creates a new instance of the Gamepad.
  80166. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80167. * @returns the new gamepad instance
  80168. */
  80169. create(gamepadInfo: any): Gamepad;
  80170. }
  80171. /**
  80172. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80173. */
  80174. export class PoseEnabledControllerHelper {
  80175. /** @hidden */
  80176. static _ControllerFactories: _GamePadFactory[];
  80177. /** @hidden */
  80178. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80179. /**
  80180. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80181. * @param vrGamepad the gamepad to initialized
  80182. * @returns a vr controller of the type the gamepad identified as
  80183. */
  80184. static InitiateController(vrGamepad: any): Gamepad;
  80185. }
  80186. /**
  80187. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80188. */
  80189. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80190. /**
  80191. * If the controller is used in a webXR session
  80192. */
  80193. isXR: boolean;
  80194. private _deviceRoomPosition;
  80195. private _deviceRoomRotationQuaternion;
  80196. /**
  80197. * The device position in babylon space
  80198. */
  80199. devicePosition: Vector3;
  80200. /**
  80201. * The device rotation in babylon space
  80202. */
  80203. deviceRotationQuaternion: Quaternion;
  80204. /**
  80205. * The scale factor of the device in babylon space
  80206. */
  80207. deviceScaleFactor: number;
  80208. /**
  80209. * (Likely devicePosition should be used instead) The device position in its room space
  80210. */
  80211. position: Vector3;
  80212. /**
  80213. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80214. */
  80215. rotationQuaternion: Quaternion;
  80216. /**
  80217. * The type of controller (Eg. Windows mixed reality)
  80218. */
  80219. controllerType: PoseEnabledControllerType;
  80220. protected _calculatedPosition: Vector3;
  80221. private _calculatedRotation;
  80222. /**
  80223. * The raw pose from the device
  80224. */
  80225. rawPose: DevicePose;
  80226. private _trackPosition;
  80227. private _maxRotationDistFromHeadset;
  80228. private _draggedRoomRotation;
  80229. /**
  80230. * @hidden
  80231. */
  80232. _disableTrackPosition(fixedPosition: Vector3): void;
  80233. /**
  80234. * Internal, the mesh attached to the controller
  80235. * @hidden
  80236. */
  80237. _mesh: Nullable<AbstractMesh>;
  80238. private _poseControlledCamera;
  80239. private _leftHandSystemQuaternion;
  80240. /**
  80241. * Internal, matrix used to convert room space to babylon space
  80242. * @hidden
  80243. */
  80244. _deviceToWorld: Matrix;
  80245. /**
  80246. * Node to be used when casting a ray from the controller
  80247. * @hidden
  80248. */
  80249. _pointingPoseNode: Nullable<TransformNode>;
  80250. /**
  80251. * Name of the child mesh that can be used to cast a ray from the controller
  80252. */
  80253. static readonly POINTING_POSE: string;
  80254. /**
  80255. * Creates a new PoseEnabledController from a gamepad
  80256. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80257. */
  80258. constructor(browserGamepad: any);
  80259. private _workingMatrix;
  80260. /**
  80261. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80262. */
  80263. update(): void;
  80264. /**
  80265. * Updates only the pose device and mesh without doing any button event checking
  80266. */
  80267. protected _updatePoseAndMesh(): void;
  80268. /**
  80269. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80270. * @param poseData raw pose fromthe device
  80271. */
  80272. updateFromDevice(poseData: DevicePose): void;
  80273. /**
  80274. * @hidden
  80275. */
  80276. _meshAttachedObservable: Observable<AbstractMesh>;
  80277. /**
  80278. * Attaches a mesh to the controller
  80279. * @param mesh the mesh to be attached
  80280. */
  80281. attachToMesh(mesh: AbstractMesh): void;
  80282. /**
  80283. * Attaches the controllers mesh to a camera
  80284. * @param camera the camera the mesh should be attached to
  80285. */
  80286. attachToPoseControlledCamera(camera: TargetCamera): void;
  80287. /**
  80288. * Disposes of the controller
  80289. */
  80290. dispose(): void;
  80291. /**
  80292. * The mesh that is attached to the controller
  80293. */
  80294. readonly mesh: Nullable<AbstractMesh>;
  80295. /**
  80296. * Gets the ray of the controller in the direction the controller is pointing
  80297. * @param length the length the resulting ray should be
  80298. * @returns a ray in the direction the controller is pointing
  80299. */
  80300. getForwardRay(length?: number): Ray;
  80301. }
  80302. }
  80303. declare module BABYLON {
  80304. /**
  80305. * Defines the WebVRController object that represents controllers tracked in 3D space
  80306. */
  80307. export abstract class WebVRController extends PoseEnabledController {
  80308. /**
  80309. * Internal, the default controller model for the controller
  80310. */
  80311. protected _defaultModel: AbstractMesh;
  80312. /**
  80313. * Fired when the trigger state has changed
  80314. */
  80315. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80316. /**
  80317. * Fired when the main button state has changed
  80318. */
  80319. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80320. /**
  80321. * Fired when the secondary button state has changed
  80322. */
  80323. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80324. /**
  80325. * Fired when the pad state has changed
  80326. */
  80327. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80328. /**
  80329. * Fired when controllers stick values have changed
  80330. */
  80331. onPadValuesChangedObservable: Observable<StickValues>;
  80332. /**
  80333. * Array of button availible on the controller
  80334. */
  80335. protected _buttons: Array<MutableGamepadButton>;
  80336. private _onButtonStateChange;
  80337. /**
  80338. * Fired when a controller button's state has changed
  80339. * @param callback the callback containing the button that was modified
  80340. */
  80341. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80342. /**
  80343. * X and Y axis corresponding to the controllers joystick
  80344. */
  80345. pad: StickValues;
  80346. /**
  80347. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80348. */
  80349. hand: string;
  80350. /**
  80351. * The default controller model for the controller
  80352. */
  80353. readonly defaultModel: AbstractMesh;
  80354. /**
  80355. * Creates a new WebVRController from a gamepad
  80356. * @param vrGamepad the gamepad that the WebVRController should be created from
  80357. */
  80358. constructor(vrGamepad: any);
  80359. /**
  80360. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80361. */
  80362. update(): void;
  80363. /**
  80364. * Function to be called when a button is modified
  80365. */
  80366. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80367. /**
  80368. * Loads a mesh and attaches it to the controller
  80369. * @param scene the scene the mesh should be added to
  80370. * @param meshLoaded callback for when the mesh has been loaded
  80371. */
  80372. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80373. private _setButtonValue;
  80374. private _changes;
  80375. private _checkChanges;
  80376. /**
  80377. * Disposes of th webVRCOntroller
  80378. */
  80379. dispose(): void;
  80380. }
  80381. }
  80382. declare module BABYLON {
  80383. /**
  80384. * The HemisphericLight simulates the ambient environment light,
  80385. * so the passed direction is the light reflection direction, not the incoming direction.
  80386. */
  80387. export class HemisphericLight extends Light {
  80388. /**
  80389. * The groundColor is the light in the opposite direction to the one specified during creation.
  80390. * 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.
  80391. */
  80392. groundColor: Color3;
  80393. /**
  80394. * The light reflection direction, not the incoming direction.
  80395. */
  80396. direction: Vector3;
  80397. /**
  80398. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80399. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80400. * The HemisphericLight can't cast shadows.
  80401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80402. * @param name The friendly name of the light
  80403. * @param direction The direction of the light reflection
  80404. * @param scene The scene the light belongs to
  80405. */
  80406. constructor(name: string, direction: Vector3, scene: Scene);
  80407. protected _buildUniformLayout(): void;
  80408. /**
  80409. * Returns the string "HemisphericLight".
  80410. * @return The class name
  80411. */
  80412. getClassName(): string;
  80413. /**
  80414. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80415. * Returns the updated direction.
  80416. * @param target The target the direction should point to
  80417. * @return The computed direction
  80418. */
  80419. setDirectionToTarget(target: Vector3): Vector3;
  80420. /**
  80421. * Returns the shadow generator associated to the light.
  80422. * @returns Always null for hemispheric lights because it does not support shadows.
  80423. */
  80424. getShadowGenerator(): Nullable<IShadowGenerator>;
  80425. /**
  80426. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80427. * @param effect The effect to update
  80428. * @param lightIndex The index of the light in the effect to update
  80429. * @returns The hemispheric light
  80430. */
  80431. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80433. /**
  80434. * Computes the world matrix of the node
  80435. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80436. * @param useWasUpdatedFlag defines a reserved property
  80437. * @returns the world matrix
  80438. */
  80439. computeWorldMatrix(): Matrix;
  80440. /**
  80441. * Returns the integer 3.
  80442. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80443. */
  80444. getTypeID(): number;
  80445. /**
  80446. * Prepares the list of defines specific to the light type.
  80447. * @param defines the list of defines
  80448. * @param lightIndex defines the index of the light for the effect
  80449. */
  80450. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80451. }
  80452. }
  80453. declare module BABYLON {
  80454. /** @hidden */
  80455. export var vrMultiviewToSingleviewPixelShader: {
  80456. name: string;
  80457. shader: string;
  80458. };
  80459. }
  80460. declare module BABYLON {
  80461. /**
  80462. * Renders to multiple views with a single draw call
  80463. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80464. */
  80465. export class MultiviewRenderTarget extends RenderTargetTexture {
  80466. /**
  80467. * Creates a multiview render target
  80468. * @param scene scene used with the render target
  80469. * @param size the size of the render target (used for each view)
  80470. */
  80471. constructor(scene: Scene, size?: number | {
  80472. width: number;
  80473. height: number;
  80474. } | {
  80475. ratio: number;
  80476. });
  80477. /**
  80478. * @hidden
  80479. * @param faceIndex the face index, if its a cube texture
  80480. */
  80481. _bindFrameBuffer(faceIndex?: number): void;
  80482. /**
  80483. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80484. * @returns the view count
  80485. */
  80486. getViewCount(): number;
  80487. }
  80488. }
  80489. declare module BABYLON {
  80490. /**
  80491. * Represents a camera frustum
  80492. */
  80493. export class Frustum {
  80494. /**
  80495. * Gets the planes representing the frustum
  80496. * @param transform matrix to be applied to the returned planes
  80497. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80498. */
  80499. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80500. /**
  80501. * Gets the near frustum plane transformed by the transform matrix
  80502. * @param transform transformation matrix to be applied to the resulting frustum plane
  80503. * @param frustumPlane the resuling frustum plane
  80504. */
  80505. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80506. /**
  80507. * Gets the far frustum plane transformed by the transform matrix
  80508. * @param transform transformation matrix to be applied to the resulting frustum plane
  80509. * @param frustumPlane the resuling frustum plane
  80510. */
  80511. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80512. /**
  80513. * Gets the left frustum plane transformed by the transform matrix
  80514. * @param transform transformation matrix to be applied to the resulting frustum plane
  80515. * @param frustumPlane the resuling frustum plane
  80516. */
  80517. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80518. /**
  80519. * Gets the right frustum plane transformed by the transform matrix
  80520. * @param transform transformation matrix to be applied to the resulting frustum plane
  80521. * @param frustumPlane the resuling frustum plane
  80522. */
  80523. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80524. /**
  80525. * Gets the top frustum plane transformed by the transform matrix
  80526. * @param transform transformation matrix to be applied to the resulting frustum plane
  80527. * @param frustumPlane the resuling frustum plane
  80528. */
  80529. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80530. /**
  80531. * Gets the bottom frustum plane transformed by the transform matrix
  80532. * @param transform transformation matrix to be applied to the resulting frustum plane
  80533. * @param frustumPlane the resuling frustum plane
  80534. */
  80535. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80536. /**
  80537. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80538. * @param transform transformation matrix to be applied to the resulting frustum planes
  80539. * @param frustumPlanes the resuling frustum planes
  80540. */
  80541. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80542. }
  80543. }
  80544. declare module BABYLON {
  80545. interface Engine {
  80546. /**
  80547. * Creates a new multiview render target
  80548. * @param width defines the width of the texture
  80549. * @param height defines the height of the texture
  80550. * @returns the created multiview texture
  80551. */
  80552. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80553. /**
  80554. * Binds a multiview framebuffer to be drawn to
  80555. * @param multiviewTexture texture to bind
  80556. */
  80557. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80558. }
  80559. interface Camera {
  80560. /**
  80561. * @hidden
  80562. * 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)
  80563. */
  80564. _useMultiviewToSingleView: boolean;
  80565. /**
  80566. * @hidden
  80567. * 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)
  80568. */
  80569. _multiviewTexture: Nullable<RenderTargetTexture>;
  80570. /**
  80571. * @hidden
  80572. * ensures the multiview texture of the camera exists and has the specified width/height
  80573. * @param width height to set on the multiview texture
  80574. * @param height width to set on the multiview texture
  80575. */
  80576. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80577. }
  80578. interface Scene {
  80579. /** @hidden */
  80580. _transformMatrixR: Matrix;
  80581. /** @hidden */
  80582. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80583. /** @hidden */
  80584. _createMultiviewUbo(): void;
  80585. /** @hidden */
  80586. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80587. /** @hidden */
  80588. _renderMultiviewToSingleView(camera: Camera): void;
  80589. }
  80590. }
  80591. declare module BABYLON {
  80592. /**
  80593. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80594. * This will not be used for webXR as it supports displaying texture arrays directly
  80595. */
  80596. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80597. /**
  80598. * Initializes a VRMultiviewToSingleview
  80599. * @param name name of the post process
  80600. * @param camera camera to be applied to
  80601. * @param scaleFactor scaling factor to the size of the output texture
  80602. */
  80603. constructor(name: string, camera: Camera, scaleFactor: number);
  80604. }
  80605. }
  80606. declare module BABYLON {
  80607. interface Engine {
  80608. /** @hidden */
  80609. _vrDisplay: any;
  80610. /** @hidden */
  80611. _vrSupported: boolean;
  80612. /** @hidden */
  80613. _oldSize: Size;
  80614. /** @hidden */
  80615. _oldHardwareScaleFactor: number;
  80616. /** @hidden */
  80617. _vrExclusivePointerMode: boolean;
  80618. /** @hidden */
  80619. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80620. /** @hidden */
  80621. _onVRDisplayPointerRestricted: () => void;
  80622. /** @hidden */
  80623. _onVRDisplayPointerUnrestricted: () => void;
  80624. /** @hidden */
  80625. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80626. /** @hidden */
  80627. _onVrDisplayDisconnect: Nullable<() => void>;
  80628. /** @hidden */
  80629. _onVrDisplayPresentChange: Nullable<() => void>;
  80630. /**
  80631. * Observable signaled when VR display mode changes
  80632. */
  80633. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80634. /**
  80635. * Observable signaled when VR request present is complete
  80636. */
  80637. onVRRequestPresentComplete: Observable<boolean>;
  80638. /**
  80639. * Observable signaled when VR request present starts
  80640. */
  80641. onVRRequestPresentStart: Observable<Engine>;
  80642. /**
  80643. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80644. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80645. */
  80646. isInVRExclusivePointerMode: boolean;
  80647. /**
  80648. * Gets a boolean indicating if a webVR device was detected
  80649. * @returns true if a webVR device was detected
  80650. */
  80651. isVRDevicePresent(): boolean;
  80652. /**
  80653. * Gets the current webVR device
  80654. * @returns the current webVR device (or null)
  80655. */
  80656. getVRDevice(): any;
  80657. /**
  80658. * Initializes a webVR display and starts listening to display change events
  80659. * The onVRDisplayChangedObservable will be notified upon these changes
  80660. * @returns A promise containing a VRDisplay and if vr is supported
  80661. */
  80662. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80663. /** @hidden */
  80664. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80665. /**
  80666. * Call this function to switch to webVR mode
  80667. * Will do nothing if webVR is not supported or if there is no webVR device
  80668. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80669. */
  80670. enableVR(): void;
  80671. /** @hidden */
  80672. _onVRFullScreenTriggered(): void;
  80673. }
  80674. }
  80675. declare module BABYLON {
  80676. /**
  80677. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80678. * IMPORTANT!! The data is right-hand data.
  80679. * @export
  80680. * @interface DevicePose
  80681. */
  80682. export interface DevicePose {
  80683. /**
  80684. * The position of the device, values in array are [x,y,z].
  80685. */
  80686. readonly position: Nullable<Float32Array>;
  80687. /**
  80688. * The linearVelocity of the device, values in array are [x,y,z].
  80689. */
  80690. readonly linearVelocity: Nullable<Float32Array>;
  80691. /**
  80692. * The linearAcceleration of the device, values in array are [x,y,z].
  80693. */
  80694. readonly linearAcceleration: Nullable<Float32Array>;
  80695. /**
  80696. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80697. */
  80698. readonly orientation: Nullable<Float32Array>;
  80699. /**
  80700. * The angularVelocity of the device, values in array are [x,y,z].
  80701. */
  80702. readonly angularVelocity: Nullable<Float32Array>;
  80703. /**
  80704. * The angularAcceleration of the device, values in array are [x,y,z].
  80705. */
  80706. readonly angularAcceleration: Nullable<Float32Array>;
  80707. }
  80708. /**
  80709. * Interface representing a pose controlled object in Babylon.
  80710. * A pose controlled object has both regular pose values as well as pose values
  80711. * from an external device such as a VR head mounted display
  80712. */
  80713. export interface PoseControlled {
  80714. /**
  80715. * The position of the object in babylon space.
  80716. */
  80717. position: Vector3;
  80718. /**
  80719. * The rotation quaternion of the object in babylon space.
  80720. */
  80721. rotationQuaternion: Quaternion;
  80722. /**
  80723. * The position of the device in babylon space.
  80724. */
  80725. devicePosition?: Vector3;
  80726. /**
  80727. * The rotation quaternion of the device in babylon space.
  80728. */
  80729. deviceRotationQuaternion: Quaternion;
  80730. /**
  80731. * The raw pose coming from the device.
  80732. */
  80733. rawPose: Nullable<DevicePose>;
  80734. /**
  80735. * The scale of the device to be used when translating from device space to babylon space.
  80736. */
  80737. deviceScaleFactor: number;
  80738. /**
  80739. * Updates the poseControlled values based on the input device pose.
  80740. * @param poseData the pose data to update the object with
  80741. */
  80742. updateFromDevice(poseData: DevicePose): void;
  80743. }
  80744. /**
  80745. * Set of options to customize the webVRCamera
  80746. */
  80747. export interface WebVROptions {
  80748. /**
  80749. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80750. */
  80751. trackPosition?: boolean;
  80752. /**
  80753. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80754. */
  80755. positionScale?: number;
  80756. /**
  80757. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80758. */
  80759. displayName?: string;
  80760. /**
  80761. * Should the native controller meshes be initialized. (default: true)
  80762. */
  80763. controllerMeshes?: boolean;
  80764. /**
  80765. * Creating a default HemiLight only on controllers. (default: true)
  80766. */
  80767. defaultLightingOnControllers?: boolean;
  80768. /**
  80769. * If you don't want to use the default VR button of the helper. (default: false)
  80770. */
  80771. useCustomVRButton?: boolean;
  80772. /**
  80773. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80774. */
  80775. customVRButton?: HTMLButtonElement;
  80776. /**
  80777. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80778. */
  80779. rayLength?: number;
  80780. /**
  80781. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80782. */
  80783. defaultHeight?: number;
  80784. /**
  80785. * If multiview should be used if availible (default: false)
  80786. */
  80787. useMultiview?: boolean;
  80788. }
  80789. /**
  80790. * This represents a WebVR camera.
  80791. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80792. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80793. */
  80794. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80795. private webVROptions;
  80796. /**
  80797. * @hidden
  80798. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80799. */
  80800. _vrDevice: any;
  80801. /**
  80802. * The rawPose of the vrDevice.
  80803. */
  80804. rawPose: Nullable<DevicePose>;
  80805. private _onVREnabled;
  80806. private _specsVersion;
  80807. private _attached;
  80808. private _frameData;
  80809. protected _descendants: Array<Node>;
  80810. private _deviceRoomPosition;
  80811. /** @hidden */
  80812. _deviceRoomRotationQuaternion: Quaternion;
  80813. private _standingMatrix;
  80814. /**
  80815. * Represents device position in babylon space.
  80816. */
  80817. devicePosition: Vector3;
  80818. /**
  80819. * Represents device rotation in babylon space.
  80820. */
  80821. deviceRotationQuaternion: Quaternion;
  80822. /**
  80823. * The scale of the device to be used when translating from device space to babylon space.
  80824. */
  80825. deviceScaleFactor: number;
  80826. private _deviceToWorld;
  80827. private _worldToDevice;
  80828. /**
  80829. * References to the webVR controllers for the vrDevice.
  80830. */
  80831. controllers: Array<WebVRController>;
  80832. /**
  80833. * Emits an event when a controller is attached.
  80834. */
  80835. onControllersAttachedObservable: Observable<WebVRController[]>;
  80836. /**
  80837. * Emits an event when a controller's mesh has been loaded;
  80838. */
  80839. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80840. /**
  80841. * Emits an event when the HMD's pose has been updated.
  80842. */
  80843. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80844. private _poseSet;
  80845. /**
  80846. * If the rig cameras be used as parent instead of this camera.
  80847. */
  80848. rigParenting: boolean;
  80849. private _lightOnControllers;
  80850. private _defaultHeight?;
  80851. /**
  80852. * Instantiates a WebVRFreeCamera.
  80853. * @param name The name of the WebVRFreeCamera
  80854. * @param position The starting anchor position for the camera
  80855. * @param scene The scene the camera belongs to
  80856. * @param webVROptions a set of customizable options for the webVRCamera
  80857. */
  80858. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80859. /**
  80860. * Gets the device distance from the ground in meters.
  80861. * @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.
  80862. */
  80863. deviceDistanceToRoomGround(): number;
  80864. /**
  80865. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80866. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80867. */
  80868. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80869. /**
  80870. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80871. * @returns A promise with a boolean set to if the standing matrix is supported.
  80872. */
  80873. useStandingMatrixAsync(): Promise<boolean>;
  80874. /**
  80875. * Disposes the camera
  80876. */
  80877. dispose(): void;
  80878. /**
  80879. * Gets a vrController by name.
  80880. * @param name The name of the controller to retreive
  80881. * @returns the controller matching the name specified or null if not found
  80882. */
  80883. getControllerByName(name: string): Nullable<WebVRController>;
  80884. private _leftController;
  80885. /**
  80886. * The controller corresponding to the users left hand.
  80887. */
  80888. readonly leftController: Nullable<WebVRController>;
  80889. private _rightController;
  80890. /**
  80891. * The controller corresponding to the users right hand.
  80892. */
  80893. readonly rightController: Nullable<WebVRController>;
  80894. /**
  80895. * Casts a ray forward from the vrCamera's gaze.
  80896. * @param length Length of the ray (default: 100)
  80897. * @returns the ray corresponding to the gaze
  80898. */
  80899. getForwardRay(length?: number): Ray;
  80900. /**
  80901. * @hidden
  80902. * Updates the camera based on device's frame data
  80903. */
  80904. _checkInputs(): void;
  80905. /**
  80906. * Updates the poseControlled values based on the input device pose.
  80907. * @param poseData Pose coming from the device
  80908. */
  80909. updateFromDevice(poseData: DevicePose): void;
  80910. private _htmlElementAttached;
  80911. private _detachIfAttached;
  80912. /**
  80913. * WebVR's attach control will start broadcasting frames to the device.
  80914. * Note that in certain browsers (chrome for example) this function must be called
  80915. * within a user-interaction callback. Example:
  80916. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80917. *
  80918. * @param element html element to attach the vrDevice to
  80919. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80920. */
  80921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80922. /**
  80923. * Detaches the camera from the html element and disables VR
  80924. *
  80925. * @param element html element to detach from
  80926. */
  80927. detachControl(element: HTMLElement): void;
  80928. /**
  80929. * @returns the name of this class
  80930. */
  80931. getClassName(): string;
  80932. /**
  80933. * Calls resetPose on the vrDisplay
  80934. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80935. */
  80936. resetToCurrentRotation(): void;
  80937. /**
  80938. * @hidden
  80939. * Updates the rig cameras (left and right eye)
  80940. */
  80941. _updateRigCameras(): void;
  80942. private _workingVector;
  80943. private _oneVector;
  80944. private _workingMatrix;
  80945. private updateCacheCalled;
  80946. private _correctPositionIfNotTrackPosition;
  80947. /**
  80948. * @hidden
  80949. * Updates the cached values of the camera
  80950. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80951. */
  80952. _updateCache(ignoreParentClass?: boolean): void;
  80953. /**
  80954. * @hidden
  80955. * Get current device position in babylon world
  80956. */
  80957. _computeDevicePosition(): void;
  80958. /**
  80959. * Updates the current device position and rotation in the babylon world
  80960. */
  80961. update(): void;
  80962. /**
  80963. * @hidden
  80964. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80965. * @returns an identity matrix
  80966. */
  80967. _getViewMatrix(): Matrix;
  80968. private _tmpMatrix;
  80969. /**
  80970. * This function is called by the two RIG cameras.
  80971. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80972. * @hidden
  80973. */
  80974. _getWebVRViewMatrix(): Matrix;
  80975. /** @hidden */
  80976. _getWebVRProjectionMatrix(): Matrix;
  80977. private _onGamepadConnectedObserver;
  80978. private _onGamepadDisconnectedObserver;
  80979. private _updateCacheWhenTrackingDisabledObserver;
  80980. /**
  80981. * Initializes the controllers and their meshes
  80982. */
  80983. initControllers(): void;
  80984. }
  80985. }
  80986. declare module BABYLON {
  80987. /**
  80988. * Size options for a post process
  80989. */
  80990. export type PostProcessOptions = {
  80991. width: number;
  80992. height: number;
  80993. };
  80994. /**
  80995. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80996. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80997. */
  80998. export class PostProcess {
  80999. /** Name of the PostProcess. */
  81000. name: string;
  81001. /**
  81002. * Gets or sets the unique id of the post process
  81003. */
  81004. uniqueId: number;
  81005. /**
  81006. * Width of the texture to apply the post process on
  81007. */
  81008. width: number;
  81009. /**
  81010. * Height of the texture to apply the post process on
  81011. */
  81012. height: number;
  81013. /**
  81014. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81015. * @hidden
  81016. */
  81017. _outputTexture: Nullable<InternalTexture>;
  81018. /**
  81019. * Sampling mode used by the shader
  81020. * See https://doc.babylonjs.com/classes/3.1/texture
  81021. */
  81022. renderTargetSamplingMode: number;
  81023. /**
  81024. * Clear color to use when screen clearing
  81025. */
  81026. clearColor: Color4;
  81027. /**
  81028. * If the buffer needs to be cleared before applying the post process. (default: true)
  81029. * Should be set to false if shader will overwrite all previous pixels.
  81030. */
  81031. autoClear: boolean;
  81032. /**
  81033. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81034. */
  81035. alphaMode: number;
  81036. /**
  81037. * Sets the setAlphaBlendConstants of the babylon engine
  81038. */
  81039. alphaConstants: Color4;
  81040. /**
  81041. * Animations to be used for the post processing
  81042. */
  81043. animations: Animation[];
  81044. /**
  81045. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81046. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81047. */
  81048. enablePixelPerfectMode: boolean;
  81049. /**
  81050. * Force the postprocess to be applied without taking in account viewport
  81051. */
  81052. forceFullscreenViewport: boolean;
  81053. /**
  81054. * List of inspectable custom properties (used by the Inspector)
  81055. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81056. */
  81057. inspectableCustomProperties: IInspectable[];
  81058. /**
  81059. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81060. *
  81061. * | Value | Type | Description |
  81062. * | ----- | ----------------------------------- | ----------- |
  81063. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81064. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81065. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81066. *
  81067. */
  81068. scaleMode: number;
  81069. /**
  81070. * Force textures to be a power of two (default: false)
  81071. */
  81072. alwaysForcePOT: boolean;
  81073. private _samples;
  81074. /**
  81075. * Number of sample textures (default: 1)
  81076. */
  81077. samples: number;
  81078. /**
  81079. * Modify the scale of the post process to be the same as the viewport (default: false)
  81080. */
  81081. adaptScaleToCurrentViewport: boolean;
  81082. private _camera;
  81083. private _scene;
  81084. private _engine;
  81085. private _options;
  81086. private _reusable;
  81087. private _textureType;
  81088. /**
  81089. * Smart array of input and output textures for the post process.
  81090. * @hidden
  81091. */
  81092. _textures: SmartArray<InternalTexture>;
  81093. /**
  81094. * The index in _textures that corresponds to the output texture.
  81095. * @hidden
  81096. */
  81097. _currentRenderTextureInd: number;
  81098. private _effect;
  81099. private _samplers;
  81100. private _fragmentUrl;
  81101. private _vertexUrl;
  81102. private _parameters;
  81103. private _scaleRatio;
  81104. protected _indexParameters: any;
  81105. private _shareOutputWithPostProcess;
  81106. private _texelSize;
  81107. private _forcedOutputTexture;
  81108. /**
  81109. * Returns the fragment url or shader name used in the post process.
  81110. * @returns the fragment url or name in the shader store.
  81111. */
  81112. getEffectName(): string;
  81113. /**
  81114. * An event triggered when the postprocess is activated.
  81115. */
  81116. onActivateObservable: Observable<Camera>;
  81117. private _onActivateObserver;
  81118. /**
  81119. * A function that is added to the onActivateObservable
  81120. */
  81121. onActivate: Nullable<(camera: Camera) => void>;
  81122. /**
  81123. * An event triggered when the postprocess changes its size.
  81124. */
  81125. onSizeChangedObservable: Observable<PostProcess>;
  81126. private _onSizeChangedObserver;
  81127. /**
  81128. * A function that is added to the onSizeChangedObservable
  81129. */
  81130. onSizeChanged: (postProcess: PostProcess) => void;
  81131. /**
  81132. * An event triggered when the postprocess applies its effect.
  81133. */
  81134. onApplyObservable: Observable<Effect>;
  81135. private _onApplyObserver;
  81136. /**
  81137. * A function that is added to the onApplyObservable
  81138. */
  81139. onApply: (effect: Effect) => void;
  81140. /**
  81141. * An event triggered before rendering the postprocess
  81142. */
  81143. onBeforeRenderObservable: Observable<Effect>;
  81144. private _onBeforeRenderObserver;
  81145. /**
  81146. * A function that is added to the onBeforeRenderObservable
  81147. */
  81148. onBeforeRender: (effect: Effect) => void;
  81149. /**
  81150. * An event triggered after rendering the postprocess
  81151. */
  81152. onAfterRenderObservable: Observable<Effect>;
  81153. private _onAfterRenderObserver;
  81154. /**
  81155. * A function that is added to the onAfterRenderObservable
  81156. */
  81157. onAfterRender: (efect: Effect) => void;
  81158. /**
  81159. * 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
  81160. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81161. */
  81162. inputTexture: InternalTexture;
  81163. /**
  81164. * Gets the camera which post process is applied to.
  81165. * @returns The camera the post process is applied to.
  81166. */
  81167. getCamera(): Camera;
  81168. /**
  81169. * Gets the texel size of the postprocess.
  81170. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81171. */
  81172. readonly texelSize: Vector2;
  81173. /**
  81174. * Creates a new instance PostProcess
  81175. * @param name The name of the PostProcess.
  81176. * @param fragmentUrl The url of the fragment shader to be used.
  81177. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81178. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81179. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81180. * @param camera The camera to apply the render pass to.
  81181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81182. * @param engine The engine which the post process will be applied. (default: current engine)
  81183. * @param reusable If the post process can be reused on the same frame. (default: false)
  81184. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81185. * @param textureType Type of textures used when performing the post process. (default: 0)
  81186. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81187. * @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
  81188. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81189. */
  81190. constructor(
  81191. /** Name of the PostProcess. */
  81192. 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);
  81193. /**
  81194. * Gets a string idenfifying the name of the class
  81195. * @returns "PostProcess" string
  81196. */
  81197. getClassName(): string;
  81198. /**
  81199. * Gets the engine which this post process belongs to.
  81200. * @returns The engine the post process was enabled with.
  81201. */
  81202. getEngine(): Engine;
  81203. /**
  81204. * The effect that is created when initializing the post process.
  81205. * @returns The created effect corresponding the the postprocess.
  81206. */
  81207. getEffect(): Effect;
  81208. /**
  81209. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81210. * @param postProcess The post process to share the output with.
  81211. * @returns This post process.
  81212. */
  81213. shareOutputWith(postProcess: PostProcess): PostProcess;
  81214. /**
  81215. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81216. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81217. */
  81218. useOwnOutput(): void;
  81219. /**
  81220. * Updates the effect with the current post process compile time values and recompiles the shader.
  81221. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81222. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81223. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81224. * @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
  81225. * @param onCompiled Called when the shader has been compiled.
  81226. * @param onError Called if there is an error when compiling a shader.
  81227. */
  81228. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81229. /**
  81230. * The post process is reusable if it can be used multiple times within one frame.
  81231. * @returns If the post process is reusable
  81232. */
  81233. isReusable(): boolean;
  81234. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81235. markTextureDirty(): void;
  81236. /**
  81237. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81238. * 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.
  81239. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81240. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81241. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81242. * @returns The target texture that was bound to be written to.
  81243. */
  81244. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81245. /**
  81246. * If the post process is supported.
  81247. */
  81248. readonly isSupported: boolean;
  81249. /**
  81250. * The aspect ratio of the output texture.
  81251. */
  81252. readonly aspectRatio: number;
  81253. /**
  81254. * Get a value indicating if the post-process is ready to be used
  81255. * @returns true if the post-process is ready (shader is compiled)
  81256. */
  81257. isReady(): boolean;
  81258. /**
  81259. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81260. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81261. */
  81262. apply(): Nullable<Effect>;
  81263. private _disposeTextures;
  81264. /**
  81265. * Disposes the post process.
  81266. * @param camera The camera to dispose the post process on.
  81267. */
  81268. dispose(camera?: Camera): void;
  81269. }
  81270. }
  81271. declare module BABYLON {
  81272. /** @hidden */
  81273. export var kernelBlurVaryingDeclaration: {
  81274. name: string;
  81275. shader: string;
  81276. };
  81277. }
  81278. declare module BABYLON {
  81279. /** @hidden */
  81280. export var kernelBlurFragment: {
  81281. name: string;
  81282. shader: string;
  81283. };
  81284. }
  81285. declare module BABYLON {
  81286. /** @hidden */
  81287. export var kernelBlurFragment2: {
  81288. name: string;
  81289. shader: string;
  81290. };
  81291. }
  81292. declare module BABYLON {
  81293. /** @hidden */
  81294. export var kernelBlurPixelShader: {
  81295. name: string;
  81296. shader: string;
  81297. };
  81298. }
  81299. declare module BABYLON {
  81300. /** @hidden */
  81301. export var kernelBlurVertex: {
  81302. name: string;
  81303. shader: string;
  81304. };
  81305. }
  81306. declare module BABYLON {
  81307. /** @hidden */
  81308. export var kernelBlurVertexShader: {
  81309. name: string;
  81310. shader: string;
  81311. };
  81312. }
  81313. declare module BABYLON {
  81314. /**
  81315. * The Blur Post Process which blurs an image based on a kernel and direction.
  81316. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81317. */
  81318. export class BlurPostProcess extends PostProcess {
  81319. /** The direction in which to blur the image. */
  81320. direction: Vector2;
  81321. private blockCompilation;
  81322. protected _kernel: number;
  81323. protected _idealKernel: number;
  81324. protected _packedFloat: boolean;
  81325. private _staticDefines;
  81326. /**
  81327. * Sets the length in pixels of the blur sample region
  81328. */
  81329. /**
  81330. * Gets the length in pixels of the blur sample region
  81331. */
  81332. kernel: number;
  81333. /**
  81334. * Sets wether or not the blur needs to unpack/repack floats
  81335. */
  81336. /**
  81337. * Gets wether or not the blur is unpacking/repacking floats
  81338. */
  81339. packedFloat: boolean;
  81340. /**
  81341. * Creates a new instance BlurPostProcess
  81342. * @param name The name of the effect.
  81343. * @param direction The direction in which to blur the image.
  81344. * @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.
  81345. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81346. * @param camera The camera to apply the render pass to.
  81347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81348. * @param engine The engine which the post process will be applied. (default: current engine)
  81349. * @param reusable If the post process can be reused on the same frame. (default: false)
  81350. * @param textureType Type of textures used when performing the post process. (default: 0)
  81351. * @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)
  81352. */
  81353. constructor(name: string,
  81354. /** The direction in which to blur the image. */
  81355. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81356. /**
  81357. * Updates the effect with the current post process compile time values and recompiles the shader.
  81358. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81359. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81360. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81361. * @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
  81362. * @param onCompiled Called when the shader has been compiled.
  81363. * @param onError Called if there is an error when compiling a shader.
  81364. */
  81365. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81366. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81367. /**
  81368. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81369. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81370. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81371. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81372. * The gaps between physical kernels are compensated for in the weighting of the samples
  81373. * @param idealKernel Ideal blur kernel.
  81374. * @return Nearest best kernel.
  81375. */
  81376. protected _nearestBestKernel(idealKernel: number): number;
  81377. /**
  81378. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81379. * @param x The point on the Gaussian distribution to sample.
  81380. * @return the value of the Gaussian function at x.
  81381. */
  81382. protected _gaussianWeight(x: number): number;
  81383. /**
  81384. * Generates a string that can be used as a floating point number in GLSL.
  81385. * @param x Value to print.
  81386. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81387. * @return GLSL float string.
  81388. */
  81389. protected _glslFloat(x: number, decimalFigures?: number): string;
  81390. }
  81391. }
  81392. declare module BABYLON {
  81393. /**
  81394. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81395. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81396. * You can then easily use it as a reflectionTexture on a flat surface.
  81397. * In case the surface is not a plane, please consider relying on reflection probes.
  81398. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81399. */
  81400. export class MirrorTexture extends RenderTargetTexture {
  81401. private scene;
  81402. /**
  81403. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81404. * 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.
  81405. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81406. */
  81407. mirrorPlane: Plane;
  81408. /**
  81409. * Define the blur ratio used to blur the reflection if needed.
  81410. */
  81411. blurRatio: number;
  81412. /**
  81413. * Define the adaptive blur kernel used to blur the reflection if needed.
  81414. * This will autocompute the closest best match for the `blurKernel`
  81415. */
  81416. adaptiveBlurKernel: number;
  81417. /**
  81418. * Define the blur kernel used to blur the reflection if needed.
  81419. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81420. */
  81421. blurKernel: number;
  81422. /**
  81423. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81424. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81425. */
  81426. blurKernelX: number;
  81427. /**
  81428. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81429. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81430. */
  81431. blurKernelY: number;
  81432. private _autoComputeBlurKernel;
  81433. protected _onRatioRescale(): void;
  81434. private _updateGammaSpace;
  81435. private _imageProcessingConfigChangeObserver;
  81436. private _transformMatrix;
  81437. private _mirrorMatrix;
  81438. private _savedViewMatrix;
  81439. private _blurX;
  81440. private _blurY;
  81441. private _adaptiveBlurKernel;
  81442. private _blurKernelX;
  81443. private _blurKernelY;
  81444. private _blurRatio;
  81445. /**
  81446. * Instantiates a Mirror Texture.
  81447. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81448. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81449. * You can then easily use it as a reflectionTexture on a flat surface.
  81450. * In case the surface is not a plane, please consider relying on reflection probes.
  81451. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81452. * @param name
  81453. * @param size
  81454. * @param scene
  81455. * @param generateMipMaps
  81456. * @param type
  81457. * @param samplingMode
  81458. * @param generateDepthBuffer
  81459. */
  81460. constructor(name: string, size: number | {
  81461. width: number;
  81462. height: number;
  81463. } | {
  81464. ratio: number;
  81465. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81466. private _preparePostProcesses;
  81467. /**
  81468. * Clone the mirror texture.
  81469. * @returns the cloned texture
  81470. */
  81471. clone(): MirrorTexture;
  81472. /**
  81473. * Serialize the texture to a JSON representation you could use in Parse later on
  81474. * @returns the serialized JSON representation
  81475. */
  81476. serialize(): any;
  81477. /**
  81478. * Dispose the texture and release its associated resources.
  81479. */
  81480. dispose(): void;
  81481. }
  81482. }
  81483. declare module BABYLON {
  81484. /**
  81485. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81486. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81487. */
  81488. export class Texture extends BaseTexture {
  81489. /**
  81490. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81491. */
  81492. static SerializeBuffers: boolean;
  81493. /** @hidden */
  81494. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81495. /** @hidden */
  81496. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81497. /** @hidden */
  81498. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81499. /** nearest is mag = nearest and min = nearest and mip = linear */
  81500. static readonly NEAREST_SAMPLINGMODE: number;
  81501. /** nearest is mag = nearest and min = nearest and mip = linear */
  81502. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81503. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81504. static readonly BILINEAR_SAMPLINGMODE: number;
  81505. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81506. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81507. /** Trilinear is mag = linear and min = linear and mip = linear */
  81508. static readonly TRILINEAR_SAMPLINGMODE: number;
  81509. /** Trilinear is mag = linear and min = linear and mip = linear */
  81510. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81511. /** mag = nearest and min = nearest and mip = nearest */
  81512. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81513. /** mag = nearest and min = linear and mip = nearest */
  81514. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81515. /** mag = nearest and min = linear and mip = linear */
  81516. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81517. /** mag = nearest and min = linear and mip = none */
  81518. static readonly NEAREST_LINEAR: number;
  81519. /** mag = nearest and min = nearest and mip = none */
  81520. static readonly NEAREST_NEAREST: number;
  81521. /** mag = linear and min = nearest and mip = nearest */
  81522. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81523. /** mag = linear and min = nearest and mip = linear */
  81524. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81525. /** mag = linear and min = linear and mip = none */
  81526. static readonly LINEAR_LINEAR: number;
  81527. /** mag = linear and min = nearest and mip = none */
  81528. static readonly LINEAR_NEAREST: number;
  81529. /** Explicit coordinates mode */
  81530. static readonly EXPLICIT_MODE: number;
  81531. /** Spherical coordinates mode */
  81532. static readonly SPHERICAL_MODE: number;
  81533. /** Planar coordinates mode */
  81534. static readonly PLANAR_MODE: number;
  81535. /** Cubic coordinates mode */
  81536. static readonly CUBIC_MODE: number;
  81537. /** Projection coordinates mode */
  81538. static readonly PROJECTION_MODE: number;
  81539. /** Inverse Cubic coordinates mode */
  81540. static readonly SKYBOX_MODE: number;
  81541. /** Inverse Cubic coordinates mode */
  81542. static readonly INVCUBIC_MODE: number;
  81543. /** Equirectangular coordinates mode */
  81544. static readonly EQUIRECTANGULAR_MODE: number;
  81545. /** Equirectangular Fixed coordinates mode */
  81546. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81547. /** Equirectangular Fixed Mirrored coordinates mode */
  81548. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81549. /** Texture is not repeating outside of 0..1 UVs */
  81550. static readonly CLAMP_ADDRESSMODE: number;
  81551. /** Texture is repeating outside of 0..1 UVs */
  81552. static readonly WRAP_ADDRESSMODE: number;
  81553. /** Texture is repeating and mirrored */
  81554. static readonly MIRROR_ADDRESSMODE: number;
  81555. /**
  81556. * 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
  81557. */
  81558. static UseSerializedUrlIfAny: boolean;
  81559. /**
  81560. * Define the url of the texture.
  81561. */
  81562. url: Nullable<string>;
  81563. /**
  81564. * Define an offset on the texture to offset the u coordinates of the UVs
  81565. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81566. */
  81567. uOffset: number;
  81568. /**
  81569. * Define an offset on the texture to offset the v coordinates of the UVs
  81570. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81571. */
  81572. vOffset: number;
  81573. /**
  81574. * Define an offset on the texture to scale the u coordinates of the UVs
  81575. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81576. */
  81577. uScale: number;
  81578. /**
  81579. * Define an offset on the texture to scale the v coordinates of the UVs
  81580. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81581. */
  81582. vScale: number;
  81583. /**
  81584. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81585. * @see http://doc.babylonjs.com/how_to/more_materials
  81586. */
  81587. uAng: number;
  81588. /**
  81589. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81590. * @see http://doc.babylonjs.com/how_to/more_materials
  81591. */
  81592. vAng: number;
  81593. /**
  81594. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81595. * @see http://doc.babylonjs.com/how_to/more_materials
  81596. */
  81597. wAng: number;
  81598. /**
  81599. * Defines the center of rotation (U)
  81600. */
  81601. uRotationCenter: number;
  81602. /**
  81603. * Defines the center of rotation (V)
  81604. */
  81605. vRotationCenter: number;
  81606. /**
  81607. * Defines the center of rotation (W)
  81608. */
  81609. wRotationCenter: number;
  81610. /**
  81611. * Are mip maps generated for this texture or not.
  81612. */
  81613. readonly noMipmap: boolean;
  81614. /**
  81615. * List of inspectable custom properties (used by the Inspector)
  81616. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81617. */
  81618. inspectableCustomProperties: Nullable<IInspectable[]>;
  81619. private _noMipmap;
  81620. /** @hidden */
  81621. _invertY: boolean;
  81622. private _rowGenerationMatrix;
  81623. private _cachedTextureMatrix;
  81624. private _projectionModeMatrix;
  81625. private _t0;
  81626. private _t1;
  81627. private _t2;
  81628. private _cachedUOffset;
  81629. private _cachedVOffset;
  81630. private _cachedUScale;
  81631. private _cachedVScale;
  81632. private _cachedUAng;
  81633. private _cachedVAng;
  81634. private _cachedWAng;
  81635. private _cachedProjectionMatrixId;
  81636. private _cachedCoordinatesMode;
  81637. /** @hidden */
  81638. protected _initialSamplingMode: number;
  81639. /** @hidden */
  81640. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81641. private _deleteBuffer;
  81642. protected _format: Nullable<number>;
  81643. private _delayedOnLoad;
  81644. private _delayedOnError;
  81645. /**
  81646. * Observable triggered once the texture has been loaded.
  81647. */
  81648. onLoadObservable: Observable<Texture>;
  81649. protected _isBlocking: boolean;
  81650. /**
  81651. * Is the texture preventing material to render while loading.
  81652. * If false, a default texture will be used instead of the loading one during the preparation step.
  81653. */
  81654. isBlocking: boolean;
  81655. /**
  81656. * Get the current sampling mode associated with the texture.
  81657. */
  81658. readonly samplingMode: number;
  81659. /**
  81660. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81661. */
  81662. readonly invertY: boolean;
  81663. /**
  81664. * Instantiates a new texture.
  81665. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81666. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81667. * @param url define the url of the picture to load as a texture
  81668. * @param scene define the scene or engine the texture will belong to
  81669. * @param noMipmap define if the texture will require mip maps or not
  81670. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81671. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81672. * @param onLoad define a callback triggered when the texture has been loaded
  81673. * @param onError define a callback triggered when an error occurred during the loading session
  81674. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81675. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81676. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81677. */
  81678. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81679. /**
  81680. * Update the url (and optional buffer) of this texture if url was null during construction.
  81681. * @param url the url of the texture
  81682. * @param buffer the buffer of the texture (defaults to null)
  81683. * @param onLoad callback called when the texture is loaded (defaults to null)
  81684. */
  81685. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81686. /**
  81687. * Finish the loading sequence of a texture flagged as delayed load.
  81688. * @hidden
  81689. */
  81690. delayLoad(): void;
  81691. private _prepareRowForTextureGeneration;
  81692. /**
  81693. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81694. * @returns the transform matrix of the texture.
  81695. */
  81696. getTextureMatrix(): Matrix;
  81697. /**
  81698. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81699. * @returns The reflection texture transform
  81700. */
  81701. getReflectionTextureMatrix(): Matrix;
  81702. /**
  81703. * Clones the texture.
  81704. * @returns the cloned texture
  81705. */
  81706. clone(): Texture;
  81707. /**
  81708. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81709. * @returns The JSON representation of the texture
  81710. */
  81711. serialize(): any;
  81712. /**
  81713. * Get the current class name of the texture useful for serialization or dynamic coding.
  81714. * @returns "Texture"
  81715. */
  81716. getClassName(): string;
  81717. /**
  81718. * Dispose the texture and release its associated resources.
  81719. */
  81720. dispose(): void;
  81721. /**
  81722. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81723. * @param parsedTexture Define the JSON representation of the texture
  81724. * @param scene Define the scene the parsed texture should be instantiated in
  81725. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81726. * @returns The parsed texture if successful
  81727. */
  81728. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81729. /**
  81730. * Creates a texture from its base 64 representation.
  81731. * @param data Define the base64 payload without the data: prefix
  81732. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81733. * @param scene Define the scene the texture should belong to
  81734. * @param noMipmap Forces the texture to not create mip map information if true
  81735. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81736. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81737. * @param onLoad define a callback triggered when the texture has been loaded
  81738. * @param onError define a callback triggered when an error occurred during the loading session
  81739. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81740. * @returns the created texture
  81741. */
  81742. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81743. /**
  81744. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81745. * @param data Define the base64 payload without the data: prefix
  81746. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81747. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81748. * @param scene Define the scene the texture should belong to
  81749. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81750. * @param noMipmap Forces the texture to not create mip map information if true
  81751. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81752. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81753. * @param onLoad define a callback triggered when the texture has been loaded
  81754. * @param onError define a callback triggered when an error occurred during the loading session
  81755. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81756. * @returns the created texture
  81757. */
  81758. 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;
  81759. }
  81760. }
  81761. declare module BABYLON {
  81762. /**
  81763. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81764. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81765. */
  81766. export class PostProcessManager {
  81767. private _scene;
  81768. private _indexBuffer;
  81769. private _vertexBuffers;
  81770. /**
  81771. * Creates a new instance PostProcess
  81772. * @param scene The scene that the post process is associated with.
  81773. */
  81774. constructor(scene: Scene);
  81775. private _prepareBuffers;
  81776. private _buildIndexBuffer;
  81777. /**
  81778. * Rebuilds the vertex buffers of the manager.
  81779. * @hidden
  81780. */
  81781. _rebuild(): void;
  81782. /**
  81783. * Prepares a frame to be run through a post process.
  81784. * @param sourceTexture The input texture to the post procesess. (default: null)
  81785. * @param postProcesses An array of post processes to be run. (default: null)
  81786. * @returns True if the post processes were able to be run.
  81787. * @hidden
  81788. */
  81789. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81790. /**
  81791. * Manually render a set of post processes to a texture.
  81792. * @param postProcesses An array of post processes to be run.
  81793. * @param targetTexture The target texture to render to.
  81794. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81795. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81796. * @param lodLevel defines which lod of the texture to render to
  81797. */
  81798. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81799. /**
  81800. * Finalize the result of the output of the postprocesses.
  81801. * @param doNotPresent If true the result will not be displayed to the screen.
  81802. * @param targetTexture The target texture to render to.
  81803. * @param faceIndex The index of the face to bind the target texture to.
  81804. * @param postProcesses The array of post processes to render.
  81805. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81806. * @hidden
  81807. */
  81808. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81809. /**
  81810. * Disposes of the post process manager.
  81811. */
  81812. dispose(): void;
  81813. }
  81814. }
  81815. declare module BABYLON {
  81816. /** Interface used by value gradients (color, factor, ...) */
  81817. export interface IValueGradient {
  81818. /**
  81819. * Gets or sets the gradient value (between 0 and 1)
  81820. */
  81821. gradient: number;
  81822. }
  81823. /** Class used to store color4 gradient */
  81824. export class ColorGradient implements IValueGradient {
  81825. /**
  81826. * Gets or sets the gradient value (between 0 and 1)
  81827. */
  81828. gradient: number;
  81829. /**
  81830. * Gets or sets first associated color
  81831. */
  81832. color1: Color4;
  81833. /**
  81834. * Gets or sets second associated color
  81835. */
  81836. color2?: Color4;
  81837. /**
  81838. * Will get a color picked randomly between color1 and color2.
  81839. * If color2 is undefined then color1 will be used
  81840. * @param result defines the target Color4 to store the result in
  81841. */
  81842. getColorToRef(result: Color4): void;
  81843. }
  81844. /** Class used to store color 3 gradient */
  81845. export class Color3Gradient implements IValueGradient {
  81846. /**
  81847. * Gets or sets the gradient value (between 0 and 1)
  81848. */
  81849. gradient: number;
  81850. /**
  81851. * Gets or sets the associated color
  81852. */
  81853. color: Color3;
  81854. }
  81855. /** Class used to store factor gradient */
  81856. export class FactorGradient implements IValueGradient {
  81857. /**
  81858. * Gets or sets the gradient value (between 0 and 1)
  81859. */
  81860. gradient: number;
  81861. /**
  81862. * Gets or sets first associated factor
  81863. */
  81864. factor1: number;
  81865. /**
  81866. * Gets or sets second associated factor
  81867. */
  81868. factor2?: number;
  81869. /**
  81870. * Will get a number picked randomly between factor1 and factor2.
  81871. * If factor2 is undefined then factor1 will be used
  81872. * @returns the picked number
  81873. */
  81874. getFactor(): number;
  81875. }
  81876. /**
  81877. * Helper used to simplify some generic gradient tasks
  81878. */
  81879. export class GradientHelper {
  81880. /**
  81881. * Gets the current gradient from an array of IValueGradient
  81882. * @param ratio defines the current ratio to get
  81883. * @param gradients defines the array of IValueGradient
  81884. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81885. */
  81886. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81887. }
  81888. }
  81889. declare module BABYLON {
  81890. /**
  81891. * A class extending Texture allowing drawing on a texture
  81892. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81893. */
  81894. export class DynamicTexture extends Texture {
  81895. private _generateMipMaps;
  81896. private _canvas;
  81897. private _context;
  81898. private _engine;
  81899. /**
  81900. * Creates a DynamicTexture
  81901. * @param name defines the name of the texture
  81902. * @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
  81903. * @param scene defines the scene where you want the texture
  81904. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81905. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81906. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81907. */
  81908. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81909. /**
  81910. * Get the current class name of the texture useful for serialization or dynamic coding.
  81911. * @returns "DynamicTexture"
  81912. */
  81913. getClassName(): string;
  81914. /**
  81915. * Gets the current state of canRescale
  81916. */
  81917. readonly canRescale: boolean;
  81918. private _recreate;
  81919. /**
  81920. * Scales the texture
  81921. * @param ratio the scale factor to apply to both width and height
  81922. */
  81923. scale(ratio: number): void;
  81924. /**
  81925. * Resizes the texture
  81926. * @param width the new width
  81927. * @param height the new height
  81928. */
  81929. scaleTo(width: number, height: number): void;
  81930. /**
  81931. * Gets the context of the canvas used by the texture
  81932. * @returns the canvas context of the dynamic texture
  81933. */
  81934. getContext(): CanvasRenderingContext2D;
  81935. /**
  81936. * Clears the texture
  81937. */
  81938. clear(): void;
  81939. /**
  81940. * Updates the texture
  81941. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81942. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81943. */
  81944. update(invertY?: boolean, premulAlpha?: boolean): void;
  81945. /**
  81946. * Draws text onto the texture
  81947. * @param text defines the text to be drawn
  81948. * @param x defines the placement of the text from the left
  81949. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81950. * @param font defines the font to be used with font-style, font-size, font-name
  81951. * @param color defines the color used for the text
  81952. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81953. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81954. * @param update defines whether texture is immediately update (default is true)
  81955. */
  81956. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81957. /**
  81958. * Clones the texture
  81959. * @returns the clone of the texture.
  81960. */
  81961. clone(): DynamicTexture;
  81962. /**
  81963. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81964. * @returns a serialized dynamic texture object
  81965. */
  81966. serialize(): any;
  81967. /** @hidden */
  81968. _rebuild(): void;
  81969. }
  81970. }
  81971. declare module BABYLON {
  81972. interface AbstractScene {
  81973. /**
  81974. * The list of procedural textures added to the scene
  81975. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81976. */
  81977. proceduralTextures: Array<ProceduralTexture>;
  81978. }
  81979. /**
  81980. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81981. * in a given scene.
  81982. */
  81983. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81984. /**
  81985. * The component name helpfull to identify the component in the list of scene components.
  81986. */
  81987. readonly name: string;
  81988. /**
  81989. * The scene the component belongs to.
  81990. */
  81991. scene: Scene;
  81992. /**
  81993. * Creates a new instance of the component for the given scene
  81994. * @param scene Defines the scene to register the component in
  81995. */
  81996. constructor(scene: Scene);
  81997. /**
  81998. * Registers the component in a given scene
  81999. */
  82000. register(): void;
  82001. /**
  82002. * Rebuilds the elements related to this component in case of
  82003. * context lost for instance.
  82004. */
  82005. rebuild(): void;
  82006. /**
  82007. * Disposes the component and the associated ressources.
  82008. */
  82009. dispose(): void;
  82010. private _beforeClear;
  82011. }
  82012. }
  82013. declare module BABYLON {
  82014. interface Engine {
  82015. /**
  82016. * Creates a new render target cube texture
  82017. * @param size defines the size of the texture
  82018. * @param options defines the options used to create the texture
  82019. * @returns a new render target cube texture stored in an InternalTexture
  82020. */
  82021. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82022. }
  82023. }
  82024. declare module BABYLON {
  82025. /** @hidden */
  82026. export var proceduralVertexShader: {
  82027. name: string;
  82028. shader: string;
  82029. };
  82030. }
  82031. declare module BABYLON {
  82032. /**
  82033. * 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.
  82034. * This is the base class of any Procedural texture and contains most of the shareable code.
  82035. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82036. */
  82037. export class ProceduralTexture extends Texture {
  82038. isCube: boolean;
  82039. /**
  82040. * Define if the texture is enabled or not (disabled texture will not render)
  82041. */
  82042. isEnabled: boolean;
  82043. /**
  82044. * Define if the texture must be cleared before rendering (default is true)
  82045. */
  82046. autoClear: boolean;
  82047. /**
  82048. * Callback called when the texture is generated
  82049. */
  82050. onGenerated: () => void;
  82051. /**
  82052. * Event raised when the texture is generated
  82053. */
  82054. onGeneratedObservable: Observable<ProceduralTexture>;
  82055. /** @hidden */
  82056. _generateMipMaps: boolean;
  82057. /** @hidden **/
  82058. _effect: Effect;
  82059. /** @hidden */
  82060. _textures: {
  82061. [key: string]: Texture;
  82062. };
  82063. private _size;
  82064. private _currentRefreshId;
  82065. private _refreshRate;
  82066. private _vertexBuffers;
  82067. private _indexBuffer;
  82068. private _uniforms;
  82069. private _samplers;
  82070. private _fragment;
  82071. private _floats;
  82072. private _ints;
  82073. private _floatsArrays;
  82074. private _colors3;
  82075. private _colors4;
  82076. private _vectors2;
  82077. private _vectors3;
  82078. private _matrices;
  82079. private _fallbackTexture;
  82080. private _fallbackTextureUsed;
  82081. private _engine;
  82082. private _cachedDefines;
  82083. private _contentUpdateId;
  82084. private _contentData;
  82085. /**
  82086. * Instantiates a new procedural texture.
  82087. * 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.
  82088. * This is the base class of any Procedural texture and contains most of the shareable code.
  82089. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82090. * @param name Define the name of the texture
  82091. * @param size Define the size of the texture to create
  82092. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82093. * @param scene Define the scene the texture belongs to
  82094. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82095. * @param generateMipMaps Define if the texture should creates mip maps or not
  82096. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82097. */
  82098. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82099. /**
  82100. * The effect that is created when initializing the post process.
  82101. * @returns The created effect corresponding the the postprocess.
  82102. */
  82103. getEffect(): Effect;
  82104. /**
  82105. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82106. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82107. */
  82108. getContent(): Nullable<ArrayBufferView>;
  82109. private _createIndexBuffer;
  82110. /** @hidden */
  82111. _rebuild(): void;
  82112. /**
  82113. * Resets the texture in order to recreate its associated resources.
  82114. * This can be called in case of context loss
  82115. */
  82116. reset(): void;
  82117. protected _getDefines(): string;
  82118. /**
  82119. * Is the texture ready to be used ? (rendered at least once)
  82120. * @returns true if ready, otherwise, false.
  82121. */
  82122. isReady(): boolean;
  82123. /**
  82124. * Resets the refresh counter of the texture and start bak from scratch.
  82125. * Could be useful to regenerate the texture if it is setup to render only once.
  82126. */
  82127. resetRefreshCounter(): void;
  82128. /**
  82129. * Set the fragment shader to use in order to render the texture.
  82130. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82131. */
  82132. setFragment(fragment: any): void;
  82133. /**
  82134. * Define the refresh rate of the texture or the rendering frequency.
  82135. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82136. */
  82137. refreshRate: number;
  82138. /** @hidden */
  82139. _shouldRender(): boolean;
  82140. /**
  82141. * Get the size the texture is rendering at.
  82142. * @returns the size (texture is always squared)
  82143. */
  82144. getRenderSize(): number;
  82145. /**
  82146. * Resize the texture to new value.
  82147. * @param size Define the new size the texture should have
  82148. * @param generateMipMaps Define whether the new texture should create mip maps
  82149. */
  82150. resize(size: number, generateMipMaps: boolean): void;
  82151. private _checkUniform;
  82152. /**
  82153. * Set a texture in the shader program used to render.
  82154. * @param name Define the name of the uniform samplers as defined in the shader
  82155. * @param texture Define the texture to bind to this sampler
  82156. * @return the texture itself allowing "fluent" like uniform updates
  82157. */
  82158. setTexture(name: string, texture: Texture): ProceduralTexture;
  82159. /**
  82160. * Set a float in the shader.
  82161. * @param name Define the name of the uniform as defined in the shader
  82162. * @param value Define the value to give to the uniform
  82163. * @return the texture itself allowing "fluent" like uniform updates
  82164. */
  82165. setFloat(name: string, value: number): ProceduralTexture;
  82166. /**
  82167. * Set a int in the shader.
  82168. * @param name Define the name of the uniform as defined in the shader
  82169. * @param value Define the value to give to the uniform
  82170. * @return the texture itself allowing "fluent" like uniform updates
  82171. */
  82172. setInt(name: string, value: number): ProceduralTexture;
  82173. /**
  82174. * Set an array of floats in the shader.
  82175. * @param name Define the name of the uniform as defined in the shader
  82176. * @param value Define the value to give to the uniform
  82177. * @return the texture itself allowing "fluent" like uniform updates
  82178. */
  82179. setFloats(name: string, value: number[]): ProceduralTexture;
  82180. /**
  82181. * Set a vec3 in the shader from a Color3.
  82182. * @param name Define the name of the uniform as defined in the shader
  82183. * @param value Define the value to give to the uniform
  82184. * @return the texture itself allowing "fluent" like uniform updates
  82185. */
  82186. setColor3(name: string, value: Color3): ProceduralTexture;
  82187. /**
  82188. * Set a vec4 in the shader from a Color4.
  82189. * @param name Define the name of the uniform as defined in the shader
  82190. * @param value Define the value to give to the uniform
  82191. * @return the texture itself allowing "fluent" like uniform updates
  82192. */
  82193. setColor4(name: string, value: Color4): ProceduralTexture;
  82194. /**
  82195. * Set a vec2 in the shader from a Vector2.
  82196. * @param name Define the name of the uniform as defined in the shader
  82197. * @param value Define the value to give to the uniform
  82198. * @return the texture itself allowing "fluent" like uniform updates
  82199. */
  82200. setVector2(name: string, value: Vector2): ProceduralTexture;
  82201. /**
  82202. * Set a vec3 in the shader from a Vector3.
  82203. * @param name Define the name of the uniform as defined in the shader
  82204. * @param value Define the value to give to the uniform
  82205. * @return the texture itself allowing "fluent" like uniform updates
  82206. */
  82207. setVector3(name: string, value: Vector3): ProceduralTexture;
  82208. /**
  82209. * Set a mat4 in the shader from a MAtrix.
  82210. * @param name Define the name of the uniform as defined in the shader
  82211. * @param value Define the value to give to the uniform
  82212. * @return the texture itself allowing "fluent" like uniform updates
  82213. */
  82214. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82215. /**
  82216. * Render the texture to its associated render target.
  82217. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82218. */
  82219. render(useCameraPostProcess?: boolean): void;
  82220. /**
  82221. * Clone the texture.
  82222. * @returns the cloned texture
  82223. */
  82224. clone(): ProceduralTexture;
  82225. /**
  82226. * Dispose the texture and release its asoociated resources.
  82227. */
  82228. dispose(): void;
  82229. }
  82230. }
  82231. declare module BABYLON {
  82232. /**
  82233. * This represents the base class for particle system in Babylon.
  82234. * 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.
  82235. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82236. * @example https://doc.babylonjs.com/babylon101/particles
  82237. */
  82238. export class BaseParticleSystem {
  82239. /**
  82240. * Source color is added to the destination color without alpha affecting the result
  82241. */
  82242. static BLENDMODE_ONEONE: number;
  82243. /**
  82244. * Blend current color and particle color using particle’s alpha
  82245. */
  82246. static BLENDMODE_STANDARD: number;
  82247. /**
  82248. * Add current color and particle color multiplied by particle’s alpha
  82249. */
  82250. static BLENDMODE_ADD: number;
  82251. /**
  82252. * Multiply current color with particle color
  82253. */
  82254. static BLENDMODE_MULTIPLY: number;
  82255. /**
  82256. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82257. */
  82258. static BLENDMODE_MULTIPLYADD: number;
  82259. /**
  82260. * List of animations used by the particle system.
  82261. */
  82262. animations: Animation[];
  82263. /**
  82264. * The id of the Particle system.
  82265. */
  82266. id: string;
  82267. /**
  82268. * The friendly name of the Particle system.
  82269. */
  82270. name: string;
  82271. /**
  82272. * The rendering group used by the Particle system to chose when to render.
  82273. */
  82274. renderingGroupId: number;
  82275. /**
  82276. * The emitter represents the Mesh or position we are attaching the particle system to.
  82277. */
  82278. emitter: Nullable<AbstractMesh | Vector3>;
  82279. /**
  82280. * The maximum number of particles to emit per frame
  82281. */
  82282. emitRate: number;
  82283. /**
  82284. * If you want to launch only a few particles at once, that can be done, as well.
  82285. */
  82286. manualEmitCount: number;
  82287. /**
  82288. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82289. */
  82290. updateSpeed: number;
  82291. /**
  82292. * The amount of time the particle system is running (depends of the overall update speed).
  82293. */
  82294. targetStopDuration: number;
  82295. /**
  82296. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82297. */
  82298. disposeOnStop: boolean;
  82299. /**
  82300. * Minimum power of emitting particles.
  82301. */
  82302. minEmitPower: number;
  82303. /**
  82304. * Maximum power of emitting particles.
  82305. */
  82306. maxEmitPower: number;
  82307. /**
  82308. * Minimum life time of emitting particles.
  82309. */
  82310. minLifeTime: number;
  82311. /**
  82312. * Maximum life time of emitting particles.
  82313. */
  82314. maxLifeTime: number;
  82315. /**
  82316. * Minimum Size of emitting particles.
  82317. */
  82318. minSize: number;
  82319. /**
  82320. * Maximum Size of emitting particles.
  82321. */
  82322. maxSize: number;
  82323. /**
  82324. * Minimum scale of emitting particles on X axis.
  82325. */
  82326. minScaleX: number;
  82327. /**
  82328. * Maximum scale of emitting particles on X axis.
  82329. */
  82330. maxScaleX: number;
  82331. /**
  82332. * Minimum scale of emitting particles on Y axis.
  82333. */
  82334. minScaleY: number;
  82335. /**
  82336. * Maximum scale of emitting particles on Y axis.
  82337. */
  82338. maxScaleY: number;
  82339. /**
  82340. * Gets or sets the minimal initial rotation in radians.
  82341. */
  82342. minInitialRotation: number;
  82343. /**
  82344. * Gets or sets the maximal initial rotation in radians.
  82345. */
  82346. maxInitialRotation: number;
  82347. /**
  82348. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82349. */
  82350. minAngularSpeed: number;
  82351. /**
  82352. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82353. */
  82354. maxAngularSpeed: number;
  82355. /**
  82356. * The texture used to render each particle. (this can be a spritesheet)
  82357. */
  82358. particleTexture: Nullable<Texture>;
  82359. /**
  82360. * The layer mask we are rendering the particles through.
  82361. */
  82362. layerMask: number;
  82363. /**
  82364. * This can help using your own shader to render the particle system.
  82365. * The according effect will be created
  82366. */
  82367. customShader: any;
  82368. /**
  82369. * By default particle system starts as soon as they are created. This prevents the
  82370. * automatic start to happen and let you decide when to start emitting particles.
  82371. */
  82372. preventAutoStart: boolean;
  82373. private _noiseTexture;
  82374. /**
  82375. * Gets or sets a texture used to add random noise to particle positions
  82376. */
  82377. noiseTexture: Nullable<ProceduralTexture>;
  82378. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82379. noiseStrength: Vector3;
  82380. /**
  82381. * Callback triggered when the particle animation is ending.
  82382. */
  82383. onAnimationEnd: Nullable<() => void>;
  82384. /**
  82385. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82386. */
  82387. blendMode: number;
  82388. /**
  82389. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82390. * to override the particles.
  82391. */
  82392. forceDepthWrite: boolean;
  82393. /** 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 */
  82394. preWarmCycles: number;
  82395. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82396. preWarmStepOffset: number;
  82397. /**
  82398. * 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)
  82399. */
  82400. spriteCellChangeSpeed: number;
  82401. /**
  82402. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82403. */
  82404. startSpriteCellID: number;
  82405. /**
  82406. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82407. */
  82408. endSpriteCellID: number;
  82409. /**
  82410. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82411. */
  82412. spriteCellWidth: number;
  82413. /**
  82414. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82415. */
  82416. spriteCellHeight: number;
  82417. /**
  82418. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82419. */
  82420. spriteRandomStartCell: boolean;
  82421. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82422. translationPivot: Vector2;
  82423. /** @hidden */
  82424. protected _isAnimationSheetEnabled: boolean;
  82425. /**
  82426. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82427. */
  82428. beginAnimationOnStart: boolean;
  82429. /**
  82430. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82431. */
  82432. beginAnimationFrom: number;
  82433. /**
  82434. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82435. */
  82436. beginAnimationTo: number;
  82437. /**
  82438. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82439. */
  82440. beginAnimationLoop: boolean;
  82441. /**
  82442. * Gets or sets a world offset applied to all particles
  82443. */
  82444. worldOffset: Vector3;
  82445. /**
  82446. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82447. */
  82448. isAnimationSheetEnabled: boolean;
  82449. /**
  82450. * Get hosting scene
  82451. * @returns the scene
  82452. */
  82453. getScene(): Scene;
  82454. /**
  82455. * You can use gravity if you want to give an orientation to your particles.
  82456. */
  82457. gravity: Vector3;
  82458. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82459. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82460. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82461. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82462. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82463. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82464. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82465. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82466. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82467. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82468. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82469. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82470. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82471. /**
  82472. * Defines the delay in milliseconds before starting the system (0 by default)
  82473. */
  82474. startDelay: number;
  82475. /**
  82476. * Gets the current list of drag gradients.
  82477. * You must use addDragGradient and removeDragGradient to udpate this list
  82478. * @returns the list of drag gradients
  82479. */
  82480. getDragGradients(): Nullable<Array<FactorGradient>>;
  82481. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82482. limitVelocityDamping: number;
  82483. /**
  82484. * Gets the current list of limit velocity gradients.
  82485. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82486. * @returns the list of limit velocity gradients
  82487. */
  82488. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82489. /**
  82490. * Gets the current list of color gradients.
  82491. * You must use addColorGradient and removeColorGradient to udpate this list
  82492. * @returns the list of color gradients
  82493. */
  82494. getColorGradients(): Nullable<Array<ColorGradient>>;
  82495. /**
  82496. * Gets the current list of size gradients.
  82497. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82498. * @returns the list of size gradients
  82499. */
  82500. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82501. /**
  82502. * Gets the current list of color remap gradients.
  82503. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82504. * @returns the list of color remap gradients
  82505. */
  82506. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82507. /**
  82508. * Gets the current list of alpha remap gradients.
  82509. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82510. * @returns the list of alpha remap gradients
  82511. */
  82512. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82513. /**
  82514. * Gets the current list of life time gradients.
  82515. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82516. * @returns the list of life time gradients
  82517. */
  82518. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82519. /**
  82520. * Gets the current list of angular speed gradients.
  82521. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82522. * @returns the list of angular speed gradients
  82523. */
  82524. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82525. /**
  82526. * Gets the current list of velocity gradients.
  82527. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82528. * @returns the list of velocity gradients
  82529. */
  82530. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82531. /**
  82532. * Gets the current list of start size gradients.
  82533. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82534. * @returns the list of start size gradients
  82535. */
  82536. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82537. /**
  82538. * Gets the current list of emit rate gradients.
  82539. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82540. * @returns the list of emit rate gradients
  82541. */
  82542. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82543. /**
  82544. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82545. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82546. */
  82547. direction1: Vector3;
  82548. /**
  82549. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82550. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82551. */
  82552. direction2: Vector3;
  82553. /**
  82554. * 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.
  82555. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82556. */
  82557. minEmitBox: Vector3;
  82558. /**
  82559. * 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.
  82560. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82561. */
  82562. maxEmitBox: Vector3;
  82563. /**
  82564. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82565. */
  82566. color1: Color4;
  82567. /**
  82568. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82569. */
  82570. color2: Color4;
  82571. /**
  82572. * Color the particle will have at the end of its lifetime
  82573. */
  82574. colorDead: Color4;
  82575. /**
  82576. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82577. */
  82578. textureMask: Color4;
  82579. /**
  82580. * The particle emitter type defines the emitter used by the particle system.
  82581. * It can be for example box, sphere, or cone...
  82582. */
  82583. particleEmitterType: IParticleEmitterType;
  82584. /** @hidden */
  82585. _isSubEmitter: boolean;
  82586. /**
  82587. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82588. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82589. */
  82590. billboardMode: number;
  82591. protected _isBillboardBased: boolean;
  82592. /**
  82593. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82594. */
  82595. isBillboardBased: boolean;
  82596. /**
  82597. * The scene the particle system belongs to.
  82598. */
  82599. protected _scene: Scene;
  82600. /**
  82601. * Local cache of defines for image processing.
  82602. */
  82603. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82604. /**
  82605. * Default configuration related to image processing available in the standard Material.
  82606. */
  82607. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82608. /**
  82609. * Gets the image processing configuration used either in this material.
  82610. */
  82611. /**
  82612. * Sets the Default image processing configuration used either in the this material.
  82613. *
  82614. * If sets to null, the scene one is in use.
  82615. */
  82616. imageProcessingConfiguration: ImageProcessingConfiguration;
  82617. /**
  82618. * Attaches a new image processing configuration to the Standard Material.
  82619. * @param configuration
  82620. */
  82621. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82622. /** @hidden */
  82623. protected _reset(): void;
  82624. /** @hidden */
  82625. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82626. /**
  82627. * Instantiates a particle system.
  82628. * 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.
  82629. * @param name The name of the particle system
  82630. */
  82631. constructor(name: string);
  82632. /**
  82633. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82634. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82635. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82636. * @returns the emitter
  82637. */
  82638. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82639. /**
  82640. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82641. * @param radius The radius of the hemisphere to emit from
  82642. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82643. * @returns the emitter
  82644. */
  82645. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82646. /**
  82647. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82648. * @param radius The radius of the sphere to emit from
  82649. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82650. * @returns the emitter
  82651. */
  82652. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82653. /**
  82654. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82655. * @param radius The radius of the sphere to emit from
  82656. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82657. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82658. * @returns the emitter
  82659. */
  82660. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82661. /**
  82662. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82663. * @param radius The radius of the emission cylinder
  82664. * @param height The height of the emission cylinder
  82665. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82666. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82667. * @returns the emitter
  82668. */
  82669. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82670. /**
  82671. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82672. * @param radius The radius of the cylinder to emit from
  82673. * @param height The height of the emission cylinder
  82674. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82677. * @returns the emitter
  82678. */
  82679. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82680. /**
  82681. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82682. * @param radius The radius of the cone to emit from
  82683. * @param angle The base angle of the cone
  82684. * @returns the emitter
  82685. */
  82686. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82687. /**
  82688. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82689. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82690. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82691. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82692. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82693. * @returns the emitter
  82694. */
  82695. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82696. }
  82697. }
  82698. declare module BABYLON {
  82699. /**
  82700. * Type of sub emitter
  82701. */
  82702. export enum SubEmitterType {
  82703. /**
  82704. * Attached to the particle over it's lifetime
  82705. */
  82706. ATTACHED = 0,
  82707. /**
  82708. * Created when the particle dies
  82709. */
  82710. END = 1
  82711. }
  82712. /**
  82713. * Sub emitter class used to emit particles from an existing particle
  82714. */
  82715. export class SubEmitter {
  82716. /**
  82717. * the particle system to be used by the sub emitter
  82718. */
  82719. particleSystem: ParticleSystem;
  82720. /**
  82721. * Type of the submitter (Default: END)
  82722. */
  82723. type: SubEmitterType;
  82724. /**
  82725. * 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)
  82726. * Note: This only is supported when using an emitter of type Mesh
  82727. */
  82728. inheritDirection: boolean;
  82729. /**
  82730. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82731. */
  82732. inheritedVelocityAmount: number;
  82733. /**
  82734. * Creates a sub emitter
  82735. * @param particleSystem the particle system to be used by the sub emitter
  82736. */
  82737. constructor(
  82738. /**
  82739. * the particle system to be used by the sub emitter
  82740. */
  82741. particleSystem: ParticleSystem);
  82742. /**
  82743. * Clones the sub emitter
  82744. * @returns the cloned sub emitter
  82745. */
  82746. clone(): SubEmitter;
  82747. /**
  82748. * Serialize current object to a JSON object
  82749. * @returns the serialized object
  82750. */
  82751. serialize(): any;
  82752. /** @hidden */
  82753. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82754. /**
  82755. * Creates a new SubEmitter from a serialized JSON version
  82756. * @param serializationObject defines the JSON object to read from
  82757. * @param scene defines the hosting scene
  82758. * @param rootUrl defines the rootUrl for data loading
  82759. * @returns a new SubEmitter
  82760. */
  82761. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82762. /** Release associated resources */
  82763. dispose(): void;
  82764. }
  82765. }
  82766. declare module BABYLON {
  82767. /** @hidden */
  82768. export var clipPlaneFragmentDeclaration: {
  82769. name: string;
  82770. shader: string;
  82771. };
  82772. }
  82773. declare module BABYLON {
  82774. /** @hidden */
  82775. export var imageProcessingDeclaration: {
  82776. name: string;
  82777. shader: string;
  82778. };
  82779. }
  82780. declare module BABYLON {
  82781. /** @hidden */
  82782. export var imageProcessingFunctions: {
  82783. name: string;
  82784. shader: string;
  82785. };
  82786. }
  82787. declare module BABYLON {
  82788. /** @hidden */
  82789. export var clipPlaneFragment: {
  82790. name: string;
  82791. shader: string;
  82792. };
  82793. }
  82794. declare module BABYLON {
  82795. /** @hidden */
  82796. export var particlesPixelShader: {
  82797. name: string;
  82798. shader: string;
  82799. };
  82800. }
  82801. declare module BABYLON {
  82802. /** @hidden */
  82803. export var clipPlaneVertexDeclaration: {
  82804. name: string;
  82805. shader: string;
  82806. };
  82807. }
  82808. declare module BABYLON {
  82809. /** @hidden */
  82810. export var clipPlaneVertex: {
  82811. name: string;
  82812. shader: string;
  82813. };
  82814. }
  82815. declare module BABYLON {
  82816. /** @hidden */
  82817. export var particlesVertexShader: {
  82818. name: string;
  82819. shader: string;
  82820. };
  82821. }
  82822. declare module BABYLON {
  82823. /**
  82824. * This represents a particle system in Babylon.
  82825. * 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.
  82826. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82827. * @example https://doc.babylonjs.com/babylon101/particles
  82828. */
  82829. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82830. /**
  82831. * Billboard mode will only apply to Y axis
  82832. */
  82833. static readonly BILLBOARDMODE_Y: number;
  82834. /**
  82835. * Billboard mode will apply to all axes
  82836. */
  82837. static readonly BILLBOARDMODE_ALL: number;
  82838. /**
  82839. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82840. */
  82841. static readonly BILLBOARDMODE_STRETCHED: number;
  82842. /**
  82843. * This function can be defined to provide custom update for active particles.
  82844. * This function will be called instead of regular update (age, position, color, etc.).
  82845. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82846. */
  82847. updateFunction: (particles: Particle[]) => void;
  82848. private _emitterWorldMatrix;
  82849. /**
  82850. * This function can be defined to specify initial direction for every new particle.
  82851. * It by default use the emitterType defined function
  82852. */
  82853. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82854. /**
  82855. * This function can be defined to specify initial position for every new particle.
  82856. * It by default use the emitterType defined function
  82857. */
  82858. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82859. /**
  82860. * @hidden
  82861. */
  82862. _inheritedVelocityOffset: Vector3;
  82863. /**
  82864. * An event triggered when the system is disposed
  82865. */
  82866. onDisposeObservable: Observable<ParticleSystem>;
  82867. private _onDisposeObserver;
  82868. /**
  82869. * Sets a callback that will be triggered when the system is disposed
  82870. */
  82871. onDispose: () => void;
  82872. private _particles;
  82873. private _epsilon;
  82874. private _capacity;
  82875. private _stockParticles;
  82876. private _newPartsExcess;
  82877. private _vertexData;
  82878. private _vertexBuffer;
  82879. private _vertexBuffers;
  82880. private _spriteBuffer;
  82881. private _indexBuffer;
  82882. private _effect;
  82883. private _customEffect;
  82884. private _cachedDefines;
  82885. private _scaledColorStep;
  82886. private _colorDiff;
  82887. private _scaledDirection;
  82888. private _scaledGravity;
  82889. private _currentRenderId;
  82890. private _alive;
  82891. private _useInstancing;
  82892. private _started;
  82893. private _stopped;
  82894. private _actualFrame;
  82895. private _scaledUpdateSpeed;
  82896. private _vertexBufferSize;
  82897. /** @hidden */
  82898. _currentEmitRateGradient: Nullable<FactorGradient>;
  82899. /** @hidden */
  82900. _currentEmitRate1: number;
  82901. /** @hidden */
  82902. _currentEmitRate2: number;
  82903. /** @hidden */
  82904. _currentStartSizeGradient: Nullable<FactorGradient>;
  82905. /** @hidden */
  82906. _currentStartSize1: number;
  82907. /** @hidden */
  82908. _currentStartSize2: number;
  82909. private readonly _rawTextureWidth;
  82910. private _rampGradientsTexture;
  82911. private _useRampGradients;
  82912. /** Gets or sets a boolean indicating that ramp gradients must be used
  82913. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82914. */
  82915. useRampGradients: boolean;
  82916. /**
  82917. * 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.
  82918. * 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: [])
  82919. */
  82920. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82921. private _subEmitters;
  82922. /**
  82923. * @hidden
  82924. * If the particle systems emitter should be disposed when the particle system is disposed
  82925. */
  82926. _disposeEmitterOnDispose: boolean;
  82927. /**
  82928. * The current active Sub-systems, this property is used by the root particle system only.
  82929. */
  82930. activeSubSystems: Array<ParticleSystem>;
  82931. private _rootParticleSystem;
  82932. /**
  82933. * Gets the current list of active particles
  82934. */
  82935. readonly particles: Particle[];
  82936. /**
  82937. * Returns the string "ParticleSystem"
  82938. * @returns a string containing the class name
  82939. */
  82940. getClassName(): string;
  82941. /**
  82942. * Instantiates a particle system.
  82943. * 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.
  82944. * @param name The name of the particle system
  82945. * @param capacity The max number of particles alive at the same time
  82946. * @param scene The scene the particle system belongs to
  82947. * @param customEffect a custom effect used to change the way particles are rendered by default
  82948. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82949. * @param epsilon Offset used to render the particles
  82950. */
  82951. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82952. private _addFactorGradient;
  82953. private _removeFactorGradient;
  82954. /**
  82955. * Adds a new life time gradient
  82956. * @param gradient defines the gradient to use (between 0 and 1)
  82957. * @param factor defines the life time factor to affect to the specified gradient
  82958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82959. * @returns the current particle system
  82960. */
  82961. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82962. /**
  82963. * Remove a specific life time gradient
  82964. * @param gradient defines the gradient to remove
  82965. * @returns the current particle system
  82966. */
  82967. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82968. /**
  82969. * Adds a new size gradient
  82970. * @param gradient defines the gradient to use (between 0 and 1)
  82971. * @param factor defines the size factor to affect to the specified gradient
  82972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82973. * @returns the current particle system
  82974. */
  82975. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82976. /**
  82977. * Remove a specific size gradient
  82978. * @param gradient defines the gradient to remove
  82979. * @returns the current particle system
  82980. */
  82981. removeSizeGradient(gradient: number): IParticleSystem;
  82982. /**
  82983. * Adds a new color remap gradient
  82984. * @param gradient defines the gradient to use (between 0 and 1)
  82985. * @param min defines the color remap minimal range
  82986. * @param max defines the color remap maximal range
  82987. * @returns the current particle system
  82988. */
  82989. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82990. /**
  82991. * Remove a specific color remap gradient
  82992. * @param gradient defines the gradient to remove
  82993. * @returns the current particle system
  82994. */
  82995. removeColorRemapGradient(gradient: number): IParticleSystem;
  82996. /**
  82997. * Adds a new alpha remap gradient
  82998. * @param gradient defines the gradient to use (between 0 and 1)
  82999. * @param min defines the alpha remap minimal range
  83000. * @param max defines the alpha remap maximal range
  83001. * @returns the current particle system
  83002. */
  83003. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83004. /**
  83005. * Remove a specific alpha remap gradient
  83006. * @param gradient defines the gradient to remove
  83007. * @returns the current particle system
  83008. */
  83009. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83010. /**
  83011. * Adds a new angular speed gradient
  83012. * @param gradient defines the gradient to use (between 0 and 1)
  83013. * @param factor defines the angular speed to affect to the specified gradient
  83014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83015. * @returns the current particle system
  83016. */
  83017. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83018. /**
  83019. * Remove a specific angular speed gradient
  83020. * @param gradient defines the gradient to remove
  83021. * @returns the current particle system
  83022. */
  83023. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83024. /**
  83025. * Adds a new velocity gradient
  83026. * @param gradient defines the gradient to use (between 0 and 1)
  83027. * @param factor defines the velocity to affect to the specified gradient
  83028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83029. * @returns the current particle system
  83030. */
  83031. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83032. /**
  83033. * Remove a specific velocity gradient
  83034. * @param gradient defines the gradient to remove
  83035. * @returns the current particle system
  83036. */
  83037. removeVelocityGradient(gradient: number): IParticleSystem;
  83038. /**
  83039. * Adds a new limit velocity gradient
  83040. * @param gradient defines the gradient to use (between 0 and 1)
  83041. * @param factor defines the limit velocity value to affect to the specified gradient
  83042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83043. * @returns the current particle system
  83044. */
  83045. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83046. /**
  83047. * Remove a specific limit velocity gradient
  83048. * @param gradient defines the gradient to remove
  83049. * @returns the current particle system
  83050. */
  83051. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83052. /**
  83053. * Adds a new drag gradient
  83054. * @param gradient defines the gradient to use (between 0 and 1)
  83055. * @param factor defines the drag value to affect to the specified gradient
  83056. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83057. * @returns the current particle system
  83058. */
  83059. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83060. /**
  83061. * Remove a specific drag gradient
  83062. * @param gradient defines the gradient to remove
  83063. * @returns the current particle system
  83064. */
  83065. removeDragGradient(gradient: number): IParticleSystem;
  83066. /**
  83067. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83068. * @param gradient defines the gradient to use (between 0 and 1)
  83069. * @param factor defines the emit rate value to affect to the specified gradient
  83070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83071. * @returns the current particle system
  83072. */
  83073. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83074. /**
  83075. * Remove a specific emit rate gradient
  83076. * @param gradient defines the gradient to remove
  83077. * @returns the current particle system
  83078. */
  83079. removeEmitRateGradient(gradient: number): IParticleSystem;
  83080. /**
  83081. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83082. * @param gradient defines the gradient to use (between 0 and 1)
  83083. * @param factor defines the start size value to affect to the specified gradient
  83084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83085. * @returns the current particle system
  83086. */
  83087. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83088. /**
  83089. * Remove a specific start size gradient
  83090. * @param gradient defines the gradient to remove
  83091. * @returns the current particle system
  83092. */
  83093. removeStartSizeGradient(gradient: number): IParticleSystem;
  83094. private _createRampGradientTexture;
  83095. /**
  83096. * Gets the current list of ramp gradients.
  83097. * You must use addRampGradient and removeRampGradient to udpate this list
  83098. * @returns the list of ramp gradients
  83099. */
  83100. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83101. /**
  83102. * Adds a new ramp gradient used to remap particle colors
  83103. * @param gradient defines the gradient to use (between 0 and 1)
  83104. * @param color defines the color to affect to the specified gradient
  83105. * @returns the current particle system
  83106. */
  83107. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83108. /**
  83109. * Remove a specific ramp gradient
  83110. * @param gradient defines the gradient to remove
  83111. * @returns the current particle system
  83112. */
  83113. removeRampGradient(gradient: number): ParticleSystem;
  83114. /**
  83115. * Adds a new color gradient
  83116. * @param gradient defines the gradient to use (between 0 and 1)
  83117. * @param color1 defines the color to affect to the specified gradient
  83118. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83119. * @returns this particle system
  83120. */
  83121. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83122. /**
  83123. * Remove a specific color gradient
  83124. * @param gradient defines the gradient to remove
  83125. * @returns this particle system
  83126. */
  83127. removeColorGradient(gradient: number): IParticleSystem;
  83128. private _fetchR;
  83129. protected _reset(): void;
  83130. private _resetEffect;
  83131. private _createVertexBuffers;
  83132. private _createIndexBuffer;
  83133. /**
  83134. * Gets the maximum number of particles active at the same time.
  83135. * @returns The max number of active particles.
  83136. */
  83137. getCapacity(): number;
  83138. /**
  83139. * Gets whether there are still active particles in the system.
  83140. * @returns True if it is alive, otherwise false.
  83141. */
  83142. isAlive(): boolean;
  83143. /**
  83144. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83145. * @returns True if it has been started, otherwise false.
  83146. */
  83147. isStarted(): boolean;
  83148. private _prepareSubEmitterInternalArray;
  83149. /**
  83150. * Starts the particle system and begins to emit
  83151. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83152. */
  83153. start(delay?: number): void;
  83154. /**
  83155. * Stops the particle system.
  83156. * @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.
  83157. */
  83158. stop(stopSubEmitters?: boolean): void;
  83159. /**
  83160. * Remove all active particles
  83161. */
  83162. reset(): void;
  83163. /**
  83164. * @hidden (for internal use only)
  83165. */
  83166. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83167. /**
  83168. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83169. * Its lifetime will start back at 0.
  83170. */
  83171. recycleParticle: (particle: Particle) => void;
  83172. private _stopSubEmitters;
  83173. private _createParticle;
  83174. private _removeFromRoot;
  83175. private _emitFromParticle;
  83176. private _update;
  83177. /** @hidden */
  83178. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83179. /** @hidden */
  83180. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83181. /** @hidden */
  83182. private _getEffect;
  83183. /**
  83184. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83185. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83186. */
  83187. animate(preWarmOnly?: boolean): void;
  83188. private _appendParticleVertices;
  83189. /**
  83190. * Rebuilds the particle system.
  83191. */
  83192. rebuild(): void;
  83193. /**
  83194. * Is this system ready to be used/rendered
  83195. * @return true if the system is ready
  83196. */
  83197. isReady(): boolean;
  83198. private _render;
  83199. /**
  83200. * Renders the particle system in its current state.
  83201. * @returns the current number of particles
  83202. */
  83203. render(): number;
  83204. /**
  83205. * Disposes the particle system and free the associated resources
  83206. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83207. */
  83208. dispose(disposeTexture?: boolean): void;
  83209. /**
  83210. * Clones the particle system.
  83211. * @param name The name of the cloned object
  83212. * @param newEmitter The new emitter to use
  83213. * @returns the cloned particle system
  83214. */
  83215. clone(name: string, newEmitter: any): ParticleSystem;
  83216. /**
  83217. * Serializes the particle system to a JSON object.
  83218. * @returns the JSON object
  83219. */
  83220. serialize(): any;
  83221. /** @hidden */
  83222. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83223. /** @hidden */
  83224. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83225. /**
  83226. * Parses a JSON object to create a particle system.
  83227. * @param parsedParticleSystem The JSON object to parse
  83228. * @param scene The scene to create the particle system in
  83229. * @param rootUrl The root url to use to load external dependencies like texture
  83230. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83231. * @returns the Parsed particle system
  83232. */
  83233. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83234. }
  83235. }
  83236. declare module BABYLON {
  83237. /**
  83238. * A particle represents one of the element emitted by a particle system.
  83239. * This is mainly define by its coordinates, direction, velocity and age.
  83240. */
  83241. export class Particle {
  83242. /**
  83243. * The particle system the particle belongs to.
  83244. */
  83245. particleSystem: ParticleSystem;
  83246. private static _Count;
  83247. /**
  83248. * Unique ID of the particle
  83249. */
  83250. id: number;
  83251. /**
  83252. * The world position of the particle in the scene.
  83253. */
  83254. position: Vector3;
  83255. /**
  83256. * The world direction of the particle in the scene.
  83257. */
  83258. direction: Vector3;
  83259. /**
  83260. * The color of the particle.
  83261. */
  83262. color: Color4;
  83263. /**
  83264. * The color change of the particle per step.
  83265. */
  83266. colorStep: Color4;
  83267. /**
  83268. * Defines how long will the life of the particle be.
  83269. */
  83270. lifeTime: number;
  83271. /**
  83272. * The current age of the particle.
  83273. */
  83274. age: number;
  83275. /**
  83276. * The current size of the particle.
  83277. */
  83278. size: number;
  83279. /**
  83280. * The current scale of the particle.
  83281. */
  83282. scale: Vector2;
  83283. /**
  83284. * The current angle of the particle.
  83285. */
  83286. angle: number;
  83287. /**
  83288. * Defines how fast is the angle changing.
  83289. */
  83290. angularSpeed: number;
  83291. /**
  83292. * Defines the cell index used by the particle to be rendered from a sprite.
  83293. */
  83294. cellIndex: number;
  83295. /**
  83296. * The information required to support color remapping
  83297. */
  83298. remapData: Vector4;
  83299. /** @hidden */
  83300. _randomCellOffset?: number;
  83301. /** @hidden */
  83302. _initialDirection: Nullable<Vector3>;
  83303. /** @hidden */
  83304. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83305. /** @hidden */
  83306. _initialStartSpriteCellID: number;
  83307. /** @hidden */
  83308. _initialEndSpriteCellID: number;
  83309. /** @hidden */
  83310. _currentColorGradient: Nullable<ColorGradient>;
  83311. /** @hidden */
  83312. _currentColor1: Color4;
  83313. /** @hidden */
  83314. _currentColor2: Color4;
  83315. /** @hidden */
  83316. _currentSizeGradient: Nullable<FactorGradient>;
  83317. /** @hidden */
  83318. _currentSize1: number;
  83319. /** @hidden */
  83320. _currentSize2: number;
  83321. /** @hidden */
  83322. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83323. /** @hidden */
  83324. _currentAngularSpeed1: number;
  83325. /** @hidden */
  83326. _currentAngularSpeed2: number;
  83327. /** @hidden */
  83328. _currentVelocityGradient: Nullable<FactorGradient>;
  83329. /** @hidden */
  83330. _currentVelocity1: number;
  83331. /** @hidden */
  83332. _currentVelocity2: number;
  83333. /** @hidden */
  83334. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83335. /** @hidden */
  83336. _currentLimitVelocity1: number;
  83337. /** @hidden */
  83338. _currentLimitVelocity2: number;
  83339. /** @hidden */
  83340. _currentDragGradient: Nullable<FactorGradient>;
  83341. /** @hidden */
  83342. _currentDrag1: number;
  83343. /** @hidden */
  83344. _currentDrag2: number;
  83345. /** @hidden */
  83346. _randomNoiseCoordinates1: Vector3;
  83347. /** @hidden */
  83348. _randomNoiseCoordinates2: Vector3;
  83349. /**
  83350. * Creates a new instance Particle
  83351. * @param particleSystem the particle system the particle belongs to
  83352. */
  83353. constructor(
  83354. /**
  83355. * The particle system the particle belongs to.
  83356. */
  83357. particleSystem: ParticleSystem);
  83358. private updateCellInfoFromSystem;
  83359. /**
  83360. * Defines how the sprite cell index is updated for the particle
  83361. */
  83362. updateCellIndex(): void;
  83363. /** @hidden */
  83364. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83365. /** @hidden */
  83366. _inheritParticleInfoToSubEmitters(): void;
  83367. /** @hidden */
  83368. _reset(): void;
  83369. /**
  83370. * Copy the properties of particle to another one.
  83371. * @param other the particle to copy the information to.
  83372. */
  83373. copyTo(other: Particle): void;
  83374. }
  83375. }
  83376. declare module BABYLON {
  83377. /**
  83378. * Particle emitter represents a volume emitting particles.
  83379. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83380. */
  83381. export interface IParticleEmitterType {
  83382. /**
  83383. * Called by the particle System when the direction is computed for the created particle.
  83384. * @param worldMatrix is the world matrix of the particle system
  83385. * @param directionToUpdate is the direction vector to update with the result
  83386. * @param particle is the particle we are computed the direction for
  83387. */
  83388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83389. /**
  83390. * Called by the particle System when the position is computed for the created particle.
  83391. * @param worldMatrix is the world matrix of the particle system
  83392. * @param positionToUpdate is the position vector to update with the result
  83393. * @param particle is the particle we are computed the position for
  83394. */
  83395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83396. /**
  83397. * Clones the current emitter and returns a copy of it
  83398. * @returns the new emitter
  83399. */
  83400. clone(): IParticleEmitterType;
  83401. /**
  83402. * Called by the GPUParticleSystem to setup the update shader
  83403. * @param effect defines the update shader
  83404. */
  83405. applyToShader(effect: Effect): void;
  83406. /**
  83407. * Returns a string to use to update the GPU particles update shader
  83408. * @returns the effect defines string
  83409. */
  83410. getEffectDefines(): string;
  83411. /**
  83412. * Returns a string representing the class name
  83413. * @returns a string containing the class name
  83414. */
  83415. getClassName(): string;
  83416. /**
  83417. * Serializes the particle system to a JSON object.
  83418. * @returns the JSON object
  83419. */
  83420. serialize(): any;
  83421. /**
  83422. * Parse properties from a JSON object
  83423. * @param serializationObject defines the JSON object
  83424. */
  83425. parse(serializationObject: any): void;
  83426. }
  83427. }
  83428. declare module BABYLON {
  83429. /**
  83430. * Particle emitter emitting particles from the inside of a box.
  83431. * It emits the particles randomly between 2 given directions.
  83432. */
  83433. export class BoxParticleEmitter implements IParticleEmitterType {
  83434. /**
  83435. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83436. */
  83437. direction1: Vector3;
  83438. /**
  83439. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83440. */
  83441. direction2: Vector3;
  83442. /**
  83443. * 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.
  83444. */
  83445. minEmitBox: Vector3;
  83446. /**
  83447. * 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.
  83448. */
  83449. maxEmitBox: Vector3;
  83450. /**
  83451. * Creates a new instance BoxParticleEmitter
  83452. */
  83453. constructor();
  83454. /**
  83455. * Called by the particle System when the direction is computed for the created particle.
  83456. * @param worldMatrix is the world matrix of the particle system
  83457. * @param directionToUpdate is the direction vector to update with the result
  83458. * @param particle is the particle we are computed the direction for
  83459. */
  83460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83461. /**
  83462. * Called by the particle System when the position is computed for the created particle.
  83463. * @param worldMatrix is the world matrix of the particle system
  83464. * @param positionToUpdate is the position vector to update with the result
  83465. * @param particle is the particle we are computed the position for
  83466. */
  83467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83468. /**
  83469. * Clones the current emitter and returns a copy of it
  83470. * @returns the new emitter
  83471. */
  83472. clone(): BoxParticleEmitter;
  83473. /**
  83474. * Called by the GPUParticleSystem to setup the update shader
  83475. * @param effect defines the update shader
  83476. */
  83477. applyToShader(effect: Effect): void;
  83478. /**
  83479. * Returns a string to use to update the GPU particles update shader
  83480. * @returns a string containng the defines string
  83481. */
  83482. getEffectDefines(): string;
  83483. /**
  83484. * Returns the string "BoxParticleEmitter"
  83485. * @returns a string containing the class name
  83486. */
  83487. getClassName(): string;
  83488. /**
  83489. * Serializes the particle system to a JSON object.
  83490. * @returns the JSON object
  83491. */
  83492. serialize(): any;
  83493. /**
  83494. * Parse properties from a JSON object
  83495. * @param serializationObject defines the JSON object
  83496. */
  83497. parse(serializationObject: any): void;
  83498. }
  83499. }
  83500. declare module BABYLON {
  83501. /**
  83502. * Particle emitter emitting particles from the inside of a cone.
  83503. * It emits the particles alongside the cone volume from the base to the particle.
  83504. * The emission direction might be randomized.
  83505. */
  83506. export class ConeParticleEmitter implements IParticleEmitterType {
  83507. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83508. directionRandomizer: number;
  83509. private _radius;
  83510. private _angle;
  83511. private _height;
  83512. /**
  83513. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83514. */
  83515. radiusRange: number;
  83516. /**
  83517. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83518. */
  83519. heightRange: number;
  83520. /**
  83521. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83522. */
  83523. emitFromSpawnPointOnly: boolean;
  83524. /**
  83525. * Gets or sets the radius of the emission cone
  83526. */
  83527. radius: number;
  83528. /**
  83529. * Gets or sets the angle of the emission cone
  83530. */
  83531. angle: number;
  83532. private _buildHeight;
  83533. /**
  83534. * Creates a new instance ConeParticleEmitter
  83535. * @param radius the radius of the emission cone (1 by default)
  83536. * @param angle the cone base angle (PI by default)
  83537. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83538. */
  83539. constructor(radius?: number, angle?: number,
  83540. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83541. directionRandomizer?: number);
  83542. /**
  83543. * Called by the particle System when the direction is computed for the created particle.
  83544. * @param worldMatrix is the world matrix of the particle system
  83545. * @param directionToUpdate is the direction vector to update with the result
  83546. * @param particle is the particle we are computed the direction for
  83547. */
  83548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83549. /**
  83550. * Called by the particle System when the position is computed for the created particle.
  83551. * @param worldMatrix is the world matrix of the particle system
  83552. * @param positionToUpdate is the position vector to update with the result
  83553. * @param particle is the particle we are computed the position for
  83554. */
  83555. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83556. /**
  83557. * Clones the current emitter and returns a copy of it
  83558. * @returns the new emitter
  83559. */
  83560. clone(): ConeParticleEmitter;
  83561. /**
  83562. * Called by the GPUParticleSystem to setup the update shader
  83563. * @param effect defines the update shader
  83564. */
  83565. applyToShader(effect: Effect): void;
  83566. /**
  83567. * Returns a string to use to update the GPU particles update shader
  83568. * @returns a string containng the defines string
  83569. */
  83570. getEffectDefines(): string;
  83571. /**
  83572. * Returns the string "ConeParticleEmitter"
  83573. * @returns a string containing the class name
  83574. */
  83575. getClassName(): string;
  83576. /**
  83577. * Serializes the particle system to a JSON object.
  83578. * @returns the JSON object
  83579. */
  83580. serialize(): any;
  83581. /**
  83582. * Parse properties from a JSON object
  83583. * @param serializationObject defines the JSON object
  83584. */
  83585. parse(serializationObject: any): void;
  83586. }
  83587. }
  83588. declare module BABYLON {
  83589. /**
  83590. * Particle emitter emitting particles from the inside of a cylinder.
  83591. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83592. */
  83593. export class CylinderParticleEmitter implements IParticleEmitterType {
  83594. /**
  83595. * The radius of the emission cylinder.
  83596. */
  83597. radius: number;
  83598. /**
  83599. * The height of the emission cylinder.
  83600. */
  83601. height: number;
  83602. /**
  83603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83604. */
  83605. radiusRange: number;
  83606. /**
  83607. * How much to randomize the particle direction [0-1].
  83608. */
  83609. directionRandomizer: number;
  83610. /**
  83611. * Creates a new instance CylinderParticleEmitter
  83612. * @param radius the radius of the emission cylinder (1 by default)
  83613. * @param height the height of the emission cylinder (1 by default)
  83614. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83615. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83616. */
  83617. constructor(
  83618. /**
  83619. * The radius of the emission cylinder.
  83620. */
  83621. radius?: number,
  83622. /**
  83623. * The height of the emission cylinder.
  83624. */
  83625. height?: number,
  83626. /**
  83627. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83628. */
  83629. radiusRange?: number,
  83630. /**
  83631. * How much to randomize the particle direction [0-1].
  83632. */
  83633. directionRandomizer?: number);
  83634. /**
  83635. * Called by the particle System when the direction is computed for the created particle.
  83636. * @param worldMatrix is the world matrix of the particle system
  83637. * @param directionToUpdate is the direction vector to update with the result
  83638. * @param particle is the particle we are computed the direction for
  83639. */
  83640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83641. /**
  83642. * Called by the particle System when the position is computed for the created particle.
  83643. * @param worldMatrix is the world matrix of the particle system
  83644. * @param positionToUpdate is the position vector to update with the result
  83645. * @param particle is the particle we are computed the position for
  83646. */
  83647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83648. /**
  83649. * Clones the current emitter and returns a copy of it
  83650. * @returns the new emitter
  83651. */
  83652. clone(): CylinderParticleEmitter;
  83653. /**
  83654. * Called by the GPUParticleSystem to setup the update shader
  83655. * @param effect defines the update shader
  83656. */
  83657. applyToShader(effect: Effect): void;
  83658. /**
  83659. * Returns a string to use to update the GPU particles update shader
  83660. * @returns a string containng the defines string
  83661. */
  83662. getEffectDefines(): string;
  83663. /**
  83664. * Returns the string "CylinderParticleEmitter"
  83665. * @returns a string containing the class name
  83666. */
  83667. getClassName(): string;
  83668. /**
  83669. * Serializes the particle system to a JSON object.
  83670. * @returns the JSON object
  83671. */
  83672. serialize(): any;
  83673. /**
  83674. * Parse properties from a JSON object
  83675. * @param serializationObject defines the JSON object
  83676. */
  83677. parse(serializationObject: any): void;
  83678. }
  83679. /**
  83680. * Particle emitter emitting particles from the inside of a cylinder.
  83681. * It emits the particles randomly between two vectors.
  83682. */
  83683. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83684. /**
  83685. * The min limit of the emission direction.
  83686. */
  83687. direction1: Vector3;
  83688. /**
  83689. * The max limit of the emission direction.
  83690. */
  83691. direction2: Vector3;
  83692. /**
  83693. * Creates a new instance CylinderDirectedParticleEmitter
  83694. * @param radius the radius of the emission cylinder (1 by default)
  83695. * @param height the height of the emission cylinder (1 by default)
  83696. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83697. * @param direction1 the min limit of the emission direction (up vector by default)
  83698. * @param direction2 the max limit of the emission direction (up vector by default)
  83699. */
  83700. constructor(radius?: number, height?: number, radiusRange?: number,
  83701. /**
  83702. * The min limit of the emission direction.
  83703. */
  83704. direction1?: Vector3,
  83705. /**
  83706. * The max limit of the emission direction.
  83707. */
  83708. direction2?: Vector3);
  83709. /**
  83710. * Called by the particle System when the direction is computed for the created particle.
  83711. * @param worldMatrix is the world matrix of the particle system
  83712. * @param directionToUpdate is the direction vector to update with the result
  83713. * @param particle is the particle we are computed the direction for
  83714. */
  83715. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83716. /**
  83717. * Clones the current emitter and returns a copy of it
  83718. * @returns the new emitter
  83719. */
  83720. clone(): CylinderDirectedParticleEmitter;
  83721. /**
  83722. * Called by the GPUParticleSystem to setup the update shader
  83723. * @param effect defines the update shader
  83724. */
  83725. applyToShader(effect: Effect): void;
  83726. /**
  83727. * Returns a string to use to update the GPU particles update shader
  83728. * @returns a string containng the defines string
  83729. */
  83730. getEffectDefines(): string;
  83731. /**
  83732. * Returns the string "CylinderDirectedParticleEmitter"
  83733. * @returns a string containing the class name
  83734. */
  83735. getClassName(): string;
  83736. /**
  83737. * Serializes the particle system to a JSON object.
  83738. * @returns the JSON object
  83739. */
  83740. serialize(): any;
  83741. /**
  83742. * Parse properties from a JSON object
  83743. * @param serializationObject defines the JSON object
  83744. */
  83745. parse(serializationObject: any): void;
  83746. }
  83747. }
  83748. declare module BABYLON {
  83749. /**
  83750. * Particle emitter emitting particles from the inside of a hemisphere.
  83751. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83752. */
  83753. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83754. /**
  83755. * The radius of the emission hemisphere.
  83756. */
  83757. radius: number;
  83758. /**
  83759. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83760. */
  83761. radiusRange: number;
  83762. /**
  83763. * How much to randomize the particle direction [0-1].
  83764. */
  83765. directionRandomizer: number;
  83766. /**
  83767. * Creates a new instance HemisphericParticleEmitter
  83768. * @param radius the radius of the emission hemisphere (1 by default)
  83769. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83770. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83771. */
  83772. constructor(
  83773. /**
  83774. * The radius of the emission hemisphere.
  83775. */
  83776. radius?: number,
  83777. /**
  83778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83779. */
  83780. radiusRange?: number,
  83781. /**
  83782. * How much to randomize the particle direction [0-1].
  83783. */
  83784. directionRandomizer?: number);
  83785. /**
  83786. * Called by the particle System when the direction is computed for the created particle.
  83787. * @param worldMatrix is the world matrix of the particle system
  83788. * @param directionToUpdate is the direction vector to update with the result
  83789. * @param particle is the particle we are computed the direction for
  83790. */
  83791. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83792. /**
  83793. * Called by the particle System when the position is computed for the created particle.
  83794. * @param worldMatrix is the world matrix of the particle system
  83795. * @param positionToUpdate is the position vector to update with the result
  83796. * @param particle is the particle we are computed the position for
  83797. */
  83798. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83799. /**
  83800. * Clones the current emitter and returns a copy of it
  83801. * @returns the new emitter
  83802. */
  83803. clone(): HemisphericParticleEmitter;
  83804. /**
  83805. * Called by the GPUParticleSystem to setup the update shader
  83806. * @param effect defines the update shader
  83807. */
  83808. applyToShader(effect: Effect): void;
  83809. /**
  83810. * Returns a string to use to update the GPU particles update shader
  83811. * @returns a string containng the defines string
  83812. */
  83813. getEffectDefines(): string;
  83814. /**
  83815. * Returns the string "HemisphericParticleEmitter"
  83816. * @returns a string containing the class name
  83817. */
  83818. getClassName(): string;
  83819. /**
  83820. * Serializes the particle system to a JSON object.
  83821. * @returns the JSON object
  83822. */
  83823. serialize(): any;
  83824. /**
  83825. * Parse properties from a JSON object
  83826. * @param serializationObject defines the JSON object
  83827. */
  83828. parse(serializationObject: any): void;
  83829. }
  83830. }
  83831. declare module BABYLON {
  83832. /**
  83833. * Particle emitter emitting particles from a point.
  83834. * It emits the particles randomly between 2 given directions.
  83835. */
  83836. export class PointParticleEmitter implements IParticleEmitterType {
  83837. /**
  83838. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83839. */
  83840. direction1: Vector3;
  83841. /**
  83842. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83843. */
  83844. direction2: Vector3;
  83845. /**
  83846. * Creates a new instance PointParticleEmitter
  83847. */
  83848. constructor();
  83849. /**
  83850. * Called by the particle System when the direction is computed for the created particle.
  83851. * @param worldMatrix is the world matrix of the particle system
  83852. * @param directionToUpdate is the direction vector to update with the result
  83853. * @param particle is the particle we are computed the direction for
  83854. */
  83855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83856. /**
  83857. * Called by the particle System when the position is computed for the created particle.
  83858. * @param worldMatrix is the world matrix of the particle system
  83859. * @param positionToUpdate is the position vector to update with the result
  83860. * @param particle is the particle we are computed the position for
  83861. */
  83862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83863. /**
  83864. * Clones the current emitter and returns a copy of it
  83865. * @returns the new emitter
  83866. */
  83867. clone(): PointParticleEmitter;
  83868. /**
  83869. * Called by the GPUParticleSystem to setup the update shader
  83870. * @param effect defines the update shader
  83871. */
  83872. applyToShader(effect: Effect): void;
  83873. /**
  83874. * Returns a string to use to update the GPU particles update shader
  83875. * @returns a string containng the defines string
  83876. */
  83877. getEffectDefines(): string;
  83878. /**
  83879. * Returns the string "PointParticleEmitter"
  83880. * @returns a string containing the class name
  83881. */
  83882. getClassName(): string;
  83883. /**
  83884. * Serializes the particle system to a JSON object.
  83885. * @returns the JSON object
  83886. */
  83887. serialize(): any;
  83888. /**
  83889. * Parse properties from a JSON object
  83890. * @param serializationObject defines the JSON object
  83891. */
  83892. parse(serializationObject: any): void;
  83893. }
  83894. }
  83895. declare module BABYLON {
  83896. /**
  83897. * Particle emitter emitting particles from the inside of a sphere.
  83898. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83899. */
  83900. export class SphereParticleEmitter implements IParticleEmitterType {
  83901. /**
  83902. * The radius of the emission sphere.
  83903. */
  83904. radius: number;
  83905. /**
  83906. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83907. */
  83908. radiusRange: number;
  83909. /**
  83910. * How much to randomize the particle direction [0-1].
  83911. */
  83912. directionRandomizer: number;
  83913. /**
  83914. * Creates a new instance SphereParticleEmitter
  83915. * @param radius the radius of the emission sphere (1 by default)
  83916. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83917. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83918. */
  83919. constructor(
  83920. /**
  83921. * The radius of the emission sphere.
  83922. */
  83923. radius?: number,
  83924. /**
  83925. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83926. */
  83927. radiusRange?: number,
  83928. /**
  83929. * How much to randomize the particle direction [0-1].
  83930. */
  83931. directionRandomizer?: number);
  83932. /**
  83933. * Called by the particle System when the direction is computed for the created particle.
  83934. * @param worldMatrix is the world matrix of the particle system
  83935. * @param directionToUpdate is the direction vector to update with the result
  83936. * @param particle is the particle we are computed the direction for
  83937. */
  83938. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83939. /**
  83940. * Called by the particle System when the position is computed for the created particle.
  83941. * @param worldMatrix is the world matrix of the particle system
  83942. * @param positionToUpdate is the position vector to update with the result
  83943. * @param particle is the particle we are computed the position for
  83944. */
  83945. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83946. /**
  83947. * Clones the current emitter and returns a copy of it
  83948. * @returns the new emitter
  83949. */
  83950. clone(): SphereParticleEmitter;
  83951. /**
  83952. * Called by the GPUParticleSystem to setup the update shader
  83953. * @param effect defines the update shader
  83954. */
  83955. applyToShader(effect: Effect): void;
  83956. /**
  83957. * Returns a string to use to update the GPU particles update shader
  83958. * @returns a string containng the defines string
  83959. */
  83960. getEffectDefines(): string;
  83961. /**
  83962. * Returns the string "SphereParticleEmitter"
  83963. * @returns a string containing the class name
  83964. */
  83965. getClassName(): string;
  83966. /**
  83967. * Serializes the particle system to a JSON object.
  83968. * @returns the JSON object
  83969. */
  83970. serialize(): any;
  83971. /**
  83972. * Parse properties from a JSON object
  83973. * @param serializationObject defines the JSON object
  83974. */
  83975. parse(serializationObject: any): void;
  83976. }
  83977. /**
  83978. * Particle emitter emitting particles from the inside of a sphere.
  83979. * It emits the particles randomly between two vectors.
  83980. */
  83981. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83982. /**
  83983. * The min limit of the emission direction.
  83984. */
  83985. direction1: Vector3;
  83986. /**
  83987. * The max limit of the emission direction.
  83988. */
  83989. direction2: Vector3;
  83990. /**
  83991. * Creates a new instance SphereDirectedParticleEmitter
  83992. * @param radius the radius of the emission sphere (1 by default)
  83993. * @param direction1 the min limit of the emission direction (up vector by default)
  83994. * @param direction2 the max limit of the emission direction (up vector by default)
  83995. */
  83996. constructor(radius?: number,
  83997. /**
  83998. * The min limit of the emission direction.
  83999. */
  84000. direction1?: Vector3,
  84001. /**
  84002. * The max limit of the emission direction.
  84003. */
  84004. direction2?: Vector3);
  84005. /**
  84006. * Called by the particle System when the direction is computed for the created particle.
  84007. * @param worldMatrix is the world matrix of the particle system
  84008. * @param directionToUpdate is the direction vector to update with the result
  84009. * @param particle is the particle we are computed the direction for
  84010. */
  84011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84012. /**
  84013. * Clones the current emitter and returns a copy of it
  84014. * @returns the new emitter
  84015. */
  84016. clone(): SphereDirectedParticleEmitter;
  84017. /**
  84018. * Called by the GPUParticleSystem to setup the update shader
  84019. * @param effect defines the update shader
  84020. */
  84021. applyToShader(effect: Effect): void;
  84022. /**
  84023. * Returns a string to use to update the GPU particles update shader
  84024. * @returns a string containng the defines string
  84025. */
  84026. getEffectDefines(): string;
  84027. /**
  84028. * Returns the string "SphereDirectedParticleEmitter"
  84029. * @returns a string containing the class name
  84030. */
  84031. getClassName(): string;
  84032. /**
  84033. * Serializes the particle system to a JSON object.
  84034. * @returns the JSON object
  84035. */
  84036. serialize(): any;
  84037. /**
  84038. * Parse properties from a JSON object
  84039. * @param serializationObject defines the JSON object
  84040. */
  84041. parse(serializationObject: any): void;
  84042. }
  84043. }
  84044. declare module BABYLON {
  84045. /**
  84046. * Interface representing a particle system in Babylon.js.
  84047. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84048. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84049. */
  84050. export interface IParticleSystem {
  84051. /**
  84052. * List of animations used by the particle system.
  84053. */
  84054. animations: Animation[];
  84055. /**
  84056. * The id of the Particle system.
  84057. */
  84058. id: string;
  84059. /**
  84060. * The name of the Particle system.
  84061. */
  84062. name: string;
  84063. /**
  84064. * The emitter represents the Mesh or position we are attaching the particle system to.
  84065. */
  84066. emitter: Nullable<AbstractMesh | Vector3>;
  84067. /**
  84068. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84069. */
  84070. isBillboardBased: boolean;
  84071. /**
  84072. * The rendering group used by the Particle system to chose when to render.
  84073. */
  84074. renderingGroupId: number;
  84075. /**
  84076. * The layer mask we are rendering the particles through.
  84077. */
  84078. layerMask: number;
  84079. /**
  84080. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84081. */
  84082. updateSpeed: number;
  84083. /**
  84084. * The amount of time the particle system is running (depends of the overall update speed).
  84085. */
  84086. targetStopDuration: number;
  84087. /**
  84088. * The texture used to render each particle. (this can be a spritesheet)
  84089. */
  84090. particleTexture: Nullable<Texture>;
  84091. /**
  84092. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84093. */
  84094. blendMode: number;
  84095. /**
  84096. * Minimum life time of emitting particles.
  84097. */
  84098. minLifeTime: number;
  84099. /**
  84100. * Maximum life time of emitting particles.
  84101. */
  84102. maxLifeTime: number;
  84103. /**
  84104. * Minimum Size of emitting particles.
  84105. */
  84106. minSize: number;
  84107. /**
  84108. * Maximum Size of emitting particles.
  84109. */
  84110. maxSize: number;
  84111. /**
  84112. * Minimum scale of emitting particles on X axis.
  84113. */
  84114. minScaleX: number;
  84115. /**
  84116. * Maximum scale of emitting particles on X axis.
  84117. */
  84118. maxScaleX: number;
  84119. /**
  84120. * Minimum scale of emitting particles on Y axis.
  84121. */
  84122. minScaleY: number;
  84123. /**
  84124. * Maximum scale of emitting particles on Y axis.
  84125. */
  84126. maxScaleY: number;
  84127. /**
  84128. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84129. */
  84130. color1: Color4;
  84131. /**
  84132. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84133. */
  84134. color2: Color4;
  84135. /**
  84136. * Color the particle will have at the end of its lifetime.
  84137. */
  84138. colorDead: Color4;
  84139. /**
  84140. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84141. */
  84142. emitRate: number;
  84143. /**
  84144. * You can use gravity if you want to give an orientation to your particles.
  84145. */
  84146. gravity: Vector3;
  84147. /**
  84148. * Minimum power of emitting particles.
  84149. */
  84150. minEmitPower: number;
  84151. /**
  84152. * Maximum power of emitting particles.
  84153. */
  84154. maxEmitPower: number;
  84155. /**
  84156. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84157. */
  84158. minAngularSpeed: number;
  84159. /**
  84160. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84161. */
  84162. maxAngularSpeed: number;
  84163. /**
  84164. * Gets or sets the minimal initial rotation in radians.
  84165. */
  84166. minInitialRotation: number;
  84167. /**
  84168. * Gets or sets the maximal initial rotation in radians.
  84169. */
  84170. maxInitialRotation: number;
  84171. /**
  84172. * The particle emitter type defines the emitter used by the particle system.
  84173. * It can be for example box, sphere, or cone...
  84174. */
  84175. particleEmitterType: Nullable<IParticleEmitterType>;
  84176. /**
  84177. * Defines the delay in milliseconds before starting the system (0 by default)
  84178. */
  84179. startDelay: number;
  84180. /**
  84181. * 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
  84182. */
  84183. preWarmCycles: number;
  84184. /**
  84185. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84186. */
  84187. preWarmStepOffset: number;
  84188. /**
  84189. * 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)
  84190. */
  84191. spriteCellChangeSpeed: number;
  84192. /**
  84193. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84194. */
  84195. startSpriteCellID: number;
  84196. /**
  84197. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84198. */
  84199. endSpriteCellID: number;
  84200. /**
  84201. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84202. */
  84203. spriteCellWidth: number;
  84204. /**
  84205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84206. */
  84207. spriteCellHeight: number;
  84208. /**
  84209. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84210. */
  84211. spriteRandomStartCell: boolean;
  84212. /**
  84213. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84214. */
  84215. isAnimationSheetEnabled: boolean;
  84216. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84217. translationPivot: Vector2;
  84218. /**
  84219. * Gets or sets a texture used to add random noise to particle positions
  84220. */
  84221. noiseTexture: Nullable<BaseTexture>;
  84222. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84223. noiseStrength: Vector3;
  84224. /**
  84225. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84226. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84227. */
  84228. billboardMode: number;
  84229. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84230. limitVelocityDamping: number;
  84231. /**
  84232. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84233. */
  84234. beginAnimationOnStart: boolean;
  84235. /**
  84236. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84237. */
  84238. beginAnimationFrom: number;
  84239. /**
  84240. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84241. */
  84242. beginAnimationTo: number;
  84243. /**
  84244. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84245. */
  84246. beginAnimationLoop: boolean;
  84247. /**
  84248. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84249. */
  84250. disposeOnStop: boolean;
  84251. /**
  84252. * Gets the maximum number of particles active at the same time.
  84253. * @returns The max number of active particles.
  84254. */
  84255. getCapacity(): number;
  84256. /**
  84257. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84258. * @returns True if it has been started, otherwise false.
  84259. */
  84260. isStarted(): boolean;
  84261. /**
  84262. * Animates the particle system for this frame.
  84263. */
  84264. animate(): void;
  84265. /**
  84266. * Renders the particle system in its current state.
  84267. * @returns the current number of particles
  84268. */
  84269. render(): number;
  84270. /**
  84271. * Dispose the particle system and frees its associated resources.
  84272. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84273. */
  84274. dispose(disposeTexture?: boolean): void;
  84275. /**
  84276. * Clones the particle system.
  84277. * @param name The name of the cloned object
  84278. * @param newEmitter The new emitter to use
  84279. * @returns the cloned particle system
  84280. */
  84281. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84282. /**
  84283. * Serializes the particle system to a JSON object.
  84284. * @returns the JSON object
  84285. */
  84286. serialize(): any;
  84287. /**
  84288. * Rebuild the particle system
  84289. */
  84290. rebuild(): void;
  84291. /**
  84292. * Starts the particle system and begins to emit
  84293. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84294. */
  84295. start(delay?: number): void;
  84296. /**
  84297. * Stops the particle system.
  84298. */
  84299. stop(): void;
  84300. /**
  84301. * Remove all active particles
  84302. */
  84303. reset(): void;
  84304. /**
  84305. * Is this system ready to be used/rendered
  84306. * @return true if the system is ready
  84307. */
  84308. isReady(): boolean;
  84309. /**
  84310. * Adds a new color gradient
  84311. * @param gradient defines the gradient to use (between 0 and 1)
  84312. * @param color1 defines the color to affect to the specified gradient
  84313. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84314. * @returns the current particle system
  84315. */
  84316. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84317. /**
  84318. * Remove a specific color gradient
  84319. * @param gradient defines the gradient to remove
  84320. * @returns the current particle system
  84321. */
  84322. removeColorGradient(gradient: number): IParticleSystem;
  84323. /**
  84324. * Adds a new size gradient
  84325. * @param gradient defines the gradient to use (between 0 and 1)
  84326. * @param factor defines the size factor to affect to the specified gradient
  84327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84328. * @returns the current particle system
  84329. */
  84330. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84331. /**
  84332. * Remove a specific size gradient
  84333. * @param gradient defines the gradient to remove
  84334. * @returns the current particle system
  84335. */
  84336. removeSizeGradient(gradient: number): IParticleSystem;
  84337. /**
  84338. * Gets the current list of color gradients.
  84339. * You must use addColorGradient and removeColorGradient to udpate this list
  84340. * @returns the list of color gradients
  84341. */
  84342. getColorGradients(): Nullable<Array<ColorGradient>>;
  84343. /**
  84344. * Gets the current list of size gradients.
  84345. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84346. * @returns the list of size gradients
  84347. */
  84348. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84349. /**
  84350. * Gets the current list of angular speed gradients.
  84351. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84352. * @returns the list of angular speed gradients
  84353. */
  84354. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84355. /**
  84356. * Adds a new angular speed gradient
  84357. * @param gradient defines the gradient to use (between 0 and 1)
  84358. * @param factor defines the angular speed to affect to the specified gradient
  84359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84360. * @returns the current particle system
  84361. */
  84362. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84363. /**
  84364. * Remove a specific angular speed gradient
  84365. * @param gradient defines the gradient to remove
  84366. * @returns the current particle system
  84367. */
  84368. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84369. /**
  84370. * Gets the current list of velocity gradients.
  84371. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84372. * @returns the list of velocity gradients
  84373. */
  84374. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84375. /**
  84376. * Adds a new velocity gradient
  84377. * @param gradient defines the gradient to use (between 0 and 1)
  84378. * @param factor defines the velocity to affect to the specified gradient
  84379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84380. * @returns the current particle system
  84381. */
  84382. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84383. /**
  84384. * Remove a specific velocity gradient
  84385. * @param gradient defines the gradient to remove
  84386. * @returns the current particle system
  84387. */
  84388. removeVelocityGradient(gradient: number): IParticleSystem;
  84389. /**
  84390. * Gets the current list of limit velocity gradients.
  84391. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84392. * @returns the list of limit velocity gradients
  84393. */
  84394. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84395. /**
  84396. * Adds a new limit velocity gradient
  84397. * @param gradient defines the gradient to use (between 0 and 1)
  84398. * @param factor defines the limit velocity to affect to the specified gradient
  84399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84400. * @returns the current particle system
  84401. */
  84402. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84403. /**
  84404. * Remove a specific limit velocity gradient
  84405. * @param gradient defines the gradient to remove
  84406. * @returns the current particle system
  84407. */
  84408. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84409. /**
  84410. * Adds a new drag gradient
  84411. * @param gradient defines the gradient to use (between 0 and 1)
  84412. * @param factor defines the drag to affect to the specified gradient
  84413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84414. * @returns the current particle system
  84415. */
  84416. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84417. /**
  84418. * Remove a specific drag gradient
  84419. * @param gradient defines the gradient to remove
  84420. * @returns the current particle system
  84421. */
  84422. removeDragGradient(gradient: number): IParticleSystem;
  84423. /**
  84424. * Gets the current list of drag gradients.
  84425. * You must use addDragGradient and removeDragGradient to udpate this list
  84426. * @returns the list of drag gradients
  84427. */
  84428. getDragGradients(): Nullable<Array<FactorGradient>>;
  84429. /**
  84430. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84431. * @param gradient defines the gradient to use (between 0 and 1)
  84432. * @param factor defines the emit rate to affect to the specified gradient
  84433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84434. * @returns the current particle system
  84435. */
  84436. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84437. /**
  84438. * Remove a specific emit rate gradient
  84439. * @param gradient defines the gradient to remove
  84440. * @returns the current particle system
  84441. */
  84442. removeEmitRateGradient(gradient: number): IParticleSystem;
  84443. /**
  84444. * Gets the current list of emit rate gradients.
  84445. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84446. * @returns the list of emit rate gradients
  84447. */
  84448. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84449. /**
  84450. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84451. * @param gradient defines the gradient to use (between 0 and 1)
  84452. * @param factor defines the start size to affect to the specified gradient
  84453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84454. * @returns the current particle system
  84455. */
  84456. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84457. /**
  84458. * Remove a specific start size gradient
  84459. * @param gradient defines the gradient to remove
  84460. * @returns the current particle system
  84461. */
  84462. removeStartSizeGradient(gradient: number): IParticleSystem;
  84463. /**
  84464. * Gets the current list of start size gradients.
  84465. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84466. * @returns the list of start size gradients
  84467. */
  84468. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84469. /**
  84470. * Adds a new life time gradient
  84471. * @param gradient defines the gradient to use (between 0 and 1)
  84472. * @param factor defines the life time factor to affect to the specified gradient
  84473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84474. * @returns the current particle system
  84475. */
  84476. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84477. /**
  84478. * Remove a specific life time gradient
  84479. * @param gradient defines the gradient to remove
  84480. * @returns the current particle system
  84481. */
  84482. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84483. /**
  84484. * Gets the current list of life time gradients.
  84485. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84486. * @returns the list of life time gradients
  84487. */
  84488. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84489. /**
  84490. * Gets the current list of color gradients.
  84491. * You must use addColorGradient and removeColorGradient to udpate this list
  84492. * @returns the list of color gradients
  84493. */
  84494. getColorGradients(): Nullable<Array<ColorGradient>>;
  84495. /**
  84496. * Adds a new ramp gradient used to remap particle colors
  84497. * @param gradient defines the gradient to use (between 0 and 1)
  84498. * @param color defines the color to affect to the specified gradient
  84499. * @returns the current particle system
  84500. */
  84501. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84502. /**
  84503. * Gets the current list of ramp gradients.
  84504. * You must use addRampGradient and removeRampGradient to udpate this list
  84505. * @returns the list of ramp gradients
  84506. */
  84507. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84508. /** Gets or sets a boolean indicating that ramp gradients must be used
  84509. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84510. */
  84511. useRampGradients: boolean;
  84512. /**
  84513. * Adds a new color remap gradient
  84514. * @param gradient defines the gradient to use (between 0 and 1)
  84515. * @param min defines the color remap minimal range
  84516. * @param max defines the color remap maximal range
  84517. * @returns the current particle system
  84518. */
  84519. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84520. /**
  84521. * Gets the current list of color remap gradients.
  84522. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84523. * @returns the list of color remap gradients
  84524. */
  84525. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84526. /**
  84527. * Adds a new alpha remap gradient
  84528. * @param gradient defines the gradient to use (between 0 and 1)
  84529. * @param min defines the alpha remap minimal range
  84530. * @param max defines the alpha remap maximal range
  84531. * @returns the current particle system
  84532. */
  84533. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84534. /**
  84535. * Gets the current list of alpha remap gradients.
  84536. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84537. * @returns the list of alpha remap gradients
  84538. */
  84539. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84540. /**
  84541. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84542. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84543. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84544. * @returns the emitter
  84545. */
  84546. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84547. /**
  84548. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84549. * @param radius The radius of the hemisphere to emit from
  84550. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84551. * @returns the emitter
  84552. */
  84553. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84554. /**
  84555. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84556. * @param radius The radius of the sphere to emit from
  84557. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84558. * @returns the emitter
  84559. */
  84560. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84561. /**
  84562. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84563. * @param radius The radius of the sphere to emit from
  84564. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84565. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84566. * @returns the emitter
  84567. */
  84568. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84569. /**
  84570. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84571. * @param radius The radius of the emission cylinder
  84572. * @param height The height of the emission cylinder
  84573. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84574. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84575. * @returns the emitter
  84576. */
  84577. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84578. /**
  84579. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84580. * @param radius The radius of the cylinder to emit from
  84581. * @param height The height of the emission cylinder
  84582. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84583. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84584. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84585. * @returns the emitter
  84586. */
  84587. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84588. /**
  84589. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84590. * @param radius The radius of the cone to emit from
  84591. * @param angle The base angle of the cone
  84592. * @returns the emitter
  84593. */
  84594. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84595. /**
  84596. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84599. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84600. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84601. * @returns the emitter
  84602. */
  84603. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84604. /**
  84605. * Get hosting scene
  84606. * @returns the scene
  84607. */
  84608. getScene(): Scene;
  84609. }
  84610. }
  84611. declare module BABYLON {
  84612. /**
  84613. * Creates an instance based on a source mesh.
  84614. */
  84615. export class InstancedMesh extends AbstractMesh {
  84616. private _sourceMesh;
  84617. private _currentLOD;
  84618. /** @hidden */
  84619. _indexInSourceMeshInstanceArray: number;
  84620. constructor(name: string, source: Mesh);
  84621. /**
  84622. * Returns the string "InstancedMesh".
  84623. */
  84624. getClassName(): string;
  84625. /** Gets the list of lights affecting that mesh */
  84626. readonly lightSources: Light[];
  84627. _resyncLightSources(): void;
  84628. _resyncLighSource(light: Light): void;
  84629. _removeLightSource(light: Light, dispose: boolean): void;
  84630. /**
  84631. * If the source mesh receives shadows
  84632. */
  84633. readonly receiveShadows: boolean;
  84634. /**
  84635. * The material of the source mesh
  84636. */
  84637. readonly material: Nullable<Material>;
  84638. /**
  84639. * Visibility of the source mesh
  84640. */
  84641. readonly visibility: number;
  84642. /**
  84643. * Skeleton of the source mesh
  84644. */
  84645. readonly skeleton: Nullable<Skeleton>;
  84646. /**
  84647. * Rendering ground id of the source mesh
  84648. */
  84649. renderingGroupId: number;
  84650. /**
  84651. * Returns the total number of vertices (integer).
  84652. */
  84653. getTotalVertices(): number;
  84654. /**
  84655. * Returns a positive integer : the total number of indices in this mesh geometry.
  84656. * @returns the numner of indices or zero if the mesh has no geometry.
  84657. */
  84658. getTotalIndices(): number;
  84659. /**
  84660. * The source mesh of the instance
  84661. */
  84662. readonly sourceMesh: Mesh;
  84663. /**
  84664. * Is this node ready to be used/rendered
  84665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84666. * @return {boolean} is it ready
  84667. */
  84668. isReady(completeCheck?: boolean): boolean;
  84669. /**
  84670. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84671. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84672. * @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.
  84673. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84674. */
  84675. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84676. /**
  84677. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84678. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84679. * The `data` are either a numeric array either a Float32Array.
  84680. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84681. * 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).
  84682. * Note that a new underlying VertexBuffer object is created each call.
  84683. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84684. *
  84685. * Possible `kind` values :
  84686. * - VertexBuffer.PositionKind
  84687. * - VertexBuffer.UVKind
  84688. * - VertexBuffer.UV2Kind
  84689. * - VertexBuffer.UV3Kind
  84690. * - VertexBuffer.UV4Kind
  84691. * - VertexBuffer.UV5Kind
  84692. * - VertexBuffer.UV6Kind
  84693. * - VertexBuffer.ColorKind
  84694. * - VertexBuffer.MatricesIndicesKind
  84695. * - VertexBuffer.MatricesIndicesExtraKind
  84696. * - VertexBuffer.MatricesWeightsKind
  84697. * - VertexBuffer.MatricesWeightsExtraKind
  84698. *
  84699. * Returns the Mesh.
  84700. */
  84701. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84702. /**
  84703. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84704. * If the mesh has no geometry, it is simply returned as it is.
  84705. * The `data` are either a numeric array either a Float32Array.
  84706. * No new underlying VertexBuffer object is created.
  84707. * 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.
  84708. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84709. *
  84710. * Possible `kind` values :
  84711. * - VertexBuffer.PositionKind
  84712. * - VertexBuffer.UVKind
  84713. * - VertexBuffer.UV2Kind
  84714. * - VertexBuffer.UV3Kind
  84715. * - VertexBuffer.UV4Kind
  84716. * - VertexBuffer.UV5Kind
  84717. * - VertexBuffer.UV6Kind
  84718. * - VertexBuffer.ColorKind
  84719. * - VertexBuffer.MatricesIndicesKind
  84720. * - VertexBuffer.MatricesIndicesExtraKind
  84721. * - VertexBuffer.MatricesWeightsKind
  84722. * - VertexBuffer.MatricesWeightsExtraKind
  84723. *
  84724. * Returns the Mesh.
  84725. */
  84726. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84727. /**
  84728. * Sets the mesh indices.
  84729. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84730. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84731. * This method creates a new index buffer each call.
  84732. * Returns the Mesh.
  84733. */
  84734. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84735. /**
  84736. * Boolean : True if the mesh owns the requested kind of data.
  84737. */
  84738. isVerticesDataPresent(kind: string): boolean;
  84739. /**
  84740. * Returns an array of indices (IndicesArray).
  84741. */
  84742. getIndices(): Nullable<IndicesArray>;
  84743. readonly _positions: Nullable<Vector3[]>;
  84744. /**
  84745. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84746. * This means the mesh underlying bounding box and sphere are recomputed.
  84747. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84748. * @returns the current mesh
  84749. */
  84750. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84751. /** @hidden */
  84752. _preActivate(): InstancedMesh;
  84753. /** @hidden */
  84754. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84755. /** @hidden */
  84756. _postActivate(): void;
  84757. getWorldMatrix(): Matrix;
  84758. readonly isAnInstance: boolean;
  84759. /**
  84760. * Returns the current associated LOD AbstractMesh.
  84761. */
  84762. getLOD(camera: Camera): AbstractMesh;
  84763. /** @hidden */
  84764. _syncSubMeshes(): InstancedMesh;
  84765. /** @hidden */
  84766. _generatePointsArray(): boolean;
  84767. /**
  84768. * Creates a new InstancedMesh from the current mesh.
  84769. * - name (string) : the cloned mesh name
  84770. * - newParent (optional Node) : the optional Node to parent the clone to.
  84771. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84772. *
  84773. * Returns the clone.
  84774. */
  84775. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84776. /**
  84777. * Disposes the InstancedMesh.
  84778. * Returns nothing.
  84779. */
  84780. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84781. }
  84782. }
  84783. declare module BABYLON {
  84784. /**
  84785. * Defines the options associated with the creation of a shader material.
  84786. */
  84787. export interface IShaderMaterialOptions {
  84788. /**
  84789. * Does the material work in alpha blend mode
  84790. */
  84791. needAlphaBlending: boolean;
  84792. /**
  84793. * Does the material work in alpha test mode
  84794. */
  84795. needAlphaTesting: boolean;
  84796. /**
  84797. * The list of attribute names used in the shader
  84798. */
  84799. attributes: string[];
  84800. /**
  84801. * The list of unifrom names used in the shader
  84802. */
  84803. uniforms: string[];
  84804. /**
  84805. * The list of UBO names used in the shader
  84806. */
  84807. uniformBuffers: string[];
  84808. /**
  84809. * The list of sampler names used in the shader
  84810. */
  84811. samplers: string[];
  84812. /**
  84813. * The list of defines used in the shader
  84814. */
  84815. defines: string[];
  84816. }
  84817. /**
  84818. * 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.
  84819. *
  84820. * This returned material effects how the mesh will look based on the code in the shaders.
  84821. *
  84822. * @see http://doc.babylonjs.com/how_to/shader_material
  84823. */
  84824. export class ShaderMaterial extends Material {
  84825. private _shaderPath;
  84826. private _options;
  84827. private _textures;
  84828. private _textureArrays;
  84829. private _floats;
  84830. private _ints;
  84831. private _floatsArrays;
  84832. private _colors3;
  84833. private _colors3Arrays;
  84834. private _colors4;
  84835. private _colors4Arrays;
  84836. private _vectors2;
  84837. private _vectors3;
  84838. private _vectors4;
  84839. private _matrices;
  84840. private _matrices3x3;
  84841. private _matrices2x2;
  84842. private _vectors2Arrays;
  84843. private _vectors3Arrays;
  84844. private _vectors4Arrays;
  84845. private _cachedWorldViewMatrix;
  84846. private _cachedWorldViewProjectionMatrix;
  84847. private _renderId;
  84848. /**
  84849. * Instantiate a new shader material.
  84850. * 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.
  84851. * This returned material effects how the mesh will look based on the code in the shaders.
  84852. * @see http://doc.babylonjs.com/how_to/shader_material
  84853. * @param name Define the name of the material in the scene
  84854. * @param scene Define the scene the material belongs to
  84855. * @param shaderPath Defines the route to the shader code in one of three ways:
  84856. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84857. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84858. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84859. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84860. * @param options Define the options used to create the shader
  84861. */
  84862. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84863. /**
  84864. * Gets the options used to compile the shader.
  84865. * They can be modified to trigger a new compilation
  84866. */
  84867. readonly options: IShaderMaterialOptions;
  84868. /**
  84869. * Gets the current class name of the material e.g. "ShaderMaterial"
  84870. * Mainly use in serialization.
  84871. * @returns the class name
  84872. */
  84873. getClassName(): string;
  84874. /**
  84875. * Specifies if the material will require alpha blending
  84876. * @returns a boolean specifying if alpha blending is needed
  84877. */
  84878. needAlphaBlending(): boolean;
  84879. /**
  84880. * Specifies if this material should be rendered in alpha test mode
  84881. * @returns a boolean specifying if an alpha test is needed.
  84882. */
  84883. needAlphaTesting(): boolean;
  84884. private _checkUniform;
  84885. /**
  84886. * Set a texture in the shader.
  84887. * @param name Define the name of the uniform samplers as defined in the shader
  84888. * @param texture Define the texture to bind to this sampler
  84889. * @return the material itself allowing "fluent" like uniform updates
  84890. */
  84891. setTexture(name: string, texture: Texture): ShaderMaterial;
  84892. /**
  84893. * Set a texture array in the shader.
  84894. * @param name Define the name of the uniform sampler array as defined in the shader
  84895. * @param textures Define the list of textures to bind to this sampler
  84896. * @return the material itself allowing "fluent" like uniform updates
  84897. */
  84898. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84899. /**
  84900. * Set a float in the shader.
  84901. * @param name Define the name of the uniform as defined in the shader
  84902. * @param value Define the value to give to the uniform
  84903. * @return the material itself allowing "fluent" like uniform updates
  84904. */
  84905. setFloat(name: string, value: number): ShaderMaterial;
  84906. /**
  84907. * Set a int in the shader.
  84908. * @param name Define the name of the uniform as defined in the shader
  84909. * @param value Define the value to give to the uniform
  84910. * @return the material itself allowing "fluent" like uniform updates
  84911. */
  84912. setInt(name: string, value: number): ShaderMaterial;
  84913. /**
  84914. * Set an array of floats in the shader.
  84915. * @param name Define the name of the uniform as defined in the shader
  84916. * @param value Define the value to give to the uniform
  84917. * @return the material itself allowing "fluent" like uniform updates
  84918. */
  84919. setFloats(name: string, value: number[]): ShaderMaterial;
  84920. /**
  84921. * Set a vec3 in the shader from a Color3.
  84922. * @param name Define the name of the uniform as defined in the shader
  84923. * @param value Define the value to give to the uniform
  84924. * @return the material itself allowing "fluent" like uniform updates
  84925. */
  84926. setColor3(name: string, value: Color3): ShaderMaterial;
  84927. /**
  84928. * Set a vec3 array in the shader from a Color3 array.
  84929. * @param name Define the name of the uniform as defined in the shader
  84930. * @param value Define the value to give to the uniform
  84931. * @return the material itself allowing "fluent" like uniform updates
  84932. */
  84933. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84934. /**
  84935. * Set a vec4 in the shader from a Color4.
  84936. * @param name Define the name of the uniform as defined in the shader
  84937. * @param value Define the value to give to the uniform
  84938. * @return the material itself allowing "fluent" like uniform updates
  84939. */
  84940. setColor4(name: string, value: Color4): ShaderMaterial;
  84941. /**
  84942. * Set a vec4 array in the shader from a Color4 array.
  84943. * @param name Define the name of the uniform as defined in the shader
  84944. * @param value Define the value to give to the uniform
  84945. * @return the material itself allowing "fluent" like uniform updates
  84946. */
  84947. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84948. /**
  84949. * Set a vec2 in the shader from a Vector2.
  84950. * @param name Define the name of the uniform as defined in the shader
  84951. * @param value Define the value to give to the uniform
  84952. * @return the material itself allowing "fluent" like uniform updates
  84953. */
  84954. setVector2(name: string, value: Vector2): ShaderMaterial;
  84955. /**
  84956. * Set a vec3 in the shader from a Vector3.
  84957. * @param name Define the name of the uniform as defined in the shader
  84958. * @param value Define the value to give to the uniform
  84959. * @return the material itself allowing "fluent" like uniform updates
  84960. */
  84961. setVector3(name: string, value: Vector3): ShaderMaterial;
  84962. /**
  84963. * Set a vec4 in the shader from a Vector4.
  84964. * @param name Define the name of the uniform as defined in the shader
  84965. * @param value Define the value to give to the uniform
  84966. * @return the material itself allowing "fluent" like uniform updates
  84967. */
  84968. setVector4(name: string, value: Vector4): ShaderMaterial;
  84969. /**
  84970. * Set a mat4 in the shader from a Matrix.
  84971. * @param name Define the name of the uniform as defined in the shader
  84972. * @param value Define the value to give to the uniform
  84973. * @return the material itself allowing "fluent" like uniform updates
  84974. */
  84975. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84976. /**
  84977. * Set a mat3 in the shader from a Float32Array.
  84978. * @param name Define the name of the uniform as defined in the shader
  84979. * @param value Define the value to give to the uniform
  84980. * @return the material itself allowing "fluent" like uniform updates
  84981. */
  84982. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84983. /**
  84984. * Set a mat2 in the shader from a Float32Array.
  84985. * @param name Define the name of the uniform as defined in the shader
  84986. * @param value Define the value to give to the uniform
  84987. * @return the material itself allowing "fluent" like uniform updates
  84988. */
  84989. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84990. /**
  84991. * Set a vec2 array in the shader from a number array.
  84992. * @param name Define the name of the uniform as defined in the shader
  84993. * @param value Define the value to give to the uniform
  84994. * @return the material itself allowing "fluent" like uniform updates
  84995. */
  84996. setArray2(name: string, value: number[]): ShaderMaterial;
  84997. /**
  84998. * Set a vec3 array in the shader from a number array.
  84999. * @param name Define the name of the uniform as defined in the shader
  85000. * @param value Define the value to give to the uniform
  85001. * @return the material itself allowing "fluent" like uniform updates
  85002. */
  85003. setArray3(name: string, value: number[]): ShaderMaterial;
  85004. /**
  85005. * Set a vec4 array in the shader from a number array.
  85006. * @param name Define the name of the uniform as defined in the shader
  85007. * @param value Define the value to give to the uniform
  85008. * @return the material itself allowing "fluent" like uniform updates
  85009. */
  85010. setArray4(name: string, value: number[]): ShaderMaterial;
  85011. private _checkCache;
  85012. /**
  85013. * Specifies that the submesh is ready to be used
  85014. * @param mesh defines the mesh to check
  85015. * @param subMesh defines which submesh to check
  85016. * @param useInstances specifies that instances should be used
  85017. * @returns a boolean indicating that the submesh is ready or not
  85018. */
  85019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85020. /**
  85021. * Checks if the material is ready to render the requested mesh
  85022. * @param mesh Define the mesh to render
  85023. * @param useInstances Define whether or not the material is used with instances
  85024. * @returns true if ready, otherwise false
  85025. */
  85026. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85027. /**
  85028. * Binds the world matrix to the material
  85029. * @param world defines the world transformation matrix
  85030. */
  85031. bindOnlyWorldMatrix(world: Matrix): void;
  85032. /**
  85033. * Binds the material to the mesh
  85034. * @param world defines the world transformation matrix
  85035. * @param mesh defines the mesh to bind the material to
  85036. */
  85037. bind(world: Matrix, mesh?: Mesh): void;
  85038. /**
  85039. * Gets the active textures from the material
  85040. * @returns an array of textures
  85041. */
  85042. getActiveTextures(): BaseTexture[];
  85043. /**
  85044. * Specifies if the material uses a texture
  85045. * @param texture defines the texture to check against the material
  85046. * @returns a boolean specifying if the material uses the texture
  85047. */
  85048. hasTexture(texture: BaseTexture): boolean;
  85049. /**
  85050. * Makes a duplicate of the material, and gives it a new name
  85051. * @param name defines the new name for the duplicated material
  85052. * @returns the cloned material
  85053. */
  85054. clone(name: string): ShaderMaterial;
  85055. /**
  85056. * Disposes the material
  85057. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85058. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85059. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85060. */
  85061. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85062. /**
  85063. * Serializes this material in a JSON representation
  85064. * @returns the serialized material object
  85065. */
  85066. serialize(): any;
  85067. /**
  85068. * Creates a shader material from parsed shader material data
  85069. * @param source defines the JSON represnetation of the material
  85070. * @param scene defines the hosting scene
  85071. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85072. * @returns a new material
  85073. */
  85074. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85075. }
  85076. }
  85077. declare module BABYLON {
  85078. /** @hidden */
  85079. export var colorPixelShader: {
  85080. name: string;
  85081. shader: string;
  85082. };
  85083. }
  85084. declare module BABYLON {
  85085. /** @hidden */
  85086. export var colorVertexShader: {
  85087. name: string;
  85088. shader: string;
  85089. };
  85090. }
  85091. declare module BABYLON {
  85092. /**
  85093. * Line mesh
  85094. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85095. */
  85096. export class LinesMesh extends Mesh {
  85097. /**
  85098. * If vertex color should be applied to the mesh
  85099. */
  85100. readonly useVertexColor?: boolean | undefined;
  85101. /**
  85102. * If vertex alpha should be applied to the mesh
  85103. */
  85104. readonly useVertexAlpha?: boolean | undefined;
  85105. /**
  85106. * Color of the line (Default: White)
  85107. */
  85108. color: Color3;
  85109. /**
  85110. * Alpha of the line (Default: 1)
  85111. */
  85112. alpha: number;
  85113. /**
  85114. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85115. * This margin is expressed in world space coordinates, so its value may vary.
  85116. * Default value is 0.1
  85117. */
  85118. intersectionThreshold: number;
  85119. private _colorShader;
  85120. private color4;
  85121. /**
  85122. * Creates a new LinesMesh
  85123. * @param name defines the name
  85124. * @param scene defines the hosting scene
  85125. * @param parent defines the parent mesh if any
  85126. * @param source defines the optional source LinesMesh used to clone data from
  85127. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85128. * When false, achieved by calling a clone(), also passing False.
  85129. * This will make creation of children, recursive.
  85130. * @param useVertexColor defines if this LinesMesh supports vertex color
  85131. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85132. */
  85133. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85134. /**
  85135. * If vertex color should be applied to the mesh
  85136. */
  85137. useVertexColor?: boolean | undefined,
  85138. /**
  85139. * If vertex alpha should be applied to the mesh
  85140. */
  85141. useVertexAlpha?: boolean | undefined);
  85142. private _addClipPlaneDefine;
  85143. private _removeClipPlaneDefine;
  85144. isReady(): boolean;
  85145. /**
  85146. * Returns the string "LineMesh"
  85147. */
  85148. getClassName(): string;
  85149. /**
  85150. * @hidden
  85151. */
  85152. /**
  85153. * @hidden
  85154. */
  85155. material: Material;
  85156. /**
  85157. * @hidden
  85158. */
  85159. readonly checkCollisions: boolean;
  85160. /** @hidden */
  85161. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85162. /** @hidden */
  85163. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85164. /**
  85165. * Disposes of the line mesh
  85166. * @param doNotRecurse If children should be disposed
  85167. */
  85168. dispose(doNotRecurse?: boolean): void;
  85169. /**
  85170. * Returns a new LineMesh object cloned from the current one.
  85171. */
  85172. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85173. /**
  85174. * Creates a new InstancedLinesMesh object from the mesh model.
  85175. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85176. * @param name defines the name of the new instance
  85177. * @returns a new InstancedLinesMesh
  85178. */
  85179. createInstance(name: string): InstancedLinesMesh;
  85180. }
  85181. /**
  85182. * Creates an instance based on a source LinesMesh
  85183. */
  85184. export class InstancedLinesMesh extends InstancedMesh {
  85185. /**
  85186. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85187. * This margin is expressed in world space coordinates, so its value may vary.
  85188. * Initilized with the intersectionThreshold value of the source LinesMesh
  85189. */
  85190. intersectionThreshold: number;
  85191. constructor(name: string, source: LinesMesh);
  85192. /**
  85193. * Returns the string "InstancedLinesMesh".
  85194. */
  85195. getClassName(): string;
  85196. }
  85197. }
  85198. declare module BABYLON {
  85199. /** @hidden */
  85200. export var linePixelShader: {
  85201. name: string;
  85202. shader: string;
  85203. };
  85204. }
  85205. declare module BABYLON {
  85206. /** @hidden */
  85207. export var lineVertexShader: {
  85208. name: string;
  85209. shader: string;
  85210. };
  85211. }
  85212. declare module BABYLON {
  85213. interface AbstractMesh {
  85214. /**
  85215. * Gets the edgesRenderer associated with the mesh
  85216. */
  85217. edgesRenderer: Nullable<EdgesRenderer>;
  85218. }
  85219. interface LinesMesh {
  85220. /**
  85221. * Enables the edge rendering mode on the mesh.
  85222. * This mode makes the mesh edges visible
  85223. * @param epsilon defines the maximal distance between two angles to detect a face
  85224. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85225. * @returns the currentAbstractMesh
  85226. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85227. */
  85228. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85229. }
  85230. interface InstancedLinesMesh {
  85231. /**
  85232. * Enables the edge rendering mode on the mesh.
  85233. * This mode makes the mesh edges visible
  85234. * @param epsilon defines the maximal distance between two angles to detect a face
  85235. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85236. * @returns the current InstancedLinesMesh
  85237. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85238. */
  85239. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85240. }
  85241. /**
  85242. * Defines the minimum contract an Edges renderer should follow.
  85243. */
  85244. export interface IEdgesRenderer extends IDisposable {
  85245. /**
  85246. * Gets or sets a boolean indicating if the edgesRenderer is active
  85247. */
  85248. isEnabled: boolean;
  85249. /**
  85250. * Renders the edges of the attached mesh,
  85251. */
  85252. render(): void;
  85253. /**
  85254. * Checks wether or not the edges renderer is ready to render.
  85255. * @return true if ready, otherwise false.
  85256. */
  85257. isReady(): boolean;
  85258. }
  85259. /**
  85260. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85261. */
  85262. export class EdgesRenderer implements IEdgesRenderer {
  85263. /**
  85264. * Define the size of the edges with an orthographic camera
  85265. */
  85266. edgesWidthScalerForOrthographic: number;
  85267. /**
  85268. * Define the size of the edges with a perspective camera
  85269. */
  85270. edgesWidthScalerForPerspective: number;
  85271. protected _source: AbstractMesh;
  85272. protected _linesPositions: number[];
  85273. protected _linesNormals: number[];
  85274. protected _linesIndices: number[];
  85275. protected _epsilon: number;
  85276. protected _indicesCount: number;
  85277. protected _lineShader: ShaderMaterial;
  85278. protected _ib: DataBuffer;
  85279. protected _buffers: {
  85280. [key: string]: Nullable<VertexBuffer>;
  85281. };
  85282. protected _checkVerticesInsteadOfIndices: boolean;
  85283. private _meshRebuildObserver;
  85284. private _meshDisposeObserver;
  85285. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85286. isEnabled: boolean;
  85287. /**
  85288. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85289. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85290. * @param source Mesh used to create edges
  85291. * @param epsilon sum of angles in adjacency to check for edge
  85292. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85293. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85294. */
  85295. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85296. protected _prepareRessources(): void;
  85297. /** @hidden */
  85298. _rebuild(): void;
  85299. /**
  85300. * Releases the required resources for the edges renderer
  85301. */
  85302. dispose(): void;
  85303. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85304. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85305. /**
  85306. * Checks if the pair of p0 and p1 is en edge
  85307. * @param faceIndex
  85308. * @param edge
  85309. * @param faceNormals
  85310. * @param p0
  85311. * @param p1
  85312. * @private
  85313. */
  85314. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85315. /**
  85316. * push line into the position, normal and index buffer
  85317. * @protected
  85318. */
  85319. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85320. /**
  85321. * Generates lines edges from adjacencjes
  85322. * @private
  85323. */
  85324. _generateEdgesLines(): void;
  85325. /**
  85326. * Checks wether or not the edges renderer is ready to render.
  85327. * @return true if ready, otherwise false.
  85328. */
  85329. isReady(): boolean;
  85330. /**
  85331. * Renders the edges of the attached mesh,
  85332. */
  85333. render(): void;
  85334. }
  85335. /**
  85336. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85337. */
  85338. export class LineEdgesRenderer extends EdgesRenderer {
  85339. /**
  85340. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85341. * @param source LineMesh used to generate edges
  85342. * @param epsilon not important (specified angle for edge detection)
  85343. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85344. */
  85345. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85346. /**
  85347. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85348. */
  85349. _generateEdgesLines(): void;
  85350. }
  85351. }
  85352. declare module BABYLON {
  85353. /**
  85354. * This represents the object necessary to create a rendering group.
  85355. * This is exclusively used and created by the rendering manager.
  85356. * To modify the behavior, you use the available helpers in your scene or meshes.
  85357. * @hidden
  85358. */
  85359. export class RenderingGroup {
  85360. index: number;
  85361. private static _zeroVector;
  85362. private _scene;
  85363. private _opaqueSubMeshes;
  85364. private _transparentSubMeshes;
  85365. private _alphaTestSubMeshes;
  85366. private _depthOnlySubMeshes;
  85367. private _particleSystems;
  85368. private _spriteManagers;
  85369. private _opaqueSortCompareFn;
  85370. private _alphaTestSortCompareFn;
  85371. private _transparentSortCompareFn;
  85372. private _renderOpaque;
  85373. private _renderAlphaTest;
  85374. private _renderTransparent;
  85375. /** @hidden */
  85376. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85377. onBeforeTransparentRendering: () => void;
  85378. /**
  85379. * Set the opaque sort comparison function.
  85380. * If null the sub meshes will be render in the order they were created
  85381. */
  85382. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85383. /**
  85384. * Set the alpha test sort comparison function.
  85385. * If null the sub meshes will be render in the order they were created
  85386. */
  85387. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85388. /**
  85389. * Set the transparent sort comparison function.
  85390. * If null the sub meshes will be render in the order they were created
  85391. */
  85392. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85393. /**
  85394. * Creates a new rendering group.
  85395. * @param index The rendering group index
  85396. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85397. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85398. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85399. */
  85400. 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>);
  85401. /**
  85402. * Render all the sub meshes contained in the group.
  85403. * @param customRenderFunction Used to override the default render behaviour of the group.
  85404. * @returns true if rendered some submeshes.
  85405. */
  85406. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85407. /**
  85408. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85409. * @param subMeshes The submeshes to render
  85410. */
  85411. private renderOpaqueSorted;
  85412. /**
  85413. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85414. * @param subMeshes The submeshes to render
  85415. */
  85416. private renderAlphaTestSorted;
  85417. /**
  85418. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85419. * @param subMeshes The submeshes to render
  85420. */
  85421. private renderTransparentSorted;
  85422. /**
  85423. * Renders the submeshes in a specified order.
  85424. * @param subMeshes The submeshes to sort before render
  85425. * @param sortCompareFn The comparison function use to sort
  85426. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85427. * @param transparent Specifies to activate blending if true
  85428. */
  85429. private static renderSorted;
  85430. /**
  85431. * Renders the submeshes in the order they were dispatched (no sort applied).
  85432. * @param subMeshes The submeshes to render
  85433. */
  85434. private static renderUnsorted;
  85435. /**
  85436. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85437. * are rendered back to front if in the same alpha index.
  85438. *
  85439. * @param a The first submesh
  85440. * @param b The second submesh
  85441. * @returns The result of the comparison
  85442. */
  85443. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85444. /**
  85445. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85446. * are rendered back to front.
  85447. *
  85448. * @param a The first submesh
  85449. * @param b The second submesh
  85450. * @returns The result of the comparison
  85451. */
  85452. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85453. /**
  85454. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85455. * are rendered front to back (prevent overdraw).
  85456. *
  85457. * @param a The first submesh
  85458. * @param b The second submesh
  85459. * @returns The result of the comparison
  85460. */
  85461. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85462. /**
  85463. * Resets the different lists of submeshes to prepare a new frame.
  85464. */
  85465. prepare(): void;
  85466. dispose(): void;
  85467. /**
  85468. * Inserts the submesh in its correct queue depending on its material.
  85469. * @param subMesh The submesh to dispatch
  85470. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85471. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85472. */
  85473. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85474. dispatchSprites(spriteManager: ISpriteManager): void;
  85475. dispatchParticles(particleSystem: IParticleSystem): void;
  85476. private _renderParticles;
  85477. private _renderSprites;
  85478. }
  85479. }
  85480. declare module BABYLON {
  85481. /**
  85482. * Interface describing the different options available in the rendering manager
  85483. * regarding Auto Clear between groups.
  85484. */
  85485. export interface IRenderingManagerAutoClearSetup {
  85486. /**
  85487. * Defines whether or not autoclear is enable.
  85488. */
  85489. autoClear: boolean;
  85490. /**
  85491. * Defines whether or not to autoclear the depth buffer.
  85492. */
  85493. depth: boolean;
  85494. /**
  85495. * Defines whether or not to autoclear the stencil buffer.
  85496. */
  85497. stencil: boolean;
  85498. }
  85499. /**
  85500. * This class is used by the onRenderingGroupObservable
  85501. */
  85502. export class RenderingGroupInfo {
  85503. /**
  85504. * The Scene that being rendered
  85505. */
  85506. scene: Scene;
  85507. /**
  85508. * The camera currently used for the rendering pass
  85509. */
  85510. camera: Nullable<Camera>;
  85511. /**
  85512. * The ID of the renderingGroup being processed
  85513. */
  85514. renderingGroupId: number;
  85515. }
  85516. /**
  85517. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85518. * It is enable to manage the different groups as well as the different necessary sort functions.
  85519. * This should not be used directly aside of the few static configurations
  85520. */
  85521. export class RenderingManager {
  85522. /**
  85523. * The max id used for rendering groups (not included)
  85524. */
  85525. static MAX_RENDERINGGROUPS: number;
  85526. /**
  85527. * The min id used for rendering groups (included)
  85528. */
  85529. static MIN_RENDERINGGROUPS: number;
  85530. /**
  85531. * Used to globally prevent autoclearing scenes.
  85532. */
  85533. static AUTOCLEAR: boolean;
  85534. /**
  85535. * @hidden
  85536. */
  85537. _useSceneAutoClearSetup: boolean;
  85538. private _scene;
  85539. private _renderingGroups;
  85540. private _depthStencilBufferAlreadyCleaned;
  85541. private _autoClearDepthStencil;
  85542. private _customOpaqueSortCompareFn;
  85543. private _customAlphaTestSortCompareFn;
  85544. private _customTransparentSortCompareFn;
  85545. private _renderingGroupInfo;
  85546. /**
  85547. * Instantiates a new rendering group for a particular scene
  85548. * @param scene Defines the scene the groups belongs to
  85549. */
  85550. constructor(scene: Scene);
  85551. private _clearDepthStencilBuffer;
  85552. /**
  85553. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85554. * @hidden
  85555. */
  85556. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85557. /**
  85558. * Resets the different information of the group to prepare a new frame
  85559. * @hidden
  85560. */
  85561. reset(): void;
  85562. /**
  85563. * Dispose and release the group and its associated resources.
  85564. * @hidden
  85565. */
  85566. dispose(): void;
  85567. /**
  85568. * Clear the info related to rendering groups preventing retention points during dispose.
  85569. */
  85570. freeRenderingGroups(): void;
  85571. private _prepareRenderingGroup;
  85572. /**
  85573. * Add a sprite manager to the rendering manager in order to render it this frame.
  85574. * @param spriteManager Define the sprite manager to render
  85575. */
  85576. dispatchSprites(spriteManager: ISpriteManager): void;
  85577. /**
  85578. * Add a particle system to the rendering manager in order to render it this frame.
  85579. * @param particleSystem Define the particle system to render
  85580. */
  85581. dispatchParticles(particleSystem: IParticleSystem): void;
  85582. /**
  85583. * Add a submesh to the manager in order to render it this frame
  85584. * @param subMesh The submesh to dispatch
  85585. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85586. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85587. */
  85588. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85589. /**
  85590. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85591. * This allowed control for front to back rendering or reversly depending of the special needs.
  85592. *
  85593. * @param renderingGroupId The rendering group id corresponding to its index
  85594. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85595. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85596. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85597. */
  85598. 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;
  85599. /**
  85600. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85601. *
  85602. * @param renderingGroupId The rendering group id corresponding to its index
  85603. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85604. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85605. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85606. */
  85607. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85608. /**
  85609. * Gets the current auto clear configuration for one rendering group of the rendering
  85610. * manager.
  85611. * @param index the rendering group index to get the information for
  85612. * @returns The auto clear setup for the requested rendering group
  85613. */
  85614. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85615. }
  85616. }
  85617. declare module BABYLON {
  85618. /**
  85619. * This Helps creating a texture that will be created from a camera in your scene.
  85620. * It is basically a dynamic texture that could be used to create special effects for instance.
  85621. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85622. */
  85623. export class RenderTargetTexture extends Texture {
  85624. isCube: boolean;
  85625. /**
  85626. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85627. */
  85628. static readonly REFRESHRATE_RENDER_ONCE: number;
  85629. /**
  85630. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85631. */
  85632. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85633. /**
  85634. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85635. * the central point of your effect and can save a lot of performances.
  85636. */
  85637. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85638. /**
  85639. * Use this predicate to dynamically define the list of mesh you want to render.
  85640. * If set, the renderList property will be overwritten.
  85641. */
  85642. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85643. private _renderList;
  85644. /**
  85645. * Use this list to define the list of mesh you want to render.
  85646. */
  85647. renderList: Nullable<Array<AbstractMesh>>;
  85648. private _hookArray;
  85649. /**
  85650. * Define if particles should be rendered in your texture.
  85651. */
  85652. renderParticles: boolean;
  85653. /**
  85654. * Define if sprites should be rendered in your texture.
  85655. */
  85656. renderSprites: boolean;
  85657. /**
  85658. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85659. */
  85660. coordinatesMode: number;
  85661. /**
  85662. * Define the camera used to render the texture.
  85663. */
  85664. activeCamera: Nullable<Camera>;
  85665. /**
  85666. * Override the render function of the texture with your own one.
  85667. */
  85668. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85669. /**
  85670. * Define if camera post processes should be use while rendering the texture.
  85671. */
  85672. useCameraPostProcesses: boolean;
  85673. /**
  85674. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85675. */
  85676. ignoreCameraViewport: boolean;
  85677. private _postProcessManager;
  85678. private _postProcesses;
  85679. private _resizeObserver;
  85680. /**
  85681. * An event triggered when the texture is unbind.
  85682. */
  85683. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85684. /**
  85685. * An event triggered when the texture is unbind.
  85686. */
  85687. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85688. private _onAfterUnbindObserver;
  85689. /**
  85690. * Set a after unbind callback in the texture.
  85691. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85692. */
  85693. onAfterUnbind: () => void;
  85694. /**
  85695. * An event triggered before rendering the texture
  85696. */
  85697. onBeforeRenderObservable: Observable<number>;
  85698. private _onBeforeRenderObserver;
  85699. /**
  85700. * Set a before render callback in the texture.
  85701. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85702. */
  85703. onBeforeRender: (faceIndex: number) => void;
  85704. /**
  85705. * An event triggered after rendering the texture
  85706. */
  85707. onAfterRenderObservable: Observable<number>;
  85708. private _onAfterRenderObserver;
  85709. /**
  85710. * Set a after render callback in the texture.
  85711. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85712. */
  85713. onAfterRender: (faceIndex: number) => void;
  85714. /**
  85715. * An event triggered after the texture clear
  85716. */
  85717. onClearObservable: Observable<Engine>;
  85718. private _onClearObserver;
  85719. /**
  85720. * Set a clear callback in the texture.
  85721. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85722. */
  85723. onClear: (Engine: Engine) => void;
  85724. /**
  85725. * An event triggered when the texture is resized.
  85726. */
  85727. onResizeObservable: Observable<RenderTargetTexture>;
  85728. /**
  85729. * Define the clear color of the Render Target if it should be different from the scene.
  85730. */
  85731. clearColor: Color4;
  85732. protected _size: number | {
  85733. width: number;
  85734. height: number;
  85735. };
  85736. protected _initialSizeParameter: number | {
  85737. width: number;
  85738. height: number;
  85739. } | {
  85740. ratio: number;
  85741. };
  85742. protected _sizeRatio: Nullable<number>;
  85743. /** @hidden */
  85744. _generateMipMaps: boolean;
  85745. protected _renderingManager: RenderingManager;
  85746. /** @hidden */
  85747. _waitingRenderList: string[];
  85748. protected _doNotChangeAspectRatio: boolean;
  85749. protected _currentRefreshId: number;
  85750. protected _refreshRate: number;
  85751. protected _textureMatrix: Matrix;
  85752. protected _samples: number;
  85753. protected _renderTargetOptions: RenderTargetCreationOptions;
  85754. /**
  85755. * Gets render target creation options that were used.
  85756. */
  85757. readonly renderTargetOptions: RenderTargetCreationOptions;
  85758. protected _engine: Engine;
  85759. protected _onRatioRescale(): void;
  85760. /**
  85761. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85762. * It must define where the camera used to render the texture is set
  85763. */
  85764. boundingBoxPosition: Vector3;
  85765. private _boundingBoxSize;
  85766. /**
  85767. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85768. * When defined, the cubemap will switch to local mode
  85769. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85770. * @example https://www.babylonjs-playground.com/#RNASML
  85771. */
  85772. boundingBoxSize: Vector3;
  85773. /**
  85774. * In case the RTT has been created with a depth texture, get the associated
  85775. * depth texture.
  85776. * Otherwise, return null.
  85777. */
  85778. depthStencilTexture: Nullable<InternalTexture>;
  85779. /**
  85780. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85781. * or used a shadow, depth texture...
  85782. * @param name The friendly name of the texture
  85783. * @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)
  85784. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85785. * @param generateMipMaps True if mip maps need to be generated after render.
  85786. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85787. * @param type The type of the buffer in the RTT (int, half float, float...)
  85788. * @param isCube True if a cube texture needs to be created
  85789. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85790. * @param generateDepthBuffer True to generate a depth buffer
  85791. * @param generateStencilBuffer True to generate a stencil buffer
  85792. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85793. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85794. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85795. */
  85796. constructor(name: string, size: number | {
  85797. width: number;
  85798. height: number;
  85799. } | {
  85800. ratio: number;
  85801. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85802. /**
  85803. * Creates a depth stencil texture.
  85804. * This is only available in WebGL 2 or with the depth texture extension available.
  85805. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85806. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85807. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85808. */
  85809. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85810. private _processSizeParameter;
  85811. /**
  85812. * Define the number of samples to use in case of MSAA.
  85813. * It defaults to one meaning no MSAA has been enabled.
  85814. */
  85815. samples: number;
  85816. /**
  85817. * Resets the refresh counter of the texture and start bak from scratch.
  85818. * Could be useful to regenerate the texture if it is setup to render only once.
  85819. */
  85820. resetRefreshCounter(): void;
  85821. /**
  85822. * Define the refresh rate of the texture or the rendering frequency.
  85823. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85824. */
  85825. refreshRate: number;
  85826. /**
  85827. * Adds a post process to the render target rendering passes.
  85828. * @param postProcess define the post process to add
  85829. */
  85830. addPostProcess(postProcess: PostProcess): void;
  85831. /**
  85832. * Clear all the post processes attached to the render target
  85833. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85834. */
  85835. clearPostProcesses(dispose?: boolean): void;
  85836. /**
  85837. * Remove one of the post process from the list of attached post processes to the texture
  85838. * @param postProcess define the post process to remove from the list
  85839. */
  85840. removePostProcess(postProcess: PostProcess): void;
  85841. /** @hidden */
  85842. _shouldRender(): boolean;
  85843. /**
  85844. * Gets the actual render size of the texture.
  85845. * @returns the width of the render size
  85846. */
  85847. getRenderSize(): number;
  85848. /**
  85849. * Gets the actual render width of the texture.
  85850. * @returns the width of the render size
  85851. */
  85852. getRenderWidth(): number;
  85853. /**
  85854. * Gets the actual render height of the texture.
  85855. * @returns the height of the render size
  85856. */
  85857. getRenderHeight(): number;
  85858. /**
  85859. * Get if the texture can be rescaled or not.
  85860. */
  85861. readonly canRescale: boolean;
  85862. /**
  85863. * Resize the texture using a ratio.
  85864. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85865. */
  85866. scale(ratio: number): void;
  85867. /**
  85868. * Get the texture reflection matrix used to rotate/transform the reflection.
  85869. * @returns the reflection matrix
  85870. */
  85871. getReflectionTextureMatrix(): Matrix;
  85872. /**
  85873. * Resize the texture to a new desired size.
  85874. * Be carrefull as it will recreate all the data in the new texture.
  85875. * @param size Define the new size. It can be:
  85876. * - a number for squared texture,
  85877. * - an object containing { width: number, height: number }
  85878. * - or an object containing a ratio { ratio: number }
  85879. */
  85880. resize(size: number | {
  85881. width: number;
  85882. height: number;
  85883. } | {
  85884. ratio: number;
  85885. }): void;
  85886. /**
  85887. * Renders all the objects from the render list into the texture.
  85888. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85889. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85890. */
  85891. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85892. private _bestReflectionRenderTargetDimension;
  85893. /**
  85894. * @hidden
  85895. * @param faceIndex face index to bind to if this is a cubetexture
  85896. */
  85897. _bindFrameBuffer(faceIndex?: number): void;
  85898. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85899. private renderToTarget;
  85900. /**
  85901. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85902. * This allowed control for front to back rendering or reversly depending of the special needs.
  85903. *
  85904. * @param renderingGroupId The rendering group id corresponding to its index
  85905. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85906. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85907. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85908. */
  85909. 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;
  85910. /**
  85911. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85912. *
  85913. * @param renderingGroupId The rendering group id corresponding to its index
  85914. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85915. */
  85916. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85917. /**
  85918. * Clones the texture.
  85919. * @returns the cloned texture
  85920. */
  85921. clone(): RenderTargetTexture;
  85922. /**
  85923. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85924. * @returns The JSON representation of the texture
  85925. */
  85926. serialize(): any;
  85927. /**
  85928. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85929. */
  85930. disposeFramebufferObjects(): void;
  85931. /**
  85932. * Dispose the texture and release its associated resources.
  85933. */
  85934. dispose(): void;
  85935. /** @hidden */
  85936. _rebuild(): void;
  85937. /**
  85938. * Clear the info related to rendering groups preventing retention point in material dispose.
  85939. */
  85940. freeRenderingGroups(): void;
  85941. /**
  85942. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85943. * @returns the view count
  85944. */
  85945. getViewCount(): number;
  85946. }
  85947. }
  85948. declare module BABYLON {
  85949. /**
  85950. * Base class for the main features of a material in Babylon.js
  85951. */
  85952. export class Material implements IAnimatable {
  85953. /**
  85954. * Returns the triangle fill mode
  85955. */
  85956. static readonly TriangleFillMode: number;
  85957. /**
  85958. * Returns the wireframe mode
  85959. */
  85960. static readonly WireFrameFillMode: number;
  85961. /**
  85962. * Returns the point fill mode
  85963. */
  85964. static readonly PointFillMode: number;
  85965. /**
  85966. * Returns the point list draw mode
  85967. */
  85968. static readonly PointListDrawMode: number;
  85969. /**
  85970. * Returns the line list draw mode
  85971. */
  85972. static readonly LineListDrawMode: number;
  85973. /**
  85974. * Returns the line loop draw mode
  85975. */
  85976. static readonly LineLoopDrawMode: number;
  85977. /**
  85978. * Returns the line strip draw mode
  85979. */
  85980. static readonly LineStripDrawMode: number;
  85981. /**
  85982. * Returns the triangle strip draw mode
  85983. */
  85984. static readonly TriangleStripDrawMode: number;
  85985. /**
  85986. * Returns the triangle fan draw mode
  85987. */
  85988. static readonly TriangleFanDrawMode: number;
  85989. /**
  85990. * Stores the clock-wise side orientation
  85991. */
  85992. static readonly ClockWiseSideOrientation: number;
  85993. /**
  85994. * Stores the counter clock-wise side orientation
  85995. */
  85996. static readonly CounterClockWiseSideOrientation: number;
  85997. /**
  85998. * The dirty texture flag value
  85999. */
  86000. static readonly TextureDirtyFlag: number;
  86001. /**
  86002. * The dirty light flag value
  86003. */
  86004. static readonly LightDirtyFlag: number;
  86005. /**
  86006. * The dirty fresnel flag value
  86007. */
  86008. static readonly FresnelDirtyFlag: number;
  86009. /**
  86010. * The dirty attribute flag value
  86011. */
  86012. static readonly AttributesDirtyFlag: number;
  86013. /**
  86014. * The dirty misc flag value
  86015. */
  86016. static readonly MiscDirtyFlag: number;
  86017. /**
  86018. * The all dirty flag value
  86019. */
  86020. static readonly AllDirtyFlag: number;
  86021. /**
  86022. * The ID of the material
  86023. */
  86024. id: string;
  86025. /**
  86026. * Gets or sets the unique id of the material
  86027. */
  86028. uniqueId: number;
  86029. /**
  86030. * The name of the material
  86031. */
  86032. name: string;
  86033. /**
  86034. * Gets or sets user defined metadata
  86035. */
  86036. metadata: any;
  86037. /**
  86038. * For internal use only. Please do not use.
  86039. */
  86040. reservedDataStore: any;
  86041. /**
  86042. * Specifies if the ready state should be checked on each call
  86043. */
  86044. checkReadyOnEveryCall: boolean;
  86045. /**
  86046. * Specifies if the ready state should be checked once
  86047. */
  86048. checkReadyOnlyOnce: boolean;
  86049. /**
  86050. * The state of the material
  86051. */
  86052. state: string;
  86053. /**
  86054. * The alpha value of the material
  86055. */
  86056. protected _alpha: number;
  86057. /**
  86058. * List of inspectable custom properties (used by the Inspector)
  86059. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86060. */
  86061. inspectableCustomProperties: IInspectable[];
  86062. /**
  86063. * Sets the alpha value of the material
  86064. */
  86065. /**
  86066. * Gets the alpha value of the material
  86067. */
  86068. alpha: number;
  86069. /**
  86070. * Specifies if back face culling is enabled
  86071. */
  86072. protected _backFaceCulling: boolean;
  86073. /**
  86074. * Sets the back-face culling state
  86075. */
  86076. /**
  86077. * Gets the back-face culling state
  86078. */
  86079. backFaceCulling: boolean;
  86080. /**
  86081. * Stores the value for side orientation
  86082. */
  86083. sideOrientation: number;
  86084. /**
  86085. * Callback triggered when the material is compiled
  86086. */
  86087. onCompiled: Nullable<(effect: Effect) => void>;
  86088. /**
  86089. * Callback triggered when an error occurs
  86090. */
  86091. onError: Nullable<(effect: Effect, errors: string) => void>;
  86092. /**
  86093. * Callback triggered to get the render target textures
  86094. */
  86095. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86096. /**
  86097. * Gets a boolean indicating that current material needs to register RTT
  86098. */
  86099. readonly hasRenderTargetTextures: boolean;
  86100. /**
  86101. * Specifies if the material should be serialized
  86102. */
  86103. doNotSerialize: boolean;
  86104. /**
  86105. * @hidden
  86106. */
  86107. _storeEffectOnSubMeshes: boolean;
  86108. /**
  86109. * Stores the animations for the material
  86110. */
  86111. animations: Nullable<Array<Animation>>;
  86112. /**
  86113. * An event triggered when the material is disposed
  86114. */
  86115. onDisposeObservable: Observable<Material>;
  86116. /**
  86117. * An observer which watches for dispose events
  86118. */
  86119. private _onDisposeObserver;
  86120. private _onUnBindObservable;
  86121. /**
  86122. * Called during a dispose event
  86123. */
  86124. onDispose: () => void;
  86125. private _onBindObservable;
  86126. /**
  86127. * An event triggered when the material is bound
  86128. */
  86129. readonly onBindObservable: Observable<AbstractMesh>;
  86130. /**
  86131. * An observer which watches for bind events
  86132. */
  86133. private _onBindObserver;
  86134. /**
  86135. * Called during a bind event
  86136. */
  86137. onBind: (Mesh: AbstractMesh) => void;
  86138. /**
  86139. * An event triggered when the material is unbound
  86140. */
  86141. readonly onUnBindObservable: Observable<Material>;
  86142. /**
  86143. * Stores the value of the alpha mode
  86144. */
  86145. private _alphaMode;
  86146. /**
  86147. * Sets the value of the alpha mode.
  86148. *
  86149. * | Value | Type | Description |
  86150. * | --- | --- | --- |
  86151. * | 0 | ALPHA_DISABLE | |
  86152. * | 1 | ALPHA_ADD | |
  86153. * | 2 | ALPHA_COMBINE | |
  86154. * | 3 | ALPHA_SUBTRACT | |
  86155. * | 4 | ALPHA_MULTIPLY | |
  86156. * | 5 | ALPHA_MAXIMIZED | |
  86157. * | 6 | ALPHA_ONEONE | |
  86158. * | 7 | ALPHA_PREMULTIPLIED | |
  86159. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86160. * | 9 | ALPHA_INTERPOLATE | |
  86161. * | 10 | ALPHA_SCREENMODE | |
  86162. *
  86163. */
  86164. /**
  86165. * Gets the value of the alpha mode
  86166. */
  86167. alphaMode: number;
  86168. /**
  86169. * Stores the state of the need depth pre-pass value
  86170. */
  86171. private _needDepthPrePass;
  86172. /**
  86173. * Sets the need depth pre-pass value
  86174. */
  86175. /**
  86176. * Gets the depth pre-pass value
  86177. */
  86178. needDepthPrePass: boolean;
  86179. /**
  86180. * Specifies if depth writing should be disabled
  86181. */
  86182. disableDepthWrite: boolean;
  86183. /**
  86184. * Specifies if depth writing should be forced
  86185. */
  86186. forceDepthWrite: boolean;
  86187. /**
  86188. * Specifies if there should be a separate pass for culling
  86189. */
  86190. separateCullingPass: boolean;
  86191. /**
  86192. * Stores the state specifing if fog should be enabled
  86193. */
  86194. private _fogEnabled;
  86195. /**
  86196. * Sets the state for enabling fog
  86197. */
  86198. /**
  86199. * Gets the value of the fog enabled state
  86200. */
  86201. fogEnabled: boolean;
  86202. /**
  86203. * Stores the size of points
  86204. */
  86205. pointSize: number;
  86206. /**
  86207. * Stores the z offset value
  86208. */
  86209. zOffset: number;
  86210. /**
  86211. * Gets a value specifying if wireframe mode is enabled
  86212. */
  86213. /**
  86214. * Sets the state of wireframe mode
  86215. */
  86216. wireframe: boolean;
  86217. /**
  86218. * Gets the value specifying if point clouds are enabled
  86219. */
  86220. /**
  86221. * Sets the state of point cloud mode
  86222. */
  86223. pointsCloud: boolean;
  86224. /**
  86225. * Gets the material fill mode
  86226. */
  86227. /**
  86228. * Sets the material fill mode
  86229. */
  86230. fillMode: number;
  86231. /**
  86232. * @hidden
  86233. * Stores the effects for the material
  86234. */
  86235. _effect: Nullable<Effect>;
  86236. /**
  86237. * @hidden
  86238. * Specifies if the material was previously ready
  86239. */
  86240. _wasPreviouslyReady: boolean;
  86241. /**
  86242. * Specifies if uniform buffers should be used
  86243. */
  86244. private _useUBO;
  86245. /**
  86246. * Stores a reference to the scene
  86247. */
  86248. private _scene;
  86249. /**
  86250. * Stores the fill mode state
  86251. */
  86252. private _fillMode;
  86253. /**
  86254. * Specifies if the depth write state should be cached
  86255. */
  86256. private _cachedDepthWriteState;
  86257. /**
  86258. * Stores the uniform buffer
  86259. */
  86260. protected _uniformBuffer: UniformBuffer;
  86261. /** @hidden */
  86262. _indexInSceneMaterialArray: number;
  86263. /** @hidden */
  86264. meshMap: Nullable<{
  86265. [id: string]: AbstractMesh | undefined;
  86266. }>;
  86267. /**
  86268. * Creates a material instance
  86269. * @param name defines the name of the material
  86270. * @param scene defines the scene to reference
  86271. * @param doNotAdd specifies if the material should be added to the scene
  86272. */
  86273. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86274. /**
  86275. * Returns a string representation of the current material
  86276. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86277. * @returns a string with material information
  86278. */
  86279. toString(fullDetails?: boolean): string;
  86280. /**
  86281. * Gets the class name of the material
  86282. * @returns a string with the class name of the material
  86283. */
  86284. getClassName(): string;
  86285. /**
  86286. * Specifies if updates for the material been locked
  86287. */
  86288. readonly isFrozen: boolean;
  86289. /**
  86290. * Locks updates for the material
  86291. */
  86292. freeze(): void;
  86293. /**
  86294. * Unlocks updates for the material
  86295. */
  86296. unfreeze(): void;
  86297. /**
  86298. * Specifies if the material is ready to be used
  86299. * @param mesh defines the mesh to check
  86300. * @param useInstances specifies if instances should be used
  86301. * @returns a boolean indicating if the material is ready to be used
  86302. */
  86303. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86304. /**
  86305. * Specifies that the submesh is ready to be used
  86306. * @param mesh defines the mesh to check
  86307. * @param subMesh defines which submesh to check
  86308. * @param useInstances specifies that instances should be used
  86309. * @returns a boolean indicating that the submesh is ready or not
  86310. */
  86311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86312. /**
  86313. * Returns the material effect
  86314. * @returns the effect associated with the material
  86315. */
  86316. getEffect(): Nullable<Effect>;
  86317. /**
  86318. * Returns the current scene
  86319. * @returns a Scene
  86320. */
  86321. getScene(): Scene;
  86322. /**
  86323. * Specifies if the material will require alpha blending
  86324. * @returns a boolean specifying if alpha blending is needed
  86325. */
  86326. needAlphaBlending(): boolean;
  86327. /**
  86328. * Specifies if the mesh will require alpha blending
  86329. * @param mesh defines the mesh to check
  86330. * @returns a boolean specifying if alpha blending is needed for the mesh
  86331. */
  86332. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86333. /**
  86334. * Specifies if this material should be rendered in alpha test mode
  86335. * @returns a boolean specifying if an alpha test is needed.
  86336. */
  86337. needAlphaTesting(): boolean;
  86338. /**
  86339. * Gets the texture used for the alpha test
  86340. * @returns the texture to use for alpha testing
  86341. */
  86342. getAlphaTestTexture(): Nullable<BaseTexture>;
  86343. /**
  86344. * Marks the material to indicate that it needs to be re-calculated
  86345. */
  86346. markDirty(): void;
  86347. /** @hidden */
  86348. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86349. /**
  86350. * Binds the material to the mesh
  86351. * @param world defines the world transformation matrix
  86352. * @param mesh defines the mesh to bind the material to
  86353. */
  86354. bind(world: Matrix, mesh?: Mesh): void;
  86355. /**
  86356. * Binds the submesh to the material
  86357. * @param world defines the world transformation matrix
  86358. * @param mesh defines the mesh containing the submesh
  86359. * @param subMesh defines the submesh to bind the material to
  86360. */
  86361. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86362. /**
  86363. * Binds the world matrix to the material
  86364. * @param world defines the world transformation matrix
  86365. */
  86366. bindOnlyWorldMatrix(world: Matrix): void;
  86367. /**
  86368. * Binds the scene's uniform buffer to the effect.
  86369. * @param effect defines the effect to bind to the scene uniform buffer
  86370. * @param sceneUbo defines the uniform buffer storing scene data
  86371. */
  86372. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86373. /**
  86374. * Binds the view matrix to the effect
  86375. * @param effect defines the effect to bind the view matrix to
  86376. */
  86377. bindView(effect: Effect): void;
  86378. /**
  86379. * Binds the view projection matrix to the effect
  86380. * @param effect defines the effect to bind the view projection matrix to
  86381. */
  86382. bindViewProjection(effect: Effect): void;
  86383. /**
  86384. * Specifies if material alpha testing should be turned on for the mesh
  86385. * @param mesh defines the mesh to check
  86386. */
  86387. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86388. /**
  86389. * Processes to execute after binding the material to a mesh
  86390. * @param mesh defines the rendered mesh
  86391. */
  86392. protected _afterBind(mesh?: Mesh): void;
  86393. /**
  86394. * Unbinds the material from the mesh
  86395. */
  86396. unbind(): void;
  86397. /**
  86398. * Gets the active textures from the material
  86399. * @returns an array of textures
  86400. */
  86401. getActiveTextures(): BaseTexture[];
  86402. /**
  86403. * Specifies if the material uses a texture
  86404. * @param texture defines the texture to check against the material
  86405. * @returns a boolean specifying if the material uses the texture
  86406. */
  86407. hasTexture(texture: BaseTexture): boolean;
  86408. /**
  86409. * Makes a duplicate of the material, and gives it a new name
  86410. * @param name defines the new name for the duplicated material
  86411. * @returns the cloned material
  86412. */
  86413. clone(name: string): Nullable<Material>;
  86414. /**
  86415. * Gets the meshes bound to the material
  86416. * @returns an array of meshes bound to the material
  86417. */
  86418. getBindedMeshes(): AbstractMesh[];
  86419. /**
  86420. * Force shader compilation
  86421. * @param mesh defines the mesh associated with this material
  86422. * @param onCompiled defines a function to execute once the material is compiled
  86423. * @param options defines the options to configure the compilation
  86424. */
  86425. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86426. clipPlane: boolean;
  86427. }>): void;
  86428. /**
  86429. * Force shader compilation
  86430. * @param mesh defines the mesh that will use this material
  86431. * @param options defines additional options for compiling the shaders
  86432. * @returns a promise that resolves when the compilation completes
  86433. */
  86434. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86435. clipPlane: boolean;
  86436. }>): Promise<void>;
  86437. private static readonly _AllDirtyCallBack;
  86438. private static readonly _ImageProcessingDirtyCallBack;
  86439. private static readonly _TextureDirtyCallBack;
  86440. private static readonly _FresnelDirtyCallBack;
  86441. private static readonly _MiscDirtyCallBack;
  86442. private static readonly _LightsDirtyCallBack;
  86443. private static readonly _AttributeDirtyCallBack;
  86444. private static _FresnelAndMiscDirtyCallBack;
  86445. private static _TextureAndMiscDirtyCallBack;
  86446. private static readonly _DirtyCallbackArray;
  86447. private static readonly _RunDirtyCallBacks;
  86448. /**
  86449. * Marks a define in the material to indicate that it needs to be re-computed
  86450. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86451. */
  86452. markAsDirty(flag: number): void;
  86453. /**
  86454. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86455. * @param func defines a function which checks material defines against the submeshes
  86456. */
  86457. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86458. /**
  86459. * Indicates that we need to re-calculated for all submeshes
  86460. */
  86461. protected _markAllSubMeshesAsAllDirty(): void;
  86462. /**
  86463. * Indicates that image processing needs to be re-calculated for all submeshes
  86464. */
  86465. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86466. /**
  86467. * Indicates that textures need to be re-calculated for all submeshes
  86468. */
  86469. protected _markAllSubMeshesAsTexturesDirty(): void;
  86470. /**
  86471. * Indicates that fresnel needs to be re-calculated for all submeshes
  86472. */
  86473. protected _markAllSubMeshesAsFresnelDirty(): void;
  86474. /**
  86475. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86476. */
  86477. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86478. /**
  86479. * Indicates that lights need to be re-calculated for all submeshes
  86480. */
  86481. protected _markAllSubMeshesAsLightsDirty(): void;
  86482. /**
  86483. * Indicates that attributes need to be re-calculated for all submeshes
  86484. */
  86485. protected _markAllSubMeshesAsAttributesDirty(): void;
  86486. /**
  86487. * Indicates that misc needs to be re-calculated for all submeshes
  86488. */
  86489. protected _markAllSubMeshesAsMiscDirty(): void;
  86490. /**
  86491. * Indicates that textures and misc need to be re-calculated for all submeshes
  86492. */
  86493. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86494. /**
  86495. * Disposes the material
  86496. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86497. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86498. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86499. */
  86500. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86501. /** @hidden */
  86502. private releaseVertexArrayObject;
  86503. /**
  86504. * Serializes this material
  86505. * @returns the serialized material object
  86506. */
  86507. serialize(): any;
  86508. /**
  86509. * Creates a material from parsed material data
  86510. * @param parsedMaterial defines parsed material data
  86511. * @param scene defines the hosting scene
  86512. * @param rootUrl defines the root URL to use to load textures
  86513. * @returns a new material
  86514. */
  86515. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86516. }
  86517. }
  86518. declare module BABYLON {
  86519. /**
  86520. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86521. * separate meshes. This can be use to improve performances.
  86522. * @see http://doc.babylonjs.com/how_to/multi_materials
  86523. */
  86524. export class MultiMaterial extends Material {
  86525. private _subMaterials;
  86526. /**
  86527. * Gets or Sets the list of Materials used within the multi material.
  86528. * They need to be ordered according to the submeshes order in the associated mesh
  86529. */
  86530. subMaterials: Nullable<Material>[];
  86531. /**
  86532. * Function used to align with Node.getChildren()
  86533. * @returns the list of Materials used within the multi material
  86534. */
  86535. getChildren(): Nullable<Material>[];
  86536. /**
  86537. * Instantiates a new Multi Material
  86538. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86539. * separate meshes. This can be use to improve performances.
  86540. * @see http://doc.babylonjs.com/how_to/multi_materials
  86541. * @param name Define the name in the scene
  86542. * @param scene Define the scene the material belongs to
  86543. */
  86544. constructor(name: string, scene: Scene);
  86545. private _hookArray;
  86546. /**
  86547. * Get one of the submaterial by its index in the submaterials array
  86548. * @param index The index to look the sub material at
  86549. * @returns The Material if the index has been defined
  86550. */
  86551. getSubMaterial(index: number): Nullable<Material>;
  86552. /**
  86553. * Get the list of active textures for the whole sub materials list.
  86554. * @returns All the textures that will be used during the rendering
  86555. */
  86556. getActiveTextures(): BaseTexture[];
  86557. /**
  86558. * Gets the current class name of the material e.g. "MultiMaterial"
  86559. * Mainly use in serialization.
  86560. * @returns the class name
  86561. */
  86562. getClassName(): string;
  86563. /**
  86564. * Checks if the material is ready to render the requested sub mesh
  86565. * @param mesh Define the mesh the submesh belongs to
  86566. * @param subMesh Define the sub mesh to look readyness for
  86567. * @param useInstances Define whether or not the material is used with instances
  86568. * @returns true if ready, otherwise false
  86569. */
  86570. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86571. /**
  86572. * Clones the current material and its related sub materials
  86573. * @param name Define the name of the newly cloned material
  86574. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86575. * @returns the cloned material
  86576. */
  86577. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86578. /**
  86579. * Serializes the materials into a JSON representation.
  86580. * @returns the JSON representation
  86581. */
  86582. serialize(): any;
  86583. /**
  86584. * Dispose the material and release its associated resources
  86585. * @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)
  86586. * @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)
  86587. * @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)
  86588. */
  86589. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86590. /**
  86591. * Creates a MultiMaterial from parsed MultiMaterial data.
  86592. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86593. * @param scene defines the hosting scene
  86594. * @returns a new MultiMaterial
  86595. */
  86596. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86597. }
  86598. }
  86599. declare module BABYLON {
  86600. /**
  86601. * Base class for submeshes
  86602. */
  86603. export class BaseSubMesh {
  86604. /** @hidden */
  86605. _materialDefines: Nullable<MaterialDefines>;
  86606. /** @hidden */
  86607. _materialEffect: Nullable<Effect>;
  86608. /**
  86609. * Gets associated effect
  86610. */
  86611. readonly effect: Nullable<Effect>;
  86612. /**
  86613. * Sets associated effect (effect used to render this submesh)
  86614. * @param effect defines the effect to associate with
  86615. * @param defines defines the set of defines used to compile this effect
  86616. */
  86617. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86618. }
  86619. /**
  86620. * Defines a subdivision inside a mesh
  86621. */
  86622. export class SubMesh extends BaseSubMesh implements ICullable {
  86623. /** the material index to use */
  86624. materialIndex: number;
  86625. /** vertex index start */
  86626. verticesStart: number;
  86627. /** vertices count */
  86628. verticesCount: number;
  86629. /** index start */
  86630. indexStart: number;
  86631. /** indices count */
  86632. indexCount: number;
  86633. /** @hidden */
  86634. _linesIndexCount: number;
  86635. private _mesh;
  86636. private _renderingMesh;
  86637. private _boundingInfo;
  86638. private _linesIndexBuffer;
  86639. /** @hidden */
  86640. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86641. /** @hidden */
  86642. _trianglePlanes: Plane[];
  86643. /** @hidden */
  86644. _lastColliderTransformMatrix: Nullable<Matrix>;
  86645. /** @hidden */
  86646. _renderId: number;
  86647. /** @hidden */
  86648. _alphaIndex: number;
  86649. /** @hidden */
  86650. _distanceToCamera: number;
  86651. /** @hidden */
  86652. _id: number;
  86653. private _currentMaterial;
  86654. /**
  86655. * Add a new submesh to a mesh
  86656. * @param materialIndex defines the material index to use
  86657. * @param verticesStart defines vertex index start
  86658. * @param verticesCount defines vertices count
  86659. * @param indexStart defines index start
  86660. * @param indexCount defines indices count
  86661. * @param mesh defines the parent mesh
  86662. * @param renderingMesh defines an optional rendering mesh
  86663. * @param createBoundingBox defines if bounding box should be created for this submesh
  86664. * @returns the new submesh
  86665. */
  86666. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86667. /**
  86668. * Creates a new submesh
  86669. * @param materialIndex defines the material index to use
  86670. * @param verticesStart defines vertex index start
  86671. * @param verticesCount defines vertices count
  86672. * @param indexStart defines index start
  86673. * @param indexCount defines indices count
  86674. * @param mesh defines the parent mesh
  86675. * @param renderingMesh defines an optional rendering mesh
  86676. * @param createBoundingBox defines if bounding box should be created for this submesh
  86677. */
  86678. constructor(
  86679. /** the material index to use */
  86680. materialIndex: number,
  86681. /** vertex index start */
  86682. verticesStart: number,
  86683. /** vertices count */
  86684. verticesCount: number,
  86685. /** index start */
  86686. indexStart: number,
  86687. /** indices count */
  86688. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86689. /**
  86690. * Returns true if this submesh covers the entire parent mesh
  86691. * @ignorenaming
  86692. */
  86693. readonly IsGlobal: boolean;
  86694. /**
  86695. * Returns the submesh BoudingInfo object
  86696. * @returns current bounding info (or mesh's one if the submesh is global)
  86697. */
  86698. getBoundingInfo(): BoundingInfo;
  86699. /**
  86700. * Sets the submesh BoundingInfo
  86701. * @param boundingInfo defines the new bounding info to use
  86702. * @returns the SubMesh
  86703. */
  86704. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86705. /**
  86706. * Returns the mesh of the current submesh
  86707. * @return the parent mesh
  86708. */
  86709. getMesh(): AbstractMesh;
  86710. /**
  86711. * Returns the rendering mesh of the submesh
  86712. * @returns the rendering mesh (could be different from parent mesh)
  86713. */
  86714. getRenderingMesh(): Mesh;
  86715. /**
  86716. * Returns the submesh material
  86717. * @returns null or the current material
  86718. */
  86719. getMaterial(): Nullable<Material>;
  86720. /**
  86721. * Sets a new updated BoundingInfo object to the submesh
  86722. * @param data defines an optional position array to use to determine the bounding info
  86723. * @returns the SubMesh
  86724. */
  86725. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86726. /** @hidden */
  86727. _checkCollision(collider: Collider): boolean;
  86728. /**
  86729. * Updates the submesh BoundingInfo
  86730. * @param world defines the world matrix to use to update the bounding info
  86731. * @returns the submesh
  86732. */
  86733. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86734. /**
  86735. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86736. * @param frustumPlanes defines the frustum planes
  86737. * @returns true if the submesh is intersecting with the frustum
  86738. */
  86739. isInFrustum(frustumPlanes: Plane[]): boolean;
  86740. /**
  86741. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86742. * @param frustumPlanes defines the frustum planes
  86743. * @returns true if the submesh is inside the frustum
  86744. */
  86745. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86746. /**
  86747. * Renders the submesh
  86748. * @param enableAlphaMode defines if alpha needs to be used
  86749. * @returns the submesh
  86750. */
  86751. render(enableAlphaMode: boolean): SubMesh;
  86752. /**
  86753. * @hidden
  86754. */
  86755. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86756. /**
  86757. * Checks if the submesh intersects with a ray
  86758. * @param ray defines the ray to test
  86759. * @returns true is the passed ray intersects the submesh bounding box
  86760. */
  86761. canIntersects(ray: Ray): boolean;
  86762. /**
  86763. * Intersects current submesh with a ray
  86764. * @param ray defines the ray to test
  86765. * @param positions defines mesh's positions array
  86766. * @param indices defines mesh's indices array
  86767. * @param fastCheck defines if only bounding info should be used
  86768. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86769. * @returns intersection info or null if no intersection
  86770. */
  86771. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86772. /** @hidden */
  86773. private _intersectLines;
  86774. /** @hidden */
  86775. private _intersectUnIndexedLines;
  86776. /** @hidden */
  86777. private _intersectTriangles;
  86778. /** @hidden */
  86779. private _intersectUnIndexedTriangles;
  86780. /** @hidden */
  86781. _rebuild(): void;
  86782. /**
  86783. * Creates a new submesh from the passed mesh
  86784. * @param newMesh defines the new hosting mesh
  86785. * @param newRenderingMesh defines an optional rendering mesh
  86786. * @returns the new submesh
  86787. */
  86788. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86789. /**
  86790. * Release associated resources
  86791. */
  86792. dispose(): void;
  86793. /**
  86794. * Gets the class name
  86795. * @returns the string "SubMesh".
  86796. */
  86797. getClassName(): string;
  86798. /**
  86799. * Creates a new submesh from indices data
  86800. * @param materialIndex the index of the main mesh material
  86801. * @param startIndex the index where to start the copy in the mesh indices array
  86802. * @param indexCount the number of indices to copy then from the startIndex
  86803. * @param mesh the main mesh to create the submesh from
  86804. * @param renderingMesh the optional rendering mesh
  86805. * @returns a new submesh
  86806. */
  86807. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86808. }
  86809. }
  86810. declare module BABYLON {
  86811. /**
  86812. * Class used to represent data loading progression
  86813. */
  86814. export class SceneLoaderFlags {
  86815. private static _ForceFullSceneLoadingForIncremental;
  86816. private static _ShowLoadingScreen;
  86817. private static _CleanBoneMatrixWeights;
  86818. private static _loggingLevel;
  86819. /**
  86820. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86821. */
  86822. static ForceFullSceneLoadingForIncremental: boolean;
  86823. /**
  86824. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86825. */
  86826. static ShowLoadingScreen: boolean;
  86827. /**
  86828. * Defines the current logging level (while loading the scene)
  86829. * @ignorenaming
  86830. */
  86831. static loggingLevel: number;
  86832. /**
  86833. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86834. */
  86835. static CleanBoneMatrixWeights: boolean;
  86836. }
  86837. }
  86838. declare module BABYLON {
  86839. /**
  86840. * Class used to store geometry data (vertex buffers + index buffer)
  86841. */
  86842. export class Geometry implements IGetSetVerticesData {
  86843. /**
  86844. * Gets or sets the ID of the geometry
  86845. */
  86846. id: string;
  86847. /**
  86848. * Gets or sets the unique ID of the geometry
  86849. */
  86850. uniqueId: number;
  86851. /**
  86852. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86853. */
  86854. delayLoadState: number;
  86855. /**
  86856. * Gets the file containing the data to load when running in delay load state
  86857. */
  86858. delayLoadingFile: Nullable<string>;
  86859. /**
  86860. * Callback called when the geometry is updated
  86861. */
  86862. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86863. private _scene;
  86864. private _engine;
  86865. private _meshes;
  86866. private _totalVertices;
  86867. /** @hidden */
  86868. _indices: IndicesArray;
  86869. /** @hidden */
  86870. _vertexBuffers: {
  86871. [key: string]: VertexBuffer;
  86872. };
  86873. private _isDisposed;
  86874. private _extend;
  86875. private _boundingBias;
  86876. /** @hidden */
  86877. _delayInfo: Array<string>;
  86878. private _indexBuffer;
  86879. private _indexBufferIsUpdatable;
  86880. /** @hidden */
  86881. _boundingInfo: Nullable<BoundingInfo>;
  86882. /** @hidden */
  86883. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86884. /** @hidden */
  86885. _softwareSkinningFrameId: number;
  86886. private _vertexArrayObjects;
  86887. private _updatable;
  86888. /** @hidden */
  86889. _positions: Nullable<Vector3[]>;
  86890. /**
  86891. * 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
  86892. */
  86893. /**
  86894. * 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
  86895. */
  86896. boundingBias: Vector2;
  86897. /**
  86898. * Static function used to attach a new empty geometry to a mesh
  86899. * @param mesh defines the mesh to attach the geometry to
  86900. * @returns the new Geometry
  86901. */
  86902. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86903. /**
  86904. * Creates a new geometry
  86905. * @param id defines the unique ID
  86906. * @param scene defines the hosting scene
  86907. * @param vertexData defines the VertexData used to get geometry data
  86908. * @param updatable defines if geometry must be updatable (false by default)
  86909. * @param mesh defines the mesh that will be associated with the geometry
  86910. */
  86911. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86912. /**
  86913. * Gets the current extend of the geometry
  86914. */
  86915. readonly extend: {
  86916. minimum: Vector3;
  86917. maximum: Vector3;
  86918. };
  86919. /**
  86920. * Gets the hosting scene
  86921. * @returns the hosting Scene
  86922. */
  86923. getScene(): Scene;
  86924. /**
  86925. * Gets the hosting engine
  86926. * @returns the hosting Engine
  86927. */
  86928. getEngine(): Engine;
  86929. /**
  86930. * Defines if the geometry is ready to use
  86931. * @returns true if the geometry is ready to be used
  86932. */
  86933. isReady(): boolean;
  86934. /**
  86935. * Gets a value indicating that the geometry should not be serialized
  86936. */
  86937. readonly doNotSerialize: boolean;
  86938. /** @hidden */
  86939. _rebuild(): void;
  86940. /**
  86941. * Affects all geometry data in one call
  86942. * @param vertexData defines the geometry data
  86943. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86944. */
  86945. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86946. /**
  86947. * Set specific vertex data
  86948. * @param kind defines the data kind (Position, normal, etc...)
  86949. * @param data defines the vertex data to use
  86950. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86951. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86952. */
  86953. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86954. /**
  86955. * Removes a specific vertex data
  86956. * @param kind defines the data kind (Position, normal, etc...)
  86957. */
  86958. removeVerticesData(kind: string): void;
  86959. /**
  86960. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86961. * @param buffer defines the vertex buffer to use
  86962. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86963. */
  86964. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86965. /**
  86966. * Update a specific vertex buffer
  86967. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86968. * It will do nothing if the buffer is not updatable
  86969. * @param kind defines the data kind (Position, normal, etc...)
  86970. * @param data defines the data to use
  86971. * @param offset defines the offset in the target buffer where to store the data
  86972. * @param useBytes set to true if the offset is in bytes
  86973. */
  86974. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86975. /**
  86976. * Update a specific vertex buffer
  86977. * This function will create a new buffer if the current one is not updatable
  86978. * @param kind defines the data kind (Position, normal, etc...)
  86979. * @param data defines the data to use
  86980. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86981. */
  86982. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86983. private _updateBoundingInfo;
  86984. /** @hidden */
  86985. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86986. /**
  86987. * Gets total number of vertices
  86988. * @returns the total number of vertices
  86989. */
  86990. getTotalVertices(): number;
  86991. /**
  86992. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86993. * @param kind defines the data kind (Position, normal, etc...)
  86994. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86996. * @returns a float array containing vertex data
  86997. */
  86998. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86999. /**
  87000. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87001. * @param kind defines the data kind (Position, normal, etc...)
  87002. * @returns true if the vertex buffer with the specified kind is updatable
  87003. */
  87004. isVertexBufferUpdatable(kind: string): boolean;
  87005. /**
  87006. * Gets a specific vertex buffer
  87007. * @param kind defines the data kind (Position, normal, etc...)
  87008. * @returns a VertexBuffer
  87009. */
  87010. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87011. /**
  87012. * Returns all vertex buffers
  87013. * @return an object holding all vertex buffers indexed by kind
  87014. */
  87015. getVertexBuffers(): Nullable<{
  87016. [key: string]: VertexBuffer;
  87017. }>;
  87018. /**
  87019. * Gets a boolean indicating if specific vertex buffer is present
  87020. * @param kind defines the data kind (Position, normal, etc...)
  87021. * @returns true if data is present
  87022. */
  87023. isVerticesDataPresent(kind: string): boolean;
  87024. /**
  87025. * Gets a list of all attached data kinds (Position, normal, etc...)
  87026. * @returns a list of string containing all kinds
  87027. */
  87028. getVerticesDataKinds(): string[];
  87029. /**
  87030. * Update index buffer
  87031. * @param indices defines the indices to store in the index buffer
  87032. * @param offset defines the offset in the target buffer where to store the data
  87033. * @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)
  87034. */
  87035. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87036. /**
  87037. * Creates a new index buffer
  87038. * @param indices defines the indices to store in the index buffer
  87039. * @param totalVertices defines the total number of vertices (could be null)
  87040. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87041. */
  87042. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87043. /**
  87044. * Return the total number of indices
  87045. * @returns the total number of indices
  87046. */
  87047. getTotalIndices(): number;
  87048. /**
  87049. * Gets the index buffer array
  87050. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87051. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87052. * @returns the index buffer array
  87053. */
  87054. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87055. /**
  87056. * Gets the index buffer
  87057. * @return the index buffer
  87058. */
  87059. getIndexBuffer(): Nullable<DataBuffer>;
  87060. /** @hidden */
  87061. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87062. /**
  87063. * Release the associated resources for a specific mesh
  87064. * @param mesh defines the source mesh
  87065. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87066. */
  87067. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87068. /**
  87069. * Apply current geometry to a given mesh
  87070. * @param mesh defines the mesh to apply geometry to
  87071. */
  87072. applyToMesh(mesh: Mesh): void;
  87073. private _updateExtend;
  87074. private _applyToMesh;
  87075. private notifyUpdate;
  87076. /**
  87077. * Load the geometry if it was flagged as delay loaded
  87078. * @param scene defines the hosting scene
  87079. * @param onLoaded defines a callback called when the geometry is loaded
  87080. */
  87081. load(scene: Scene, onLoaded?: () => void): void;
  87082. private _queueLoad;
  87083. /**
  87084. * Invert the geometry to move from a right handed system to a left handed one.
  87085. */
  87086. toLeftHanded(): void;
  87087. /** @hidden */
  87088. _resetPointsArrayCache(): void;
  87089. /** @hidden */
  87090. _generatePointsArray(): boolean;
  87091. /**
  87092. * Gets a value indicating if the geometry is disposed
  87093. * @returns true if the geometry was disposed
  87094. */
  87095. isDisposed(): boolean;
  87096. private _disposeVertexArrayObjects;
  87097. /**
  87098. * Free all associated resources
  87099. */
  87100. dispose(): void;
  87101. /**
  87102. * Clone the current geometry into a new geometry
  87103. * @param id defines the unique ID of the new geometry
  87104. * @returns a new geometry object
  87105. */
  87106. copy(id: string): Geometry;
  87107. /**
  87108. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87109. * @return a JSON representation of the current geometry data (without the vertices data)
  87110. */
  87111. serialize(): any;
  87112. private toNumberArray;
  87113. /**
  87114. * Serialize all vertices data into a JSON oject
  87115. * @returns a JSON representation of the current geometry data
  87116. */
  87117. serializeVerticeData(): any;
  87118. /**
  87119. * Extracts a clone of a mesh geometry
  87120. * @param mesh defines the source mesh
  87121. * @param id defines the unique ID of the new geometry object
  87122. * @returns the new geometry object
  87123. */
  87124. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87125. /**
  87126. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87127. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87128. * Be aware Math.random() could cause collisions, but:
  87129. * "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"
  87130. * @returns a string containing a new GUID
  87131. */
  87132. static RandomId(): string;
  87133. /** @hidden */
  87134. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87135. private static _CleanMatricesWeights;
  87136. /**
  87137. * Create a new geometry from persisted data (Using .babylon file format)
  87138. * @param parsedVertexData defines the persisted data
  87139. * @param scene defines the hosting scene
  87140. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87141. * @returns the new geometry object
  87142. */
  87143. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87144. }
  87145. }
  87146. declare module BABYLON {
  87147. /**
  87148. * Define an interface for all classes that will get and set the data on vertices
  87149. */
  87150. export interface IGetSetVerticesData {
  87151. /**
  87152. * Gets a boolean indicating if specific vertex data is present
  87153. * @param kind defines the vertex data kind to use
  87154. * @returns true is data kind is present
  87155. */
  87156. isVerticesDataPresent(kind: string): boolean;
  87157. /**
  87158. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87159. * @param kind defines the data kind (Position, normal, etc...)
  87160. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87161. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87162. * @returns a float array containing vertex data
  87163. */
  87164. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87165. /**
  87166. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87167. * @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.
  87168. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87169. * @returns the indices array or an empty array if the mesh has no geometry
  87170. */
  87171. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87172. /**
  87173. * Set specific vertex data
  87174. * @param kind defines the data kind (Position, normal, etc...)
  87175. * @param data defines the vertex data to use
  87176. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87177. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87178. */
  87179. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87180. /**
  87181. * Update a specific associated vertex buffer
  87182. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87183. * - VertexBuffer.PositionKind
  87184. * - VertexBuffer.UVKind
  87185. * - VertexBuffer.UV2Kind
  87186. * - VertexBuffer.UV3Kind
  87187. * - VertexBuffer.UV4Kind
  87188. * - VertexBuffer.UV5Kind
  87189. * - VertexBuffer.UV6Kind
  87190. * - VertexBuffer.ColorKind
  87191. * - VertexBuffer.MatricesIndicesKind
  87192. * - VertexBuffer.MatricesIndicesExtraKind
  87193. * - VertexBuffer.MatricesWeightsKind
  87194. * - VertexBuffer.MatricesWeightsExtraKind
  87195. * @param data defines the data source
  87196. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87197. * @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)
  87198. */
  87199. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87200. /**
  87201. * Creates a new index buffer
  87202. * @param indices defines the indices to store in the index buffer
  87203. * @param totalVertices defines the total number of vertices (could be null)
  87204. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87205. */
  87206. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87207. }
  87208. /**
  87209. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87210. */
  87211. export class VertexData {
  87212. /**
  87213. * Mesh side orientation : usually the external or front surface
  87214. */
  87215. static readonly FRONTSIDE: number;
  87216. /**
  87217. * Mesh side orientation : usually the internal or back surface
  87218. */
  87219. static readonly BACKSIDE: number;
  87220. /**
  87221. * Mesh side orientation : both internal and external or front and back surfaces
  87222. */
  87223. static readonly DOUBLESIDE: number;
  87224. /**
  87225. * Mesh side orientation : by default, `FRONTSIDE`
  87226. */
  87227. static readonly DEFAULTSIDE: number;
  87228. /**
  87229. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87230. */
  87231. positions: Nullable<FloatArray>;
  87232. /**
  87233. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87234. */
  87235. normals: Nullable<FloatArray>;
  87236. /**
  87237. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87238. */
  87239. tangents: Nullable<FloatArray>;
  87240. /**
  87241. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87242. */
  87243. uvs: Nullable<FloatArray>;
  87244. /**
  87245. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87246. */
  87247. uvs2: Nullable<FloatArray>;
  87248. /**
  87249. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87250. */
  87251. uvs3: Nullable<FloatArray>;
  87252. /**
  87253. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87254. */
  87255. uvs4: Nullable<FloatArray>;
  87256. /**
  87257. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87258. */
  87259. uvs5: Nullable<FloatArray>;
  87260. /**
  87261. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87262. */
  87263. uvs6: Nullable<FloatArray>;
  87264. /**
  87265. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87266. */
  87267. colors: Nullable<FloatArray>;
  87268. /**
  87269. * 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).
  87270. */
  87271. matricesIndices: Nullable<FloatArray>;
  87272. /**
  87273. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87274. */
  87275. matricesWeights: Nullable<FloatArray>;
  87276. /**
  87277. * An array extending the number of possible indices
  87278. */
  87279. matricesIndicesExtra: Nullable<FloatArray>;
  87280. /**
  87281. * An array extending the number of possible weights when the number of indices is extended
  87282. */
  87283. matricesWeightsExtra: Nullable<FloatArray>;
  87284. /**
  87285. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87286. */
  87287. indices: Nullable<IndicesArray>;
  87288. /**
  87289. * Uses the passed data array to set the set the values for the specified kind of data
  87290. * @param data a linear array of floating numbers
  87291. * @param kind the type of data that is being set, eg positions, colors etc
  87292. */
  87293. set(data: FloatArray, kind: string): void;
  87294. /**
  87295. * Associates the vertexData to the passed Mesh.
  87296. * Sets it as updatable or not (default `false`)
  87297. * @param mesh the mesh the vertexData is applied to
  87298. * @param updatable when used and having the value true allows new data to update the vertexData
  87299. * @returns the VertexData
  87300. */
  87301. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87302. /**
  87303. * Associates the vertexData to the passed Geometry.
  87304. * Sets it as updatable or not (default `false`)
  87305. * @param geometry the geometry the vertexData is applied to
  87306. * @param updatable when used and having the value true allows new data to update the vertexData
  87307. * @returns VertexData
  87308. */
  87309. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87310. /**
  87311. * Updates the associated mesh
  87312. * @param mesh the mesh to be updated
  87313. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87314. * @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
  87315. * @returns VertexData
  87316. */
  87317. updateMesh(mesh: Mesh): VertexData;
  87318. /**
  87319. * Updates the associated geometry
  87320. * @param geometry the geometry to be updated
  87321. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87322. * @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
  87323. * @returns VertexData.
  87324. */
  87325. updateGeometry(geometry: Geometry): VertexData;
  87326. private _applyTo;
  87327. private _update;
  87328. /**
  87329. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87330. * @param matrix the transforming matrix
  87331. * @returns the VertexData
  87332. */
  87333. transform(matrix: Matrix): VertexData;
  87334. /**
  87335. * Merges the passed VertexData into the current one
  87336. * @param other the VertexData to be merged into the current one
  87337. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87338. * @returns the modified VertexData
  87339. */
  87340. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87341. private _mergeElement;
  87342. private _validate;
  87343. /**
  87344. * Serializes the VertexData
  87345. * @returns a serialized object
  87346. */
  87347. serialize(): any;
  87348. /**
  87349. * Extracts the vertexData from a mesh
  87350. * @param mesh the mesh from which to extract the VertexData
  87351. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87352. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87353. * @returns the object VertexData associated to the passed mesh
  87354. */
  87355. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87356. /**
  87357. * Extracts the vertexData from the geometry
  87358. * @param geometry the geometry from which to extract the VertexData
  87359. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87360. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87361. * @returns the object VertexData associated to the passed mesh
  87362. */
  87363. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87364. private static _ExtractFrom;
  87365. /**
  87366. * Creates the VertexData for a Ribbon
  87367. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87368. * * pathArray array of paths, each of which an array of successive Vector3
  87369. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87370. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87371. * * 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
  87372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87373. * * 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)
  87374. * * 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)
  87375. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87376. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87377. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87378. * @returns the VertexData of the ribbon
  87379. */
  87380. static CreateRibbon(options: {
  87381. pathArray: Vector3[][];
  87382. closeArray?: boolean;
  87383. closePath?: boolean;
  87384. offset?: number;
  87385. sideOrientation?: number;
  87386. frontUVs?: Vector4;
  87387. backUVs?: Vector4;
  87388. invertUV?: boolean;
  87389. uvs?: Vector2[];
  87390. colors?: Color4[];
  87391. }): VertexData;
  87392. /**
  87393. * Creates the VertexData for a box
  87394. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87395. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87396. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87397. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87398. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87399. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87400. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87402. * * 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)
  87403. * * 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)
  87404. * @returns the VertexData of the box
  87405. */
  87406. static CreateBox(options: {
  87407. size?: number;
  87408. width?: number;
  87409. height?: number;
  87410. depth?: number;
  87411. faceUV?: Vector4[];
  87412. faceColors?: Color4[];
  87413. sideOrientation?: number;
  87414. frontUVs?: Vector4;
  87415. backUVs?: Vector4;
  87416. }): VertexData;
  87417. /**
  87418. * Creates the VertexData for a tiled box
  87419. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87420. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87421. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87422. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87423. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87424. * @returns the VertexData of the box
  87425. */
  87426. static CreateTiledBox(options: {
  87427. pattern?: number;
  87428. width?: number;
  87429. height?: number;
  87430. depth?: number;
  87431. tileSize?: number;
  87432. tileWidth?: number;
  87433. tileHeight?: number;
  87434. alignHorizontal?: number;
  87435. alignVertical?: number;
  87436. faceUV?: Vector4[];
  87437. faceColors?: Color4[];
  87438. sideOrientation?: number;
  87439. }): VertexData;
  87440. /**
  87441. * Creates the VertexData for a tiled plane
  87442. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87443. * * pattern a limited pattern arrangement depending on the number
  87444. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87445. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87446. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87448. * * 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)
  87449. * * 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)
  87450. * @returns the VertexData of the tiled plane
  87451. */
  87452. static CreateTiledPlane(options: {
  87453. pattern?: number;
  87454. tileSize?: number;
  87455. tileWidth?: number;
  87456. tileHeight?: number;
  87457. size?: number;
  87458. width?: number;
  87459. height?: number;
  87460. alignHorizontal?: number;
  87461. alignVertical?: number;
  87462. sideOrientation?: number;
  87463. frontUVs?: Vector4;
  87464. backUVs?: Vector4;
  87465. }): VertexData;
  87466. /**
  87467. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87469. * * segments sets the number of horizontal strips optional, default 32
  87470. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87471. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87472. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87473. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87474. * * 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
  87475. * * 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
  87476. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87477. * * 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)
  87478. * * 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)
  87479. * @returns the VertexData of the ellipsoid
  87480. */
  87481. static CreateSphere(options: {
  87482. segments?: number;
  87483. diameter?: number;
  87484. diameterX?: number;
  87485. diameterY?: number;
  87486. diameterZ?: number;
  87487. arc?: number;
  87488. slice?: number;
  87489. sideOrientation?: number;
  87490. frontUVs?: Vector4;
  87491. backUVs?: Vector4;
  87492. }): VertexData;
  87493. /**
  87494. * Creates the VertexData for a cylinder, cone or prism
  87495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87496. * * height sets the height (y direction) of the cylinder, optional, default 2
  87497. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87498. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87499. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87500. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87501. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87502. * * 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
  87503. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87504. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87505. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87506. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87508. * * 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)
  87509. * * 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)
  87510. * @returns the VertexData of the cylinder, cone or prism
  87511. */
  87512. static CreateCylinder(options: {
  87513. height?: number;
  87514. diameterTop?: number;
  87515. diameterBottom?: number;
  87516. diameter?: number;
  87517. tessellation?: number;
  87518. subdivisions?: number;
  87519. arc?: number;
  87520. faceColors?: Color4[];
  87521. faceUV?: Vector4[];
  87522. hasRings?: boolean;
  87523. enclose?: boolean;
  87524. sideOrientation?: number;
  87525. frontUVs?: Vector4;
  87526. backUVs?: Vector4;
  87527. }): VertexData;
  87528. /**
  87529. * Creates the VertexData for a torus
  87530. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87531. * * diameter the diameter of the torus, optional default 1
  87532. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87533. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87535. * * 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)
  87536. * * 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)
  87537. * @returns the VertexData of the torus
  87538. */
  87539. static CreateTorus(options: {
  87540. diameter?: number;
  87541. thickness?: number;
  87542. tessellation?: number;
  87543. sideOrientation?: number;
  87544. frontUVs?: Vector4;
  87545. backUVs?: Vector4;
  87546. }): VertexData;
  87547. /**
  87548. * Creates the VertexData of the LineSystem
  87549. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87550. * - lines an array of lines, each line being an array of successive Vector3
  87551. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87552. * @returns the VertexData of the LineSystem
  87553. */
  87554. static CreateLineSystem(options: {
  87555. lines: Vector3[][];
  87556. colors?: Nullable<Color4[][]>;
  87557. }): VertexData;
  87558. /**
  87559. * Create the VertexData for a DashedLines
  87560. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87561. * - points an array successive Vector3
  87562. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87563. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87564. * - dashNb the intended total number of dashes, optional, default 200
  87565. * @returns the VertexData for the DashedLines
  87566. */
  87567. static CreateDashedLines(options: {
  87568. points: Vector3[];
  87569. dashSize?: number;
  87570. gapSize?: number;
  87571. dashNb?: number;
  87572. }): VertexData;
  87573. /**
  87574. * Creates the VertexData for a Ground
  87575. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87576. * - width the width (x direction) of the ground, optional, default 1
  87577. * - height the height (z direction) of the ground, optional, default 1
  87578. * - subdivisions the number of subdivisions per side, optional, default 1
  87579. * @returns the VertexData of the Ground
  87580. */
  87581. static CreateGround(options: {
  87582. width?: number;
  87583. height?: number;
  87584. subdivisions?: number;
  87585. subdivisionsX?: number;
  87586. subdivisionsY?: number;
  87587. }): VertexData;
  87588. /**
  87589. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87590. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87591. * * xmin the ground minimum X coordinate, optional, default -1
  87592. * * zmin the ground minimum Z coordinate, optional, default -1
  87593. * * xmax the ground maximum X coordinate, optional, default 1
  87594. * * zmax the ground maximum Z coordinate, optional, default 1
  87595. * * 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}
  87596. * * 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}
  87597. * @returns the VertexData of the TiledGround
  87598. */
  87599. static CreateTiledGround(options: {
  87600. xmin: number;
  87601. zmin: number;
  87602. xmax: number;
  87603. zmax: number;
  87604. subdivisions?: {
  87605. w: number;
  87606. h: number;
  87607. };
  87608. precision?: {
  87609. w: number;
  87610. h: number;
  87611. };
  87612. }): VertexData;
  87613. /**
  87614. * Creates the VertexData of the Ground designed from a heightmap
  87615. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87616. * * width the width (x direction) of the ground
  87617. * * height the height (z direction) of the ground
  87618. * * subdivisions the number of subdivisions per side
  87619. * * minHeight the minimum altitude on the ground, optional, default 0
  87620. * * maxHeight the maximum altitude on the ground, optional default 1
  87621. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87622. * * buffer the array holding the image color data
  87623. * * bufferWidth the width of image
  87624. * * bufferHeight the height of image
  87625. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87626. * @returns the VertexData of the Ground designed from a heightmap
  87627. */
  87628. static CreateGroundFromHeightMap(options: {
  87629. width: number;
  87630. height: number;
  87631. subdivisions: number;
  87632. minHeight: number;
  87633. maxHeight: number;
  87634. colorFilter: Color3;
  87635. buffer: Uint8Array;
  87636. bufferWidth: number;
  87637. bufferHeight: number;
  87638. alphaFilter: number;
  87639. }): VertexData;
  87640. /**
  87641. * Creates the VertexData for a Plane
  87642. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87643. * * size sets the width and height of the plane to the value of size, optional default 1
  87644. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87645. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87646. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87647. * * 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)
  87648. * * 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)
  87649. * @returns the VertexData of the box
  87650. */
  87651. static CreatePlane(options: {
  87652. size?: number;
  87653. width?: number;
  87654. height?: number;
  87655. sideOrientation?: number;
  87656. frontUVs?: Vector4;
  87657. backUVs?: Vector4;
  87658. }): VertexData;
  87659. /**
  87660. * Creates the VertexData of the Disc or regular Polygon
  87661. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87662. * * radius the radius of the disc, optional default 0.5
  87663. * * tessellation the number of polygon sides, optional, default 64
  87664. * * 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
  87665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87666. * * 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)
  87667. * * 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)
  87668. * @returns the VertexData of the box
  87669. */
  87670. static CreateDisc(options: {
  87671. radius?: number;
  87672. tessellation?: number;
  87673. arc?: number;
  87674. sideOrientation?: number;
  87675. frontUVs?: Vector4;
  87676. backUVs?: Vector4;
  87677. }): VertexData;
  87678. /**
  87679. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87680. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87681. * @param polygon a mesh built from polygonTriangulation.build()
  87682. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87683. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87684. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87685. * @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)
  87686. * @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)
  87687. * @returns the VertexData of the Polygon
  87688. */
  87689. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87690. /**
  87691. * Creates the VertexData of the IcoSphere
  87692. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87693. * * radius the radius of the IcoSphere, optional default 1
  87694. * * radiusX allows stretching in the x direction, optional, default radius
  87695. * * radiusY allows stretching in the y direction, optional, default radius
  87696. * * radiusZ allows stretching in the z direction, optional, default radius
  87697. * * flat when true creates a flat shaded mesh, optional, default true
  87698. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87699. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87700. * * 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)
  87701. * * 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)
  87702. * @returns the VertexData of the IcoSphere
  87703. */
  87704. static CreateIcoSphere(options: {
  87705. radius?: number;
  87706. radiusX?: number;
  87707. radiusY?: number;
  87708. radiusZ?: number;
  87709. flat?: boolean;
  87710. subdivisions?: number;
  87711. sideOrientation?: number;
  87712. frontUVs?: Vector4;
  87713. backUVs?: Vector4;
  87714. }): VertexData;
  87715. /**
  87716. * Creates the VertexData for a Polyhedron
  87717. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87718. * * type provided types are:
  87719. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87720. * * 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)
  87721. * * size the size of the IcoSphere, optional default 1
  87722. * * sizeX allows stretching in the x direction, optional, default size
  87723. * * sizeY allows stretching in the y direction, optional, default size
  87724. * * sizeZ allows stretching in the z direction, optional, default size
  87725. * * 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
  87726. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87727. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87728. * * flat when true creates a flat shaded mesh, optional, default true
  87729. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87731. * * 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)
  87732. * * 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)
  87733. * @returns the VertexData of the Polyhedron
  87734. */
  87735. static CreatePolyhedron(options: {
  87736. type?: number;
  87737. size?: number;
  87738. sizeX?: number;
  87739. sizeY?: number;
  87740. sizeZ?: number;
  87741. custom?: any;
  87742. faceUV?: Vector4[];
  87743. faceColors?: Color4[];
  87744. flat?: boolean;
  87745. sideOrientation?: number;
  87746. frontUVs?: Vector4;
  87747. backUVs?: Vector4;
  87748. }): VertexData;
  87749. /**
  87750. * Creates the VertexData for a TorusKnot
  87751. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87752. * * radius the radius of the torus knot, optional, default 2
  87753. * * tube the thickness of the tube, optional, default 0.5
  87754. * * radialSegments the number of sides on each tube segments, optional, default 32
  87755. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87756. * * p the number of windings around the z axis, optional, default 2
  87757. * * q the number of windings around the x axis, optional, default 3
  87758. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87759. * * 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)
  87760. * * 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)
  87761. * @returns the VertexData of the Torus Knot
  87762. */
  87763. static CreateTorusKnot(options: {
  87764. radius?: number;
  87765. tube?: number;
  87766. radialSegments?: number;
  87767. tubularSegments?: number;
  87768. p?: number;
  87769. q?: number;
  87770. sideOrientation?: number;
  87771. frontUVs?: Vector4;
  87772. backUVs?: Vector4;
  87773. }): VertexData;
  87774. /**
  87775. * Compute normals for given positions and indices
  87776. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87777. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87778. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87779. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87780. * * facetNormals : optional array of facet normals (vector3)
  87781. * * facetPositions : optional array of facet positions (vector3)
  87782. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87783. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87784. * * bInfo : optional bounding info, required for facetPartitioning computation
  87785. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87786. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87787. * * useRightHandedSystem: optional boolean to for right handed system computation
  87788. * * depthSort : optional boolean to enable the facet depth sort computation
  87789. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87790. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87791. */
  87792. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87793. facetNormals?: any;
  87794. facetPositions?: any;
  87795. facetPartitioning?: any;
  87796. ratio?: number;
  87797. bInfo?: any;
  87798. bbSize?: Vector3;
  87799. subDiv?: any;
  87800. useRightHandedSystem?: boolean;
  87801. depthSort?: boolean;
  87802. distanceTo?: Vector3;
  87803. depthSortedFacets?: any;
  87804. }): void;
  87805. /** @hidden */
  87806. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87807. /**
  87808. * Applies VertexData created from the imported parameters to the geometry
  87809. * @param parsedVertexData the parsed data from an imported file
  87810. * @param geometry the geometry to apply the VertexData to
  87811. */
  87812. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87813. }
  87814. }
  87815. declare module BABYLON {
  87816. /**
  87817. * Defines a target to use with MorphTargetManager
  87818. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87819. */
  87820. export class MorphTarget implements IAnimatable {
  87821. /** defines the name of the target */
  87822. name: string;
  87823. /**
  87824. * Gets or sets the list of animations
  87825. */
  87826. animations: Animation[];
  87827. private _scene;
  87828. private _positions;
  87829. private _normals;
  87830. private _tangents;
  87831. private _uvs;
  87832. private _influence;
  87833. /**
  87834. * Observable raised when the influence changes
  87835. */
  87836. onInfluenceChanged: Observable<boolean>;
  87837. /** @hidden */
  87838. _onDataLayoutChanged: Observable<void>;
  87839. /**
  87840. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87841. */
  87842. influence: number;
  87843. /**
  87844. * Gets or sets the id of the morph Target
  87845. */
  87846. id: string;
  87847. private _animationPropertiesOverride;
  87848. /**
  87849. * Gets or sets the animation properties override
  87850. */
  87851. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87852. /**
  87853. * Creates a new MorphTarget
  87854. * @param name defines the name of the target
  87855. * @param influence defines the influence to use
  87856. * @param scene defines the scene the morphtarget belongs to
  87857. */
  87858. constructor(
  87859. /** defines the name of the target */
  87860. name: string, influence?: number, scene?: Nullable<Scene>);
  87861. /**
  87862. * Gets a boolean defining if the target contains position data
  87863. */
  87864. readonly hasPositions: boolean;
  87865. /**
  87866. * Gets a boolean defining if the target contains normal data
  87867. */
  87868. readonly hasNormals: boolean;
  87869. /**
  87870. * Gets a boolean defining if the target contains tangent data
  87871. */
  87872. readonly hasTangents: boolean;
  87873. /**
  87874. * Gets a boolean defining if the target contains texture coordinates data
  87875. */
  87876. readonly hasUVs: boolean;
  87877. /**
  87878. * Affects position data to this target
  87879. * @param data defines the position data to use
  87880. */
  87881. setPositions(data: Nullable<FloatArray>): void;
  87882. /**
  87883. * Gets the position data stored in this target
  87884. * @returns a FloatArray containing the position data (or null if not present)
  87885. */
  87886. getPositions(): Nullable<FloatArray>;
  87887. /**
  87888. * Affects normal data to this target
  87889. * @param data defines the normal data to use
  87890. */
  87891. setNormals(data: Nullable<FloatArray>): void;
  87892. /**
  87893. * Gets the normal data stored in this target
  87894. * @returns a FloatArray containing the normal data (or null if not present)
  87895. */
  87896. getNormals(): Nullable<FloatArray>;
  87897. /**
  87898. * Affects tangent data to this target
  87899. * @param data defines the tangent data to use
  87900. */
  87901. setTangents(data: Nullable<FloatArray>): void;
  87902. /**
  87903. * Gets the tangent data stored in this target
  87904. * @returns a FloatArray containing the tangent data (or null if not present)
  87905. */
  87906. getTangents(): Nullable<FloatArray>;
  87907. /**
  87908. * Affects texture coordinates data to this target
  87909. * @param data defines the texture coordinates data to use
  87910. */
  87911. setUVs(data: Nullable<FloatArray>): void;
  87912. /**
  87913. * Gets the texture coordinates data stored in this target
  87914. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87915. */
  87916. getUVs(): Nullable<FloatArray>;
  87917. /**
  87918. * Serializes the current target into a Serialization object
  87919. * @returns the serialized object
  87920. */
  87921. serialize(): any;
  87922. /**
  87923. * Returns the string "MorphTarget"
  87924. * @returns "MorphTarget"
  87925. */
  87926. getClassName(): string;
  87927. /**
  87928. * Creates a new target from serialized data
  87929. * @param serializationObject defines the serialized data to use
  87930. * @returns a new MorphTarget
  87931. */
  87932. static Parse(serializationObject: any): MorphTarget;
  87933. /**
  87934. * Creates a MorphTarget from mesh data
  87935. * @param mesh defines the source mesh
  87936. * @param name defines the name to use for the new target
  87937. * @param influence defines the influence to attach to the target
  87938. * @returns a new MorphTarget
  87939. */
  87940. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87941. }
  87942. }
  87943. declare module BABYLON {
  87944. /**
  87945. * This class is used to deform meshes using morphing between different targets
  87946. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87947. */
  87948. export class MorphTargetManager {
  87949. private _targets;
  87950. private _targetInfluenceChangedObservers;
  87951. private _targetDataLayoutChangedObservers;
  87952. private _activeTargets;
  87953. private _scene;
  87954. private _influences;
  87955. private _supportsNormals;
  87956. private _supportsTangents;
  87957. private _supportsUVs;
  87958. private _vertexCount;
  87959. private _uniqueId;
  87960. private _tempInfluences;
  87961. /**
  87962. * Gets or sets a boolean indicating if normals must be morphed
  87963. */
  87964. enableNormalMorphing: boolean;
  87965. /**
  87966. * Gets or sets a boolean indicating if tangents must be morphed
  87967. */
  87968. enableTangentMorphing: boolean;
  87969. /**
  87970. * Gets or sets a boolean indicating if UV must be morphed
  87971. */
  87972. enableUVMorphing: boolean;
  87973. /**
  87974. * Creates a new MorphTargetManager
  87975. * @param scene defines the current scene
  87976. */
  87977. constructor(scene?: Nullable<Scene>);
  87978. /**
  87979. * Gets the unique ID of this manager
  87980. */
  87981. readonly uniqueId: number;
  87982. /**
  87983. * Gets the number of vertices handled by this manager
  87984. */
  87985. readonly vertexCount: number;
  87986. /**
  87987. * Gets a boolean indicating if this manager supports morphing of normals
  87988. */
  87989. readonly supportsNormals: boolean;
  87990. /**
  87991. * Gets a boolean indicating if this manager supports morphing of tangents
  87992. */
  87993. readonly supportsTangents: boolean;
  87994. /**
  87995. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87996. */
  87997. readonly supportsUVs: boolean;
  87998. /**
  87999. * Gets the number of targets stored in this manager
  88000. */
  88001. readonly numTargets: number;
  88002. /**
  88003. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88004. */
  88005. readonly numInfluencers: number;
  88006. /**
  88007. * Gets the list of influences (one per target)
  88008. */
  88009. readonly influences: Float32Array;
  88010. /**
  88011. * Gets the active target at specified index. An active target is a target with an influence > 0
  88012. * @param index defines the index to check
  88013. * @returns the requested target
  88014. */
  88015. getActiveTarget(index: number): MorphTarget;
  88016. /**
  88017. * Gets the target at specified index
  88018. * @param index defines the index to check
  88019. * @returns the requested target
  88020. */
  88021. getTarget(index: number): MorphTarget;
  88022. /**
  88023. * Add a new target to this manager
  88024. * @param target defines the target to add
  88025. */
  88026. addTarget(target: MorphTarget): void;
  88027. /**
  88028. * Removes a target from the manager
  88029. * @param target defines the target to remove
  88030. */
  88031. removeTarget(target: MorphTarget): void;
  88032. /**
  88033. * Serializes the current manager into a Serialization object
  88034. * @returns the serialized object
  88035. */
  88036. serialize(): any;
  88037. private _syncActiveTargets;
  88038. /**
  88039. * Syncrhonize the targets with all the meshes using this morph target manager
  88040. */
  88041. synchronize(): void;
  88042. /**
  88043. * Creates a new MorphTargetManager from serialized data
  88044. * @param serializationObject defines the serialized data
  88045. * @param scene defines the hosting scene
  88046. * @returns the new MorphTargetManager
  88047. */
  88048. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88049. }
  88050. }
  88051. declare module BABYLON {
  88052. /**
  88053. * Class used to represent a specific level of detail of a mesh
  88054. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88055. */
  88056. export class MeshLODLevel {
  88057. /** Defines the distance where this level should start being displayed */
  88058. distance: number;
  88059. /** Defines the mesh to use to render this level */
  88060. mesh: Nullable<Mesh>;
  88061. /**
  88062. * Creates a new LOD level
  88063. * @param distance defines the distance where this level should star being displayed
  88064. * @param mesh defines the mesh to use to render this level
  88065. */
  88066. constructor(
  88067. /** Defines the distance where this level should start being displayed */
  88068. distance: number,
  88069. /** Defines the mesh to use to render this level */
  88070. mesh: Nullable<Mesh>);
  88071. }
  88072. }
  88073. declare module BABYLON {
  88074. /**
  88075. * Mesh representing the gorund
  88076. */
  88077. export class GroundMesh extends Mesh {
  88078. /** If octree should be generated */
  88079. generateOctree: boolean;
  88080. private _heightQuads;
  88081. /** @hidden */
  88082. _subdivisionsX: number;
  88083. /** @hidden */
  88084. _subdivisionsY: number;
  88085. /** @hidden */
  88086. _width: number;
  88087. /** @hidden */
  88088. _height: number;
  88089. /** @hidden */
  88090. _minX: number;
  88091. /** @hidden */
  88092. _maxX: number;
  88093. /** @hidden */
  88094. _minZ: number;
  88095. /** @hidden */
  88096. _maxZ: number;
  88097. constructor(name: string, scene: Scene);
  88098. /**
  88099. * "GroundMesh"
  88100. * @returns "GroundMesh"
  88101. */
  88102. getClassName(): string;
  88103. /**
  88104. * The minimum of x and y subdivisions
  88105. */
  88106. readonly subdivisions: number;
  88107. /**
  88108. * X subdivisions
  88109. */
  88110. readonly subdivisionsX: number;
  88111. /**
  88112. * Y subdivisions
  88113. */
  88114. readonly subdivisionsY: number;
  88115. /**
  88116. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88117. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88118. * @param chunksCount the number of subdivisions for x and y
  88119. * @param octreeBlocksSize (Default: 32)
  88120. */
  88121. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  88122. /**
  88123. * Returns a height (y) value in the Worl system :
  88124. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88125. * @param x x coordinate
  88126. * @param z z coordinate
  88127. * @returns the ground y position if (x, z) are outside the ground surface.
  88128. */
  88129. getHeightAtCoordinates(x: number, z: number): number;
  88130. /**
  88131. * Returns a normalized vector (Vector3) orthogonal to the ground
  88132. * at the ground coordinates (x, z) expressed in the World system.
  88133. * @param x x coordinate
  88134. * @param z z coordinate
  88135. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88136. */
  88137. getNormalAtCoordinates(x: number, z: number): Vector3;
  88138. /**
  88139. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88140. * at the ground coordinates (x, z) expressed in the World system.
  88141. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88142. * @param x x coordinate
  88143. * @param z z coordinate
  88144. * @param ref vector to store the result
  88145. * @returns the GroundMesh.
  88146. */
  88147. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88148. /**
  88149. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88150. * if the ground has been updated.
  88151. * This can be used in the render loop.
  88152. * @returns the GroundMesh.
  88153. */
  88154. updateCoordinateHeights(): GroundMesh;
  88155. private _getFacetAt;
  88156. private _initHeightQuads;
  88157. private _computeHeightQuads;
  88158. /**
  88159. * Serializes this ground mesh
  88160. * @param serializationObject object to write serialization to
  88161. */
  88162. serialize(serializationObject: any): void;
  88163. /**
  88164. * Parses a serialized ground mesh
  88165. * @param parsedMesh the serialized mesh
  88166. * @param scene the scene to create the ground mesh in
  88167. * @returns the created ground mesh
  88168. */
  88169. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88170. }
  88171. }
  88172. declare module BABYLON {
  88173. /**
  88174. * Interface for Physics-Joint data
  88175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88176. */
  88177. export interface PhysicsJointData {
  88178. /**
  88179. * The main pivot of the joint
  88180. */
  88181. mainPivot?: Vector3;
  88182. /**
  88183. * The connected pivot of the joint
  88184. */
  88185. connectedPivot?: Vector3;
  88186. /**
  88187. * The main axis of the joint
  88188. */
  88189. mainAxis?: Vector3;
  88190. /**
  88191. * The connected axis of the joint
  88192. */
  88193. connectedAxis?: Vector3;
  88194. /**
  88195. * The collision of the joint
  88196. */
  88197. collision?: boolean;
  88198. /**
  88199. * Native Oimo/Cannon/Energy data
  88200. */
  88201. nativeParams?: any;
  88202. }
  88203. /**
  88204. * This is a holder class for the physics joint created by the physics plugin
  88205. * It holds a set of functions to control the underlying joint
  88206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88207. */
  88208. export class PhysicsJoint {
  88209. /**
  88210. * The type of the physics joint
  88211. */
  88212. type: number;
  88213. /**
  88214. * The data for the physics joint
  88215. */
  88216. jointData: PhysicsJointData;
  88217. private _physicsJoint;
  88218. protected _physicsPlugin: IPhysicsEnginePlugin;
  88219. /**
  88220. * Initializes the physics joint
  88221. * @param type The type of the physics joint
  88222. * @param jointData The data for the physics joint
  88223. */
  88224. constructor(
  88225. /**
  88226. * The type of the physics joint
  88227. */
  88228. type: number,
  88229. /**
  88230. * The data for the physics joint
  88231. */
  88232. jointData: PhysicsJointData);
  88233. /**
  88234. * Gets the physics joint
  88235. */
  88236. /**
  88237. * Sets the physics joint
  88238. */
  88239. physicsJoint: any;
  88240. /**
  88241. * Sets the physics plugin
  88242. */
  88243. physicsPlugin: IPhysicsEnginePlugin;
  88244. /**
  88245. * Execute a function that is physics-plugin specific.
  88246. * @param {Function} func the function that will be executed.
  88247. * It accepts two parameters: the physics world and the physics joint
  88248. */
  88249. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88250. /**
  88251. * Distance-Joint type
  88252. */
  88253. static DistanceJoint: number;
  88254. /**
  88255. * Hinge-Joint type
  88256. */
  88257. static HingeJoint: number;
  88258. /**
  88259. * Ball-and-Socket joint type
  88260. */
  88261. static BallAndSocketJoint: number;
  88262. /**
  88263. * Wheel-Joint type
  88264. */
  88265. static WheelJoint: number;
  88266. /**
  88267. * Slider-Joint type
  88268. */
  88269. static SliderJoint: number;
  88270. /**
  88271. * Prismatic-Joint type
  88272. */
  88273. static PrismaticJoint: number;
  88274. /**
  88275. * Universal-Joint type
  88276. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88277. */
  88278. static UniversalJoint: number;
  88279. /**
  88280. * Hinge-Joint 2 type
  88281. */
  88282. static Hinge2Joint: number;
  88283. /**
  88284. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88285. */
  88286. static PointToPointJoint: number;
  88287. /**
  88288. * Spring-Joint type
  88289. */
  88290. static SpringJoint: number;
  88291. /**
  88292. * Lock-Joint type
  88293. */
  88294. static LockJoint: number;
  88295. }
  88296. /**
  88297. * A class representing a physics distance joint
  88298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88299. */
  88300. export class DistanceJoint extends PhysicsJoint {
  88301. /**
  88302. *
  88303. * @param jointData The data for the Distance-Joint
  88304. */
  88305. constructor(jointData: DistanceJointData);
  88306. /**
  88307. * Update the predefined distance.
  88308. * @param maxDistance The maximum preferred distance
  88309. * @param minDistance The minimum preferred distance
  88310. */
  88311. updateDistance(maxDistance: number, minDistance?: number): void;
  88312. }
  88313. /**
  88314. * Represents a Motor-Enabled Joint
  88315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88316. */
  88317. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88318. /**
  88319. * Initializes the Motor-Enabled Joint
  88320. * @param type The type of the joint
  88321. * @param jointData The physica joint data for the joint
  88322. */
  88323. constructor(type: number, jointData: PhysicsJointData);
  88324. /**
  88325. * Set the motor values.
  88326. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88327. * @param force the force to apply
  88328. * @param maxForce max force for this motor.
  88329. */
  88330. setMotor(force?: number, maxForce?: number): void;
  88331. /**
  88332. * Set the motor's limits.
  88333. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88334. * @param upperLimit The upper limit of the motor
  88335. * @param lowerLimit The lower limit of the motor
  88336. */
  88337. setLimit(upperLimit: number, lowerLimit?: number): void;
  88338. }
  88339. /**
  88340. * This class represents a single physics Hinge-Joint
  88341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88342. */
  88343. export class HingeJoint extends MotorEnabledJoint {
  88344. /**
  88345. * Initializes the Hinge-Joint
  88346. * @param jointData The joint data for the Hinge-Joint
  88347. */
  88348. constructor(jointData: PhysicsJointData);
  88349. /**
  88350. * Set the motor values.
  88351. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88352. * @param {number} force the force to apply
  88353. * @param {number} maxForce max force for this motor.
  88354. */
  88355. setMotor(force?: number, maxForce?: number): void;
  88356. /**
  88357. * Set the motor's limits.
  88358. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88359. * @param upperLimit The upper limit of the motor
  88360. * @param lowerLimit The lower limit of the motor
  88361. */
  88362. setLimit(upperLimit: number, lowerLimit?: number): void;
  88363. }
  88364. /**
  88365. * This class represents a dual hinge physics joint (same as wheel joint)
  88366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88367. */
  88368. export class Hinge2Joint extends MotorEnabledJoint {
  88369. /**
  88370. * Initializes the Hinge2-Joint
  88371. * @param jointData The joint data for the Hinge2-Joint
  88372. */
  88373. constructor(jointData: PhysicsJointData);
  88374. /**
  88375. * Set the motor values.
  88376. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88377. * @param {number} targetSpeed the speed the motor is to reach
  88378. * @param {number} maxForce max force for this motor.
  88379. * @param {motorIndex} the motor's index, 0 or 1.
  88380. */
  88381. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88382. /**
  88383. * Set the motor limits.
  88384. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88385. * @param {number} upperLimit the upper limit
  88386. * @param {number} lowerLimit lower limit
  88387. * @param {motorIndex} the motor's index, 0 or 1.
  88388. */
  88389. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88390. }
  88391. /**
  88392. * Interface for a motor enabled joint
  88393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88394. */
  88395. export interface IMotorEnabledJoint {
  88396. /**
  88397. * Physics joint
  88398. */
  88399. physicsJoint: any;
  88400. /**
  88401. * Sets the motor of the motor-enabled joint
  88402. * @param force The force of the motor
  88403. * @param maxForce The maximum force of the motor
  88404. * @param motorIndex The index of the motor
  88405. */
  88406. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88407. /**
  88408. * Sets the limit of the motor
  88409. * @param upperLimit The upper limit of the motor
  88410. * @param lowerLimit The lower limit of the motor
  88411. * @param motorIndex The index of the motor
  88412. */
  88413. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88414. }
  88415. /**
  88416. * Joint data for a Distance-Joint
  88417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88418. */
  88419. export interface DistanceJointData extends PhysicsJointData {
  88420. /**
  88421. * Max distance the 2 joint objects can be apart
  88422. */
  88423. maxDistance: number;
  88424. }
  88425. /**
  88426. * Joint data from a spring joint
  88427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88428. */
  88429. export interface SpringJointData extends PhysicsJointData {
  88430. /**
  88431. * Length of the spring
  88432. */
  88433. length: number;
  88434. /**
  88435. * Stiffness of the spring
  88436. */
  88437. stiffness: number;
  88438. /**
  88439. * Damping of the spring
  88440. */
  88441. damping: number;
  88442. /** this callback will be called when applying the force to the impostors. */
  88443. forceApplicationCallback: () => void;
  88444. }
  88445. }
  88446. declare module BABYLON {
  88447. /**
  88448. * Holds the data for the raycast result
  88449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88450. */
  88451. export class PhysicsRaycastResult {
  88452. private _hasHit;
  88453. private _hitDistance;
  88454. private _hitNormalWorld;
  88455. private _hitPointWorld;
  88456. private _rayFromWorld;
  88457. private _rayToWorld;
  88458. /**
  88459. * Gets if there was a hit
  88460. */
  88461. readonly hasHit: boolean;
  88462. /**
  88463. * Gets the distance from the hit
  88464. */
  88465. readonly hitDistance: number;
  88466. /**
  88467. * Gets the hit normal/direction in the world
  88468. */
  88469. readonly hitNormalWorld: Vector3;
  88470. /**
  88471. * Gets the hit point in the world
  88472. */
  88473. readonly hitPointWorld: Vector3;
  88474. /**
  88475. * Gets the ray "start point" of the ray in the world
  88476. */
  88477. readonly rayFromWorld: Vector3;
  88478. /**
  88479. * Gets the ray "end point" of the ray in the world
  88480. */
  88481. readonly rayToWorld: Vector3;
  88482. /**
  88483. * Sets the hit data (normal & point in world space)
  88484. * @param hitNormalWorld defines the normal in world space
  88485. * @param hitPointWorld defines the point in world space
  88486. */
  88487. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88488. /**
  88489. * Sets the distance from the start point to the hit point
  88490. * @param distance
  88491. */
  88492. setHitDistance(distance: number): void;
  88493. /**
  88494. * Calculates the distance manually
  88495. */
  88496. calculateHitDistance(): void;
  88497. /**
  88498. * Resets all the values to default
  88499. * @param from The from point on world space
  88500. * @param to The to point on world space
  88501. */
  88502. reset(from?: Vector3, to?: Vector3): void;
  88503. }
  88504. /**
  88505. * Interface for the size containing width and height
  88506. */
  88507. interface IXYZ {
  88508. /**
  88509. * X
  88510. */
  88511. x: number;
  88512. /**
  88513. * Y
  88514. */
  88515. y: number;
  88516. /**
  88517. * Z
  88518. */
  88519. z: number;
  88520. }
  88521. }
  88522. declare module BABYLON {
  88523. /**
  88524. * Interface used to describe a physics joint
  88525. */
  88526. export interface PhysicsImpostorJoint {
  88527. /** Defines the main impostor to which the joint is linked */
  88528. mainImpostor: PhysicsImpostor;
  88529. /** Defines the impostor that is connected to the main impostor using this joint */
  88530. connectedImpostor: PhysicsImpostor;
  88531. /** Defines the joint itself */
  88532. joint: PhysicsJoint;
  88533. }
  88534. /** @hidden */
  88535. export interface IPhysicsEnginePlugin {
  88536. world: any;
  88537. name: string;
  88538. setGravity(gravity: Vector3): void;
  88539. setTimeStep(timeStep: number): void;
  88540. getTimeStep(): number;
  88541. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88542. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88543. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88544. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88545. removePhysicsBody(impostor: PhysicsImpostor): void;
  88546. generateJoint(joint: PhysicsImpostorJoint): void;
  88547. removeJoint(joint: PhysicsImpostorJoint): void;
  88548. isSupported(): boolean;
  88549. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88550. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88551. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88552. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88553. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88554. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88555. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88556. getBodyMass(impostor: PhysicsImpostor): number;
  88557. getBodyFriction(impostor: PhysicsImpostor): number;
  88558. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88559. getBodyRestitution(impostor: PhysicsImpostor): number;
  88560. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88561. getBodyPressure?(impostor: PhysicsImpostor): number;
  88562. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88563. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88564. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88565. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88566. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88567. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88568. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88569. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88570. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88571. sleepBody(impostor: PhysicsImpostor): void;
  88572. wakeUpBody(impostor: PhysicsImpostor): void;
  88573. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88574. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88575. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88576. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88577. getRadius(impostor: PhysicsImpostor): number;
  88578. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88579. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88580. dispose(): void;
  88581. }
  88582. /**
  88583. * Interface used to define a physics engine
  88584. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88585. */
  88586. export interface IPhysicsEngine {
  88587. /**
  88588. * Gets the gravity vector used by the simulation
  88589. */
  88590. gravity: Vector3;
  88591. /**
  88592. * Sets the gravity vector used by the simulation
  88593. * @param gravity defines the gravity vector to use
  88594. */
  88595. setGravity(gravity: Vector3): void;
  88596. /**
  88597. * Set the time step of the physics engine.
  88598. * Default is 1/60.
  88599. * To slow it down, enter 1/600 for example.
  88600. * To speed it up, 1/30
  88601. * @param newTimeStep the new timestep to apply to this world.
  88602. */
  88603. setTimeStep(newTimeStep: number): void;
  88604. /**
  88605. * Get the time step of the physics engine.
  88606. * @returns the current time step
  88607. */
  88608. getTimeStep(): number;
  88609. /**
  88610. * Release all resources
  88611. */
  88612. dispose(): void;
  88613. /**
  88614. * Gets the name of the current physics plugin
  88615. * @returns the name of the plugin
  88616. */
  88617. getPhysicsPluginName(): string;
  88618. /**
  88619. * Adding a new impostor for the impostor tracking.
  88620. * This will be done by the impostor itself.
  88621. * @param impostor the impostor to add
  88622. */
  88623. addImpostor(impostor: PhysicsImpostor): void;
  88624. /**
  88625. * Remove an impostor from the engine.
  88626. * This impostor and its mesh will not longer be updated by the physics engine.
  88627. * @param impostor the impostor to remove
  88628. */
  88629. removeImpostor(impostor: PhysicsImpostor): void;
  88630. /**
  88631. * Add a joint to the physics engine
  88632. * @param mainImpostor defines the main impostor to which the joint is added.
  88633. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88634. * @param joint defines the joint that will connect both impostors.
  88635. */
  88636. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88637. /**
  88638. * Removes a joint from the simulation
  88639. * @param mainImpostor defines the impostor used with the joint
  88640. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88641. * @param joint defines the joint to remove
  88642. */
  88643. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88644. /**
  88645. * Gets the current plugin used to run the simulation
  88646. * @returns current plugin
  88647. */
  88648. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88649. /**
  88650. * Gets the list of physic impostors
  88651. * @returns an array of PhysicsImpostor
  88652. */
  88653. getImpostors(): Array<PhysicsImpostor>;
  88654. /**
  88655. * Gets the impostor for a physics enabled object
  88656. * @param object defines the object impersonated by the impostor
  88657. * @returns the PhysicsImpostor or null if not found
  88658. */
  88659. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88660. /**
  88661. * Gets the impostor for a physics body object
  88662. * @param body defines physics body used by the impostor
  88663. * @returns the PhysicsImpostor or null if not found
  88664. */
  88665. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88666. /**
  88667. * Does a raycast in the physics world
  88668. * @param from when should the ray start?
  88669. * @param to when should the ray end?
  88670. * @returns PhysicsRaycastResult
  88671. */
  88672. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88673. /**
  88674. * Called by the scene. No need to call it.
  88675. * @param delta defines the timespam between frames
  88676. */
  88677. _step(delta: number): void;
  88678. }
  88679. }
  88680. declare module BABYLON {
  88681. /**
  88682. * The interface for the physics imposter parameters
  88683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88684. */
  88685. export interface PhysicsImpostorParameters {
  88686. /**
  88687. * The mass of the physics imposter
  88688. */
  88689. mass: number;
  88690. /**
  88691. * The friction of the physics imposter
  88692. */
  88693. friction?: number;
  88694. /**
  88695. * The coefficient of restitution of the physics imposter
  88696. */
  88697. restitution?: number;
  88698. /**
  88699. * The native options of the physics imposter
  88700. */
  88701. nativeOptions?: any;
  88702. /**
  88703. * Specifies if the parent should be ignored
  88704. */
  88705. ignoreParent?: boolean;
  88706. /**
  88707. * Specifies if bi-directional transformations should be disabled
  88708. */
  88709. disableBidirectionalTransformation?: boolean;
  88710. /**
  88711. * The pressure inside the physics imposter, soft object only
  88712. */
  88713. pressure?: number;
  88714. /**
  88715. * The stiffness the physics imposter, soft object only
  88716. */
  88717. stiffness?: number;
  88718. /**
  88719. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88720. */
  88721. velocityIterations?: number;
  88722. /**
  88723. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88724. */
  88725. positionIterations?: number;
  88726. /**
  88727. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88728. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88729. * Add to fix multiple points
  88730. */
  88731. fixedPoints?: number;
  88732. /**
  88733. * The collision margin around a soft object
  88734. */
  88735. margin?: number;
  88736. /**
  88737. * The collision margin around a soft object
  88738. */
  88739. damping?: number;
  88740. /**
  88741. * The path for a rope based on an extrusion
  88742. */
  88743. path?: any;
  88744. /**
  88745. * The shape of an extrusion used for a rope based on an extrusion
  88746. */
  88747. shape?: any;
  88748. }
  88749. /**
  88750. * Interface for a physics-enabled object
  88751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88752. */
  88753. export interface IPhysicsEnabledObject {
  88754. /**
  88755. * The position of the physics-enabled object
  88756. */
  88757. position: Vector3;
  88758. /**
  88759. * The rotation of the physics-enabled object
  88760. */
  88761. rotationQuaternion: Nullable<Quaternion>;
  88762. /**
  88763. * The scale of the physics-enabled object
  88764. */
  88765. scaling: Vector3;
  88766. /**
  88767. * The rotation of the physics-enabled object
  88768. */
  88769. rotation?: Vector3;
  88770. /**
  88771. * The parent of the physics-enabled object
  88772. */
  88773. parent?: any;
  88774. /**
  88775. * The bounding info of the physics-enabled object
  88776. * @returns The bounding info of the physics-enabled object
  88777. */
  88778. getBoundingInfo(): BoundingInfo;
  88779. /**
  88780. * Computes the world matrix
  88781. * @param force Specifies if the world matrix should be computed by force
  88782. * @returns A world matrix
  88783. */
  88784. computeWorldMatrix(force: boolean): Matrix;
  88785. /**
  88786. * Gets the world matrix
  88787. * @returns A world matrix
  88788. */
  88789. getWorldMatrix?(): Matrix;
  88790. /**
  88791. * Gets the child meshes
  88792. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88793. * @returns An array of abstract meshes
  88794. */
  88795. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88796. /**
  88797. * Gets the vertex data
  88798. * @param kind The type of vertex data
  88799. * @returns A nullable array of numbers, or a float32 array
  88800. */
  88801. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88802. /**
  88803. * Gets the indices from the mesh
  88804. * @returns A nullable array of index arrays
  88805. */
  88806. getIndices?(): Nullable<IndicesArray>;
  88807. /**
  88808. * Gets the scene from the mesh
  88809. * @returns the indices array or null
  88810. */
  88811. getScene?(): Scene;
  88812. /**
  88813. * Gets the absolute position from the mesh
  88814. * @returns the absolute position
  88815. */
  88816. getAbsolutePosition(): Vector3;
  88817. /**
  88818. * Gets the absolute pivot point from the mesh
  88819. * @returns the absolute pivot point
  88820. */
  88821. getAbsolutePivotPoint(): Vector3;
  88822. /**
  88823. * Rotates the mesh
  88824. * @param axis The axis of rotation
  88825. * @param amount The amount of rotation
  88826. * @param space The space of the rotation
  88827. * @returns The rotation transform node
  88828. */
  88829. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88830. /**
  88831. * Translates the mesh
  88832. * @param axis The axis of translation
  88833. * @param distance The distance of translation
  88834. * @param space The space of the translation
  88835. * @returns The transform node
  88836. */
  88837. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88838. /**
  88839. * Sets the absolute position of the mesh
  88840. * @param absolutePosition The absolute position of the mesh
  88841. * @returns The transform node
  88842. */
  88843. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88844. /**
  88845. * Gets the class name of the mesh
  88846. * @returns The class name
  88847. */
  88848. getClassName(): string;
  88849. }
  88850. /**
  88851. * Represents a physics imposter
  88852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88853. */
  88854. export class PhysicsImpostor {
  88855. /**
  88856. * The physics-enabled object used as the physics imposter
  88857. */
  88858. object: IPhysicsEnabledObject;
  88859. /**
  88860. * The type of the physics imposter
  88861. */
  88862. type: number;
  88863. private _options;
  88864. private _scene?;
  88865. /**
  88866. * The default object size of the imposter
  88867. */
  88868. static DEFAULT_OBJECT_SIZE: Vector3;
  88869. /**
  88870. * The identity quaternion of the imposter
  88871. */
  88872. static IDENTITY_QUATERNION: Quaternion;
  88873. /** @hidden */
  88874. _pluginData: any;
  88875. private _physicsEngine;
  88876. private _physicsBody;
  88877. private _bodyUpdateRequired;
  88878. private _onBeforePhysicsStepCallbacks;
  88879. private _onAfterPhysicsStepCallbacks;
  88880. /** @hidden */
  88881. _onPhysicsCollideCallbacks: Array<{
  88882. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88883. otherImpostors: Array<PhysicsImpostor>;
  88884. }>;
  88885. private _deltaPosition;
  88886. private _deltaRotation;
  88887. private _deltaRotationConjugated;
  88888. /** @hidden */
  88889. _isFromLine: boolean;
  88890. private _parent;
  88891. private _isDisposed;
  88892. private static _tmpVecs;
  88893. private static _tmpQuat;
  88894. /**
  88895. * Specifies if the physics imposter is disposed
  88896. */
  88897. readonly isDisposed: boolean;
  88898. /**
  88899. * Gets the mass of the physics imposter
  88900. */
  88901. mass: number;
  88902. /**
  88903. * Gets the coefficient of friction
  88904. */
  88905. /**
  88906. * Sets the coefficient of friction
  88907. */
  88908. friction: number;
  88909. /**
  88910. * Gets the coefficient of restitution
  88911. */
  88912. /**
  88913. * Sets the coefficient of restitution
  88914. */
  88915. restitution: number;
  88916. /**
  88917. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88918. */
  88919. /**
  88920. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88921. */
  88922. pressure: number;
  88923. /**
  88924. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88925. */
  88926. /**
  88927. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88928. */
  88929. stiffness: number;
  88930. /**
  88931. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88932. */
  88933. /**
  88934. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88935. */
  88936. velocityIterations: number;
  88937. /**
  88938. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88939. */
  88940. /**
  88941. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88942. */
  88943. positionIterations: number;
  88944. /**
  88945. * The unique id of the physics imposter
  88946. * set by the physics engine when adding this impostor to the array
  88947. */
  88948. uniqueId: number;
  88949. /**
  88950. * @hidden
  88951. */
  88952. soft: boolean;
  88953. /**
  88954. * @hidden
  88955. */
  88956. segments: number;
  88957. private _joints;
  88958. /**
  88959. * Initializes the physics imposter
  88960. * @param object The physics-enabled object used as the physics imposter
  88961. * @param type The type of the physics imposter
  88962. * @param _options The options for the physics imposter
  88963. * @param _scene The Babylon scene
  88964. */
  88965. constructor(
  88966. /**
  88967. * The physics-enabled object used as the physics imposter
  88968. */
  88969. object: IPhysicsEnabledObject,
  88970. /**
  88971. * The type of the physics imposter
  88972. */
  88973. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88974. /**
  88975. * This function will completly initialize this impostor.
  88976. * It will create a new body - but only if this mesh has no parent.
  88977. * If it has, this impostor will not be used other than to define the impostor
  88978. * of the child mesh.
  88979. * @hidden
  88980. */
  88981. _init(): void;
  88982. private _getPhysicsParent;
  88983. /**
  88984. * Should a new body be generated.
  88985. * @returns boolean specifying if body initialization is required
  88986. */
  88987. isBodyInitRequired(): boolean;
  88988. /**
  88989. * Sets the updated scaling
  88990. * @param updated Specifies if the scaling is updated
  88991. */
  88992. setScalingUpdated(): void;
  88993. /**
  88994. * Force a regeneration of this or the parent's impostor's body.
  88995. * Use under cautious - This will remove all joints already implemented.
  88996. */
  88997. forceUpdate(): void;
  88998. /**
  88999. * Gets the body that holds this impostor. Either its own, or its parent.
  89000. */
  89001. /**
  89002. * Set the physics body. Used mainly by the physics engine/plugin
  89003. */
  89004. physicsBody: any;
  89005. /**
  89006. * Get the parent of the physics imposter
  89007. * @returns Physics imposter or null
  89008. */
  89009. /**
  89010. * Sets the parent of the physics imposter
  89011. */
  89012. parent: Nullable<PhysicsImpostor>;
  89013. /**
  89014. * Resets the update flags
  89015. */
  89016. resetUpdateFlags(): void;
  89017. /**
  89018. * Gets the object extend size
  89019. * @returns the object extend size
  89020. */
  89021. getObjectExtendSize(): Vector3;
  89022. /**
  89023. * Gets the object center
  89024. * @returns The object center
  89025. */
  89026. getObjectCenter(): Vector3;
  89027. /**
  89028. * Get a specific parametes from the options parameter
  89029. * @param paramName The object parameter name
  89030. * @returns The object parameter
  89031. */
  89032. getParam(paramName: string): any;
  89033. /**
  89034. * Sets a specific parameter in the options given to the physics plugin
  89035. * @param paramName The parameter name
  89036. * @param value The value of the parameter
  89037. */
  89038. setParam(paramName: string, value: number): void;
  89039. /**
  89040. * Specifically change the body's mass option. Won't recreate the physics body object
  89041. * @param mass The mass of the physics imposter
  89042. */
  89043. setMass(mass: number): void;
  89044. /**
  89045. * Gets the linear velocity
  89046. * @returns linear velocity or null
  89047. */
  89048. getLinearVelocity(): Nullable<Vector3>;
  89049. /**
  89050. * Sets the linear velocity
  89051. * @param velocity linear velocity or null
  89052. */
  89053. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89054. /**
  89055. * Gets the angular velocity
  89056. * @returns angular velocity or null
  89057. */
  89058. getAngularVelocity(): Nullable<Vector3>;
  89059. /**
  89060. * Sets the angular velocity
  89061. * @param velocity The velocity or null
  89062. */
  89063. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89064. /**
  89065. * Execute a function with the physics plugin native code
  89066. * Provide a function the will have two variables - the world object and the physics body object
  89067. * @param func The function to execute with the physics plugin native code
  89068. */
  89069. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89070. /**
  89071. * Register a function that will be executed before the physics world is stepping forward
  89072. * @param func The function to execute before the physics world is stepped forward
  89073. */
  89074. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89075. /**
  89076. * Unregister a function that will be executed before the physics world is stepping forward
  89077. * @param func The function to execute before the physics world is stepped forward
  89078. */
  89079. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89080. /**
  89081. * Register a function that will be executed after the physics step
  89082. * @param func The function to execute after physics step
  89083. */
  89084. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89085. /**
  89086. * Unregisters a function that will be executed after the physics step
  89087. * @param func The function to execute after physics step
  89088. */
  89089. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89090. /**
  89091. * register a function that will be executed when this impostor collides against a different body
  89092. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89093. * @param func Callback that is executed on collision
  89094. */
  89095. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89096. /**
  89097. * Unregisters the physics imposter on contact
  89098. * @param collideAgainst The physics object to collide against
  89099. * @param func Callback to execute on collision
  89100. */
  89101. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89102. private _tmpQuat;
  89103. private _tmpQuat2;
  89104. /**
  89105. * Get the parent rotation
  89106. * @returns The parent rotation
  89107. */
  89108. getParentsRotation(): Quaternion;
  89109. /**
  89110. * this function is executed by the physics engine.
  89111. */
  89112. beforeStep: () => void;
  89113. /**
  89114. * this function is executed by the physics engine
  89115. */
  89116. afterStep: () => void;
  89117. /**
  89118. * Legacy collision detection event support
  89119. */
  89120. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  89121. /**
  89122. * event and body object due to cannon's event-based architecture.
  89123. */
  89124. onCollide: (e: {
  89125. body: any;
  89126. }) => void;
  89127. /**
  89128. * Apply a force
  89129. * @param force The force to apply
  89130. * @param contactPoint The contact point for the force
  89131. * @returns The physics imposter
  89132. */
  89133. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89134. /**
  89135. * Apply an impulse
  89136. * @param force The impulse force
  89137. * @param contactPoint The contact point for the impulse force
  89138. * @returns The physics imposter
  89139. */
  89140. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89141. /**
  89142. * A help function to create a joint
  89143. * @param otherImpostor A physics imposter used to create a joint
  89144. * @param jointType The type of joint
  89145. * @param jointData The data for the joint
  89146. * @returns The physics imposter
  89147. */
  89148. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89149. /**
  89150. * Add a joint to this impostor with a different impostor
  89151. * @param otherImpostor A physics imposter used to add a joint
  89152. * @param joint The joint to add
  89153. * @returns The physics imposter
  89154. */
  89155. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89156. /**
  89157. * Add an anchor to a cloth impostor
  89158. * @param otherImpostor rigid impostor to anchor to
  89159. * @param width ratio across width from 0 to 1
  89160. * @param height ratio up height from 0 to 1
  89161. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89162. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89163. * @returns impostor the soft imposter
  89164. */
  89165. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89166. /**
  89167. * Add a hook to a rope impostor
  89168. * @param otherImpostor rigid impostor to anchor to
  89169. * @param length ratio across rope from 0 to 1
  89170. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89171. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89172. * @returns impostor the rope imposter
  89173. */
  89174. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89175. /**
  89176. * Will keep this body still, in a sleep mode.
  89177. * @returns the physics imposter
  89178. */
  89179. sleep(): PhysicsImpostor;
  89180. /**
  89181. * Wake the body up.
  89182. * @returns The physics imposter
  89183. */
  89184. wakeUp(): PhysicsImpostor;
  89185. /**
  89186. * Clones the physics imposter
  89187. * @param newObject The physics imposter clones to this physics-enabled object
  89188. * @returns A nullable physics imposter
  89189. */
  89190. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89191. /**
  89192. * Disposes the physics imposter
  89193. */
  89194. dispose(): void;
  89195. /**
  89196. * Sets the delta position
  89197. * @param position The delta position amount
  89198. */
  89199. setDeltaPosition(position: Vector3): void;
  89200. /**
  89201. * Sets the delta rotation
  89202. * @param rotation The delta rotation amount
  89203. */
  89204. setDeltaRotation(rotation: Quaternion): void;
  89205. /**
  89206. * Gets the box size of the physics imposter and stores the result in the input parameter
  89207. * @param result Stores the box size
  89208. * @returns The physics imposter
  89209. */
  89210. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89211. /**
  89212. * Gets the radius of the physics imposter
  89213. * @returns Radius of the physics imposter
  89214. */
  89215. getRadius(): number;
  89216. /**
  89217. * Sync a bone with this impostor
  89218. * @param bone The bone to sync to the impostor.
  89219. * @param boneMesh The mesh that the bone is influencing.
  89220. * @param jointPivot The pivot of the joint / bone in local space.
  89221. * @param distToJoint Optional distance from the impostor to the joint.
  89222. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89223. */
  89224. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89225. /**
  89226. * Sync impostor to a bone
  89227. * @param bone The bone that the impostor will be synced to.
  89228. * @param boneMesh The mesh that the bone is influencing.
  89229. * @param jointPivot The pivot of the joint / bone in local space.
  89230. * @param distToJoint Optional distance from the impostor to the joint.
  89231. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89232. * @param boneAxis Optional vector3 axis the bone is aligned with
  89233. */
  89234. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89235. /**
  89236. * No-Imposter type
  89237. */
  89238. static NoImpostor: number;
  89239. /**
  89240. * Sphere-Imposter type
  89241. */
  89242. static SphereImpostor: number;
  89243. /**
  89244. * Box-Imposter type
  89245. */
  89246. static BoxImpostor: number;
  89247. /**
  89248. * Plane-Imposter type
  89249. */
  89250. static PlaneImpostor: number;
  89251. /**
  89252. * Mesh-imposter type
  89253. */
  89254. static MeshImpostor: number;
  89255. /**
  89256. * Capsule-Impostor type (Ammo.js plugin only)
  89257. */
  89258. static CapsuleImpostor: number;
  89259. /**
  89260. * Cylinder-Imposter type
  89261. */
  89262. static CylinderImpostor: number;
  89263. /**
  89264. * Particle-Imposter type
  89265. */
  89266. static ParticleImpostor: number;
  89267. /**
  89268. * Heightmap-Imposter type
  89269. */
  89270. static HeightmapImpostor: number;
  89271. /**
  89272. * ConvexHull-Impostor type (Ammo.js plugin only)
  89273. */
  89274. static ConvexHullImpostor: number;
  89275. /**
  89276. * Rope-Imposter type
  89277. */
  89278. static RopeImpostor: number;
  89279. /**
  89280. * Cloth-Imposter type
  89281. */
  89282. static ClothImpostor: number;
  89283. /**
  89284. * Softbody-Imposter type
  89285. */
  89286. static SoftbodyImpostor: number;
  89287. }
  89288. }
  89289. declare module BABYLON {
  89290. /**
  89291. * @hidden
  89292. **/
  89293. export class _CreationDataStorage {
  89294. closePath?: boolean;
  89295. closeArray?: boolean;
  89296. idx: number[];
  89297. dashSize: number;
  89298. gapSize: number;
  89299. path3D: Path3D;
  89300. pathArray: Vector3[][];
  89301. arc: number;
  89302. radius: number;
  89303. cap: number;
  89304. tessellation: number;
  89305. }
  89306. /**
  89307. * @hidden
  89308. **/
  89309. class _InstanceDataStorage {
  89310. visibleInstances: any;
  89311. batchCache: _InstancesBatch;
  89312. instancesBufferSize: number;
  89313. instancesBuffer: Nullable<Buffer>;
  89314. instancesData: Float32Array;
  89315. overridenInstanceCount: number;
  89316. isFrozen: boolean;
  89317. previousBatch: Nullable<_InstancesBatch>;
  89318. hardwareInstancedRendering: boolean;
  89319. sideOrientation: number;
  89320. }
  89321. /**
  89322. * @hidden
  89323. **/
  89324. export class _InstancesBatch {
  89325. mustReturn: boolean;
  89326. visibleInstances: Nullable<InstancedMesh[]>[];
  89327. renderSelf: boolean[];
  89328. hardwareInstancedRendering: boolean[];
  89329. }
  89330. /**
  89331. * Class used to represent renderable models
  89332. */
  89333. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89334. /**
  89335. * Mesh side orientation : usually the external or front surface
  89336. */
  89337. static readonly FRONTSIDE: number;
  89338. /**
  89339. * Mesh side orientation : usually the internal or back surface
  89340. */
  89341. static readonly BACKSIDE: number;
  89342. /**
  89343. * Mesh side orientation : both internal and external or front and back surfaces
  89344. */
  89345. static readonly DOUBLESIDE: number;
  89346. /**
  89347. * Mesh side orientation : by default, `FRONTSIDE`
  89348. */
  89349. static readonly DEFAULTSIDE: number;
  89350. /**
  89351. * Mesh cap setting : no cap
  89352. */
  89353. static readonly NO_CAP: number;
  89354. /**
  89355. * Mesh cap setting : one cap at the beginning of the mesh
  89356. */
  89357. static readonly CAP_START: number;
  89358. /**
  89359. * Mesh cap setting : one cap at the end of the mesh
  89360. */
  89361. static readonly CAP_END: number;
  89362. /**
  89363. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89364. */
  89365. static readonly CAP_ALL: number;
  89366. /**
  89367. * Mesh pattern setting : no flip or rotate
  89368. */
  89369. static readonly NO_FLIP: number;
  89370. /**
  89371. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89372. */
  89373. static readonly FLIP_TILE: number;
  89374. /**
  89375. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89376. */
  89377. static readonly ROTATE_TILE: number;
  89378. /**
  89379. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89380. */
  89381. static readonly FLIP_ROW: number;
  89382. /**
  89383. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89384. */
  89385. static readonly ROTATE_ROW: number;
  89386. /**
  89387. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89388. */
  89389. static readonly FLIP_N_ROTATE_TILE: number;
  89390. /**
  89391. * Mesh pattern setting : rotate pattern and rotate
  89392. */
  89393. static readonly FLIP_N_ROTATE_ROW: number;
  89394. /**
  89395. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89396. */
  89397. static readonly CENTER: number;
  89398. /**
  89399. * Mesh tile positioning : part tiles on left
  89400. */
  89401. static readonly LEFT: number;
  89402. /**
  89403. * Mesh tile positioning : part tiles on right
  89404. */
  89405. static readonly RIGHT: number;
  89406. /**
  89407. * Mesh tile positioning : part tiles on top
  89408. */
  89409. static readonly TOP: number;
  89410. /**
  89411. * Mesh tile positioning : part tiles on bottom
  89412. */
  89413. static readonly BOTTOM: number;
  89414. /**
  89415. * Gets the default side orientation.
  89416. * @param orientation the orientation to value to attempt to get
  89417. * @returns the default orientation
  89418. * @hidden
  89419. */
  89420. static _GetDefaultSideOrientation(orientation?: number): number;
  89421. private _internalMeshDataInfo;
  89422. /**
  89423. * An event triggered before rendering the mesh
  89424. */
  89425. readonly onBeforeRenderObservable: Observable<Mesh>;
  89426. /**
  89427. * An event triggered before binding the mesh
  89428. */
  89429. readonly onBeforeBindObservable: Observable<Mesh>;
  89430. /**
  89431. * An event triggered after rendering the mesh
  89432. */
  89433. readonly onAfterRenderObservable: Observable<Mesh>;
  89434. /**
  89435. * An event triggered before drawing the mesh
  89436. */
  89437. readonly onBeforeDrawObservable: Observable<Mesh>;
  89438. private _onBeforeDrawObserver;
  89439. /**
  89440. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89441. */
  89442. onBeforeDraw: () => void;
  89443. readonly hasInstances: boolean;
  89444. /**
  89445. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89446. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89447. */
  89448. delayLoadState: number;
  89449. /**
  89450. * Gets the list of instances created from this mesh
  89451. * it is not supposed to be modified manually.
  89452. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89453. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89454. */
  89455. instances: InstancedMesh[];
  89456. /**
  89457. * Gets the file containing delay loading data for this mesh
  89458. */
  89459. delayLoadingFile: string;
  89460. /** @hidden */
  89461. _binaryInfo: any;
  89462. /**
  89463. * User defined function used to change how LOD level selection is done
  89464. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89465. */
  89466. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89467. /**
  89468. * Gets or sets the morph target manager
  89469. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89470. */
  89471. morphTargetManager: Nullable<MorphTargetManager>;
  89472. /** @hidden */
  89473. _creationDataStorage: Nullable<_CreationDataStorage>;
  89474. /** @hidden */
  89475. _geometry: Nullable<Geometry>;
  89476. /** @hidden */
  89477. _delayInfo: Array<string>;
  89478. /** @hidden */
  89479. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89480. /** @hidden */
  89481. _instanceDataStorage: _InstanceDataStorage;
  89482. private _effectiveMaterial;
  89483. /** @hidden */
  89484. _shouldGenerateFlatShading: boolean;
  89485. /** @hidden */
  89486. _originalBuilderSideOrientation: number;
  89487. /**
  89488. * Use this property to change the original side orientation defined at construction time
  89489. */
  89490. overrideMaterialSideOrientation: Nullable<number>;
  89491. /**
  89492. * Gets the source mesh (the one used to clone this one from)
  89493. */
  89494. readonly source: Nullable<Mesh>;
  89495. /**
  89496. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89497. */
  89498. isUnIndexed: boolean;
  89499. /**
  89500. * @constructor
  89501. * @param name The value used by scene.getMeshByName() to do a lookup.
  89502. * @param scene The scene to add this mesh to.
  89503. * @param parent The parent of this mesh, if it has one
  89504. * @param source An optional Mesh from which geometry is shared, cloned.
  89505. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89506. * When false, achieved by calling a clone(), also passing False.
  89507. * This will make creation of children, recursive.
  89508. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89509. */
  89510. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89511. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89512. /**
  89513. * Gets the class name
  89514. * @returns the string "Mesh".
  89515. */
  89516. getClassName(): string;
  89517. /** @hidden */
  89518. readonly _isMesh: boolean;
  89519. /**
  89520. * Returns a description of this mesh
  89521. * @param fullDetails define if full details about this mesh must be used
  89522. * @returns a descriptive string representing this mesh
  89523. */
  89524. toString(fullDetails?: boolean): string;
  89525. /** @hidden */
  89526. _unBindEffect(): void;
  89527. /**
  89528. * Gets a boolean indicating if this mesh has LOD
  89529. */
  89530. readonly hasLODLevels: boolean;
  89531. /**
  89532. * Gets the list of MeshLODLevel associated with the current mesh
  89533. * @returns an array of MeshLODLevel
  89534. */
  89535. getLODLevels(): MeshLODLevel[];
  89536. private _sortLODLevels;
  89537. /**
  89538. * Add a mesh as LOD level triggered at the given distance.
  89539. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89540. * @param distance The distance from the center of the object to show this level
  89541. * @param mesh The mesh to be added as LOD level (can be null)
  89542. * @return This mesh (for chaining)
  89543. */
  89544. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89545. /**
  89546. * Returns the LOD level mesh at the passed distance or null if not found.
  89547. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89548. * @param distance The distance from the center of the object to show this level
  89549. * @returns a Mesh or `null`
  89550. */
  89551. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89552. /**
  89553. * Remove a mesh from the LOD array
  89554. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89555. * @param mesh defines the mesh to be removed
  89556. * @return This mesh (for chaining)
  89557. */
  89558. removeLODLevel(mesh: Mesh): Mesh;
  89559. /**
  89560. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89561. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89562. * @param camera defines the camera to use to compute distance
  89563. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89564. * @return This mesh (for chaining)
  89565. */
  89566. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89567. /**
  89568. * Gets the mesh internal Geometry object
  89569. */
  89570. readonly geometry: Nullable<Geometry>;
  89571. /**
  89572. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89573. * @returns the total number of vertices
  89574. */
  89575. getTotalVertices(): number;
  89576. /**
  89577. * Returns the content of an associated vertex buffer
  89578. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89579. * - VertexBuffer.PositionKind
  89580. * - VertexBuffer.UVKind
  89581. * - VertexBuffer.UV2Kind
  89582. * - VertexBuffer.UV3Kind
  89583. * - VertexBuffer.UV4Kind
  89584. * - VertexBuffer.UV5Kind
  89585. * - VertexBuffer.UV6Kind
  89586. * - VertexBuffer.ColorKind
  89587. * - VertexBuffer.MatricesIndicesKind
  89588. * - VertexBuffer.MatricesIndicesExtraKind
  89589. * - VertexBuffer.MatricesWeightsKind
  89590. * - VertexBuffer.MatricesWeightsExtraKind
  89591. * @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
  89592. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89593. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89594. */
  89595. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89596. /**
  89597. * Returns the mesh VertexBuffer object from the requested `kind`
  89598. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89599. * - VertexBuffer.PositionKind
  89600. * - VertexBuffer.NormalKind
  89601. * - VertexBuffer.UVKind
  89602. * - VertexBuffer.UV2Kind
  89603. * - VertexBuffer.UV3Kind
  89604. * - VertexBuffer.UV4Kind
  89605. * - VertexBuffer.UV5Kind
  89606. * - VertexBuffer.UV6Kind
  89607. * - VertexBuffer.ColorKind
  89608. * - VertexBuffer.MatricesIndicesKind
  89609. * - VertexBuffer.MatricesIndicesExtraKind
  89610. * - VertexBuffer.MatricesWeightsKind
  89611. * - VertexBuffer.MatricesWeightsExtraKind
  89612. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89613. */
  89614. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89615. /**
  89616. * Tests if a specific vertex buffer is associated with this mesh
  89617. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89618. * - VertexBuffer.PositionKind
  89619. * - VertexBuffer.NormalKind
  89620. * - VertexBuffer.UVKind
  89621. * - VertexBuffer.UV2Kind
  89622. * - VertexBuffer.UV3Kind
  89623. * - VertexBuffer.UV4Kind
  89624. * - VertexBuffer.UV5Kind
  89625. * - VertexBuffer.UV6Kind
  89626. * - VertexBuffer.ColorKind
  89627. * - VertexBuffer.MatricesIndicesKind
  89628. * - VertexBuffer.MatricesIndicesExtraKind
  89629. * - VertexBuffer.MatricesWeightsKind
  89630. * - VertexBuffer.MatricesWeightsExtraKind
  89631. * @returns a boolean
  89632. */
  89633. isVerticesDataPresent(kind: string): boolean;
  89634. /**
  89635. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89636. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89637. * - VertexBuffer.PositionKind
  89638. * - VertexBuffer.UVKind
  89639. * - VertexBuffer.UV2Kind
  89640. * - VertexBuffer.UV3Kind
  89641. * - VertexBuffer.UV4Kind
  89642. * - VertexBuffer.UV5Kind
  89643. * - VertexBuffer.UV6Kind
  89644. * - VertexBuffer.ColorKind
  89645. * - VertexBuffer.MatricesIndicesKind
  89646. * - VertexBuffer.MatricesIndicesExtraKind
  89647. * - VertexBuffer.MatricesWeightsKind
  89648. * - VertexBuffer.MatricesWeightsExtraKind
  89649. * @returns a boolean
  89650. */
  89651. isVertexBufferUpdatable(kind: string): boolean;
  89652. /**
  89653. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89654. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89655. * - VertexBuffer.PositionKind
  89656. * - VertexBuffer.NormalKind
  89657. * - VertexBuffer.UVKind
  89658. * - VertexBuffer.UV2Kind
  89659. * - VertexBuffer.UV3Kind
  89660. * - VertexBuffer.UV4Kind
  89661. * - VertexBuffer.UV5Kind
  89662. * - VertexBuffer.UV6Kind
  89663. * - VertexBuffer.ColorKind
  89664. * - VertexBuffer.MatricesIndicesKind
  89665. * - VertexBuffer.MatricesIndicesExtraKind
  89666. * - VertexBuffer.MatricesWeightsKind
  89667. * - VertexBuffer.MatricesWeightsExtraKind
  89668. * @returns an array of strings
  89669. */
  89670. getVerticesDataKinds(): string[];
  89671. /**
  89672. * Returns a positive integer : the total number of indices in this mesh geometry.
  89673. * @returns the numner of indices or zero if the mesh has no geometry.
  89674. */
  89675. getTotalIndices(): number;
  89676. /**
  89677. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89678. * @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.
  89679. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89680. * @returns the indices array or an empty array if the mesh has no geometry
  89681. */
  89682. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89683. readonly isBlocked: boolean;
  89684. /**
  89685. * Determine if the current mesh is ready to be rendered
  89686. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89687. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89688. * @returns true if all associated assets are ready (material, textures, shaders)
  89689. */
  89690. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89691. /**
  89692. * 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.
  89693. */
  89694. readonly areNormalsFrozen: boolean;
  89695. /**
  89696. * 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.
  89697. * @returns the current mesh
  89698. */
  89699. freezeNormals(): Mesh;
  89700. /**
  89701. * 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
  89702. * @returns the current mesh
  89703. */
  89704. unfreezeNormals(): Mesh;
  89705. /**
  89706. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89707. */
  89708. overridenInstanceCount: number;
  89709. /** @hidden */
  89710. _preActivate(): Mesh;
  89711. /** @hidden */
  89712. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89713. /** @hidden */
  89714. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89715. /**
  89716. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89717. * This means the mesh underlying bounding box and sphere are recomputed.
  89718. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89719. * @returns the current mesh
  89720. */
  89721. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89722. /** @hidden */
  89723. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89724. /**
  89725. * This function will subdivide the mesh into multiple submeshes
  89726. * @param count defines the expected number of submeshes
  89727. */
  89728. subdivide(count: number): void;
  89729. /**
  89730. * Copy a FloatArray into a specific associated vertex buffer
  89731. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89732. * - VertexBuffer.PositionKind
  89733. * - VertexBuffer.UVKind
  89734. * - VertexBuffer.UV2Kind
  89735. * - VertexBuffer.UV3Kind
  89736. * - VertexBuffer.UV4Kind
  89737. * - VertexBuffer.UV5Kind
  89738. * - VertexBuffer.UV6Kind
  89739. * - VertexBuffer.ColorKind
  89740. * - VertexBuffer.MatricesIndicesKind
  89741. * - VertexBuffer.MatricesIndicesExtraKind
  89742. * - VertexBuffer.MatricesWeightsKind
  89743. * - VertexBuffer.MatricesWeightsExtraKind
  89744. * @param data defines the data source
  89745. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89746. * @param stride defines the data stride size (can be null)
  89747. * @returns the current mesh
  89748. */
  89749. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89750. /**
  89751. * Flags an associated vertex buffer as updatable
  89752. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89753. * - VertexBuffer.PositionKind
  89754. * - VertexBuffer.UVKind
  89755. * - VertexBuffer.UV2Kind
  89756. * - VertexBuffer.UV3Kind
  89757. * - VertexBuffer.UV4Kind
  89758. * - VertexBuffer.UV5Kind
  89759. * - VertexBuffer.UV6Kind
  89760. * - VertexBuffer.ColorKind
  89761. * - VertexBuffer.MatricesIndicesKind
  89762. * - VertexBuffer.MatricesIndicesExtraKind
  89763. * - VertexBuffer.MatricesWeightsKind
  89764. * - VertexBuffer.MatricesWeightsExtraKind
  89765. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89766. */
  89767. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89768. /**
  89769. * Sets the mesh global Vertex Buffer
  89770. * @param buffer defines the buffer to use
  89771. * @returns the current mesh
  89772. */
  89773. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89774. /**
  89775. * Update a specific associated vertex buffer
  89776. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89777. * - VertexBuffer.PositionKind
  89778. * - VertexBuffer.UVKind
  89779. * - VertexBuffer.UV2Kind
  89780. * - VertexBuffer.UV3Kind
  89781. * - VertexBuffer.UV4Kind
  89782. * - VertexBuffer.UV5Kind
  89783. * - VertexBuffer.UV6Kind
  89784. * - VertexBuffer.ColorKind
  89785. * - VertexBuffer.MatricesIndicesKind
  89786. * - VertexBuffer.MatricesIndicesExtraKind
  89787. * - VertexBuffer.MatricesWeightsKind
  89788. * - VertexBuffer.MatricesWeightsExtraKind
  89789. * @param data defines the data source
  89790. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89791. * @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)
  89792. * @returns the current mesh
  89793. */
  89794. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89795. /**
  89796. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89797. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89798. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89799. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89800. * @returns the current mesh
  89801. */
  89802. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89803. /**
  89804. * Creates a un-shared specific occurence of the geometry for the mesh.
  89805. * @returns the current mesh
  89806. */
  89807. makeGeometryUnique(): Mesh;
  89808. /**
  89809. * Set the index buffer of this mesh
  89810. * @param indices defines the source data
  89811. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89812. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89813. * @returns the current mesh
  89814. */
  89815. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89816. /**
  89817. * Update the current index buffer
  89818. * @param indices defines the source data
  89819. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89820. * @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)
  89821. * @returns the current mesh
  89822. */
  89823. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89824. /**
  89825. * Invert the geometry to move from a right handed system to a left handed one.
  89826. * @returns the current mesh
  89827. */
  89828. toLeftHanded(): Mesh;
  89829. /** @hidden */
  89830. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89831. /** @hidden */
  89832. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89833. /**
  89834. * Registers for this mesh a javascript function called just before the rendering process
  89835. * @param func defines the function to call before rendering this mesh
  89836. * @returns the current mesh
  89837. */
  89838. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89839. /**
  89840. * Disposes a previously registered javascript function called before the rendering
  89841. * @param func defines the function to remove
  89842. * @returns the current mesh
  89843. */
  89844. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89845. /**
  89846. * Registers for this mesh a javascript function called just after the rendering is complete
  89847. * @param func defines the function to call after rendering this mesh
  89848. * @returns the current mesh
  89849. */
  89850. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89851. /**
  89852. * Disposes a previously registered javascript function called after the rendering.
  89853. * @param func defines the function to remove
  89854. * @returns the current mesh
  89855. */
  89856. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89857. /** @hidden */
  89858. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89859. /** @hidden */
  89860. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89861. /** @hidden */
  89862. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89863. /** @hidden */
  89864. _rebuild(): void;
  89865. /** @hidden */
  89866. _freeze(): void;
  89867. /** @hidden */
  89868. _unFreeze(): void;
  89869. /**
  89870. * 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
  89871. * @param subMesh defines the subMesh to render
  89872. * @param enableAlphaMode defines if alpha mode can be changed
  89873. * @returns the current mesh
  89874. */
  89875. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89876. private _onBeforeDraw;
  89877. /**
  89878. * Renormalize the mesh and patch it up if there are no weights
  89879. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89880. * However in the case of zero weights then we set just a single influence to 1.
  89881. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89882. */
  89883. cleanMatrixWeights(): void;
  89884. private normalizeSkinFourWeights;
  89885. private normalizeSkinWeightsAndExtra;
  89886. /**
  89887. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89888. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89889. * the user know there was an issue with importing the mesh
  89890. * @returns a validation object with skinned, valid and report string
  89891. */
  89892. validateSkinning(): {
  89893. skinned: boolean;
  89894. valid: boolean;
  89895. report: string;
  89896. };
  89897. /** @hidden */
  89898. _checkDelayState(): Mesh;
  89899. private _queueLoad;
  89900. /**
  89901. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89902. * A mesh is in the frustum if its bounding box intersects the frustum
  89903. * @param frustumPlanes defines the frustum to test
  89904. * @returns true if the mesh is in the frustum planes
  89905. */
  89906. isInFrustum(frustumPlanes: Plane[]): boolean;
  89907. /**
  89908. * Sets the mesh material by the material or multiMaterial `id` property
  89909. * @param id is a string identifying the material or the multiMaterial
  89910. * @returns the current mesh
  89911. */
  89912. setMaterialByID(id: string): Mesh;
  89913. /**
  89914. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89915. * @returns an array of IAnimatable
  89916. */
  89917. getAnimatables(): IAnimatable[];
  89918. /**
  89919. * Modifies the mesh geometry according to the passed transformation matrix.
  89920. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89921. * The mesh normals are modified using the same transformation.
  89922. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89923. * @param transform defines the transform matrix to use
  89924. * @see http://doc.babylonjs.com/resources/baking_transformations
  89925. * @returns the current mesh
  89926. */
  89927. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89928. /**
  89929. * Modifies the mesh geometry according to its own current World Matrix.
  89930. * The mesh World Matrix is then reset.
  89931. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89932. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89933. * @see http://doc.babylonjs.com/resources/baking_transformations
  89934. * @returns the current mesh
  89935. */
  89936. bakeCurrentTransformIntoVertices(): Mesh;
  89937. /** @hidden */
  89938. readonly _positions: Nullable<Vector3[]>;
  89939. /** @hidden */
  89940. _resetPointsArrayCache(): Mesh;
  89941. /** @hidden */
  89942. _generatePointsArray(): boolean;
  89943. /**
  89944. * Returns a new Mesh object generated from the current mesh properties.
  89945. * This method must not get confused with createInstance()
  89946. * @param name is a string, the name given to the new mesh
  89947. * @param newParent can be any Node object (default `null`)
  89948. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89949. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89950. * @returns a new mesh
  89951. */
  89952. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89953. /**
  89954. * Releases resources associated with this mesh.
  89955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89957. */
  89958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89959. /**
  89960. * Modifies the mesh geometry according to a displacement map.
  89961. * 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.
  89962. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89963. * @param url is a string, the URL from the image file is to be downloaded.
  89964. * @param minHeight is the lower limit of the displacement.
  89965. * @param maxHeight is the upper limit of the displacement.
  89966. * @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.
  89967. * @param uvOffset is an optional vector2 used to offset UV.
  89968. * @param uvScale is an optional vector2 used to scale UV.
  89969. * @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.
  89970. * @returns the Mesh.
  89971. */
  89972. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89973. /**
  89974. * Modifies the mesh geometry according to a displacementMap buffer.
  89975. * 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.
  89976. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89977. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89978. * @param heightMapWidth is the width of the buffer image.
  89979. * @param heightMapHeight is the height of the buffer image.
  89980. * @param minHeight is the lower limit of the displacement.
  89981. * @param maxHeight is the upper limit of the displacement.
  89982. * @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.
  89983. * @param uvOffset is an optional vector2 used to offset UV.
  89984. * @param uvScale is an optional vector2 used to scale UV.
  89985. * @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.
  89986. * @returns the Mesh.
  89987. */
  89988. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89989. /**
  89990. * Modify the mesh to get a flat shading rendering.
  89991. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89992. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89993. * @returns current mesh
  89994. */
  89995. convertToFlatShadedMesh(): Mesh;
  89996. /**
  89997. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89998. * In other words, more vertices, no more indices and a single bigger VBO.
  89999. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90000. * @returns current mesh
  90001. */
  90002. convertToUnIndexedMesh(): Mesh;
  90003. /**
  90004. * Inverses facet orientations.
  90005. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90006. * @param flipNormals will also inverts the normals
  90007. * @returns current mesh
  90008. */
  90009. flipFaces(flipNormals?: boolean): Mesh;
  90010. /**
  90011. * Increase the number of facets and hence vertices in a mesh
  90012. * Vertex normals are interpolated from existing vertex normals
  90013. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90014. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90015. */
  90016. increaseVertices(numberPerEdge: number): void;
  90017. /**
  90018. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90019. * This will undo any application of covertToFlatShadedMesh
  90020. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90021. */
  90022. forceSharedVertices(): void;
  90023. /** @hidden */
  90024. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90025. /** @hidden */
  90026. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90027. /**
  90028. * Creates a new InstancedMesh object from the mesh model.
  90029. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90030. * @param name defines the name of the new instance
  90031. * @returns a new InstancedMesh
  90032. */
  90033. createInstance(name: string): InstancedMesh;
  90034. /**
  90035. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90036. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90037. * @returns the current mesh
  90038. */
  90039. synchronizeInstances(): Mesh;
  90040. /**
  90041. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90042. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90043. * This should be used together with the simplification to avoid disappearing triangles.
  90044. * @param successCallback an optional success callback to be called after the optimization finished.
  90045. * @returns the current mesh
  90046. */
  90047. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90048. /**
  90049. * Serialize current mesh
  90050. * @param serializationObject defines the object which will receive the serialization data
  90051. */
  90052. serialize(serializationObject: any): void;
  90053. /** @hidden */
  90054. _syncGeometryWithMorphTargetManager(): void;
  90055. /** @hidden */
  90056. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90057. /**
  90058. * Returns a new Mesh object parsed from the source provided.
  90059. * @param parsedMesh is the source
  90060. * @param scene defines the hosting scene
  90061. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90062. * @returns a new Mesh
  90063. */
  90064. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90065. /**
  90066. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90067. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90068. * @param name defines the name of the mesh to create
  90069. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90070. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90071. * @param closePath creates a seam between the first and the last points of each path of the path array
  90072. * @param offset is taken in account only if the `pathArray` is containing a single path
  90073. * @param scene defines the hosting scene
  90074. * @param updatable defines if the mesh must be flagged as updatable
  90075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90076. * @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)
  90077. * @returns a new Mesh
  90078. */
  90079. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90080. /**
  90081. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90082. * @param name defines the name of the mesh to create
  90083. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90084. * @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
  90085. * @param scene defines the hosting scene
  90086. * @param updatable defines if the mesh must be flagged as updatable
  90087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90088. * @returns a new Mesh
  90089. */
  90090. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90091. /**
  90092. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90093. * @param name defines the name of the mesh to create
  90094. * @param size sets the size (float) of each box side (default 1)
  90095. * @param scene defines the hosting scene
  90096. * @param updatable defines if the mesh must be flagged as updatable
  90097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90098. * @returns a new Mesh
  90099. */
  90100. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90101. /**
  90102. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90103. * @param name defines the name of the mesh to create
  90104. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90105. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90106. * @param scene defines the hosting scene
  90107. * @param updatable defines if the mesh must be flagged as updatable
  90108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90109. * @returns a new Mesh
  90110. */
  90111. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90112. /**
  90113. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90114. * @param name defines the name of the mesh to create
  90115. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90116. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90117. * @param scene defines the hosting scene
  90118. * @returns a new Mesh
  90119. */
  90120. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  90121. /**
  90122. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90123. * @param name defines the name of the mesh to create
  90124. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90125. * @param diameterTop set the top cap diameter (floats, default 1)
  90126. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90127. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90128. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90129. * @param scene defines the hosting scene
  90130. * @param updatable defines if the mesh must be flagged as updatable
  90131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90132. * @returns a new Mesh
  90133. */
  90134. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90135. /**
  90136. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90137. * @param name defines the name of the mesh to create
  90138. * @param diameter sets the diameter size (float) of the torus (default 1)
  90139. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90140. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90141. * @param scene defines the hosting scene
  90142. * @param updatable defines if the mesh must be flagged as updatable
  90143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90144. * @returns a new Mesh
  90145. */
  90146. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90147. /**
  90148. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90149. * @param name defines the name of the mesh to create
  90150. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90151. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90152. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90153. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90154. * @param p the number of windings on X axis (positive integers, default 2)
  90155. * @param q the number of windings on Y axis (positive integers, default 3)
  90156. * @param scene defines the hosting scene
  90157. * @param updatable defines if the mesh must be flagged as updatable
  90158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90159. * @returns a new Mesh
  90160. */
  90161. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90162. /**
  90163. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90164. * @param name defines the name of the mesh to create
  90165. * @param points is an array successive Vector3
  90166. * @param scene defines the hosting scene
  90167. * @param updatable defines if the mesh must be flagged as updatable
  90168. * @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).
  90169. * @returns a new Mesh
  90170. */
  90171. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90172. /**
  90173. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90174. * @param name defines the name of the mesh to create
  90175. * @param points is an array successive Vector3
  90176. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90177. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90178. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90179. * @param scene defines the hosting scene
  90180. * @param updatable defines if the mesh must be flagged as updatable
  90181. * @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)
  90182. * @returns a new Mesh
  90183. */
  90184. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90185. /**
  90186. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90187. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90188. * 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.
  90189. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90190. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90191. * Remember you can only change the shape positions, not their number when updating a polygon.
  90192. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90193. * @param name defines the name of the mesh to create
  90194. * @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
  90195. * @param scene defines the hosting scene
  90196. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90197. * @param updatable defines if the mesh must be flagged as updatable
  90198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90199. * @param earcutInjection can be used to inject your own earcut reference
  90200. * @returns a new Mesh
  90201. */
  90202. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90203. /**
  90204. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90205. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90206. * @param name defines the name of the mesh to create
  90207. * @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
  90208. * @param depth defines the height of extrusion
  90209. * @param scene defines the hosting scene
  90210. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90211. * @param updatable defines if the mesh must be flagged as updatable
  90212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90213. * @param earcutInjection can be used to inject your own earcut reference
  90214. * @returns a new Mesh
  90215. */
  90216. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90217. /**
  90218. * Creates an extruded shape mesh.
  90219. * 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
  90220. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90221. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90222. * @param name defines the name of the mesh to create
  90223. * @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
  90224. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90225. * @param scale is the value to scale the shape
  90226. * @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
  90227. * @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
  90228. * @param scene defines the hosting scene
  90229. * @param updatable defines if the mesh must be flagged as updatable
  90230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90231. * @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)
  90232. * @returns a new Mesh
  90233. */
  90234. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90235. /**
  90236. * Creates an custom extruded shape mesh.
  90237. * The custom extrusion is a parametric shape.
  90238. * It has no predefined shape. Its final shape will depend on the input parameters.
  90239. * Please consider using the same method from the MeshBuilder class instead
  90240. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90241. * @param name defines the name of the mesh to create
  90242. * @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
  90243. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90244. * @param scaleFunction is a custom Javascript function called on each path point
  90245. * @param rotationFunction is a custom Javascript function called on each path point
  90246. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90247. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90248. * @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
  90249. * @param scene defines the hosting scene
  90250. * @param updatable defines if the mesh must be flagged as updatable
  90251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90252. * @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)
  90253. * @returns a new Mesh
  90254. */
  90255. 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;
  90256. /**
  90257. * Creates lathe mesh.
  90258. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90259. * Please consider using the same method from the MeshBuilder class instead
  90260. * @param name defines the name of the mesh to create
  90261. * @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
  90262. * @param radius is the radius value of the lathe
  90263. * @param tessellation is the side number of the lathe.
  90264. * @param scene defines the hosting scene
  90265. * @param updatable defines if the mesh must be flagged as updatable
  90266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90267. * @returns a new Mesh
  90268. */
  90269. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90270. /**
  90271. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90272. * @param name defines the name of the mesh to create
  90273. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90274. * @param scene defines the hosting scene
  90275. * @param updatable defines if the mesh must be flagged as updatable
  90276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90277. * @returns a new Mesh
  90278. */
  90279. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90280. /**
  90281. * Creates a ground mesh.
  90282. * Please consider using the same method from the MeshBuilder class instead
  90283. * @param name defines the name of the mesh to create
  90284. * @param width set the width of the ground
  90285. * @param height set the height of the ground
  90286. * @param subdivisions sets the number of subdivisions per side
  90287. * @param scene defines the hosting scene
  90288. * @param updatable defines if the mesh must be flagged as updatable
  90289. * @returns a new Mesh
  90290. */
  90291. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90292. /**
  90293. * Creates a tiled ground mesh.
  90294. * Please consider using the same method from the MeshBuilder class instead
  90295. * @param name defines the name of the mesh to create
  90296. * @param xmin set the ground minimum X coordinate
  90297. * @param zmin set the ground minimum Y coordinate
  90298. * @param xmax set the ground maximum X coordinate
  90299. * @param zmax set the ground maximum Z coordinate
  90300. * @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
  90301. * @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
  90302. * @param scene defines the hosting scene
  90303. * @param updatable defines if the mesh must be flagged as updatable
  90304. * @returns a new Mesh
  90305. */
  90306. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90307. w: number;
  90308. h: number;
  90309. }, precision: {
  90310. w: number;
  90311. h: number;
  90312. }, scene: Scene, updatable?: boolean): Mesh;
  90313. /**
  90314. * Creates a ground mesh from a height map.
  90315. * Please consider using the same method from the MeshBuilder class instead
  90316. * @see http://doc.babylonjs.com/babylon101/height_map
  90317. * @param name defines the name of the mesh to create
  90318. * @param url sets the URL of the height map image resource
  90319. * @param width set the ground width size
  90320. * @param height set the ground height size
  90321. * @param subdivisions sets the number of subdivision per side
  90322. * @param minHeight is the minimum altitude on the ground
  90323. * @param maxHeight is the maximum altitude on the ground
  90324. * @param scene defines the hosting scene
  90325. * @param updatable defines if the mesh must be flagged as updatable
  90326. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90327. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90328. * @returns a new Mesh
  90329. */
  90330. 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;
  90331. /**
  90332. * Creates a tube mesh.
  90333. * The tube is a parametric shape.
  90334. * It has no predefined shape. Its final shape will depend on the input parameters.
  90335. * Please consider using the same method from the MeshBuilder class instead
  90336. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90337. * @param name defines the name of the mesh to create
  90338. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90339. * @param radius sets the tube radius size
  90340. * @param tessellation is the number of sides on the tubular surface
  90341. * @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
  90342. * @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
  90343. * @param scene defines the hosting scene
  90344. * @param updatable defines if the mesh must be flagged as updatable
  90345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90346. * @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)
  90347. * @returns a new Mesh
  90348. */
  90349. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90350. (i: number, distance: number): number;
  90351. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90352. /**
  90353. * Creates a polyhedron mesh.
  90354. * Please consider using the same method from the MeshBuilder class instead.
  90355. * * 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
  90356. * * The parameter `size` (positive float, default 1) sets the polygon size
  90357. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90358. * * 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`
  90359. * * 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
  90360. * * 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)`)
  90361. * * 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
  90362. * * 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
  90363. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90364. * * If you create a double-sided mesh, you can choose what parts of 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
  90365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90366. * @param name defines the name of the mesh to create
  90367. * @param options defines the options used to create the mesh
  90368. * @param scene defines the hosting scene
  90369. * @returns a new Mesh
  90370. */
  90371. static CreatePolyhedron(name: string, options: {
  90372. type?: number;
  90373. size?: number;
  90374. sizeX?: number;
  90375. sizeY?: number;
  90376. sizeZ?: number;
  90377. custom?: any;
  90378. faceUV?: Vector4[];
  90379. faceColors?: Color4[];
  90380. updatable?: boolean;
  90381. sideOrientation?: number;
  90382. }, scene: Scene): Mesh;
  90383. /**
  90384. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90385. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90386. * * 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`)
  90387. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90388. * * 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
  90389. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90390. * * If you create a double-sided mesh, you can choose what parts of 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
  90391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90392. * @param name defines the name of the mesh
  90393. * @param options defines the options used to create the mesh
  90394. * @param scene defines the hosting scene
  90395. * @returns a new Mesh
  90396. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90397. */
  90398. static CreateIcoSphere(name: string, options: {
  90399. radius?: number;
  90400. flat?: boolean;
  90401. subdivisions?: number;
  90402. sideOrientation?: number;
  90403. updatable?: boolean;
  90404. }, scene: Scene): Mesh;
  90405. /**
  90406. * Creates a decal mesh.
  90407. * Please consider using the same method from the MeshBuilder class instead.
  90408. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90409. * @param name defines the name of the mesh
  90410. * @param sourceMesh defines the mesh receiving the decal
  90411. * @param position sets the position of the decal in world coordinates
  90412. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90413. * @param size sets the decal scaling
  90414. * @param angle sets the angle to rotate the decal
  90415. * @returns a new Mesh
  90416. */
  90417. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90418. /**
  90419. * Prepare internal position array for software CPU skinning
  90420. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90421. */
  90422. setPositionsForCPUSkinning(): Float32Array;
  90423. /**
  90424. * Prepare internal normal array for software CPU skinning
  90425. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90426. */
  90427. setNormalsForCPUSkinning(): Float32Array;
  90428. /**
  90429. * Updates the vertex buffer by applying transformation from the bones
  90430. * @param skeleton defines the skeleton to apply to current mesh
  90431. * @returns the current mesh
  90432. */
  90433. applySkeleton(skeleton: Skeleton): Mesh;
  90434. /**
  90435. * 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
  90436. * @param meshes defines the list of meshes to scan
  90437. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90438. */
  90439. static MinMax(meshes: AbstractMesh[]): {
  90440. min: Vector3;
  90441. max: Vector3;
  90442. };
  90443. /**
  90444. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90445. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90446. * @returns a vector3
  90447. */
  90448. static Center(meshesOrMinMaxVector: {
  90449. min: Vector3;
  90450. max: Vector3;
  90451. } | AbstractMesh[]): Vector3;
  90452. /**
  90453. * Merge the array of meshes into a single mesh for performance reasons.
  90454. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90455. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90456. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90457. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90458. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90459. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90460. * @returns a new mesh
  90461. */
  90462. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90463. /** @hidden */
  90464. addInstance(instance: InstancedMesh): void;
  90465. /** @hidden */
  90466. removeInstance(instance: InstancedMesh): void;
  90467. }
  90468. }
  90469. declare module BABYLON {
  90470. /**
  90471. * This is the base class of all the camera used in the application.
  90472. * @see http://doc.babylonjs.com/features/cameras
  90473. */
  90474. export class Camera extends Node {
  90475. /** @hidden */
  90476. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90477. /**
  90478. * This is the default projection mode used by the cameras.
  90479. * It helps recreating a feeling of perspective and better appreciate depth.
  90480. * This is the best way to simulate real life cameras.
  90481. */
  90482. static readonly PERSPECTIVE_CAMERA: number;
  90483. /**
  90484. * This helps creating camera with an orthographic mode.
  90485. * 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.
  90486. */
  90487. static readonly ORTHOGRAPHIC_CAMERA: number;
  90488. /**
  90489. * This is the default FOV mode for perspective cameras.
  90490. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90491. */
  90492. static readonly FOVMODE_VERTICAL_FIXED: number;
  90493. /**
  90494. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90495. */
  90496. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90497. /**
  90498. * This specifies ther is no need for a camera rig.
  90499. * Basically only one eye is rendered corresponding to the camera.
  90500. */
  90501. static readonly RIG_MODE_NONE: number;
  90502. /**
  90503. * Simulates a camera Rig with one blue eye and one red eye.
  90504. * This can be use with 3d blue and red glasses.
  90505. */
  90506. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90507. /**
  90508. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90509. */
  90510. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90511. /**
  90512. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90513. */
  90514. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90515. /**
  90516. * Defines that both eyes of the camera will be rendered over under each other.
  90517. */
  90518. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90519. /**
  90520. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90521. */
  90522. static readonly RIG_MODE_VR: number;
  90523. /**
  90524. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90525. */
  90526. static readonly RIG_MODE_WEBVR: number;
  90527. /**
  90528. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90529. */
  90530. static readonly RIG_MODE_CUSTOM: number;
  90531. /**
  90532. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90533. */
  90534. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90535. /**
  90536. * Define the input manager associated with the camera.
  90537. */
  90538. inputs: CameraInputsManager<Camera>;
  90539. /** @hidden */
  90540. _position: Vector3;
  90541. /**
  90542. * Define the current local position of the camera in the scene
  90543. */
  90544. position: Vector3;
  90545. /**
  90546. * The vector the camera should consider as up.
  90547. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90548. */
  90549. upVector: Vector3;
  90550. /**
  90551. * Define the current limit on the left side for an orthographic camera
  90552. * In scene unit
  90553. */
  90554. orthoLeft: Nullable<number>;
  90555. /**
  90556. * Define the current limit on the right side for an orthographic camera
  90557. * In scene unit
  90558. */
  90559. orthoRight: Nullable<number>;
  90560. /**
  90561. * Define the current limit on the bottom side for an orthographic camera
  90562. * In scene unit
  90563. */
  90564. orthoBottom: Nullable<number>;
  90565. /**
  90566. * Define the current limit on the top side for an orthographic camera
  90567. * In scene unit
  90568. */
  90569. orthoTop: Nullable<number>;
  90570. /**
  90571. * Field Of View is set in Radians. (default is 0.8)
  90572. */
  90573. fov: number;
  90574. /**
  90575. * Define the minimum distance the camera can see from.
  90576. * This is important to note that the depth buffer are not infinite and the closer it starts
  90577. * the more your scene might encounter depth fighting issue.
  90578. */
  90579. minZ: number;
  90580. /**
  90581. * Define the maximum distance the camera can see to.
  90582. * This is important to note that the depth buffer are not infinite and the further it end
  90583. * the more your scene might encounter depth fighting issue.
  90584. */
  90585. maxZ: number;
  90586. /**
  90587. * Define the default inertia of the camera.
  90588. * This helps giving a smooth feeling to the camera movement.
  90589. */
  90590. inertia: number;
  90591. /**
  90592. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90593. */
  90594. mode: number;
  90595. /**
  90596. * Define wether the camera is intermediate.
  90597. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90598. */
  90599. isIntermediate: boolean;
  90600. /**
  90601. * Define the viewport of the camera.
  90602. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90603. */
  90604. viewport: Viewport;
  90605. /**
  90606. * Restricts the camera to viewing objects with the same layerMask.
  90607. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90608. */
  90609. layerMask: number;
  90610. /**
  90611. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90612. */
  90613. fovMode: number;
  90614. /**
  90615. * Rig mode of the camera.
  90616. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90617. * This is normally controlled byt the camera themselves as internal use.
  90618. */
  90619. cameraRigMode: number;
  90620. /**
  90621. * Defines the distance between both "eyes" in case of a RIG
  90622. */
  90623. interaxialDistance: number;
  90624. /**
  90625. * Defines if stereoscopic rendering is done side by side or over under.
  90626. */
  90627. isStereoscopicSideBySide: boolean;
  90628. /**
  90629. * 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
  90630. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90631. * else in the scene. (Eg. security camera)
  90632. *
  90633. * 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)
  90634. */
  90635. customRenderTargets: RenderTargetTexture[];
  90636. /**
  90637. * When set, the camera will render to this render target instead of the default canvas
  90638. *
  90639. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90640. */
  90641. outputRenderTarget: Nullable<RenderTargetTexture>;
  90642. /**
  90643. * Observable triggered when the camera view matrix has changed.
  90644. */
  90645. onViewMatrixChangedObservable: Observable<Camera>;
  90646. /**
  90647. * Observable triggered when the camera Projection matrix has changed.
  90648. */
  90649. onProjectionMatrixChangedObservable: Observable<Camera>;
  90650. /**
  90651. * Observable triggered when the inputs have been processed.
  90652. */
  90653. onAfterCheckInputsObservable: Observable<Camera>;
  90654. /**
  90655. * Observable triggered when reset has been called and applied to the camera.
  90656. */
  90657. onRestoreStateObservable: Observable<Camera>;
  90658. /** @hidden */
  90659. _cameraRigParams: any;
  90660. /** @hidden */
  90661. _rigCameras: Camera[];
  90662. /** @hidden */
  90663. _rigPostProcess: Nullable<PostProcess>;
  90664. protected _webvrViewMatrix: Matrix;
  90665. /** @hidden */
  90666. _skipRendering: boolean;
  90667. /** @hidden */
  90668. _projectionMatrix: Matrix;
  90669. /** @hidden */
  90670. _postProcesses: Nullable<PostProcess>[];
  90671. /** @hidden */
  90672. _activeMeshes: SmartArray<AbstractMesh>;
  90673. protected _globalPosition: Vector3;
  90674. /** @hidden */
  90675. _computedViewMatrix: Matrix;
  90676. private _doNotComputeProjectionMatrix;
  90677. private _transformMatrix;
  90678. private _frustumPlanes;
  90679. private _refreshFrustumPlanes;
  90680. private _storedFov;
  90681. private _stateStored;
  90682. /**
  90683. * Instantiates a new camera object.
  90684. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90685. * @see http://doc.babylonjs.com/features/cameras
  90686. * @param name Defines the name of the camera in the scene
  90687. * @param position Defines the position of the camera
  90688. * @param scene Defines the scene the camera belongs too
  90689. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90690. */
  90691. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90692. /**
  90693. * Store current camera state (fov, position, etc..)
  90694. * @returns the camera
  90695. */
  90696. storeState(): Camera;
  90697. /**
  90698. * Restores the camera state values if it has been stored. You must call storeState() first
  90699. */
  90700. protected _restoreStateValues(): boolean;
  90701. /**
  90702. * Restored camera state. You must call storeState() first.
  90703. * @returns true if restored and false otherwise
  90704. */
  90705. restoreState(): boolean;
  90706. /**
  90707. * Gets the class name of the camera.
  90708. * @returns the class name
  90709. */
  90710. getClassName(): string;
  90711. /** @hidden */
  90712. readonly _isCamera: boolean;
  90713. /**
  90714. * Gets a string representation of the camera useful for debug purpose.
  90715. * @param fullDetails Defines that a more verboe level of logging is required
  90716. * @returns the string representation
  90717. */
  90718. toString(fullDetails?: boolean): string;
  90719. /**
  90720. * Gets the current world space position of the camera.
  90721. */
  90722. readonly globalPosition: Vector3;
  90723. /**
  90724. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90725. * @returns the active meshe list
  90726. */
  90727. getActiveMeshes(): SmartArray<AbstractMesh>;
  90728. /**
  90729. * Check wether a mesh is part of the current active mesh list of the camera
  90730. * @param mesh Defines the mesh to check
  90731. * @returns true if active, false otherwise
  90732. */
  90733. isActiveMesh(mesh: Mesh): boolean;
  90734. /**
  90735. * Is this camera ready to be used/rendered
  90736. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90737. * @return true if the camera is ready
  90738. */
  90739. isReady(completeCheck?: boolean): boolean;
  90740. /** @hidden */
  90741. _initCache(): void;
  90742. /** @hidden */
  90743. _updateCache(ignoreParentClass?: boolean): void;
  90744. /** @hidden */
  90745. _isSynchronized(): boolean;
  90746. /** @hidden */
  90747. _isSynchronizedViewMatrix(): boolean;
  90748. /** @hidden */
  90749. _isSynchronizedProjectionMatrix(): boolean;
  90750. /**
  90751. * Attach the input controls to a specific dom element to get the input from.
  90752. * @param element Defines the element the controls should be listened from
  90753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90754. */
  90755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90756. /**
  90757. * Detach the current controls from the specified dom element.
  90758. * @param element Defines the element to stop listening the inputs from
  90759. */
  90760. detachControl(element: HTMLElement): void;
  90761. /**
  90762. * Update the camera state according to the different inputs gathered during the frame.
  90763. */
  90764. update(): void;
  90765. /** @hidden */
  90766. _checkInputs(): void;
  90767. /** @hidden */
  90768. readonly rigCameras: Camera[];
  90769. /**
  90770. * Gets the post process used by the rig cameras
  90771. */
  90772. readonly rigPostProcess: Nullable<PostProcess>;
  90773. /**
  90774. * Internal, gets the first post proces.
  90775. * @returns the first post process to be run on this camera.
  90776. */
  90777. _getFirstPostProcess(): Nullable<PostProcess>;
  90778. private _cascadePostProcessesToRigCams;
  90779. /**
  90780. * Attach a post process to the camera.
  90781. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90782. * @param postProcess The post process to attach to the camera
  90783. * @param insertAt The position of the post process in case several of them are in use in the scene
  90784. * @returns the position the post process has been inserted at
  90785. */
  90786. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90787. /**
  90788. * Detach a post process to the camera.
  90789. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90790. * @param postProcess The post process to detach from the camera
  90791. */
  90792. detachPostProcess(postProcess: PostProcess): void;
  90793. /**
  90794. * Gets the current world matrix of the camera
  90795. */
  90796. getWorldMatrix(): Matrix;
  90797. /** @hidden */
  90798. _getViewMatrix(): Matrix;
  90799. /**
  90800. * Gets the current view matrix of the camera.
  90801. * @param force forces the camera to recompute the matrix without looking at the cached state
  90802. * @returns the view matrix
  90803. */
  90804. getViewMatrix(force?: boolean): Matrix;
  90805. /**
  90806. * Freeze the projection matrix.
  90807. * It will prevent the cache check of the camera projection compute and can speed up perf
  90808. * if no parameter of the camera are meant to change
  90809. * @param projection Defines manually a projection if necessary
  90810. */
  90811. freezeProjectionMatrix(projection?: Matrix): void;
  90812. /**
  90813. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90814. */
  90815. unfreezeProjectionMatrix(): void;
  90816. /**
  90817. * Gets the current projection matrix of the camera.
  90818. * @param force forces the camera to recompute the matrix without looking at the cached state
  90819. * @returns the projection matrix
  90820. */
  90821. getProjectionMatrix(force?: boolean): Matrix;
  90822. /**
  90823. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90824. * @returns a Matrix
  90825. */
  90826. getTransformationMatrix(): Matrix;
  90827. private _updateFrustumPlanes;
  90828. /**
  90829. * Checks if a cullable object (mesh...) is in the camera frustum
  90830. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90831. * @param target The object to check
  90832. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90833. * @returns true if the object is in frustum otherwise false
  90834. */
  90835. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90836. /**
  90837. * Checks if a cullable object (mesh...) is in the camera frustum
  90838. * Unlike isInFrustum this cheks the full bounding box
  90839. * @param target The object to check
  90840. * @returns true if the object is in frustum otherwise false
  90841. */
  90842. isCompletelyInFrustum(target: ICullable): boolean;
  90843. /**
  90844. * Gets a ray in the forward direction from the camera.
  90845. * @param length Defines the length of the ray to create
  90846. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90847. * @param origin Defines the start point of the ray which defaults to the camera position
  90848. * @returns the forward ray
  90849. */
  90850. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90851. /**
  90852. * Releases resources associated with this node.
  90853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90855. */
  90856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90857. /** @hidden */
  90858. _isLeftCamera: boolean;
  90859. /**
  90860. * Gets the left camera of a rig setup in case of Rigged Camera
  90861. */
  90862. readonly isLeftCamera: boolean;
  90863. /** @hidden */
  90864. _isRightCamera: boolean;
  90865. /**
  90866. * Gets the right camera of a rig setup in case of Rigged Camera
  90867. */
  90868. readonly isRightCamera: boolean;
  90869. /**
  90870. * Gets the left camera of a rig setup in case of Rigged Camera
  90871. */
  90872. readonly leftCamera: Nullable<FreeCamera>;
  90873. /**
  90874. * Gets the right camera of a rig setup in case of Rigged Camera
  90875. */
  90876. readonly rightCamera: Nullable<FreeCamera>;
  90877. /**
  90878. * Gets the left camera target of a rig setup in case of Rigged Camera
  90879. * @returns the target position
  90880. */
  90881. getLeftTarget(): Nullable<Vector3>;
  90882. /**
  90883. * Gets the right camera target of a rig setup in case of Rigged Camera
  90884. * @returns the target position
  90885. */
  90886. getRightTarget(): Nullable<Vector3>;
  90887. /**
  90888. * @hidden
  90889. */
  90890. setCameraRigMode(mode: number, rigParams: any): void;
  90891. /** @hidden */
  90892. static _setStereoscopicRigMode(camera: Camera): void;
  90893. /** @hidden */
  90894. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90895. /** @hidden */
  90896. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90897. /** @hidden */
  90898. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90899. /** @hidden */
  90900. _getVRProjectionMatrix(): Matrix;
  90901. protected _updateCameraRotationMatrix(): void;
  90902. protected _updateWebVRCameraRotationMatrix(): void;
  90903. /**
  90904. * This function MUST be overwritten by the different WebVR cameras available.
  90905. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90906. * @hidden
  90907. */
  90908. _getWebVRProjectionMatrix(): Matrix;
  90909. /**
  90910. * This function MUST be overwritten by the different WebVR cameras available.
  90911. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90912. * @hidden
  90913. */
  90914. _getWebVRViewMatrix(): Matrix;
  90915. /** @hidden */
  90916. setCameraRigParameter(name: string, value: any): void;
  90917. /**
  90918. * needs to be overridden by children so sub has required properties to be copied
  90919. * @hidden
  90920. */
  90921. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90922. /**
  90923. * May need to be overridden by children
  90924. * @hidden
  90925. */
  90926. _updateRigCameras(): void;
  90927. /** @hidden */
  90928. _setupInputs(): void;
  90929. /**
  90930. * Serialiaze the camera setup to a json represention
  90931. * @returns the JSON representation
  90932. */
  90933. serialize(): any;
  90934. /**
  90935. * Clones the current camera.
  90936. * @param name The cloned camera name
  90937. * @returns the cloned camera
  90938. */
  90939. clone(name: string): Camera;
  90940. /**
  90941. * Gets the direction of the camera relative to a given local axis.
  90942. * @param localAxis Defines the reference axis to provide a relative direction.
  90943. * @return the direction
  90944. */
  90945. getDirection(localAxis: Vector3): Vector3;
  90946. /**
  90947. * Returns the current camera absolute rotation
  90948. */
  90949. readonly absoluteRotation: Quaternion;
  90950. /**
  90951. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90952. * @param localAxis Defines the reference axis to provide a relative direction.
  90953. * @param result Defines the vector to store the result in
  90954. */
  90955. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90956. /**
  90957. * Gets a camera constructor for a given camera type
  90958. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90959. * @param name The name of the camera the result will be able to instantiate
  90960. * @param scene The scene the result will construct the camera in
  90961. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90962. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90963. * @returns a factory method to construc the camera
  90964. */
  90965. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90966. /**
  90967. * Compute the world matrix of the camera.
  90968. * @returns the camera workd matrix
  90969. */
  90970. computeWorldMatrix(): Matrix;
  90971. /**
  90972. * Parse a JSON and creates the camera from the parsed information
  90973. * @param parsedCamera The JSON to parse
  90974. * @param scene The scene to instantiate the camera in
  90975. * @returns the newly constructed camera
  90976. */
  90977. static Parse(parsedCamera: any, scene: Scene): Camera;
  90978. }
  90979. }
  90980. declare module BABYLON {
  90981. /**
  90982. * Class containing static functions to help procedurally build meshes
  90983. */
  90984. export class DiscBuilder {
  90985. /**
  90986. * Creates a plane polygonal mesh. By default, this is a disc
  90987. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90988. * * 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
  90989. * * 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
  90990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90993. * @param name defines the name of the mesh
  90994. * @param options defines the options used to create the mesh
  90995. * @param scene defines the hosting scene
  90996. * @returns the plane polygonal mesh
  90997. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90998. */
  90999. static CreateDisc(name: string, options: {
  91000. radius?: number;
  91001. tessellation?: number;
  91002. arc?: number;
  91003. updatable?: boolean;
  91004. sideOrientation?: number;
  91005. frontUVs?: Vector4;
  91006. backUVs?: Vector4;
  91007. }, scene?: Nullable<Scene>): Mesh;
  91008. }
  91009. }
  91010. declare module BABYLON {
  91011. /**
  91012. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91013. *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.
  91014. * The SPS is also a particle system. It provides some methods to manage the particles.
  91015. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91016. *
  91017. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91018. */
  91019. export class SolidParticleSystem implements IDisposable {
  91020. /**
  91021. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91022. * Example : var p = SPS.particles[i];
  91023. */
  91024. particles: SolidParticle[];
  91025. /**
  91026. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91027. */
  91028. nbParticles: number;
  91029. /**
  91030. * If the particles must ever face the camera (default false). Useful for planar particles.
  91031. */
  91032. billboard: boolean;
  91033. /**
  91034. * Recompute normals when adding a shape
  91035. */
  91036. recomputeNormals: boolean;
  91037. /**
  91038. * This a counter ofr your own usage. It's not set by any SPS functions.
  91039. */
  91040. counter: number;
  91041. /**
  91042. * The SPS name. This name is also given to the underlying mesh.
  91043. */
  91044. name: string;
  91045. /**
  91046. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91047. */
  91048. mesh: Mesh;
  91049. /**
  91050. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91051. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91052. */
  91053. vars: any;
  91054. /**
  91055. * This array is populated when the SPS is set as 'pickable'.
  91056. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91057. * Each element of this array is an object `{idx: int, faceId: int}`.
  91058. * `idx` is the picked particle index in the `SPS.particles` array
  91059. * `faceId` is the picked face index counted within this particle.
  91060. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91061. */
  91062. pickedParticles: {
  91063. idx: number;
  91064. faceId: number;
  91065. }[];
  91066. /**
  91067. * This array is populated when `enableDepthSort` is set to true.
  91068. * Each element of this array is an instance of the class DepthSortedParticle.
  91069. */
  91070. depthSortedParticles: DepthSortedParticle[];
  91071. /**
  91072. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91073. * @hidden
  91074. */
  91075. _bSphereOnly: boolean;
  91076. /**
  91077. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91078. * @hidden
  91079. */
  91080. _bSphereRadiusFactor: number;
  91081. private _scene;
  91082. private _positions;
  91083. private _indices;
  91084. private _normals;
  91085. private _colors;
  91086. private _uvs;
  91087. private _indices32;
  91088. private _positions32;
  91089. private _normals32;
  91090. private _fixedNormal32;
  91091. private _colors32;
  91092. private _uvs32;
  91093. private _index;
  91094. private _updatable;
  91095. private _pickable;
  91096. private _isVisibilityBoxLocked;
  91097. private _alwaysVisible;
  91098. private _depthSort;
  91099. private _shapeCounter;
  91100. private _copy;
  91101. private _color;
  91102. private _computeParticleColor;
  91103. private _computeParticleTexture;
  91104. private _computeParticleRotation;
  91105. private _computeParticleVertex;
  91106. private _computeBoundingBox;
  91107. private _depthSortParticles;
  91108. private _camera;
  91109. private _mustUnrotateFixedNormals;
  91110. private _particlesIntersect;
  91111. private _needs32Bits;
  91112. /**
  91113. * Creates a SPS (Solid Particle System) object.
  91114. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91115. * @param scene (Scene) is the scene in which the SPS is added.
  91116. * @param options defines the options of the sps e.g.
  91117. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  91118. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  91119. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  91120. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  91121. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  91122. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91123. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91124. */
  91125. constructor(name: string, scene: Scene, options?: {
  91126. updatable?: boolean;
  91127. isPickable?: boolean;
  91128. enableDepthSort?: boolean;
  91129. particleIntersection?: boolean;
  91130. boundingSphereOnly?: boolean;
  91131. bSphereRadiusFactor?: number;
  91132. });
  91133. /**
  91134. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91135. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91136. * @returns the created mesh
  91137. */
  91138. buildMesh(): Mesh;
  91139. /**
  91140. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91141. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91142. * Thus the particles generated from `digest()` have their property `position` set yet.
  91143. * @param mesh ( Mesh ) is the mesh to be digested
  91144. * @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
  91145. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91146. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91147. * @returns the current SPS
  91148. */
  91149. digest(mesh: Mesh, options?: {
  91150. facetNb?: number;
  91151. number?: number;
  91152. delta?: number;
  91153. }): SolidParticleSystem;
  91154. private _unrotateFixedNormals;
  91155. private _resetCopy;
  91156. private _meshBuilder;
  91157. private _posToShape;
  91158. private _uvsToShapeUV;
  91159. private _addParticle;
  91160. /**
  91161. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91162. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91163. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91164. * @param nb (positive integer) the number of particles to be created from this model
  91165. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91166. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91167. * @returns the number of shapes in the system
  91168. */
  91169. addShape(mesh: Mesh, nb: number, options?: {
  91170. positionFunction?: any;
  91171. vertexFunction?: any;
  91172. }): number;
  91173. private _rebuildParticle;
  91174. /**
  91175. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91176. * @returns the SPS.
  91177. */
  91178. rebuildMesh(): SolidParticleSystem;
  91179. /**
  91180. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91181. * This method calls `updateParticle()` for each particle of the SPS.
  91182. * For an animated SPS, it is usually called within the render loop.
  91183. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91184. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91185. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91186. * @returns the SPS.
  91187. */
  91188. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91189. /**
  91190. * Disposes the SPS.
  91191. */
  91192. dispose(): void;
  91193. /**
  91194. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91196. * @returns the SPS.
  91197. */
  91198. refreshVisibleSize(): SolidParticleSystem;
  91199. /**
  91200. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91201. * @param size the size (float) of the visibility box
  91202. * note : this doesn't lock the SPS mesh bounding box.
  91203. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91204. */
  91205. setVisibilityBox(size: number): void;
  91206. /**
  91207. * Gets whether the SPS as always visible or not
  91208. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91209. */
  91210. /**
  91211. * Sets the SPS as always visible or not
  91212. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91213. */
  91214. isAlwaysVisible: boolean;
  91215. /**
  91216. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91217. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91218. */
  91219. /**
  91220. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91221. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91222. */
  91223. isVisibilityBoxLocked: boolean;
  91224. /**
  91225. * Tells to `setParticles()` to compute the particle rotations or not.
  91226. * Default value : true. The SPS is faster when it's set to false.
  91227. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91228. */
  91229. /**
  91230. * Gets if `setParticles()` computes the particle rotations or not.
  91231. * Default value : true. The SPS is faster when it's set to false.
  91232. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91233. */
  91234. computeParticleRotation: boolean;
  91235. /**
  91236. * Tells to `setParticles()` to compute the particle colors or not.
  91237. * Default value : true. The SPS is faster when it's set to false.
  91238. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91239. */
  91240. /**
  91241. * Gets if `setParticles()` computes the particle colors or not.
  91242. * Default value : true. The SPS is faster when it's set to false.
  91243. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91244. */
  91245. computeParticleColor: boolean;
  91246. /**
  91247. * Gets if `setParticles()` computes the particle textures or not.
  91248. * Default value : true. The SPS is faster when it's set to false.
  91249. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91250. */
  91251. computeParticleTexture: boolean;
  91252. /**
  91253. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91254. * Default value : false. The SPS is faster when it's set to false.
  91255. * Note : the particle custom vertex positions aren't stored values.
  91256. */
  91257. /**
  91258. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91259. * Default value : false. The SPS is faster when it's set to false.
  91260. * Note : the particle custom vertex positions aren't stored values.
  91261. */
  91262. computeParticleVertex: boolean;
  91263. /**
  91264. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91265. */
  91266. /**
  91267. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91268. */
  91269. computeBoundingBox: boolean;
  91270. /**
  91271. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91272. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91273. * Default : `true`
  91274. */
  91275. /**
  91276. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91277. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91278. * Default : `true`
  91279. */
  91280. depthSortParticles: boolean;
  91281. /**
  91282. * This function does nothing. It may be overwritten to set all the particle first values.
  91283. * The SPS doesn't call this function, you may have to call it by your own.
  91284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91285. */
  91286. initParticles(): void;
  91287. /**
  91288. * This function does nothing. It may be overwritten to recycle a particle.
  91289. * The SPS doesn't call this function, you may have to call it by your own.
  91290. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91291. * @param particle The particle to recycle
  91292. * @returns the recycled particle
  91293. */
  91294. recycleParticle(particle: SolidParticle): SolidParticle;
  91295. /**
  91296. * Updates a particle : this function should be overwritten by the user.
  91297. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91298. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91299. * @example : just set a particle position or velocity and recycle conditions
  91300. * @param particle The particle to update
  91301. * @returns the updated particle
  91302. */
  91303. updateParticle(particle: SolidParticle): SolidParticle;
  91304. /**
  91305. * Updates a vertex of a particle : it can be overwritten by the user.
  91306. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91307. * @param particle the current particle
  91308. * @param vertex the current index of the current particle
  91309. * @param pt the index of the current vertex in the particle shape
  91310. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91311. * @example : just set a vertex particle position
  91312. * @returns the updated vertex
  91313. */
  91314. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91315. /**
  91316. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91317. * This does nothing and may be overwritten by the user.
  91318. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91319. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91320. * @param update the boolean update value actually passed to setParticles()
  91321. */
  91322. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91323. /**
  91324. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91325. * This will be passed three parameters.
  91326. * This does nothing and may be overwritten by the user.
  91327. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91328. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91329. * @param update the boolean update value actually passed to setParticles()
  91330. */
  91331. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91332. }
  91333. }
  91334. declare module BABYLON {
  91335. /**
  91336. * Represents one particle of a solid particle system.
  91337. */
  91338. export class SolidParticle {
  91339. /**
  91340. * particle global index
  91341. */
  91342. idx: number;
  91343. /**
  91344. * The color of the particle
  91345. */
  91346. color: Nullable<Color4>;
  91347. /**
  91348. * The world space position of the particle.
  91349. */
  91350. position: Vector3;
  91351. /**
  91352. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91353. */
  91354. rotation: Vector3;
  91355. /**
  91356. * The world space rotation quaternion of the particle.
  91357. */
  91358. rotationQuaternion: Nullable<Quaternion>;
  91359. /**
  91360. * The scaling of the particle.
  91361. */
  91362. scaling: Vector3;
  91363. /**
  91364. * The uvs of the particle.
  91365. */
  91366. uvs: Vector4;
  91367. /**
  91368. * The current speed of the particle.
  91369. */
  91370. velocity: Vector3;
  91371. /**
  91372. * The pivot point in the particle local space.
  91373. */
  91374. pivot: Vector3;
  91375. /**
  91376. * Must the particle be translated from its pivot point in its local space ?
  91377. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91378. * Default : false
  91379. */
  91380. translateFromPivot: boolean;
  91381. /**
  91382. * Is the particle active or not ?
  91383. */
  91384. alive: boolean;
  91385. /**
  91386. * Is the particle visible or not ?
  91387. */
  91388. isVisible: boolean;
  91389. /**
  91390. * Index of this particle in the global "positions" array (Internal use)
  91391. * @hidden
  91392. */
  91393. _pos: number;
  91394. /**
  91395. * @hidden Index of this particle in the global "indices" array (Internal use)
  91396. */
  91397. _ind: number;
  91398. /**
  91399. * @hidden ModelShape of this particle (Internal use)
  91400. */
  91401. _model: ModelShape;
  91402. /**
  91403. * ModelShape id of this particle
  91404. */
  91405. shapeId: number;
  91406. /**
  91407. * Index of the particle in its shape id
  91408. */
  91409. idxInShape: number;
  91410. /**
  91411. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91412. */
  91413. _modelBoundingInfo: BoundingInfo;
  91414. /**
  91415. * @hidden Particle BoundingInfo object (Internal use)
  91416. */
  91417. _boundingInfo: BoundingInfo;
  91418. /**
  91419. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91420. */
  91421. _sps: SolidParticleSystem;
  91422. /**
  91423. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91424. */
  91425. _stillInvisible: boolean;
  91426. /**
  91427. * @hidden Last computed particle rotation matrix
  91428. */
  91429. _rotationMatrix: number[];
  91430. /**
  91431. * Parent particle Id, if any.
  91432. * Default null.
  91433. */
  91434. parentId: Nullable<number>;
  91435. /**
  91436. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91437. * The possible values are :
  91438. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91439. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91440. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91441. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91442. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91443. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91444. * */
  91445. cullingStrategy: number;
  91446. /**
  91447. * @hidden Internal global position in the SPS.
  91448. */
  91449. _globalPosition: Vector3;
  91450. /**
  91451. * Creates a Solid Particle object.
  91452. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91453. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91454. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91455. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91456. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91457. * @param shapeId (integer) is the model shape identifier in the SPS.
  91458. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91459. * @param sps defines the sps it is associated to
  91460. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91461. */
  91462. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91463. /**
  91464. * Legacy support, changed scale to scaling
  91465. */
  91466. /**
  91467. * Legacy support, changed scale to scaling
  91468. */
  91469. scale: Vector3;
  91470. /**
  91471. * Legacy support, changed quaternion to rotationQuaternion
  91472. */
  91473. /**
  91474. * Legacy support, changed quaternion to rotationQuaternion
  91475. */
  91476. quaternion: Nullable<Quaternion>;
  91477. /**
  91478. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91479. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91480. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91481. * @returns true if it intersects
  91482. */
  91483. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91484. /**
  91485. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91486. * A particle is in the frustum if its bounding box intersects the frustum
  91487. * @param frustumPlanes defines the frustum to test
  91488. * @returns true if the particle is in the frustum planes
  91489. */
  91490. isInFrustum(frustumPlanes: Plane[]): boolean;
  91491. /**
  91492. * get the rotation matrix of the particle
  91493. * @hidden
  91494. */
  91495. getRotationMatrix(m: Matrix): void;
  91496. }
  91497. /**
  91498. * Represents the shape of the model used by one particle of a solid particle system.
  91499. * SPS internal tool, don't use it manually.
  91500. */
  91501. export class ModelShape {
  91502. /**
  91503. * The shape id
  91504. * @hidden
  91505. */
  91506. shapeID: number;
  91507. /**
  91508. * flat array of model positions (internal use)
  91509. * @hidden
  91510. */
  91511. _shape: Vector3[];
  91512. /**
  91513. * flat array of model UVs (internal use)
  91514. * @hidden
  91515. */
  91516. _shapeUV: number[];
  91517. /**
  91518. * length of the shape in the model indices array (internal use)
  91519. * @hidden
  91520. */
  91521. _indicesLength: number;
  91522. /**
  91523. * Custom position function (internal use)
  91524. * @hidden
  91525. */
  91526. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91527. /**
  91528. * Custom vertex function (internal use)
  91529. * @hidden
  91530. */
  91531. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91532. /**
  91533. * 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.
  91534. * SPS internal tool, don't use it manually.
  91535. * @hidden
  91536. */
  91537. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  91538. }
  91539. /**
  91540. * Represents a Depth Sorted Particle in the solid particle system.
  91541. */
  91542. export class DepthSortedParticle {
  91543. /**
  91544. * Index of the particle in the "indices" array
  91545. */
  91546. ind: number;
  91547. /**
  91548. * Length of the particle shape in the "indices" array
  91549. */
  91550. indicesLength: number;
  91551. /**
  91552. * Squared distance from the particle to the camera
  91553. */
  91554. sqDistance: number;
  91555. }
  91556. }
  91557. declare module BABYLON {
  91558. /**
  91559. * @hidden
  91560. */
  91561. export class _MeshCollisionData {
  91562. _checkCollisions: boolean;
  91563. _collisionMask: number;
  91564. _collisionGroup: number;
  91565. _collider: Nullable<Collider>;
  91566. _oldPositionForCollisions: Vector3;
  91567. _diffPositionForCollisions: Vector3;
  91568. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91569. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91570. }
  91571. }
  91572. declare module BABYLON {
  91573. /** @hidden */
  91574. class _FacetDataStorage {
  91575. facetPositions: Vector3[];
  91576. facetNormals: Vector3[];
  91577. facetPartitioning: number[][];
  91578. facetNb: number;
  91579. partitioningSubdivisions: number;
  91580. partitioningBBoxRatio: number;
  91581. facetDataEnabled: boolean;
  91582. facetParameters: any;
  91583. bbSize: Vector3;
  91584. subDiv: {
  91585. max: number;
  91586. X: number;
  91587. Y: number;
  91588. Z: number;
  91589. };
  91590. facetDepthSort: boolean;
  91591. facetDepthSortEnabled: boolean;
  91592. depthSortedIndices: IndicesArray;
  91593. depthSortedFacets: {
  91594. ind: number;
  91595. sqDistance: number;
  91596. }[];
  91597. facetDepthSortFunction: (f1: {
  91598. ind: number;
  91599. sqDistance: number;
  91600. }, f2: {
  91601. ind: number;
  91602. sqDistance: number;
  91603. }) => number;
  91604. facetDepthSortFrom: Vector3;
  91605. facetDepthSortOrigin: Vector3;
  91606. invertedMatrix: Matrix;
  91607. }
  91608. /**
  91609. * @hidden
  91610. **/
  91611. class _InternalAbstractMeshDataInfo {
  91612. _hasVertexAlpha: boolean;
  91613. _useVertexColors: boolean;
  91614. _numBoneInfluencers: number;
  91615. _applyFog: boolean;
  91616. _receiveShadows: boolean;
  91617. _facetData: _FacetDataStorage;
  91618. _visibility: number;
  91619. _skeleton: Nullable<Skeleton>;
  91620. _layerMask: number;
  91621. _computeBonesUsingShaders: boolean;
  91622. _isActive: boolean;
  91623. _onlyForInstances: boolean;
  91624. _isActiveIntermediate: boolean;
  91625. _onlyForInstancesIntermediate: boolean;
  91626. }
  91627. /**
  91628. * Class used to store all common mesh properties
  91629. */
  91630. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91631. /** No occlusion */
  91632. static OCCLUSION_TYPE_NONE: number;
  91633. /** Occlusion set to optimisitic */
  91634. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91635. /** Occlusion set to strict */
  91636. static OCCLUSION_TYPE_STRICT: number;
  91637. /** Use an accurante occlusion algorithm */
  91638. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91639. /** Use a conservative occlusion algorithm */
  91640. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91641. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91642. * Test order :
  91643. * Is the bounding sphere outside the frustum ?
  91644. * If not, are the bounding box vertices outside the frustum ?
  91645. * It not, then the cullable object is in the frustum.
  91646. */
  91647. static readonly CULLINGSTRATEGY_STANDARD: number;
  91648. /** Culling strategy : Bounding Sphere Only.
  91649. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91650. * It's also less accurate than the standard because some not visible objects can still be selected.
  91651. * Test : is the bounding sphere outside the frustum ?
  91652. * If not, then the cullable object is in the frustum.
  91653. */
  91654. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91655. /** Culling strategy : Optimistic Inclusion.
  91656. * This in an inclusion test first, then the standard exclusion test.
  91657. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91658. * 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.
  91659. * Anyway, it's as accurate as the standard strategy.
  91660. * Test :
  91661. * Is the cullable object bounding sphere center in the frustum ?
  91662. * If not, apply the default culling strategy.
  91663. */
  91664. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91665. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91666. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91667. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91668. * 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.
  91669. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91670. * Test :
  91671. * Is the cullable object bounding sphere center in the frustum ?
  91672. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91673. */
  91674. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91675. /**
  91676. * No billboard
  91677. */
  91678. static readonly BILLBOARDMODE_NONE: number;
  91679. /** Billboard on X axis */
  91680. static readonly BILLBOARDMODE_X: number;
  91681. /** Billboard on Y axis */
  91682. static readonly BILLBOARDMODE_Y: number;
  91683. /** Billboard on Z axis */
  91684. static readonly BILLBOARDMODE_Z: number;
  91685. /** Billboard on all axes */
  91686. static readonly BILLBOARDMODE_ALL: number;
  91687. /** Billboard on using position instead of orientation */
  91688. static readonly BILLBOARDMODE_USE_POSITION: number;
  91689. /** @hidden */
  91690. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91691. /**
  91692. * The culling strategy to use to check whether the mesh must be rendered or not.
  91693. * This value can be changed at any time and will be used on the next render mesh selection.
  91694. * The possible values are :
  91695. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91696. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91699. * Please read each static variable documentation to get details about the culling process.
  91700. * */
  91701. cullingStrategy: number;
  91702. /**
  91703. * Gets the number of facets in the mesh
  91704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91705. */
  91706. readonly facetNb: number;
  91707. /**
  91708. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91710. */
  91711. partitioningSubdivisions: number;
  91712. /**
  91713. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91714. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91716. */
  91717. partitioningBBoxRatio: number;
  91718. /**
  91719. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91720. * Works only for updatable meshes.
  91721. * Doesn't work with multi-materials
  91722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91723. */
  91724. mustDepthSortFacets: boolean;
  91725. /**
  91726. * The location (Vector3) where the facet depth sort must be computed from.
  91727. * By default, the active camera position.
  91728. * Used only when facet depth sort is enabled
  91729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91730. */
  91731. facetDepthSortFrom: Vector3;
  91732. /**
  91733. * gets a boolean indicating if facetData is enabled
  91734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91735. */
  91736. readonly isFacetDataEnabled: boolean;
  91737. /** @hidden */
  91738. _updateNonUniformScalingState(value: boolean): boolean;
  91739. /**
  91740. * An event triggered when this mesh collides with another one
  91741. */
  91742. onCollideObservable: Observable<AbstractMesh>;
  91743. /** Set a function to call when this mesh collides with another one */
  91744. onCollide: () => void;
  91745. /**
  91746. * An event triggered when the collision's position changes
  91747. */
  91748. onCollisionPositionChangeObservable: Observable<Vector3>;
  91749. /** Set a function to call when the collision's position changes */
  91750. onCollisionPositionChange: () => void;
  91751. /**
  91752. * An event triggered when material is changed
  91753. */
  91754. onMaterialChangedObservable: Observable<AbstractMesh>;
  91755. /**
  91756. * Gets or sets the orientation for POV movement & rotation
  91757. */
  91758. definedFacingForward: boolean;
  91759. /** @hidden */
  91760. _occlusionQuery: Nullable<WebGLQuery>;
  91761. /** @hidden */
  91762. _renderingGroup: Nullable<RenderingGroup>;
  91763. /**
  91764. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91765. */
  91766. /**
  91767. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91768. */
  91769. visibility: number;
  91770. /** Gets or sets the alpha index used to sort transparent meshes
  91771. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91772. */
  91773. alphaIndex: number;
  91774. /**
  91775. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91776. */
  91777. isVisible: boolean;
  91778. /**
  91779. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91780. */
  91781. isPickable: boolean;
  91782. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91783. showSubMeshesBoundingBox: boolean;
  91784. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91785. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91786. */
  91787. isBlocker: boolean;
  91788. /**
  91789. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91790. */
  91791. enablePointerMoveEvents: boolean;
  91792. /**
  91793. * Specifies the rendering group id for this mesh (0 by default)
  91794. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91795. */
  91796. renderingGroupId: number;
  91797. private _material;
  91798. /** Gets or sets current material */
  91799. material: Nullable<Material>;
  91800. /**
  91801. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91802. * @see http://doc.babylonjs.com/babylon101/shadows
  91803. */
  91804. receiveShadows: boolean;
  91805. /** Defines color to use when rendering outline */
  91806. outlineColor: Color3;
  91807. /** Define width to use when rendering outline */
  91808. outlineWidth: number;
  91809. /** Defines color to use when rendering overlay */
  91810. overlayColor: Color3;
  91811. /** Defines alpha to use when rendering overlay */
  91812. overlayAlpha: number;
  91813. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91814. hasVertexAlpha: boolean;
  91815. /** 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) */
  91816. useVertexColors: boolean;
  91817. /**
  91818. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91819. */
  91820. computeBonesUsingShaders: boolean;
  91821. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91822. numBoneInfluencers: number;
  91823. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91824. applyFog: boolean;
  91825. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91826. useOctreeForRenderingSelection: boolean;
  91827. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91828. useOctreeForPicking: boolean;
  91829. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91830. useOctreeForCollisions: boolean;
  91831. /**
  91832. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91833. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91834. */
  91835. layerMask: number;
  91836. /**
  91837. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91838. */
  91839. alwaysSelectAsActiveMesh: boolean;
  91840. /**
  91841. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91842. */
  91843. doNotSyncBoundingInfo: boolean;
  91844. /**
  91845. * Gets or sets the current action manager
  91846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91847. */
  91848. actionManager: Nullable<AbstractActionManager>;
  91849. private _meshCollisionData;
  91850. /**
  91851. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91853. */
  91854. ellipsoid: Vector3;
  91855. /**
  91856. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91858. */
  91859. ellipsoidOffset: Vector3;
  91860. /**
  91861. * Gets or sets a collision mask used to mask collisions (default is -1).
  91862. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91863. */
  91864. collisionMask: number;
  91865. /**
  91866. * Gets or sets the current collision group mask (-1 by default).
  91867. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91868. */
  91869. collisionGroup: number;
  91870. /**
  91871. * Defines edge width used when edgesRenderer is enabled
  91872. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91873. */
  91874. edgesWidth: number;
  91875. /**
  91876. * Defines edge color used when edgesRenderer is enabled
  91877. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91878. */
  91879. edgesColor: Color4;
  91880. /** @hidden */
  91881. _edgesRenderer: Nullable<IEdgesRenderer>;
  91882. /** @hidden */
  91883. _masterMesh: Nullable<AbstractMesh>;
  91884. /** @hidden */
  91885. _boundingInfo: Nullable<BoundingInfo>;
  91886. /** @hidden */
  91887. _renderId: number;
  91888. /**
  91889. * Gets or sets the list of subMeshes
  91890. * @see http://doc.babylonjs.com/how_to/multi_materials
  91891. */
  91892. subMeshes: SubMesh[];
  91893. /** @hidden */
  91894. _intersectionsInProgress: AbstractMesh[];
  91895. /** @hidden */
  91896. _unIndexed: boolean;
  91897. /** @hidden */
  91898. _lightSources: Light[];
  91899. /** Gets the list of lights affecting that mesh */
  91900. readonly lightSources: Light[];
  91901. /** @hidden */
  91902. readonly _positions: Nullable<Vector3[]>;
  91903. /** @hidden */
  91904. _waitingData: {
  91905. lods: Nullable<any>;
  91906. actions: Nullable<any>;
  91907. freezeWorldMatrix: Nullable<boolean>;
  91908. };
  91909. /** @hidden */
  91910. _bonesTransformMatrices: Nullable<Float32Array>;
  91911. /** @hidden */
  91912. _transformMatrixTexture: Nullable<RawTexture>;
  91913. /**
  91914. * Gets or sets a skeleton to apply skining transformations
  91915. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91916. */
  91917. skeleton: Nullable<Skeleton>;
  91918. /**
  91919. * An event triggered when the mesh is rebuilt.
  91920. */
  91921. onRebuildObservable: Observable<AbstractMesh>;
  91922. /**
  91923. * Creates a new AbstractMesh
  91924. * @param name defines the name of the mesh
  91925. * @param scene defines the hosting scene
  91926. */
  91927. constructor(name: string, scene?: Nullable<Scene>);
  91928. /**
  91929. * Returns the string "AbstractMesh"
  91930. * @returns "AbstractMesh"
  91931. */
  91932. getClassName(): string;
  91933. /**
  91934. * Gets a string representation of the current mesh
  91935. * @param fullDetails defines a boolean indicating if full details must be included
  91936. * @returns a string representation of the current mesh
  91937. */
  91938. toString(fullDetails?: boolean): string;
  91939. /**
  91940. * @hidden
  91941. */
  91942. protected _getEffectiveParent(): Nullable<Node>;
  91943. /** @hidden */
  91944. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91945. /** @hidden */
  91946. _rebuild(): void;
  91947. /** @hidden */
  91948. _resyncLightSources(): void;
  91949. /** @hidden */
  91950. _resyncLighSource(light: Light): void;
  91951. /** @hidden */
  91952. _unBindEffect(): void;
  91953. /** @hidden */
  91954. _removeLightSource(light: Light, dispose: boolean): void;
  91955. private _markSubMeshesAsDirty;
  91956. /** @hidden */
  91957. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91958. /** @hidden */
  91959. _markSubMeshesAsAttributesDirty(): void;
  91960. /** @hidden */
  91961. _markSubMeshesAsMiscDirty(): void;
  91962. /**
  91963. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91964. */
  91965. scaling: Vector3;
  91966. /**
  91967. * Returns true if the mesh is blocked. Implemented by child classes
  91968. */
  91969. readonly isBlocked: boolean;
  91970. /**
  91971. * Returns the mesh itself by default. Implemented by child classes
  91972. * @param camera defines the camera to use to pick the right LOD level
  91973. * @returns the currentAbstractMesh
  91974. */
  91975. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91976. /**
  91977. * Returns 0 by default. Implemented by child classes
  91978. * @returns an integer
  91979. */
  91980. getTotalVertices(): number;
  91981. /**
  91982. * Returns a positive integer : the total number of indices in this mesh geometry.
  91983. * @returns the numner of indices or zero if the mesh has no geometry.
  91984. */
  91985. getTotalIndices(): number;
  91986. /**
  91987. * Returns null by default. Implemented by child classes
  91988. * @returns null
  91989. */
  91990. getIndices(): Nullable<IndicesArray>;
  91991. /**
  91992. * Returns the array of the requested vertex data kind. Implemented by child classes
  91993. * @param kind defines the vertex data kind to use
  91994. * @returns null
  91995. */
  91996. getVerticesData(kind: string): Nullable<FloatArray>;
  91997. /**
  91998. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91999. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92000. * Note that a new underlying VertexBuffer object is created each call.
  92001. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92002. * @param kind defines vertex data kind:
  92003. * * VertexBuffer.PositionKind
  92004. * * VertexBuffer.UVKind
  92005. * * VertexBuffer.UV2Kind
  92006. * * VertexBuffer.UV3Kind
  92007. * * VertexBuffer.UV4Kind
  92008. * * VertexBuffer.UV5Kind
  92009. * * VertexBuffer.UV6Kind
  92010. * * VertexBuffer.ColorKind
  92011. * * VertexBuffer.MatricesIndicesKind
  92012. * * VertexBuffer.MatricesIndicesExtraKind
  92013. * * VertexBuffer.MatricesWeightsKind
  92014. * * VertexBuffer.MatricesWeightsExtraKind
  92015. * @param data defines the data source
  92016. * @param updatable defines if the data must be flagged as updatable (or static)
  92017. * @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
  92018. * @returns the current mesh
  92019. */
  92020. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92021. /**
  92022. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92023. * If the mesh has no geometry, it is simply returned as it is.
  92024. * @param kind defines vertex data kind:
  92025. * * VertexBuffer.PositionKind
  92026. * * VertexBuffer.UVKind
  92027. * * VertexBuffer.UV2Kind
  92028. * * VertexBuffer.UV3Kind
  92029. * * VertexBuffer.UV4Kind
  92030. * * VertexBuffer.UV5Kind
  92031. * * VertexBuffer.UV6Kind
  92032. * * VertexBuffer.ColorKind
  92033. * * VertexBuffer.MatricesIndicesKind
  92034. * * VertexBuffer.MatricesIndicesExtraKind
  92035. * * VertexBuffer.MatricesWeightsKind
  92036. * * VertexBuffer.MatricesWeightsExtraKind
  92037. * @param data defines the data source
  92038. * @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
  92039. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92040. * @returns the current mesh
  92041. */
  92042. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92043. /**
  92044. * Sets the mesh indices,
  92045. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92046. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92047. * @param totalVertices Defines the total number of vertices
  92048. * @returns the current mesh
  92049. */
  92050. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92051. /**
  92052. * Gets a boolean indicating if specific vertex data is present
  92053. * @param kind defines the vertex data kind to use
  92054. * @returns true is data kind is present
  92055. */
  92056. isVerticesDataPresent(kind: string): boolean;
  92057. /**
  92058. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92059. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92060. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92061. * @returns a BoundingInfo
  92062. */
  92063. getBoundingInfo(): BoundingInfo;
  92064. /**
  92065. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92066. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92067. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92068. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92069. * @returns the current mesh
  92070. */
  92071. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92072. /**
  92073. * Overwrite the current bounding info
  92074. * @param boundingInfo defines the new bounding info
  92075. * @returns the current mesh
  92076. */
  92077. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92078. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92079. readonly useBones: boolean;
  92080. /** @hidden */
  92081. _preActivate(): void;
  92082. /** @hidden */
  92083. _preActivateForIntermediateRendering(renderId: number): void;
  92084. /** @hidden */
  92085. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92086. /** @hidden */
  92087. _postActivate(): void;
  92088. /** @hidden */
  92089. _freeze(): void;
  92090. /** @hidden */
  92091. _unFreeze(): void;
  92092. /**
  92093. * Gets the current world matrix
  92094. * @returns a Matrix
  92095. */
  92096. getWorldMatrix(): Matrix;
  92097. /** @hidden */
  92098. _getWorldMatrixDeterminant(): number;
  92099. /**
  92100. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92101. */
  92102. readonly isAnInstance: boolean;
  92103. /**
  92104. * Gets a boolean indicating if this mesh has instances
  92105. */
  92106. readonly hasInstances: boolean;
  92107. /**
  92108. * Perform relative position change from the point of view of behind the front of the mesh.
  92109. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92110. * Supports definition of mesh facing forward or backward
  92111. * @param amountRight defines the distance on the right axis
  92112. * @param amountUp defines the distance on the up axis
  92113. * @param amountForward defines the distance on the forward axis
  92114. * @returns the current mesh
  92115. */
  92116. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92117. /**
  92118. * Calculate relative position change from the point of view of behind the front of the mesh.
  92119. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92120. * Supports definition of mesh facing forward or backward
  92121. * @param amountRight defines the distance on the right axis
  92122. * @param amountUp defines the distance on the up axis
  92123. * @param amountForward defines the distance on the forward axis
  92124. * @returns the new displacement vector
  92125. */
  92126. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92127. /**
  92128. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92129. * Supports definition of mesh facing forward or backward
  92130. * @param flipBack defines the flip
  92131. * @param twirlClockwise defines the twirl
  92132. * @param tiltRight defines the tilt
  92133. * @returns the current mesh
  92134. */
  92135. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92136. /**
  92137. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92138. * Supports definition of mesh facing forward or backward.
  92139. * @param flipBack defines the flip
  92140. * @param twirlClockwise defines the twirl
  92141. * @param tiltRight defines the tilt
  92142. * @returns the new rotation vector
  92143. */
  92144. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92145. /**
  92146. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92147. * This means the mesh underlying bounding box and sphere are recomputed.
  92148. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92149. * @returns the current mesh
  92150. */
  92151. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92152. /** @hidden */
  92153. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92154. /** @hidden */
  92155. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92156. /** @hidden */
  92157. _updateBoundingInfo(): AbstractMesh;
  92158. /** @hidden */
  92159. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92160. /** @hidden */
  92161. protected _afterComputeWorldMatrix(): void;
  92162. /** @hidden */
  92163. readonly _effectiveMesh: AbstractMesh;
  92164. /**
  92165. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92166. * A mesh is in the frustum if its bounding box intersects the frustum
  92167. * @param frustumPlanes defines the frustum to test
  92168. * @returns true if the mesh is in the frustum planes
  92169. */
  92170. isInFrustum(frustumPlanes: Plane[]): boolean;
  92171. /**
  92172. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92173. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92174. * @param frustumPlanes defines the frustum to test
  92175. * @returns true if the mesh is completely in the frustum planes
  92176. */
  92177. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92178. /**
  92179. * True if the mesh intersects another mesh or a SolidParticle object
  92180. * @param mesh defines a target mesh or SolidParticle to test
  92181. * @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)
  92182. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92183. * @returns true if there is an intersection
  92184. */
  92185. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92186. /**
  92187. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92188. * @param point defines the point to test
  92189. * @returns true if there is an intersection
  92190. */
  92191. intersectsPoint(point: Vector3): boolean;
  92192. /**
  92193. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92195. */
  92196. checkCollisions: boolean;
  92197. /**
  92198. * Gets Collider object used to compute collisions (not physics)
  92199. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92200. */
  92201. readonly collider: Nullable<Collider>;
  92202. /**
  92203. * Move the mesh using collision engine
  92204. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92205. * @param displacement defines the requested displacement vector
  92206. * @returns the current mesh
  92207. */
  92208. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92209. private _onCollisionPositionChange;
  92210. /** @hidden */
  92211. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92212. /** @hidden */
  92213. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92214. /** @hidden */
  92215. _checkCollision(collider: Collider): AbstractMesh;
  92216. /** @hidden */
  92217. _generatePointsArray(): boolean;
  92218. /**
  92219. * Checks if the passed Ray intersects with the mesh
  92220. * @param ray defines the ray to use
  92221. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92222. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92223. * @returns the picking info
  92224. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92225. */
  92226. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92227. /**
  92228. * Clones the current mesh
  92229. * @param name defines the mesh name
  92230. * @param newParent defines the new mesh parent
  92231. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92232. * @returns the new mesh
  92233. */
  92234. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92235. /**
  92236. * Disposes all the submeshes of the current meshnp
  92237. * @returns the current mesh
  92238. */
  92239. releaseSubMeshes(): AbstractMesh;
  92240. /**
  92241. * Releases resources associated with this abstract mesh.
  92242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92244. */
  92245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92246. /**
  92247. * Adds the passed mesh as a child to the current mesh
  92248. * @param mesh defines the child mesh
  92249. * @returns the current mesh
  92250. */
  92251. addChild(mesh: AbstractMesh): AbstractMesh;
  92252. /**
  92253. * Removes the passed mesh from the current mesh children list
  92254. * @param mesh defines the child mesh
  92255. * @returns the current mesh
  92256. */
  92257. removeChild(mesh: AbstractMesh): AbstractMesh;
  92258. /** @hidden */
  92259. private _initFacetData;
  92260. /**
  92261. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92262. * This method can be called within the render loop.
  92263. * 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
  92264. * @returns the current mesh
  92265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92266. */
  92267. updateFacetData(): AbstractMesh;
  92268. /**
  92269. * Returns the facetLocalNormals array.
  92270. * The normals are expressed in the mesh local spac
  92271. * @returns an array of Vector3
  92272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92273. */
  92274. getFacetLocalNormals(): Vector3[];
  92275. /**
  92276. * Returns the facetLocalPositions array.
  92277. * The facet positions are expressed in the mesh local space
  92278. * @returns an array of Vector3
  92279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92280. */
  92281. getFacetLocalPositions(): Vector3[];
  92282. /**
  92283. * Returns the facetLocalPartioning array
  92284. * @returns an array of array of numbers
  92285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92286. */
  92287. getFacetLocalPartitioning(): number[][];
  92288. /**
  92289. * Returns the i-th facet position in the world system.
  92290. * This method allocates a new Vector3 per call
  92291. * @param i defines the facet index
  92292. * @returns a new Vector3
  92293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92294. */
  92295. getFacetPosition(i: number): Vector3;
  92296. /**
  92297. * Sets the reference Vector3 with the i-th facet position in the world system
  92298. * @param i defines the facet index
  92299. * @param ref defines the target vector
  92300. * @returns the current mesh
  92301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92302. */
  92303. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92304. /**
  92305. * Returns the i-th facet normal in the world system.
  92306. * This method allocates a new Vector3 per call
  92307. * @param i defines the facet index
  92308. * @returns a new Vector3
  92309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92310. */
  92311. getFacetNormal(i: number): Vector3;
  92312. /**
  92313. * Sets the reference Vector3 with the i-th facet normal in the world system
  92314. * @param i defines the facet index
  92315. * @param ref defines the target vector
  92316. * @returns the current mesh
  92317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92318. */
  92319. getFacetNormalToRef(i: number, ref: Vector3): this;
  92320. /**
  92321. * 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)
  92322. * @param x defines x coordinate
  92323. * @param y defines y coordinate
  92324. * @param z defines z coordinate
  92325. * @returns the array of facet indexes
  92326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92327. */
  92328. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92329. /**
  92330. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92331. * @param projected sets as the (x,y,z) world projection on the facet
  92332. * @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
  92333. * @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
  92334. * @param x defines x coordinate
  92335. * @param y defines y coordinate
  92336. * @param z defines z coordinate
  92337. * @returns the face index if found (or null instead)
  92338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92339. */
  92340. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92341. /**
  92342. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92343. * @param projected sets as the (x,y,z) local projection on the facet
  92344. * @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
  92345. * @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
  92346. * @param x defines x coordinate
  92347. * @param y defines y coordinate
  92348. * @param z defines z coordinate
  92349. * @returns the face index if found (or null instead)
  92350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92351. */
  92352. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92353. /**
  92354. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92355. * @returns the parameters
  92356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92357. */
  92358. getFacetDataParameters(): any;
  92359. /**
  92360. * Disables the feature FacetData and frees the related memory
  92361. * @returns the current mesh
  92362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92363. */
  92364. disableFacetData(): AbstractMesh;
  92365. /**
  92366. * Updates the AbstractMesh indices array
  92367. * @param indices defines the data source
  92368. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92369. * @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)
  92370. * @returns the current mesh
  92371. */
  92372. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92373. /**
  92374. * Creates new normals data for the mesh
  92375. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92376. * @returns the current mesh
  92377. */
  92378. createNormals(updatable: boolean): AbstractMesh;
  92379. /**
  92380. * Align the mesh with a normal
  92381. * @param normal defines the normal to use
  92382. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92383. * @returns the current mesh
  92384. */
  92385. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92386. /** @hidden */
  92387. _checkOcclusionQuery(): boolean;
  92388. /**
  92389. * Disables the mesh edge rendering mode
  92390. * @returns the currentAbstractMesh
  92391. */
  92392. disableEdgesRendering(): AbstractMesh;
  92393. /**
  92394. * Enables the edge rendering mode on the mesh.
  92395. * This mode makes the mesh edges visible
  92396. * @param epsilon defines the maximal distance between two angles to detect a face
  92397. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92398. * @returns the currentAbstractMesh
  92399. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92400. */
  92401. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92402. }
  92403. }
  92404. declare module BABYLON {
  92405. /**
  92406. * Interface used to define ActionEvent
  92407. */
  92408. export interface IActionEvent {
  92409. /** The mesh or sprite that triggered the action */
  92410. source: any;
  92411. /** The X mouse cursor position at the time of the event */
  92412. pointerX: number;
  92413. /** The Y mouse cursor position at the time of the event */
  92414. pointerY: number;
  92415. /** The mesh that is currently pointed at (can be null) */
  92416. meshUnderPointer: Nullable<AbstractMesh>;
  92417. /** the original (browser) event that triggered the ActionEvent */
  92418. sourceEvent?: any;
  92419. /** additional data for the event */
  92420. additionalData?: any;
  92421. }
  92422. /**
  92423. * ActionEvent is the event being sent when an action is triggered.
  92424. */
  92425. export class ActionEvent implements IActionEvent {
  92426. /** The mesh or sprite that triggered the action */
  92427. source: any;
  92428. /** The X mouse cursor position at the time of the event */
  92429. pointerX: number;
  92430. /** The Y mouse cursor position at the time of the event */
  92431. pointerY: number;
  92432. /** The mesh that is currently pointed at (can be null) */
  92433. meshUnderPointer: Nullable<AbstractMesh>;
  92434. /** the original (browser) event that triggered the ActionEvent */
  92435. sourceEvent?: any;
  92436. /** additional data for the event */
  92437. additionalData?: any;
  92438. /**
  92439. * Creates a new ActionEvent
  92440. * @param source The mesh or sprite that triggered the action
  92441. * @param pointerX The X mouse cursor position at the time of the event
  92442. * @param pointerY The Y mouse cursor position at the time of the event
  92443. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92444. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92445. * @param additionalData additional data for the event
  92446. */
  92447. constructor(
  92448. /** The mesh or sprite that triggered the action */
  92449. source: any,
  92450. /** The X mouse cursor position at the time of the event */
  92451. pointerX: number,
  92452. /** The Y mouse cursor position at the time of the event */
  92453. pointerY: number,
  92454. /** The mesh that is currently pointed at (can be null) */
  92455. meshUnderPointer: Nullable<AbstractMesh>,
  92456. /** the original (browser) event that triggered the ActionEvent */
  92457. sourceEvent?: any,
  92458. /** additional data for the event */
  92459. additionalData?: any);
  92460. /**
  92461. * Helper function to auto-create an ActionEvent from a source mesh.
  92462. * @param source The source mesh that triggered the event
  92463. * @param evt The original (browser) event
  92464. * @param additionalData additional data for the event
  92465. * @returns the new ActionEvent
  92466. */
  92467. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92468. /**
  92469. * Helper function to auto-create an ActionEvent from a source sprite
  92470. * @param source The source sprite that triggered the event
  92471. * @param scene Scene associated with the sprite
  92472. * @param evt The original (browser) event
  92473. * @param additionalData additional data for the event
  92474. * @returns the new ActionEvent
  92475. */
  92476. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92477. /**
  92478. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92479. * @param scene the scene where the event occurred
  92480. * @param evt The original (browser) event
  92481. * @returns the new ActionEvent
  92482. */
  92483. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92484. /**
  92485. * Helper function to auto-create an ActionEvent from a primitive
  92486. * @param prim defines the target primitive
  92487. * @param pointerPos defines the pointer position
  92488. * @param evt The original (browser) event
  92489. * @param additionalData additional data for the event
  92490. * @returns the new ActionEvent
  92491. */
  92492. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92493. }
  92494. }
  92495. declare module BABYLON {
  92496. /**
  92497. * Abstract class used to decouple action Manager from scene and meshes.
  92498. * Do not instantiate.
  92499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92500. */
  92501. export abstract class AbstractActionManager implements IDisposable {
  92502. /** Gets the list of active triggers */
  92503. static Triggers: {
  92504. [key: string]: number;
  92505. };
  92506. /** Gets the cursor to use when hovering items */
  92507. hoverCursor: string;
  92508. /** Gets the list of actions */
  92509. actions: IAction[];
  92510. /**
  92511. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92512. */
  92513. isRecursive: boolean;
  92514. /**
  92515. * Releases all associated resources
  92516. */
  92517. abstract dispose(): void;
  92518. /**
  92519. * Does this action manager has pointer triggers
  92520. */
  92521. abstract readonly hasPointerTriggers: boolean;
  92522. /**
  92523. * Does this action manager has pick triggers
  92524. */
  92525. abstract readonly hasPickTriggers: boolean;
  92526. /**
  92527. * Process a specific trigger
  92528. * @param trigger defines the trigger to process
  92529. * @param evt defines the event details to be processed
  92530. */
  92531. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92532. /**
  92533. * Does this action manager handles actions of any of the given triggers
  92534. * @param triggers defines the triggers to be tested
  92535. * @return a boolean indicating whether one (or more) of the triggers is handled
  92536. */
  92537. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92538. /**
  92539. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92540. * speed.
  92541. * @param triggerA defines the trigger to be tested
  92542. * @param triggerB defines the trigger to be tested
  92543. * @return a boolean indicating whether one (or more) of the triggers is handled
  92544. */
  92545. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92546. /**
  92547. * Does this action manager handles actions of a given trigger
  92548. * @param trigger defines the trigger to be tested
  92549. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92550. * @return whether the trigger is handled
  92551. */
  92552. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92553. /**
  92554. * Serialize this manager to a JSON object
  92555. * @param name defines the property name to store this manager
  92556. * @returns a JSON representation of this manager
  92557. */
  92558. abstract serialize(name: string): any;
  92559. /**
  92560. * Registers an action to this action manager
  92561. * @param action defines the action to be registered
  92562. * @return the action amended (prepared) after registration
  92563. */
  92564. abstract registerAction(action: IAction): Nullable<IAction>;
  92565. /**
  92566. * Unregisters an action to this action manager
  92567. * @param action defines the action to be unregistered
  92568. * @return a boolean indicating whether the action has been unregistered
  92569. */
  92570. abstract unregisterAction(action: IAction): Boolean;
  92571. /**
  92572. * Does exist one action manager with at least one trigger
  92573. **/
  92574. static readonly HasTriggers: boolean;
  92575. /**
  92576. * Does exist one action manager with at least one pick trigger
  92577. **/
  92578. static readonly HasPickTriggers: boolean;
  92579. /**
  92580. * Does exist one action manager that handles actions of a given trigger
  92581. * @param trigger defines the trigger to be tested
  92582. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92583. **/
  92584. static HasSpecificTrigger(trigger: number): boolean;
  92585. }
  92586. }
  92587. declare module BABYLON {
  92588. /**
  92589. * Defines how a node can be built from a string name.
  92590. */
  92591. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92592. /**
  92593. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92594. */
  92595. export class Node implements IBehaviorAware<Node> {
  92596. /** @hidden */
  92597. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92598. private static _NodeConstructors;
  92599. /**
  92600. * Add a new node constructor
  92601. * @param type defines the type name of the node to construct
  92602. * @param constructorFunc defines the constructor function
  92603. */
  92604. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92605. /**
  92606. * Returns a node constructor based on type name
  92607. * @param type defines the type name
  92608. * @param name defines the new node name
  92609. * @param scene defines the hosting scene
  92610. * @param options defines optional options to transmit to constructors
  92611. * @returns the new constructor or null
  92612. */
  92613. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92614. /**
  92615. * Gets or sets the name of the node
  92616. */
  92617. name: string;
  92618. /**
  92619. * Gets or sets the id of the node
  92620. */
  92621. id: string;
  92622. /**
  92623. * Gets or sets the unique id of the node
  92624. */
  92625. uniqueId: number;
  92626. /**
  92627. * Gets or sets a string used to store user defined state for the node
  92628. */
  92629. state: string;
  92630. /**
  92631. * Gets or sets an object used to store user defined information for the node
  92632. */
  92633. metadata: any;
  92634. /**
  92635. * For internal use only. Please do not use.
  92636. */
  92637. reservedDataStore: any;
  92638. /**
  92639. * List of inspectable custom properties (used by the Inspector)
  92640. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92641. */
  92642. inspectableCustomProperties: IInspectable[];
  92643. /**
  92644. * Gets or sets a boolean used to define if the node must be serialized
  92645. */
  92646. doNotSerialize: boolean;
  92647. /** @hidden */
  92648. _isDisposed: boolean;
  92649. /**
  92650. * Gets a list of Animations associated with the node
  92651. */
  92652. animations: Animation[];
  92653. protected _ranges: {
  92654. [name: string]: Nullable<AnimationRange>;
  92655. };
  92656. /**
  92657. * Callback raised when the node is ready to be used
  92658. */
  92659. onReady: Nullable<(node: Node) => void>;
  92660. private _isEnabled;
  92661. private _isParentEnabled;
  92662. private _isReady;
  92663. /** @hidden */
  92664. _currentRenderId: number;
  92665. private _parentUpdateId;
  92666. /** @hidden */
  92667. _childUpdateId: number;
  92668. /** @hidden */
  92669. _waitingParentId: Nullable<string>;
  92670. /** @hidden */
  92671. _scene: Scene;
  92672. /** @hidden */
  92673. _cache: any;
  92674. private _parentNode;
  92675. private _children;
  92676. /** @hidden */
  92677. _worldMatrix: Matrix;
  92678. /** @hidden */
  92679. _worldMatrixDeterminant: number;
  92680. /** @hidden */
  92681. _worldMatrixDeterminantIsDirty: boolean;
  92682. /** @hidden */
  92683. private _sceneRootNodesIndex;
  92684. /**
  92685. * Gets a boolean indicating if the node has been disposed
  92686. * @returns true if the node was disposed
  92687. */
  92688. isDisposed(): boolean;
  92689. /**
  92690. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92691. * @see https://doc.babylonjs.com/how_to/parenting
  92692. */
  92693. parent: Nullable<Node>;
  92694. private addToSceneRootNodes;
  92695. private removeFromSceneRootNodes;
  92696. private _animationPropertiesOverride;
  92697. /**
  92698. * Gets or sets the animation properties override
  92699. */
  92700. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92701. /**
  92702. * Gets a string idenfifying the name of the class
  92703. * @returns "Node" string
  92704. */
  92705. getClassName(): string;
  92706. /** @hidden */
  92707. readonly _isNode: boolean;
  92708. /**
  92709. * An event triggered when the mesh is disposed
  92710. */
  92711. onDisposeObservable: Observable<Node>;
  92712. private _onDisposeObserver;
  92713. /**
  92714. * Sets a callback that will be raised when the node will be disposed
  92715. */
  92716. onDispose: () => void;
  92717. /**
  92718. * Creates a new Node
  92719. * @param name the name and id to be given to this node
  92720. * @param scene the scene this node will be added to
  92721. * @param addToRootNodes the node will be added to scene.rootNodes
  92722. */
  92723. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92724. /**
  92725. * Gets the scene of the node
  92726. * @returns a scene
  92727. */
  92728. getScene(): Scene;
  92729. /**
  92730. * Gets the engine of the node
  92731. * @returns a Engine
  92732. */
  92733. getEngine(): Engine;
  92734. private _behaviors;
  92735. /**
  92736. * Attach a behavior to the node
  92737. * @see http://doc.babylonjs.com/features/behaviour
  92738. * @param behavior defines the behavior to attach
  92739. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92740. * @returns the current Node
  92741. */
  92742. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92743. /**
  92744. * Remove an attached behavior
  92745. * @see http://doc.babylonjs.com/features/behaviour
  92746. * @param behavior defines the behavior to attach
  92747. * @returns the current Node
  92748. */
  92749. removeBehavior(behavior: Behavior<Node>): Node;
  92750. /**
  92751. * Gets the list of attached behaviors
  92752. * @see http://doc.babylonjs.com/features/behaviour
  92753. */
  92754. readonly behaviors: Behavior<Node>[];
  92755. /**
  92756. * Gets an attached behavior by name
  92757. * @param name defines the name of the behavior to look for
  92758. * @see http://doc.babylonjs.com/features/behaviour
  92759. * @returns null if behavior was not found else the requested behavior
  92760. */
  92761. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92762. /**
  92763. * Returns the latest update of the World matrix
  92764. * @returns a Matrix
  92765. */
  92766. getWorldMatrix(): Matrix;
  92767. /** @hidden */
  92768. _getWorldMatrixDeterminant(): number;
  92769. /**
  92770. * Returns directly the latest state of the mesh World matrix.
  92771. * A Matrix is returned.
  92772. */
  92773. readonly worldMatrixFromCache: Matrix;
  92774. /** @hidden */
  92775. _initCache(): void;
  92776. /** @hidden */
  92777. updateCache(force?: boolean): void;
  92778. /** @hidden */
  92779. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92780. /** @hidden */
  92781. _updateCache(ignoreParentClass?: boolean): void;
  92782. /** @hidden */
  92783. _isSynchronized(): boolean;
  92784. /** @hidden */
  92785. _markSyncedWithParent(): void;
  92786. /** @hidden */
  92787. isSynchronizedWithParent(): boolean;
  92788. /** @hidden */
  92789. isSynchronized(): boolean;
  92790. /**
  92791. * Is this node ready to be used/rendered
  92792. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92793. * @return true if the node is ready
  92794. */
  92795. isReady(completeCheck?: boolean): boolean;
  92796. /**
  92797. * Is this node enabled?
  92798. * 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
  92799. * @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
  92800. * @return whether this node (and its parent) is enabled
  92801. */
  92802. isEnabled(checkAncestors?: boolean): boolean;
  92803. /** @hidden */
  92804. protected _syncParentEnabledState(): void;
  92805. /**
  92806. * Set the enabled state of this node
  92807. * @param value defines the new enabled state
  92808. */
  92809. setEnabled(value: boolean): void;
  92810. /**
  92811. * Is this node a descendant of the given node?
  92812. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92813. * @param ancestor defines the parent node to inspect
  92814. * @returns a boolean indicating if this node is a descendant of the given node
  92815. */
  92816. isDescendantOf(ancestor: Node): boolean;
  92817. /** @hidden */
  92818. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92819. /**
  92820. * Will return all nodes that have this node as ascendant
  92821. * @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
  92822. * @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
  92823. * @return all children nodes of all types
  92824. */
  92825. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92826. /**
  92827. * Get all child-meshes of this node
  92828. * @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)
  92829. * @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
  92830. * @returns an array of AbstractMesh
  92831. */
  92832. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92833. /**
  92834. * Get all direct children of this node
  92835. * @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
  92836. * @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)
  92837. * @returns an array of Node
  92838. */
  92839. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92840. /** @hidden */
  92841. _setReady(state: boolean): void;
  92842. /**
  92843. * Get an animation by name
  92844. * @param name defines the name of the animation to look for
  92845. * @returns null if not found else the requested animation
  92846. */
  92847. getAnimationByName(name: string): Nullable<Animation>;
  92848. /**
  92849. * Creates an animation range for this node
  92850. * @param name defines the name of the range
  92851. * @param from defines the starting key
  92852. * @param to defines the end key
  92853. */
  92854. createAnimationRange(name: string, from: number, to: number): void;
  92855. /**
  92856. * Delete a specific animation range
  92857. * @param name defines the name of the range to delete
  92858. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92859. */
  92860. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92861. /**
  92862. * Get an animation range by name
  92863. * @param name defines the name of the animation range to look for
  92864. * @returns null if not found else the requested animation range
  92865. */
  92866. getAnimationRange(name: string): Nullable<AnimationRange>;
  92867. /**
  92868. * Gets the list of all animation ranges defined on this node
  92869. * @returns an array
  92870. */
  92871. getAnimationRanges(): Nullable<AnimationRange>[];
  92872. /**
  92873. * Will start the animation sequence
  92874. * @param name defines the range frames for animation sequence
  92875. * @param loop defines if the animation should loop (false by default)
  92876. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92877. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92878. * @returns the object created for this animation. If range does not exist, it will return null
  92879. */
  92880. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92881. /**
  92882. * Serialize animation ranges into a JSON compatible object
  92883. * @returns serialization object
  92884. */
  92885. serializeAnimationRanges(): any;
  92886. /**
  92887. * Computes the world matrix of the node
  92888. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92889. * @returns the world matrix
  92890. */
  92891. computeWorldMatrix(force?: boolean): Matrix;
  92892. /**
  92893. * Releases resources associated with this node.
  92894. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92895. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92896. */
  92897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92898. /**
  92899. * Parse animation range data from a serialization object and store them into a given node
  92900. * @param node defines where to store the animation ranges
  92901. * @param parsedNode defines the serialization object to read data from
  92902. * @param scene defines the hosting scene
  92903. */
  92904. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92905. /**
  92906. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92907. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92908. * @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
  92909. * @returns the new bounding vectors
  92910. */
  92911. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92912. min: Vector3;
  92913. max: Vector3;
  92914. };
  92915. }
  92916. }
  92917. declare module BABYLON {
  92918. /**
  92919. * @hidden
  92920. */
  92921. export class _IAnimationState {
  92922. key: number;
  92923. repeatCount: number;
  92924. workValue?: any;
  92925. loopMode?: number;
  92926. offsetValue?: any;
  92927. highLimitValue?: any;
  92928. }
  92929. /**
  92930. * Class used to store any kind of animation
  92931. */
  92932. export class Animation {
  92933. /**Name of the animation */
  92934. name: string;
  92935. /**Property to animate */
  92936. targetProperty: string;
  92937. /**The frames per second of the animation */
  92938. framePerSecond: number;
  92939. /**The data type of the animation */
  92940. dataType: number;
  92941. /**The loop mode of the animation */
  92942. loopMode?: number | undefined;
  92943. /**Specifies if blending should be enabled */
  92944. enableBlending?: boolean | undefined;
  92945. /**
  92946. * Use matrix interpolation instead of using direct key value when animating matrices
  92947. */
  92948. static AllowMatricesInterpolation: boolean;
  92949. /**
  92950. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92951. */
  92952. static AllowMatrixDecomposeForInterpolation: boolean;
  92953. /**
  92954. * Stores the key frames of the animation
  92955. */
  92956. private _keys;
  92957. /**
  92958. * Stores the easing function of the animation
  92959. */
  92960. private _easingFunction;
  92961. /**
  92962. * @hidden Internal use only
  92963. */
  92964. _runtimeAnimations: RuntimeAnimation[];
  92965. /**
  92966. * The set of event that will be linked to this animation
  92967. */
  92968. private _events;
  92969. /**
  92970. * Stores an array of target property paths
  92971. */
  92972. targetPropertyPath: string[];
  92973. /**
  92974. * Stores the blending speed of the animation
  92975. */
  92976. blendingSpeed: number;
  92977. /**
  92978. * Stores the animation ranges for the animation
  92979. */
  92980. private _ranges;
  92981. /**
  92982. * @hidden Internal use
  92983. */
  92984. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92985. /**
  92986. * Sets up an animation
  92987. * @param property The property to animate
  92988. * @param animationType The animation type to apply
  92989. * @param framePerSecond The frames per second of the animation
  92990. * @param easingFunction The easing function used in the animation
  92991. * @returns The created animation
  92992. */
  92993. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92994. /**
  92995. * Create and start an animation on a node
  92996. * @param name defines the name of the global animation that will be run on all nodes
  92997. * @param node defines the root node where the animation will take place
  92998. * @param targetProperty defines property to animate
  92999. * @param framePerSecond defines the number of frame per second yo use
  93000. * @param totalFrame defines the number of frames in total
  93001. * @param from defines the initial value
  93002. * @param to defines the final value
  93003. * @param loopMode defines which loop mode you want to use (off by default)
  93004. * @param easingFunction defines the easing function to use (linear by default)
  93005. * @param onAnimationEnd defines the callback to call when animation end
  93006. * @returns the animatable created for this animation
  93007. */
  93008. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93009. /**
  93010. * Create and start an animation on a node and its descendants
  93011. * @param name defines the name of the global animation that will be run on all nodes
  93012. * @param node defines the root node where the animation will take place
  93013. * @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
  93014. * @param targetProperty defines property to animate
  93015. * @param framePerSecond defines the number of frame per second to use
  93016. * @param totalFrame defines the number of frames in total
  93017. * @param from defines the initial value
  93018. * @param to defines the final value
  93019. * @param loopMode defines which loop mode you want to use (off by default)
  93020. * @param easingFunction defines the easing function to use (linear by default)
  93021. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93022. * @returns the list of animatables created for all nodes
  93023. * @example https://www.babylonjs-playground.com/#MH0VLI
  93024. */
  93025. 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[]>;
  93026. /**
  93027. * Creates a new animation, merges it with the existing animations and starts it
  93028. * @param name Name of the animation
  93029. * @param node Node which contains the scene that begins the animations
  93030. * @param targetProperty Specifies which property to animate
  93031. * @param framePerSecond The frames per second of the animation
  93032. * @param totalFrame The total number of frames
  93033. * @param from The frame at the beginning of the animation
  93034. * @param to The frame at the end of the animation
  93035. * @param loopMode Specifies the loop mode of the animation
  93036. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93037. * @param onAnimationEnd Callback to run once the animation is complete
  93038. * @returns Nullable animation
  93039. */
  93040. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93041. /**
  93042. * Transition property of an host to the target Value
  93043. * @param property The property to transition
  93044. * @param targetValue The target Value of the property
  93045. * @param host The object where the property to animate belongs
  93046. * @param scene Scene used to run the animation
  93047. * @param frameRate Framerate (in frame/s) to use
  93048. * @param transition The transition type we want to use
  93049. * @param duration The duration of the animation, in milliseconds
  93050. * @param onAnimationEnd Callback trigger at the end of the animation
  93051. * @returns Nullable animation
  93052. */
  93053. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93054. /**
  93055. * Return the array of runtime animations currently using this animation
  93056. */
  93057. readonly runtimeAnimations: RuntimeAnimation[];
  93058. /**
  93059. * Specifies if any of the runtime animations are currently running
  93060. */
  93061. readonly hasRunningRuntimeAnimations: boolean;
  93062. /**
  93063. * Initializes the animation
  93064. * @param name Name of the animation
  93065. * @param targetProperty Property to animate
  93066. * @param framePerSecond The frames per second of the animation
  93067. * @param dataType The data type of the animation
  93068. * @param loopMode The loop mode of the animation
  93069. * @param enableBlending Specifies if blending should be enabled
  93070. */
  93071. constructor(
  93072. /**Name of the animation */
  93073. name: string,
  93074. /**Property to animate */
  93075. targetProperty: string,
  93076. /**The frames per second of the animation */
  93077. framePerSecond: number,
  93078. /**The data type of the animation */
  93079. dataType: number,
  93080. /**The loop mode of the animation */
  93081. loopMode?: number | undefined,
  93082. /**Specifies if blending should be enabled */
  93083. enableBlending?: boolean | undefined);
  93084. /**
  93085. * Converts the animation to a string
  93086. * @param fullDetails support for multiple levels of logging within scene loading
  93087. * @returns String form of the animation
  93088. */
  93089. toString(fullDetails?: boolean): string;
  93090. /**
  93091. * Add an event to this animation
  93092. * @param event Event to add
  93093. */
  93094. addEvent(event: AnimationEvent): void;
  93095. /**
  93096. * Remove all events found at the given frame
  93097. * @param frame The frame to remove events from
  93098. */
  93099. removeEvents(frame: number): void;
  93100. /**
  93101. * Retrieves all the events from the animation
  93102. * @returns Events from the animation
  93103. */
  93104. getEvents(): AnimationEvent[];
  93105. /**
  93106. * Creates an animation range
  93107. * @param name Name of the animation range
  93108. * @param from Starting frame of the animation range
  93109. * @param to Ending frame of the animation
  93110. */
  93111. createRange(name: string, from: number, to: number): void;
  93112. /**
  93113. * Deletes an animation range by name
  93114. * @param name Name of the animation range to delete
  93115. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93116. */
  93117. deleteRange(name: string, deleteFrames?: boolean): void;
  93118. /**
  93119. * Gets the animation range by name, or null if not defined
  93120. * @param name Name of the animation range
  93121. * @returns Nullable animation range
  93122. */
  93123. getRange(name: string): Nullable<AnimationRange>;
  93124. /**
  93125. * Gets the key frames from the animation
  93126. * @returns The key frames of the animation
  93127. */
  93128. getKeys(): Array<IAnimationKey>;
  93129. /**
  93130. * Gets the highest frame rate of the animation
  93131. * @returns Highest frame rate of the animation
  93132. */
  93133. getHighestFrame(): number;
  93134. /**
  93135. * Gets the easing function of the animation
  93136. * @returns Easing function of the animation
  93137. */
  93138. getEasingFunction(): IEasingFunction;
  93139. /**
  93140. * Sets the easing function of the animation
  93141. * @param easingFunction A custom mathematical formula for animation
  93142. */
  93143. setEasingFunction(easingFunction: EasingFunction): void;
  93144. /**
  93145. * Interpolates a scalar linearly
  93146. * @param startValue Start value of the animation curve
  93147. * @param endValue End value of the animation curve
  93148. * @param gradient Scalar amount to interpolate
  93149. * @returns Interpolated scalar value
  93150. */
  93151. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93152. /**
  93153. * Interpolates a scalar cubically
  93154. * @param startValue Start value of the animation curve
  93155. * @param outTangent End tangent of the animation
  93156. * @param endValue End value of the animation curve
  93157. * @param inTangent Start tangent of the animation curve
  93158. * @param gradient Scalar amount to interpolate
  93159. * @returns Interpolated scalar value
  93160. */
  93161. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93162. /**
  93163. * Interpolates a quaternion using a spherical linear interpolation
  93164. * @param startValue Start value of the animation curve
  93165. * @param endValue End value of the animation curve
  93166. * @param gradient Scalar amount to interpolate
  93167. * @returns Interpolated quaternion value
  93168. */
  93169. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93170. /**
  93171. * Interpolates a quaternion cubically
  93172. * @param startValue Start value of the animation curve
  93173. * @param outTangent End tangent of the animation curve
  93174. * @param endValue End value of the animation curve
  93175. * @param inTangent Start tangent of the animation curve
  93176. * @param gradient Scalar amount to interpolate
  93177. * @returns Interpolated quaternion value
  93178. */
  93179. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93180. /**
  93181. * Interpolates a Vector3 linearl
  93182. * @param startValue Start value of the animation curve
  93183. * @param endValue End value of the animation curve
  93184. * @param gradient Scalar amount to interpolate
  93185. * @returns Interpolated scalar value
  93186. */
  93187. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93188. /**
  93189. * Interpolates a Vector3 cubically
  93190. * @param startValue Start value of the animation curve
  93191. * @param outTangent End tangent of the animation
  93192. * @param endValue End value of the animation curve
  93193. * @param inTangent Start tangent of the animation curve
  93194. * @param gradient Scalar amount to interpolate
  93195. * @returns InterpolatedVector3 value
  93196. */
  93197. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93198. /**
  93199. * Interpolates a Vector2 linearly
  93200. * @param startValue Start value of the animation curve
  93201. * @param endValue End value of the animation curve
  93202. * @param gradient Scalar amount to interpolate
  93203. * @returns Interpolated Vector2 value
  93204. */
  93205. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93206. /**
  93207. * Interpolates a Vector2 cubically
  93208. * @param startValue Start value of the animation curve
  93209. * @param outTangent End tangent of the animation
  93210. * @param endValue End value of the animation curve
  93211. * @param inTangent Start tangent of the animation curve
  93212. * @param gradient Scalar amount to interpolate
  93213. * @returns Interpolated Vector2 value
  93214. */
  93215. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93216. /**
  93217. * Interpolates a size linearly
  93218. * @param startValue Start value of the animation curve
  93219. * @param endValue End value of the animation curve
  93220. * @param gradient Scalar amount to interpolate
  93221. * @returns Interpolated Size value
  93222. */
  93223. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93224. /**
  93225. * Interpolates a Color3 linearly
  93226. * @param startValue Start value of the animation curve
  93227. * @param endValue End value of the animation curve
  93228. * @param gradient Scalar amount to interpolate
  93229. * @returns Interpolated Color3 value
  93230. */
  93231. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93232. /**
  93233. * @hidden Internal use only
  93234. */
  93235. _getKeyValue(value: any): any;
  93236. /**
  93237. * @hidden Internal use only
  93238. */
  93239. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93240. /**
  93241. * Defines the function to use to interpolate matrices
  93242. * @param startValue defines the start matrix
  93243. * @param endValue defines the end matrix
  93244. * @param gradient defines the gradient between both matrices
  93245. * @param result defines an optional target matrix where to store the interpolation
  93246. * @returns the interpolated matrix
  93247. */
  93248. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93249. /**
  93250. * Makes a copy of the animation
  93251. * @returns Cloned animation
  93252. */
  93253. clone(): Animation;
  93254. /**
  93255. * Sets the key frames of the animation
  93256. * @param values The animation key frames to set
  93257. */
  93258. setKeys(values: Array<IAnimationKey>): void;
  93259. /**
  93260. * Serializes the animation to an object
  93261. * @returns Serialized object
  93262. */
  93263. serialize(): any;
  93264. /**
  93265. * Float animation type
  93266. */
  93267. private static _ANIMATIONTYPE_FLOAT;
  93268. /**
  93269. * Vector3 animation type
  93270. */
  93271. private static _ANIMATIONTYPE_VECTOR3;
  93272. /**
  93273. * Quaternion animation type
  93274. */
  93275. private static _ANIMATIONTYPE_QUATERNION;
  93276. /**
  93277. * Matrix animation type
  93278. */
  93279. private static _ANIMATIONTYPE_MATRIX;
  93280. /**
  93281. * Color3 animation type
  93282. */
  93283. private static _ANIMATIONTYPE_COLOR3;
  93284. /**
  93285. * Vector2 animation type
  93286. */
  93287. private static _ANIMATIONTYPE_VECTOR2;
  93288. /**
  93289. * Size animation type
  93290. */
  93291. private static _ANIMATIONTYPE_SIZE;
  93292. /**
  93293. * Relative Loop Mode
  93294. */
  93295. private static _ANIMATIONLOOPMODE_RELATIVE;
  93296. /**
  93297. * Cycle Loop Mode
  93298. */
  93299. private static _ANIMATIONLOOPMODE_CYCLE;
  93300. /**
  93301. * Constant Loop Mode
  93302. */
  93303. private static _ANIMATIONLOOPMODE_CONSTANT;
  93304. /**
  93305. * Get the float animation type
  93306. */
  93307. static readonly ANIMATIONTYPE_FLOAT: number;
  93308. /**
  93309. * Get the Vector3 animation type
  93310. */
  93311. static readonly ANIMATIONTYPE_VECTOR3: number;
  93312. /**
  93313. * Get the Vector2 animation type
  93314. */
  93315. static readonly ANIMATIONTYPE_VECTOR2: number;
  93316. /**
  93317. * Get the Size animation type
  93318. */
  93319. static readonly ANIMATIONTYPE_SIZE: number;
  93320. /**
  93321. * Get the Quaternion animation type
  93322. */
  93323. static readonly ANIMATIONTYPE_QUATERNION: number;
  93324. /**
  93325. * Get the Matrix animation type
  93326. */
  93327. static readonly ANIMATIONTYPE_MATRIX: number;
  93328. /**
  93329. * Get the Color3 animation type
  93330. */
  93331. static readonly ANIMATIONTYPE_COLOR3: number;
  93332. /**
  93333. * Get the Relative Loop Mode
  93334. */
  93335. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93336. /**
  93337. * Get the Cycle Loop Mode
  93338. */
  93339. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93340. /**
  93341. * Get the Constant Loop Mode
  93342. */
  93343. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93344. /** @hidden */
  93345. static _UniversalLerp(left: any, right: any, amount: number): any;
  93346. /**
  93347. * Parses an animation object and creates an animation
  93348. * @param parsedAnimation Parsed animation object
  93349. * @returns Animation object
  93350. */
  93351. static Parse(parsedAnimation: any): Animation;
  93352. /**
  93353. * Appends the serialized animations from the source animations
  93354. * @param source Source containing the animations
  93355. * @param destination Target to store the animations
  93356. */
  93357. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93358. }
  93359. }
  93360. declare module BABYLON {
  93361. /**
  93362. * Interface containing an array of animations
  93363. */
  93364. export interface IAnimatable {
  93365. /**
  93366. * Array of animations
  93367. */
  93368. animations: Nullable<Array<Animation>>;
  93369. }
  93370. }
  93371. declare module BABYLON {
  93372. /**
  93373. * This represents all the required information to add a fresnel effect on a material:
  93374. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93375. */
  93376. export class FresnelParameters {
  93377. private _isEnabled;
  93378. /**
  93379. * Define if the fresnel effect is enable or not.
  93380. */
  93381. isEnabled: boolean;
  93382. /**
  93383. * Define the color used on edges (grazing angle)
  93384. */
  93385. leftColor: Color3;
  93386. /**
  93387. * Define the color used on center
  93388. */
  93389. rightColor: Color3;
  93390. /**
  93391. * Define bias applied to computed fresnel term
  93392. */
  93393. bias: number;
  93394. /**
  93395. * Defined the power exponent applied to fresnel term
  93396. */
  93397. power: number;
  93398. /**
  93399. * Clones the current fresnel and its valuues
  93400. * @returns a clone fresnel configuration
  93401. */
  93402. clone(): FresnelParameters;
  93403. /**
  93404. * Serializes the current fresnel parameters to a JSON representation.
  93405. * @return the JSON serialization
  93406. */
  93407. serialize(): any;
  93408. /**
  93409. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93410. * @param parsedFresnelParameters Define the JSON representation
  93411. * @returns the parsed parameters
  93412. */
  93413. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93414. }
  93415. }
  93416. declare module BABYLON {
  93417. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93418. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93419. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93420. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93421. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93422. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93423. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93424. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93425. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93426. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93427. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93428. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93429. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93430. /**
  93431. * Decorator used to define property that can be serialized as reference to a camera
  93432. * @param sourceName defines the name of the property to decorate
  93433. */
  93434. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93435. /**
  93436. * Class used to help serialization objects
  93437. */
  93438. export class SerializationHelper {
  93439. /** @hidden */
  93440. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93441. /** @hidden */
  93442. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93443. /** @hidden */
  93444. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93445. /** @hidden */
  93446. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93447. /**
  93448. * Appends the serialized animations from the source animations
  93449. * @param source Source containing the animations
  93450. * @param destination Target to store the animations
  93451. */
  93452. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93453. /**
  93454. * Static function used to serialized a specific entity
  93455. * @param entity defines the entity to serialize
  93456. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93457. * @returns a JSON compatible object representing the serialization of the entity
  93458. */
  93459. static Serialize<T>(entity: T, serializationObject?: any): any;
  93460. /**
  93461. * Creates a new entity from a serialization data object
  93462. * @param creationFunction defines a function used to instanciated the new entity
  93463. * @param source defines the source serialization data
  93464. * @param scene defines the hosting scene
  93465. * @param rootUrl defines the root url for resources
  93466. * @returns a new entity
  93467. */
  93468. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93469. /**
  93470. * Clones an object
  93471. * @param creationFunction defines the function used to instanciate the new object
  93472. * @param source defines the source object
  93473. * @returns the cloned object
  93474. */
  93475. static Clone<T>(creationFunction: () => T, source: T): T;
  93476. /**
  93477. * Instanciates a new object based on a source one (some data will be shared between both object)
  93478. * @param creationFunction defines the function used to instanciate the new object
  93479. * @param source defines the source object
  93480. * @returns the new object
  93481. */
  93482. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93483. }
  93484. }
  93485. declare module BABYLON {
  93486. /**
  93487. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93488. */
  93489. export interface CubeMapInfo {
  93490. /**
  93491. * The pixel array for the front face.
  93492. * This is stored in format, left to right, up to down format.
  93493. */
  93494. front: Nullable<ArrayBufferView>;
  93495. /**
  93496. * The pixel array for the back face.
  93497. * This is stored in format, left to right, up to down format.
  93498. */
  93499. back: Nullable<ArrayBufferView>;
  93500. /**
  93501. * The pixel array for the left face.
  93502. * This is stored in format, left to right, up to down format.
  93503. */
  93504. left: Nullable<ArrayBufferView>;
  93505. /**
  93506. * The pixel array for the right face.
  93507. * This is stored in format, left to right, up to down format.
  93508. */
  93509. right: Nullable<ArrayBufferView>;
  93510. /**
  93511. * The pixel array for the up face.
  93512. * This is stored in format, left to right, up to down format.
  93513. */
  93514. up: Nullable<ArrayBufferView>;
  93515. /**
  93516. * The pixel array for the down face.
  93517. * This is stored in format, left to right, up to down format.
  93518. */
  93519. down: Nullable<ArrayBufferView>;
  93520. /**
  93521. * The size of the cubemap stored.
  93522. *
  93523. * Each faces will be size * size pixels.
  93524. */
  93525. size: number;
  93526. /**
  93527. * The format of the texture.
  93528. *
  93529. * RGBA, RGB.
  93530. */
  93531. format: number;
  93532. /**
  93533. * The type of the texture data.
  93534. *
  93535. * UNSIGNED_INT, FLOAT.
  93536. */
  93537. type: number;
  93538. /**
  93539. * Specifies whether the texture is in gamma space.
  93540. */
  93541. gammaSpace: boolean;
  93542. }
  93543. /**
  93544. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93545. */
  93546. export class PanoramaToCubeMapTools {
  93547. private static FACE_FRONT;
  93548. private static FACE_BACK;
  93549. private static FACE_RIGHT;
  93550. private static FACE_LEFT;
  93551. private static FACE_DOWN;
  93552. private static FACE_UP;
  93553. /**
  93554. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93555. *
  93556. * @param float32Array The source data.
  93557. * @param inputWidth The width of the input panorama.
  93558. * @param inputHeight The height of the input panorama.
  93559. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93560. * @return The cubemap data
  93561. */
  93562. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93563. private static CreateCubemapTexture;
  93564. private static CalcProjectionSpherical;
  93565. }
  93566. }
  93567. declare module BABYLON {
  93568. /**
  93569. * Helper class dealing with the extraction of spherical polynomial dataArray
  93570. * from a cube map.
  93571. */
  93572. export class CubeMapToSphericalPolynomialTools {
  93573. private static FileFaces;
  93574. /**
  93575. * Converts a texture to the according Spherical Polynomial data.
  93576. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93577. *
  93578. * @param texture The texture to extract the information from.
  93579. * @return The Spherical Polynomial data.
  93580. */
  93581. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93582. /**
  93583. * Converts a cubemap to the according Spherical Polynomial data.
  93584. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93585. *
  93586. * @param cubeInfo The Cube map to extract the information from.
  93587. * @return The Spherical Polynomial data.
  93588. */
  93589. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93590. }
  93591. }
  93592. declare module BABYLON {
  93593. /**
  93594. * Class used to manipulate GUIDs
  93595. */
  93596. export class GUID {
  93597. /**
  93598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93599. * Be aware Math.random() could cause collisions, but:
  93600. * "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"
  93601. * @returns a pseudo random id
  93602. */
  93603. static RandomId(): string;
  93604. }
  93605. }
  93606. declare module BABYLON {
  93607. /**
  93608. * Base class of all the textures in babylon.
  93609. * It groups all the common properties the materials, post process, lights... might need
  93610. * in order to make a correct use of the texture.
  93611. */
  93612. export class BaseTexture implements IAnimatable {
  93613. /**
  93614. * Default anisotropic filtering level for the application.
  93615. * It is set to 4 as a good tradeoff between perf and quality.
  93616. */
  93617. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93618. /**
  93619. * Gets or sets the unique id of the texture
  93620. */
  93621. uniqueId: number;
  93622. /**
  93623. * Define the name of the texture.
  93624. */
  93625. name: string;
  93626. /**
  93627. * Gets or sets an object used to store user defined information.
  93628. */
  93629. metadata: any;
  93630. /**
  93631. * For internal use only. Please do not use.
  93632. */
  93633. reservedDataStore: any;
  93634. private _hasAlpha;
  93635. /**
  93636. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93637. */
  93638. hasAlpha: boolean;
  93639. /**
  93640. * Defines if the alpha value should be determined via the rgb values.
  93641. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93642. */
  93643. getAlphaFromRGB: boolean;
  93644. /**
  93645. * Intensity or strength of the texture.
  93646. * It is commonly used by materials to fine tune the intensity of the texture
  93647. */
  93648. level: number;
  93649. /**
  93650. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93651. * This is part of the texture as textures usually maps to one uv set.
  93652. */
  93653. coordinatesIndex: number;
  93654. private _coordinatesMode;
  93655. /**
  93656. * How a texture is mapped.
  93657. *
  93658. * | Value | Type | Description |
  93659. * | ----- | ----------------------------------- | ----------- |
  93660. * | 0 | EXPLICIT_MODE | |
  93661. * | 1 | SPHERICAL_MODE | |
  93662. * | 2 | PLANAR_MODE | |
  93663. * | 3 | CUBIC_MODE | |
  93664. * | 4 | PROJECTION_MODE | |
  93665. * | 5 | SKYBOX_MODE | |
  93666. * | 6 | INVCUBIC_MODE | |
  93667. * | 7 | EQUIRECTANGULAR_MODE | |
  93668. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93669. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93670. */
  93671. coordinatesMode: number;
  93672. /**
  93673. * | Value | Type | Description |
  93674. * | ----- | ------------------ | ----------- |
  93675. * | 0 | CLAMP_ADDRESSMODE | |
  93676. * | 1 | WRAP_ADDRESSMODE | |
  93677. * | 2 | MIRROR_ADDRESSMODE | |
  93678. */
  93679. wrapU: number;
  93680. /**
  93681. * | Value | Type | Description |
  93682. * | ----- | ------------------ | ----------- |
  93683. * | 0 | CLAMP_ADDRESSMODE | |
  93684. * | 1 | WRAP_ADDRESSMODE | |
  93685. * | 2 | MIRROR_ADDRESSMODE | |
  93686. */
  93687. wrapV: number;
  93688. /**
  93689. * | Value | Type | Description |
  93690. * | ----- | ------------------ | ----------- |
  93691. * | 0 | CLAMP_ADDRESSMODE | |
  93692. * | 1 | WRAP_ADDRESSMODE | |
  93693. * | 2 | MIRROR_ADDRESSMODE | |
  93694. */
  93695. wrapR: number;
  93696. /**
  93697. * With compliant hardware and browser (supporting anisotropic filtering)
  93698. * this defines the level of anisotropic filtering in the texture.
  93699. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93700. */
  93701. anisotropicFilteringLevel: number;
  93702. /**
  93703. * Define if the texture is a cube texture or if false a 2d texture.
  93704. */
  93705. isCube: boolean;
  93706. /**
  93707. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93708. */
  93709. is3D: boolean;
  93710. /**
  93711. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93712. * HDR texture are usually stored in linear space.
  93713. * This only impacts the PBR and Background materials
  93714. */
  93715. gammaSpace: boolean;
  93716. /**
  93717. * Gets or sets whether or not the texture contains RGBD data.
  93718. */
  93719. isRGBD: boolean;
  93720. /**
  93721. * Is Z inverted in the texture (useful in a cube texture).
  93722. */
  93723. invertZ: boolean;
  93724. /**
  93725. * Are mip maps generated for this texture or not.
  93726. */
  93727. readonly noMipmap: boolean;
  93728. /**
  93729. * @hidden
  93730. */
  93731. lodLevelInAlpha: boolean;
  93732. /**
  93733. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93734. */
  93735. lodGenerationOffset: number;
  93736. /**
  93737. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93738. */
  93739. lodGenerationScale: number;
  93740. /**
  93741. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93742. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93743. * average roughness values.
  93744. */
  93745. linearSpecularLOD: boolean;
  93746. /**
  93747. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93748. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93749. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93750. */
  93751. irradianceTexture: Nullable<BaseTexture>;
  93752. /**
  93753. * Define if the texture is a render target.
  93754. */
  93755. isRenderTarget: boolean;
  93756. /**
  93757. * Define the unique id of the texture in the scene.
  93758. */
  93759. readonly uid: string;
  93760. /**
  93761. * Return a string representation of the texture.
  93762. * @returns the texture as a string
  93763. */
  93764. toString(): string;
  93765. /**
  93766. * Get the class name of the texture.
  93767. * @returns "BaseTexture"
  93768. */
  93769. getClassName(): string;
  93770. /**
  93771. * Define the list of animation attached to the texture.
  93772. */
  93773. animations: Animation[];
  93774. /**
  93775. * An event triggered when the texture is disposed.
  93776. */
  93777. onDisposeObservable: Observable<BaseTexture>;
  93778. private _onDisposeObserver;
  93779. /**
  93780. * Callback triggered when the texture has been disposed.
  93781. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93782. */
  93783. onDispose: () => void;
  93784. /**
  93785. * Define the current state of the loading sequence when in delayed load mode.
  93786. */
  93787. delayLoadState: number;
  93788. private _scene;
  93789. /** @hidden */
  93790. _texture: Nullable<InternalTexture>;
  93791. private _uid;
  93792. /**
  93793. * Define if the texture is preventinga material to render or not.
  93794. * If not and the texture is not ready, the engine will use a default black texture instead.
  93795. */
  93796. readonly isBlocking: boolean;
  93797. /**
  93798. * Instantiates a new BaseTexture.
  93799. * Base class of all the textures in babylon.
  93800. * It groups all the common properties the materials, post process, lights... might need
  93801. * in order to make a correct use of the texture.
  93802. * @param scene Define the scene the texture blongs to
  93803. */
  93804. constructor(scene: Nullable<Scene>);
  93805. /**
  93806. * Get the scene the texture belongs to.
  93807. * @returns the scene or null if undefined
  93808. */
  93809. getScene(): Nullable<Scene>;
  93810. /**
  93811. * Get the texture transform matrix used to offset tile the texture for istance.
  93812. * @returns the transformation matrix
  93813. */
  93814. getTextureMatrix(): Matrix;
  93815. /**
  93816. * Get the texture reflection matrix used to rotate/transform the reflection.
  93817. * @returns the reflection matrix
  93818. */
  93819. getReflectionTextureMatrix(): Matrix;
  93820. /**
  93821. * Get the underlying lower level texture from Babylon.
  93822. * @returns the insternal texture
  93823. */
  93824. getInternalTexture(): Nullable<InternalTexture>;
  93825. /**
  93826. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93827. * @returns true if ready or not blocking
  93828. */
  93829. isReadyOrNotBlocking(): boolean;
  93830. /**
  93831. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93832. * @returns true if fully ready
  93833. */
  93834. isReady(): boolean;
  93835. private _cachedSize;
  93836. /**
  93837. * Get the size of the texture.
  93838. * @returns the texture size.
  93839. */
  93840. getSize(): ISize;
  93841. /**
  93842. * Get the base size of the texture.
  93843. * It can be different from the size if the texture has been resized for POT for instance
  93844. * @returns the base size
  93845. */
  93846. getBaseSize(): ISize;
  93847. /**
  93848. * Update the sampling mode of the texture.
  93849. * Default is Trilinear mode.
  93850. *
  93851. * | Value | Type | Description |
  93852. * | ----- | ------------------ | ----------- |
  93853. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93854. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93855. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93856. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93857. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93858. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93859. * | 7 | NEAREST_LINEAR | |
  93860. * | 8 | NEAREST_NEAREST | |
  93861. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93862. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93863. * | 11 | LINEAR_LINEAR | |
  93864. * | 12 | LINEAR_NEAREST | |
  93865. *
  93866. * > _mag_: magnification filter (close to the viewer)
  93867. * > _min_: minification filter (far from the viewer)
  93868. * > _mip_: filter used between mip map levels
  93869. *@param samplingMode Define the new sampling mode of the texture
  93870. */
  93871. updateSamplingMode(samplingMode: number): void;
  93872. /**
  93873. * Scales the texture if is `canRescale()`
  93874. * @param ratio the resize factor we want to use to rescale
  93875. */
  93876. scale(ratio: number): void;
  93877. /**
  93878. * Get if the texture can rescale.
  93879. */
  93880. readonly canRescale: boolean;
  93881. /** @hidden */
  93882. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93883. /** @hidden */
  93884. _rebuild(): void;
  93885. /**
  93886. * Triggers the load sequence in delayed load mode.
  93887. */
  93888. delayLoad(): void;
  93889. /**
  93890. * Clones the texture.
  93891. * @returns the cloned texture
  93892. */
  93893. clone(): Nullable<BaseTexture>;
  93894. /**
  93895. * Get the texture underlying type (INT, FLOAT...)
  93896. */
  93897. readonly textureType: number;
  93898. /**
  93899. * Get the texture underlying format (RGB, RGBA...)
  93900. */
  93901. readonly textureFormat: number;
  93902. /**
  93903. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93904. * This will returns an RGBA array buffer containing either in values (0-255) or
  93905. * float values (0-1) depending of the underlying buffer type.
  93906. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93907. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93908. * @param buffer defines a user defined buffer to fill with data (can be null)
  93909. * @returns The Array buffer containing the pixels data.
  93910. */
  93911. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93912. /**
  93913. * Release and destroy the underlying lower level texture aka internalTexture.
  93914. */
  93915. releaseInternalTexture(): void;
  93916. /**
  93917. * Get the polynomial representation of the texture data.
  93918. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93919. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93920. */
  93921. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93922. /** @hidden */
  93923. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93924. /** @hidden */
  93925. readonly _lodTextureMid: Nullable<BaseTexture>;
  93926. /** @hidden */
  93927. readonly _lodTextureLow: Nullable<BaseTexture>;
  93928. /**
  93929. * Dispose the texture and release its associated resources.
  93930. */
  93931. dispose(): void;
  93932. /**
  93933. * Serialize the texture into a JSON representation that can be parsed later on.
  93934. * @returns the JSON representation of the texture
  93935. */
  93936. serialize(): any;
  93937. /**
  93938. * Helper function to be called back once a list of texture contains only ready textures.
  93939. * @param textures Define the list of textures to wait for
  93940. * @param callback Define the callback triggered once the entire list will be ready
  93941. */
  93942. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93943. }
  93944. }
  93945. declare module BABYLON {
  93946. /**
  93947. * Class used to store data associated with WebGL texture data for the engine
  93948. * This class should not be used directly
  93949. */
  93950. export class InternalTexture {
  93951. /** @hidden */
  93952. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93953. /**
  93954. * The source of the texture data is unknown
  93955. */
  93956. static DATASOURCE_UNKNOWN: number;
  93957. /**
  93958. * Texture data comes from an URL
  93959. */
  93960. static DATASOURCE_URL: number;
  93961. /**
  93962. * Texture data is only used for temporary storage
  93963. */
  93964. static DATASOURCE_TEMP: number;
  93965. /**
  93966. * Texture data comes from raw data (ArrayBuffer)
  93967. */
  93968. static DATASOURCE_RAW: number;
  93969. /**
  93970. * Texture content is dynamic (video or dynamic texture)
  93971. */
  93972. static DATASOURCE_DYNAMIC: number;
  93973. /**
  93974. * Texture content is generated by rendering to it
  93975. */
  93976. static DATASOURCE_RENDERTARGET: number;
  93977. /**
  93978. * Texture content is part of a multi render target process
  93979. */
  93980. static DATASOURCE_MULTIRENDERTARGET: number;
  93981. /**
  93982. * Texture data comes from a cube data file
  93983. */
  93984. static DATASOURCE_CUBE: number;
  93985. /**
  93986. * Texture data comes from a raw cube data
  93987. */
  93988. static DATASOURCE_CUBERAW: number;
  93989. /**
  93990. * Texture data come from a prefiltered cube data file
  93991. */
  93992. static DATASOURCE_CUBEPREFILTERED: number;
  93993. /**
  93994. * Texture content is raw 3D data
  93995. */
  93996. static DATASOURCE_RAW3D: number;
  93997. /**
  93998. * Texture content is a depth texture
  93999. */
  94000. static DATASOURCE_DEPTHTEXTURE: number;
  94001. /**
  94002. * Texture data comes from a raw cube data encoded with RGBD
  94003. */
  94004. static DATASOURCE_CUBERAW_RGBD: number;
  94005. /**
  94006. * Defines if the texture is ready
  94007. */
  94008. isReady: boolean;
  94009. /**
  94010. * Defines if the texture is a cube texture
  94011. */
  94012. isCube: boolean;
  94013. /**
  94014. * Defines if the texture contains 3D data
  94015. */
  94016. is3D: boolean;
  94017. /**
  94018. * Defines if the texture contains multiview data
  94019. */
  94020. isMultiview: boolean;
  94021. /**
  94022. * Gets the URL used to load this texture
  94023. */
  94024. url: string;
  94025. /**
  94026. * Gets the sampling mode of the texture
  94027. */
  94028. samplingMode: number;
  94029. /**
  94030. * Gets a boolean indicating if the texture needs mipmaps generation
  94031. */
  94032. generateMipMaps: boolean;
  94033. /**
  94034. * Gets the number of samples used by the texture (WebGL2+ only)
  94035. */
  94036. samples: number;
  94037. /**
  94038. * Gets the type of the texture (int, float...)
  94039. */
  94040. type: number;
  94041. /**
  94042. * Gets the format of the texture (RGB, RGBA...)
  94043. */
  94044. format: number;
  94045. /**
  94046. * Observable called when the texture is loaded
  94047. */
  94048. onLoadedObservable: Observable<InternalTexture>;
  94049. /**
  94050. * Gets the width of the texture
  94051. */
  94052. width: number;
  94053. /**
  94054. * Gets the height of the texture
  94055. */
  94056. height: number;
  94057. /**
  94058. * Gets the depth of the texture
  94059. */
  94060. depth: number;
  94061. /**
  94062. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  94063. */
  94064. baseWidth: number;
  94065. /**
  94066. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  94067. */
  94068. baseHeight: number;
  94069. /**
  94070. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  94071. */
  94072. baseDepth: number;
  94073. /**
  94074. * Gets a boolean indicating if the texture is inverted on Y axis
  94075. */
  94076. invertY: boolean;
  94077. /** @hidden */
  94078. _invertVScale: boolean;
  94079. /** @hidden */
  94080. _associatedChannel: number;
  94081. /** @hidden */
  94082. _dataSource: number;
  94083. /** @hidden */
  94084. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  94085. /** @hidden */
  94086. _bufferView: Nullable<ArrayBufferView>;
  94087. /** @hidden */
  94088. _bufferViewArray: Nullable<ArrayBufferView[]>;
  94089. /** @hidden */
  94090. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  94091. /** @hidden */
  94092. _size: number;
  94093. /** @hidden */
  94094. _extension: string;
  94095. /** @hidden */
  94096. _files: Nullable<string[]>;
  94097. /** @hidden */
  94098. _workingCanvas: Nullable<HTMLCanvasElement>;
  94099. /** @hidden */
  94100. _workingContext: Nullable<CanvasRenderingContext2D>;
  94101. /** @hidden */
  94102. _framebuffer: Nullable<WebGLFramebuffer>;
  94103. /** @hidden */
  94104. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  94105. /** @hidden */
  94106. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  94107. /** @hidden */
  94108. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  94109. /** @hidden */
  94110. _attachments: Nullable<number[]>;
  94111. /** @hidden */
  94112. _cachedCoordinatesMode: Nullable<number>;
  94113. /** @hidden */
  94114. _cachedWrapU: Nullable<number>;
  94115. /** @hidden */
  94116. _cachedWrapV: Nullable<number>;
  94117. /** @hidden */
  94118. _cachedWrapR: Nullable<number>;
  94119. /** @hidden */
  94120. _cachedAnisotropicFilteringLevel: Nullable<number>;
  94121. /** @hidden */
  94122. _isDisabled: boolean;
  94123. /** @hidden */
  94124. _compression: Nullable<string>;
  94125. /** @hidden */
  94126. _generateStencilBuffer: boolean;
  94127. /** @hidden */
  94128. _generateDepthBuffer: boolean;
  94129. /** @hidden */
  94130. _comparisonFunction: number;
  94131. /** @hidden */
  94132. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  94133. /** @hidden */
  94134. _lodGenerationScale: number;
  94135. /** @hidden */
  94136. _lodGenerationOffset: number;
  94137. /** @hidden */
  94138. _colorTextureArray: Nullable<WebGLTexture>;
  94139. /** @hidden */
  94140. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94141. /** @hidden */
  94142. _lodTextureHigh: Nullable<BaseTexture>;
  94143. /** @hidden */
  94144. _lodTextureMid: Nullable<BaseTexture>;
  94145. /** @hidden */
  94146. _lodTextureLow: Nullable<BaseTexture>;
  94147. /** @hidden */
  94148. _isRGBD: boolean;
  94149. /** @hidden */
  94150. _linearSpecularLOD: boolean;
  94151. /** @hidden */
  94152. _irradianceTexture: Nullable<BaseTexture>;
  94153. /** @hidden */
  94154. _webGLTexture: Nullable<WebGLTexture>;
  94155. /** @hidden */
  94156. _references: number;
  94157. private _engine;
  94158. /**
  94159. * Gets the Engine the texture belongs to.
  94160. * @returns The babylon engine
  94161. */
  94162. getEngine(): Engine;
  94163. /**
  94164. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94165. */
  94166. readonly dataSource: number;
  94167. /**
  94168. * Creates a new InternalTexture
  94169. * @param engine defines the engine to use
  94170. * @param dataSource defines the type of data that will be used
  94171. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94172. */
  94173. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94174. /**
  94175. * Increments the number of references (ie. the number of Texture that point to it)
  94176. */
  94177. incrementReferences(): void;
  94178. /**
  94179. * Change the size of the texture (not the size of the content)
  94180. * @param width defines the new width
  94181. * @param height defines the new height
  94182. * @param depth defines the new depth (1 by default)
  94183. */
  94184. updateSize(width: int, height: int, depth?: int): void;
  94185. /** @hidden */
  94186. _rebuild(): void;
  94187. /** @hidden */
  94188. _swapAndDie(target: InternalTexture): void;
  94189. /**
  94190. * Dispose the current allocated resources
  94191. */
  94192. dispose(): void;
  94193. }
  94194. }
  94195. declare module BABYLON {
  94196. /**
  94197. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94198. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94199. */
  94200. export class EffectFallbacks {
  94201. private _defines;
  94202. private _currentRank;
  94203. private _maxRank;
  94204. private _mesh;
  94205. /**
  94206. * Removes the fallback from the bound mesh.
  94207. */
  94208. unBindMesh(): void;
  94209. /**
  94210. * Adds a fallback on the specified property.
  94211. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94212. * @param define The name of the define in the shader
  94213. */
  94214. addFallback(rank: number, define: string): void;
  94215. /**
  94216. * Sets the mesh to use CPU skinning when needing to fallback.
  94217. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94218. * @param mesh The mesh to use the fallbacks.
  94219. */
  94220. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94221. /**
  94222. * Checks to see if more fallbacks are still availible.
  94223. */
  94224. readonly hasMoreFallbacks: boolean;
  94225. /**
  94226. * Removes the defines that should be removed when falling back.
  94227. * @param currentDefines defines the current define statements for the shader.
  94228. * @param effect defines the current effect we try to compile
  94229. * @returns The resulting defines with defines of the current rank removed.
  94230. */
  94231. reduce(currentDefines: string, effect: Effect): string;
  94232. }
  94233. /**
  94234. * Options to be used when creating an effect.
  94235. */
  94236. export class EffectCreationOptions {
  94237. /**
  94238. * Atrributes that will be used in the shader.
  94239. */
  94240. attributes: string[];
  94241. /**
  94242. * Uniform varible names that will be set in the shader.
  94243. */
  94244. uniformsNames: string[];
  94245. /**
  94246. * Uniform buffer varible names that will be set in the shader.
  94247. */
  94248. uniformBuffersNames: string[];
  94249. /**
  94250. * Sampler texture variable names that will be set in the shader.
  94251. */
  94252. samplers: string[];
  94253. /**
  94254. * Define statements that will be set in the shader.
  94255. */
  94256. defines: any;
  94257. /**
  94258. * Possible fallbacks for this effect to improve performance when needed.
  94259. */
  94260. fallbacks: Nullable<EffectFallbacks>;
  94261. /**
  94262. * Callback that will be called when the shader is compiled.
  94263. */
  94264. onCompiled: Nullable<(effect: Effect) => void>;
  94265. /**
  94266. * Callback that will be called if an error occurs during shader compilation.
  94267. */
  94268. onError: Nullable<(effect: Effect, errors: string) => void>;
  94269. /**
  94270. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94271. */
  94272. indexParameters: any;
  94273. /**
  94274. * Max number of lights that can be used in the shader.
  94275. */
  94276. maxSimultaneousLights: number;
  94277. /**
  94278. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94279. */
  94280. transformFeedbackVaryings: Nullable<string[]>;
  94281. }
  94282. /**
  94283. * Effect containing vertex and fragment shader that can be executed on an object.
  94284. */
  94285. export class Effect implements IDisposable {
  94286. /**
  94287. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94288. */
  94289. static ShadersRepository: string;
  94290. /**
  94291. * Name of the effect.
  94292. */
  94293. name: any;
  94294. /**
  94295. * String container all the define statements that should be set on the shader.
  94296. */
  94297. defines: string;
  94298. /**
  94299. * Callback that will be called when the shader is compiled.
  94300. */
  94301. onCompiled: Nullable<(effect: Effect) => void>;
  94302. /**
  94303. * Callback that will be called if an error occurs during shader compilation.
  94304. */
  94305. onError: Nullable<(effect: Effect, errors: string) => void>;
  94306. /**
  94307. * Callback that will be called when effect is bound.
  94308. */
  94309. onBind: Nullable<(effect: Effect) => void>;
  94310. /**
  94311. * Unique ID of the effect.
  94312. */
  94313. uniqueId: number;
  94314. /**
  94315. * Observable that will be called when the shader is compiled.
  94316. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94317. */
  94318. onCompileObservable: Observable<Effect>;
  94319. /**
  94320. * Observable that will be called if an error occurs during shader compilation.
  94321. */
  94322. onErrorObservable: Observable<Effect>;
  94323. /** @hidden */
  94324. _onBindObservable: Nullable<Observable<Effect>>;
  94325. /**
  94326. * Observable that will be called when effect is bound.
  94327. */
  94328. readonly onBindObservable: Observable<Effect>;
  94329. /** @hidden */
  94330. _bonesComputationForcedToCPU: boolean;
  94331. private static _uniqueIdSeed;
  94332. private _engine;
  94333. private _uniformBuffersNames;
  94334. private _uniformsNames;
  94335. private _samplerList;
  94336. private _samplers;
  94337. private _isReady;
  94338. private _compilationError;
  94339. private _attributesNames;
  94340. private _attributes;
  94341. private _uniforms;
  94342. /**
  94343. * Key for the effect.
  94344. * @hidden
  94345. */
  94346. _key: string;
  94347. private _indexParameters;
  94348. private _fallbacks;
  94349. private _vertexSourceCode;
  94350. private _fragmentSourceCode;
  94351. private _vertexSourceCodeOverride;
  94352. private _fragmentSourceCodeOverride;
  94353. private _transformFeedbackVaryings;
  94354. /**
  94355. * Compiled shader to webGL program.
  94356. * @hidden
  94357. */
  94358. _pipelineContext: Nullable<IPipelineContext>;
  94359. private _valueCache;
  94360. private static _baseCache;
  94361. /**
  94362. * Instantiates an effect.
  94363. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94364. * @param baseName Name of the effect.
  94365. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94366. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94367. * @param samplers List of sampler variables that will be passed to the shader.
  94368. * @param engine Engine to be used to render the effect
  94369. * @param defines Define statements to be added to the shader.
  94370. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94371. * @param onCompiled Callback that will be called when the shader is compiled.
  94372. * @param onError Callback that will be called if an error occurs during shader compilation.
  94373. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94374. */
  94375. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94376. private _useFinalCode;
  94377. /**
  94378. * Unique key for this effect
  94379. */
  94380. readonly key: string;
  94381. /**
  94382. * If the effect has been compiled and prepared.
  94383. * @returns if the effect is compiled and prepared.
  94384. */
  94385. isReady(): boolean;
  94386. private _isReadyInternal;
  94387. /**
  94388. * The engine the effect was initialized with.
  94389. * @returns the engine.
  94390. */
  94391. getEngine(): Engine;
  94392. /**
  94393. * The pipeline context for this effect
  94394. * @returns the associated pipeline context
  94395. */
  94396. getPipelineContext(): Nullable<IPipelineContext>;
  94397. /**
  94398. * The set of names of attribute variables for the shader.
  94399. * @returns An array of attribute names.
  94400. */
  94401. getAttributesNames(): string[];
  94402. /**
  94403. * Returns the attribute at the given index.
  94404. * @param index The index of the attribute.
  94405. * @returns The location of the attribute.
  94406. */
  94407. getAttributeLocation(index: number): number;
  94408. /**
  94409. * Returns the attribute based on the name of the variable.
  94410. * @param name of the attribute to look up.
  94411. * @returns the attribute location.
  94412. */
  94413. getAttributeLocationByName(name: string): number;
  94414. /**
  94415. * The number of attributes.
  94416. * @returns the numnber of attributes.
  94417. */
  94418. getAttributesCount(): number;
  94419. /**
  94420. * Gets the index of a uniform variable.
  94421. * @param uniformName of the uniform to look up.
  94422. * @returns the index.
  94423. */
  94424. getUniformIndex(uniformName: string): number;
  94425. /**
  94426. * Returns the attribute based on the name of the variable.
  94427. * @param uniformName of the uniform to look up.
  94428. * @returns the location of the uniform.
  94429. */
  94430. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94431. /**
  94432. * Returns an array of sampler variable names
  94433. * @returns The array of sampler variable neames.
  94434. */
  94435. getSamplers(): string[];
  94436. /**
  94437. * The error from the last compilation.
  94438. * @returns the error string.
  94439. */
  94440. getCompilationError(): string;
  94441. /**
  94442. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94443. * @param func The callback to be used.
  94444. */
  94445. executeWhenCompiled(func: (effect: Effect) => void): void;
  94446. private _checkIsReady;
  94447. /** @hidden */
  94448. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94449. /** @hidden */
  94450. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94451. /** @hidden */
  94452. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94453. /**
  94454. * Recompiles the webGL program
  94455. * @param vertexSourceCode The source code for the vertex shader.
  94456. * @param fragmentSourceCode The source code for the fragment shader.
  94457. * @param onCompiled Callback called when completed.
  94458. * @param onError Callback called on error.
  94459. * @hidden
  94460. */
  94461. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94462. /**
  94463. * Prepares the effect
  94464. * @hidden
  94465. */
  94466. _prepareEffect(): void;
  94467. private _processCompilationErrors;
  94468. /**
  94469. * Checks if the effect is supported. (Must be called after compilation)
  94470. */
  94471. readonly isSupported: boolean;
  94472. /**
  94473. * Binds a texture to the engine to be used as output of the shader.
  94474. * @param channel Name of the output variable.
  94475. * @param texture Texture to bind.
  94476. * @hidden
  94477. */
  94478. _bindTexture(channel: string, texture: InternalTexture): void;
  94479. /**
  94480. * Sets a texture on the engine to be used in the shader.
  94481. * @param channel Name of the sampler variable.
  94482. * @param texture Texture to set.
  94483. */
  94484. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94485. /**
  94486. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94487. * @param channel Name of the sampler variable.
  94488. * @param texture Texture to set.
  94489. */
  94490. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94491. /**
  94492. * Sets an array of textures on the engine to be used in the shader.
  94493. * @param channel Name of the variable.
  94494. * @param textures Textures to set.
  94495. */
  94496. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94497. /**
  94498. * 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)
  94499. * @param channel Name of the sampler variable.
  94500. * @param postProcess Post process to get the input texture from.
  94501. */
  94502. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94503. /**
  94504. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94505. * 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)
  94506. * @param channel Name of the sampler variable.
  94507. * @param postProcess Post process to get the output texture from.
  94508. */
  94509. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94510. /** @hidden */
  94511. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94512. /** @hidden */
  94513. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94514. /** @hidden */
  94515. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94516. /** @hidden */
  94517. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94518. /**
  94519. * Binds a buffer to a uniform.
  94520. * @param buffer Buffer to bind.
  94521. * @param name Name of the uniform variable to bind to.
  94522. */
  94523. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94524. /**
  94525. * Binds block to a uniform.
  94526. * @param blockName Name of the block to bind.
  94527. * @param index Index to bind.
  94528. */
  94529. bindUniformBlock(blockName: string, index: number): void;
  94530. /**
  94531. * Sets an interger value on a uniform variable.
  94532. * @param uniformName Name of the variable.
  94533. * @param value Value to be set.
  94534. * @returns this effect.
  94535. */
  94536. setInt(uniformName: string, value: number): Effect;
  94537. /**
  94538. * Sets an int array on a uniform variable.
  94539. * @param uniformName Name of the variable.
  94540. * @param array array to be set.
  94541. * @returns this effect.
  94542. */
  94543. setIntArray(uniformName: string, array: Int32Array): Effect;
  94544. /**
  94545. * 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)
  94546. * @param uniformName Name of the variable.
  94547. * @param array array to be set.
  94548. * @returns this effect.
  94549. */
  94550. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94551. /**
  94552. * 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)
  94553. * @param uniformName Name of the variable.
  94554. * @param array array to be set.
  94555. * @returns this effect.
  94556. */
  94557. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94558. /**
  94559. * 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)
  94560. * @param uniformName Name of the variable.
  94561. * @param array array to be set.
  94562. * @returns this effect.
  94563. */
  94564. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94565. /**
  94566. * Sets an float array on a uniform variable.
  94567. * @param uniformName Name of the variable.
  94568. * @param array array to be set.
  94569. * @returns this effect.
  94570. */
  94571. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94572. /**
  94573. * 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)
  94574. * @param uniformName Name of the variable.
  94575. * @param array array to be set.
  94576. * @returns this effect.
  94577. */
  94578. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94579. /**
  94580. * 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)
  94581. * @param uniformName Name of the variable.
  94582. * @param array array to be set.
  94583. * @returns this effect.
  94584. */
  94585. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94586. /**
  94587. * 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)
  94588. * @param uniformName Name of the variable.
  94589. * @param array array to be set.
  94590. * @returns this effect.
  94591. */
  94592. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94593. /**
  94594. * Sets an array on a uniform variable.
  94595. * @param uniformName Name of the variable.
  94596. * @param array array to be set.
  94597. * @returns this effect.
  94598. */
  94599. setArray(uniformName: string, array: number[]): Effect;
  94600. /**
  94601. * 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)
  94602. * @param uniformName Name of the variable.
  94603. * @param array array to be set.
  94604. * @returns this effect.
  94605. */
  94606. setArray2(uniformName: string, array: number[]): Effect;
  94607. /**
  94608. * 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)
  94609. * @param uniformName Name of the variable.
  94610. * @param array array to be set.
  94611. * @returns this effect.
  94612. */
  94613. setArray3(uniformName: string, array: number[]): Effect;
  94614. /**
  94615. * 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)
  94616. * @param uniformName Name of the variable.
  94617. * @param array array to be set.
  94618. * @returns this effect.
  94619. */
  94620. setArray4(uniformName: string, array: number[]): Effect;
  94621. /**
  94622. * Sets matrices on a uniform variable.
  94623. * @param uniformName Name of the variable.
  94624. * @param matrices matrices to be set.
  94625. * @returns this effect.
  94626. */
  94627. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94628. /**
  94629. * Sets matrix on a uniform variable.
  94630. * @param uniformName Name of the variable.
  94631. * @param matrix matrix to be set.
  94632. * @returns this effect.
  94633. */
  94634. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94635. /**
  94636. * 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)
  94637. * @param uniformName Name of the variable.
  94638. * @param matrix matrix to be set.
  94639. * @returns this effect.
  94640. */
  94641. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94642. /**
  94643. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94644. * @param uniformName Name of the variable.
  94645. * @param matrix matrix to be set.
  94646. * @returns this effect.
  94647. */
  94648. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94649. /**
  94650. * Sets a float on a uniform variable.
  94651. * @param uniformName Name of the variable.
  94652. * @param value value to be set.
  94653. * @returns this effect.
  94654. */
  94655. setFloat(uniformName: string, value: number): Effect;
  94656. /**
  94657. * Sets a boolean on a uniform variable.
  94658. * @param uniformName Name of the variable.
  94659. * @param bool value to be set.
  94660. * @returns this effect.
  94661. */
  94662. setBool(uniformName: string, bool: boolean): Effect;
  94663. /**
  94664. * Sets a Vector2 on a uniform variable.
  94665. * @param uniformName Name of the variable.
  94666. * @param vector2 vector2 to be set.
  94667. * @returns this effect.
  94668. */
  94669. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94670. /**
  94671. * Sets a float2 on a uniform variable.
  94672. * @param uniformName Name of the variable.
  94673. * @param x First float in float2.
  94674. * @param y Second float in float2.
  94675. * @returns this effect.
  94676. */
  94677. setFloat2(uniformName: string, x: number, y: number): Effect;
  94678. /**
  94679. * Sets a Vector3 on a uniform variable.
  94680. * @param uniformName Name of the variable.
  94681. * @param vector3 Value to be set.
  94682. * @returns this effect.
  94683. */
  94684. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94685. /**
  94686. * Sets a float3 on a uniform variable.
  94687. * @param uniformName Name of the variable.
  94688. * @param x First float in float3.
  94689. * @param y Second float in float3.
  94690. * @param z Third float in float3.
  94691. * @returns this effect.
  94692. */
  94693. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94694. /**
  94695. * Sets a Vector4 on a uniform variable.
  94696. * @param uniformName Name of the variable.
  94697. * @param vector4 Value to be set.
  94698. * @returns this effect.
  94699. */
  94700. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94701. /**
  94702. * Sets a float4 on a uniform variable.
  94703. * @param uniformName Name of the variable.
  94704. * @param x First float in float4.
  94705. * @param y Second float in float4.
  94706. * @param z Third float in float4.
  94707. * @param w Fourth float in float4.
  94708. * @returns this effect.
  94709. */
  94710. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94711. /**
  94712. * Sets a Color3 on a uniform variable.
  94713. * @param uniformName Name of the variable.
  94714. * @param color3 Value to be set.
  94715. * @returns this effect.
  94716. */
  94717. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94718. /**
  94719. * Sets a Color4 on a uniform variable.
  94720. * @param uniformName Name of the variable.
  94721. * @param color3 Value to be set.
  94722. * @param alpha Alpha value to be set.
  94723. * @returns this effect.
  94724. */
  94725. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94726. /**
  94727. * Sets a Color4 on a uniform variable
  94728. * @param uniformName defines the name of the variable
  94729. * @param color4 defines the value to be set
  94730. * @returns this effect.
  94731. */
  94732. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94733. /** Release all associated resources */
  94734. dispose(): void;
  94735. /**
  94736. * This function will add a new shader to the shader store
  94737. * @param name the name of the shader
  94738. * @param pixelShader optional pixel shader content
  94739. * @param vertexShader optional vertex shader content
  94740. */
  94741. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94742. /**
  94743. * Store of each shader (The can be looked up using effect.key)
  94744. */
  94745. static ShadersStore: {
  94746. [key: string]: string;
  94747. };
  94748. /**
  94749. * Store of each included file for a shader (The can be looked up using effect.key)
  94750. */
  94751. static IncludesShadersStore: {
  94752. [key: string]: string;
  94753. };
  94754. /**
  94755. * Resets the cache of effects.
  94756. */
  94757. static ResetCache(): void;
  94758. }
  94759. }
  94760. declare module BABYLON {
  94761. /**
  94762. * Uniform buffer objects.
  94763. *
  94764. * Handles blocks of uniform on the GPU.
  94765. *
  94766. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94767. *
  94768. * For more information, please refer to :
  94769. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94770. */
  94771. export class UniformBuffer {
  94772. private _engine;
  94773. private _buffer;
  94774. private _data;
  94775. private _bufferData;
  94776. private _dynamic?;
  94777. private _uniformLocations;
  94778. private _uniformSizes;
  94779. private _uniformLocationPointer;
  94780. private _needSync;
  94781. private _noUBO;
  94782. private _currentEffect;
  94783. private static _MAX_UNIFORM_SIZE;
  94784. private static _tempBuffer;
  94785. /**
  94786. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94787. * This is dynamic to allow compat with webgl 1 and 2.
  94788. * You will need to pass the name of the uniform as well as the value.
  94789. */
  94790. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94791. /**
  94792. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94793. * This is dynamic to allow compat with webgl 1 and 2.
  94794. * You will need to pass the name of the uniform as well as the value.
  94795. */
  94796. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94797. /**
  94798. * Lambda to Update a single float in a uniform buffer.
  94799. * This is dynamic to allow compat with webgl 1 and 2.
  94800. * You will need to pass the name of the uniform as well as the value.
  94801. */
  94802. updateFloat: (name: string, x: number) => void;
  94803. /**
  94804. * Lambda to Update a vec2 of float in a uniform buffer.
  94805. * This is dynamic to allow compat with webgl 1 and 2.
  94806. * You will need to pass the name of the uniform as well as the value.
  94807. */
  94808. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94809. /**
  94810. * Lambda to Update a vec3 of float in a uniform buffer.
  94811. * This is dynamic to allow compat with webgl 1 and 2.
  94812. * You will need to pass the name of the uniform as well as the value.
  94813. */
  94814. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94815. /**
  94816. * Lambda to Update a vec4 of float in a uniform buffer.
  94817. * This is dynamic to allow compat with webgl 1 and 2.
  94818. * You will need to pass the name of the uniform as well as the value.
  94819. */
  94820. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94821. /**
  94822. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94823. * This is dynamic to allow compat with webgl 1 and 2.
  94824. * You will need to pass the name of the uniform as well as the value.
  94825. */
  94826. updateMatrix: (name: string, mat: Matrix) => void;
  94827. /**
  94828. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94829. * This is dynamic to allow compat with webgl 1 and 2.
  94830. * You will need to pass the name of the uniform as well as the value.
  94831. */
  94832. updateVector3: (name: string, vector: Vector3) => void;
  94833. /**
  94834. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94835. * This is dynamic to allow compat with webgl 1 and 2.
  94836. * You will need to pass the name of the uniform as well as the value.
  94837. */
  94838. updateVector4: (name: string, vector: Vector4) => void;
  94839. /**
  94840. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94841. * This is dynamic to allow compat with webgl 1 and 2.
  94842. * You will need to pass the name of the uniform as well as the value.
  94843. */
  94844. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94845. /**
  94846. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94847. * This is dynamic to allow compat with webgl 1 and 2.
  94848. * You will need to pass the name of the uniform as well as the value.
  94849. */
  94850. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94851. /**
  94852. * Instantiates a new Uniform buffer objects.
  94853. *
  94854. * Handles blocks of uniform on the GPU.
  94855. *
  94856. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94857. *
  94858. * For more information, please refer to :
  94859. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94860. * @param engine Define the engine the buffer is associated with
  94861. * @param data Define the data contained in the buffer
  94862. * @param dynamic Define if the buffer is updatable
  94863. */
  94864. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94865. /**
  94866. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94867. * or just falling back on setUniformXXX calls.
  94868. */
  94869. readonly useUbo: boolean;
  94870. /**
  94871. * Indicates if the WebGL underlying uniform buffer is in sync
  94872. * with the javascript cache data.
  94873. */
  94874. readonly isSync: boolean;
  94875. /**
  94876. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94877. * Also, a dynamic UniformBuffer will disable cache verification and always
  94878. * update the underlying WebGL uniform buffer to the GPU.
  94879. * @returns if Dynamic, otherwise false
  94880. */
  94881. isDynamic(): boolean;
  94882. /**
  94883. * The data cache on JS side.
  94884. * @returns the underlying data as a float array
  94885. */
  94886. getData(): Float32Array;
  94887. /**
  94888. * The underlying WebGL Uniform buffer.
  94889. * @returns the webgl buffer
  94890. */
  94891. getBuffer(): Nullable<DataBuffer>;
  94892. /**
  94893. * std140 layout specifies how to align data within an UBO structure.
  94894. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94895. * for specs.
  94896. */
  94897. private _fillAlignment;
  94898. /**
  94899. * Adds an uniform in the buffer.
  94900. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94901. * for the layout to be correct !
  94902. * @param name Name of the uniform, as used in the uniform block in the shader.
  94903. * @param size Data size, or data directly.
  94904. */
  94905. addUniform(name: string, size: number | number[]): void;
  94906. /**
  94907. * Adds a Matrix 4x4 to the uniform buffer.
  94908. * @param name Name of the uniform, as used in the uniform block in the shader.
  94909. * @param mat A 4x4 matrix.
  94910. */
  94911. addMatrix(name: string, mat: Matrix): void;
  94912. /**
  94913. * Adds a vec2 to the uniform buffer.
  94914. * @param name Name of the uniform, as used in the uniform block in the shader.
  94915. * @param x Define the x component value of the vec2
  94916. * @param y Define the y component value of the vec2
  94917. */
  94918. addFloat2(name: string, x: number, y: number): void;
  94919. /**
  94920. * Adds a vec3 to the uniform buffer.
  94921. * @param name Name of the uniform, as used in the uniform block in the shader.
  94922. * @param x Define the x component value of the vec3
  94923. * @param y Define the y component value of the vec3
  94924. * @param z Define the z component value of the vec3
  94925. */
  94926. addFloat3(name: string, x: number, y: number, z: number): void;
  94927. /**
  94928. * Adds a vec3 to the uniform buffer.
  94929. * @param name Name of the uniform, as used in the uniform block in the shader.
  94930. * @param color Define the vec3 from a Color
  94931. */
  94932. addColor3(name: string, color: Color3): void;
  94933. /**
  94934. * Adds a vec4 to the uniform buffer.
  94935. * @param name Name of the uniform, as used in the uniform block in the shader.
  94936. * @param color Define the rgb components from a Color
  94937. * @param alpha Define the a component of the vec4
  94938. */
  94939. addColor4(name: string, color: Color3, alpha: number): void;
  94940. /**
  94941. * Adds a vec3 to the uniform buffer.
  94942. * @param name Name of the uniform, as used in the uniform block in the shader.
  94943. * @param vector Define the vec3 components from a Vector
  94944. */
  94945. addVector3(name: string, vector: Vector3): void;
  94946. /**
  94947. * Adds a Matrix 3x3 to the uniform buffer.
  94948. * @param name Name of the uniform, as used in the uniform block in the shader.
  94949. */
  94950. addMatrix3x3(name: string): void;
  94951. /**
  94952. * Adds a Matrix 2x2 to the uniform buffer.
  94953. * @param name Name of the uniform, as used in the uniform block in the shader.
  94954. */
  94955. addMatrix2x2(name: string): void;
  94956. /**
  94957. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94958. */
  94959. create(): void;
  94960. /** @hidden */
  94961. _rebuild(): void;
  94962. /**
  94963. * Updates the WebGL Uniform Buffer on the GPU.
  94964. * If the `dynamic` flag is set to true, no cache comparison is done.
  94965. * Otherwise, the buffer will be updated only if the cache differs.
  94966. */
  94967. update(): void;
  94968. /**
  94969. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94970. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94971. * @param data Define the flattened data
  94972. * @param size Define the size of the data.
  94973. */
  94974. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94975. private _valueCache;
  94976. private _cacheMatrix;
  94977. private _updateMatrix3x3ForUniform;
  94978. private _updateMatrix3x3ForEffect;
  94979. private _updateMatrix2x2ForEffect;
  94980. private _updateMatrix2x2ForUniform;
  94981. private _updateFloatForEffect;
  94982. private _updateFloatForUniform;
  94983. private _updateFloat2ForEffect;
  94984. private _updateFloat2ForUniform;
  94985. private _updateFloat3ForEffect;
  94986. private _updateFloat3ForUniform;
  94987. private _updateFloat4ForEffect;
  94988. private _updateFloat4ForUniform;
  94989. private _updateMatrixForEffect;
  94990. private _updateMatrixForUniform;
  94991. private _updateVector3ForEffect;
  94992. private _updateVector3ForUniform;
  94993. private _updateVector4ForEffect;
  94994. private _updateVector4ForUniform;
  94995. private _updateColor3ForEffect;
  94996. private _updateColor3ForUniform;
  94997. private _updateColor4ForEffect;
  94998. private _updateColor4ForUniform;
  94999. /**
  95000. * Sets a sampler uniform on the effect.
  95001. * @param name Define the name of the sampler.
  95002. * @param texture Define the texture to set in the sampler
  95003. */
  95004. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  95005. /**
  95006. * Directly updates the value of the uniform in the cache AND on the GPU.
  95007. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  95008. * @param data Define the flattened data
  95009. */
  95010. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  95011. /**
  95012. * Binds this uniform buffer to an effect.
  95013. * @param effect Define the effect to bind the buffer to
  95014. * @param name Name of the uniform block in the shader.
  95015. */
  95016. bindToEffect(effect: Effect, name: string): void;
  95017. /**
  95018. * Disposes the uniform buffer.
  95019. */
  95020. dispose(): void;
  95021. }
  95022. }
  95023. declare module BABYLON {
  95024. /**
  95025. * Class used to work with sound analyzer using fast fourier transform (FFT)
  95026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95027. */
  95028. export class Analyser {
  95029. /**
  95030. * Gets or sets the smoothing
  95031. * @ignorenaming
  95032. */
  95033. SMOOTHING: number;
  95034. /**
  95035. * Gets or sets the FFT table size
  95036. * @ignorenaming
  95037. */
  95038. FFT_SIZE: number;
  95039. /**
  95040. * Gets or sets the bar graph amplitude
  95041. * @ignorenaming
  95042. */
  95043. BARGRAPHAMPLITUDE: number;
  95044. /**
  95045. * Gets or sets the position of the debug canvas
  95046. * @ignorenaming
  95047. */
  95048. DEBUGCANVASPOS: {
  95049. x: number;
  95050. y: number;
  95051. };
  95052. /**
  95053. * Gets or sets the debug canvas size
  95054. * @ignorenaming
  95055. */
  95056. DEBUGCANVASSIZE: {
  95057. width: number;
  95058. height: number;
  95059. };
  95060. private _byteFreqs;
  95061. private _byteTime;
  95062. private _floatFreqs;
  95063. private _webAudioAnalyser;
  95064. private _debugCanvas;
  95065. private _debugCanvasContext;
  95066. private _scene;
  95067. private _registerFunc;
  95068. private _audioEngine;
  95069. /**
  95070. * Creates a new analyser
  95071. * @param scene defines hosting scene
  95072. */
  95073. constructor(scene: Scene);
  95074. /**
  95075. * Get the number of data values you will have to play with for the visualization
  95076. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  95077. * @returns a number
  95078. */
  95079. getFrequencyBinCount(): number;
  95080. /**
  95081. * Gets the current frequency data as a byte array
  95082. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  95083. * @returns a Uint8Array
  95084. */
  95085. getByteFrequencyData(): Uint8Array;
  95086. /**
  95087. * Gets the current waveform as a byte array
  95088. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  95089. * @returns a Uint8Array
  95090. */
  95091. getByteTimeDomainData(): Uint8Array;
  95092. /**
  95093. * Gets the current frequency data as a float array
  95094. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  95095. * @returns a Float32Array
  95096. */
  95097. getFloatFrequencyData(): Float32Array;
  95098. /**
  95099. * Renders the debug canvas
  95100. */
  95101. drawDebugCanvas(): void;
  95102. /**
  95103. * Stops rendering the debug canvas and removes it
  95104. */
  95105. stopDebugCanvas(): void;
  95106. /**
  95107. * Connects two audio nodes
  95108. * @param inputAudioNode defines first node to connect
  95109. * @param outputAudioNode defines second node to connect
  95110. */
  95111. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  95112. /**
  95113. * Releases all associated resources
  95114. */
  95115. dispose(): void;
  95116. }
  95117. }
  95118. declare module BABYLON {
  95119. /**
  95120. * This represents an audio engine and it is responsible
  95121. * to play, synchronize and analyse sounds throughout the application.
  95122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95123. */
  95124. export interface IAudioEngine extends IDisposable {
  95125. /**
  95126. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95127. */
  95128. readonly canUseWebAudio: boolean;
  95129. /**
  95130. * Gets the current AudioContext if available.
  95131. */
  95132. readonly audioContext: Nullable<AudioContext>;
  95133. /**
  95134. * The master gain node defines the global audio volume of your audio engine.
  95135. */
  95136. readonly masterGain: GainNode;
  95137. /**
  95138. * Gets whether or not mp3 are supported by your browser.
  95139. */
  95140. readonly isMP3supported: boolean;
  95141. /**
  95142. * Gets whether or not ogg are supported by your browser.
  95143. */
  95144. readonly isOGGsupported: boolean;
  95145. /**
  95146. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95147. * @ignoreNaming
  95148. */
  95149. WarnedWebAudioUnsupported: boolean;
  95150. /**
  95151. * Defines if the audio engine relies on a custom unlocked button.
  95152. * In this case, the embedded button will not be displayed.
  95153. */
  95154. useCustomUnlockedButton: boolean;
  95155. /**
  95156. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95157. */
  95158. readonly unlocked: boolean;
  95159. /**
  95160. * Event raised when audio has been unlocked on the browser.
  95161. */
  95162. onAudioUnlockedObservable: Observable<AudioEngine>;
  95163. /**
  95164. * Event raised when audio has been locked on the browser.
  95165. */
  95166. onAudioLockedObservable: Observable<AudioEngine>;
  95167. /**
  95168. * Flags the audio engine in Locked state.
  95169. * This happens due to new browser policies preventing audio to autoplay.
  95170. */
  95171. lock(): void;
  95172. /**
  95173. * Unlocks the audio engine once a user action has been done on the dom.
  95174. * This is helpful to resume play once browser policies have been satisfied.
  95175. */
  95176. unlock(): void;
  95177. }
  95178. /**
  95179. * This represents the default audio engine used in babylon.
  95180. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95182. */
  95183. export class AudioEngine implements IAudioEngine {
  95184. private _audioContext;
  95185. private _audioContextInitialized;
  95186. private _muteButton;
  95187. private _hostElement;
  95188. /**
  95189. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95190. */
  95191. canUseWebAudio: boolean;
  95192. /**
  95193. * The master gain node defines the global audio volume of your audio engine.
  95194. */
  95195. masterGain: GainNode;
  95196. /**
  95197. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95198. * @ignoreNaming
  95199. */
  95200. WarnedWebAudioUnsupported: boolean;
  95201. /**
  95202. * Gets whether or not mp3 are supported by your browser.
  95203. */
  95204. isMP3supported: boolean;
  95205. /**
  95206. * Gets whether or not ogg are supported by your browser.
  95207. */
  95208. isOGGsupported: boolean;
  95209. /**
  95210. * Gets whether audio has been unlocked on the device.
  95211. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95212. * a user interaction has happened.
  95213. */
  95214. unlocked: boolean;
  95215. /**
  95216. * Defines if the audio engine relies on a custom unlocked button.
  95217. * In this case, the embedded button will not be displayed.
  95218. */
  95219. useCustomUnlockedButton: boolean;
  95220. /**
  95221. * Event raised when audio has been unlocked on the browser.
  95222. */
  95223. onAudioUnlockedObservable: Observable<AudioEngine>;
  95224. /**
  95225. * Event raised when audio has been locked on the browser.
  95226. */
  95227. onAudioLockedObservable: Observable<AudioEngine>;
  95228. /**
  95229. * Gets the current AudioContext if available.
  95230. */
  95231. readonly audioContext: Nullable<AudioContext>;
  95232. private _connectedAnalyser;
  95233. /**
  95234. * Instantiates a new audio engine.
  95235. *
  95236. * There should be only one per page as some browsers restrict the number
  95237. * of audio contexts you can create.
  95238. * @param hostElement defines the host element where to display the mute icon if necessary
  95239. */
  95240. constructor(hostElement?: Nullable<HTMLElement>);
  95241. /**
  95242. * Flags the audio engine in Locked state.
  95243. * This happens due to new browser policies preventing audio to autoplay.
  95244. */
  95245. lock(): void;
  95246. /**
  95247. * Unlocks the audio engine once a user action has been done on the dom.
  95248. * This is helpful to resume play once browser policies have been satisfied.
  95249. */
  95250. unlock(): void;
  95251. private _resumeAudioContext;
  95252. private _initializeAudioContext;
  95253. private _tryToRun;
  95254. private _triggerRunningState;
  95255. private _triggerSuspendedState;
  95256. private _displayMuteButton;
  95257. private _moveButtonToTopLeft;
  95258. private _onResize;
  95259. private _hideMuteButton;
  95260. /**
  95261. * Destroy and release the resources associated with the audio ccontext.
  95262. */
  95263. dispose(): void;
  95264. /**
  95265. * Gets the global volume sets on the master gain.
  95266. * @returns the global volume if set or -1 otherwise
  95267. */
  95268. getGlobalVolume(): number;
  95269. /**
  95270. * Sets the global volume of your experience (sets on the master gain).
  95271. * @param newVolume Defines the new global volume of the application
  95272. */
  95273. setGlobalVolume(newVolume: number): void;
  95274. /**
  95275. * Connect the audio engine to an audio analyser allowing some amazing
  95276. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95278. * @param analyser The analyser to connect to the engine
  95279. */
  95280. connectToAnalyser(analyser: Analyser): void;
  95281. }
  95282. }
  95283. declare module BABYLON {
  95284. /**
  95285. * Interface used to present a loading screen while loading a scene
  95286. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95287. */
  95288. export interface ILoadingScreen {
  95289. /**
  95290. * Function called to display the loading screen
  95291. */
  95292. displayLoadingUI: () => void;
  95293. /**
  95294. * Function called to hide the loading screen
  95295. */
  95296. hideLoadingUI: () => void;
  95297. /**
  95298. * Gets or sets the color to use for the background
  95299. */
  95300. loadingUIBackgroundColor: string;
  95301. /**
  95302. * Gets or sets the text to display while loading
  95303. */
  95304. loadingUIText: string;
  95305. }
  95306. /**
  95307. * Class used for the default loading screen
  95308. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95309. */
  95310. export class DefaultLoadingScreen implements ILoadingScreen {
  95311. private _renderingCanvas;
  95312. private _loadingText;
  95313. private _loadingDivBackgroundColor;
  95314. private _loadingDiv;
  95315. private _loadingTextDiv;
  95316. /** Gets or sets the logo url to use for the default loading screen */
  95317. static DefaultLogoUrl: string;
  95318. /** Gets or sets the spinner url to use for the default loading screen */
  95319. static DefaultSpinnerUrl: string;
  95320. /**
  95321. * Creates a new default loading screen
  95322. * @param _renderingCanvas defines the canvas used to render the scene
  95323. * @param _loadingText defines the default text to display
  95324. * @param _loadingDivBackgroundColor defines the default background color
  95325. */
  95326. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95327. /**
  95328. * Function called to display the loading screen
  95329. */
  95330. displayLoadingUI(): void;
  95331. /**
  95332. * Function called to hide the loading screen
  95333. */
  95334. hideLoadingUI(): void;
  95335. /**
  95336. * Gets or sets the text to display while loading
  95337. */
  95338. loadingUIText: string;
  95339. /**
  95340. * Gets or sets the color to use for the background
  95341. */
  95342. loadingUIBackgroundColor: string;
  95343. private _resizeLoadingUI;
  95344. }
  95345. }
  95346. declare module BABYLON {
  95347. /** @hidden */
  95348. export class WebGLPipelineContext implements IPipelineContext {
  95349. engine: Engine;
  95350. program: Nullable<WebGLProgram>;
  95351. context?: WebGLRenderingContext;
  95352. vertexShader?: WebGLShader;
  95353. fragmentShader?: WebGLShader;
  95354. isParallelCompiled: boolean;
  95355. onCompiled?: () => void;
  95356. transformFeedback?: WebGLTransformFeedback | null;
  95357. readonly isAsync: boolean;
  95358. readonly isReady: boolean;
  95359. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95360. }
  95361. }
  95362. declare module BABYLON {
  95363. /** @hidden */
  95364. export class WebGLDataBuffer extends DataBuffer {
  95365. private _buffer;
  95366. constructor(resource: WebGLBuffer);
  95367. readonly underlyingResource: any;
  95368. }
  95369. }
  95370. declare module BABYLON {
  95371. /** @hidden */
  95372. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95373. attributeProcessor(attribute: string): string;
  95374. varyingProcessor(varying: string, isFragment: boolean): string;
  95375. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95376. }
  95377. }
  95378. declare module BABYLON {
  95379. /**
  95380. * This class is used to track a performance counter which is number based.
  95381. * The user has access to many properties which give statistics of different nature.
  95382. *
  95383. * The implementer can track two kinds of Performance Counter: time and count.
  95384. * 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.
  95385. * 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.
  95386. */
  95387. export class PerfCounter {
  95388. /**
  95389. * Gets or sets a global boolean to turn on and off all the counters
  95390. */
  95391. static Enabled: boolean;
  95392. /**
  95393. * Returns the smallest value ever
  95394. */
  95395. readonly min: number;
  95396. /**
  95397. * Returns the biggest value ever
  95398. */
  95399. readonly max: number;
  95400. /**
  95401. * Returns the average value since the performance counter is running
  95402. */
  95403. readonly average: number;
  95404. /**
  95405. * Returns the average value of the last second the counter was monitored
  95406. */
  95407. readonly lastSecAverage: number;
  95408. /**
  95409. * Returns the current value
  95410. */
  95411. readonly current: number;
  95412. /**
  95413. * Gets the accumulated total
  95414. */
  95415. readonly total: number;
  95416. /**
  95417. * Gets the total value count
  95418. */
  95419. readonly count: number;
  95420. /**
  95421. * Creates a new counter
  95422. */
  95423. constructor();
  95424. /**
  95425. * Call this method to start monitoring a new frame.
  95426. * 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.
  95427. */
  95428. fetchNewFrame(): void;
  95429. /**
  95430. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95431. * @param newCount the count value to add to the monitored count
  95432. * @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.
  95433. */
  95434. addCount(newCount: number, fetchResult: boolean): void;
  95435. /**
  95436. * Start monitoring this performance counter
  95437. */
  95438. beginMonitoring(): void;
  95439. /**
  95440. * Compute the time lapsed since the previous beginMonitoring() call.
  95441. * @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
  95442. */
  95443. endMonitoring(newFrame?: boolean): void;
  95444. private _fetchResult;
  95445. private _startMonitoringTime;
  95446. private _min;
  95447. private _max;
  95448. private _average;
  95449. private _current;
  95450. private _totalValueCount;
  95451. private _totalAccumulated;
  95452. private _lastSecAverage;
  95453. private _lastSecAccumulated;
  95454. private _lastSecTime;
  95455. private _lastSecValueCount;
  95456. }
  95457. }
  95458. declare module BABYLON {
  95459. /**
  95460. * Interface for any object that can request an animation frame
  95461. */
  95462. export interface ICustomAnimationFrameRequester {
  95463. /**
  95464. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95465. */
  95466. renderFunction?: Function;
  95467. /**
  95468. * Called to request the next frame to render to
  95469. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95470. */
  95471. requestAnimationFrame: Function;
  95472. /**
  95473. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95474. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95475. */
  95476. requestID?: number;
  95477. }
  95478. }
  95479. declare module BABYLON {
  95480. /**
  95481. * Settings for finer control over video usage
  95482. */
  95483. export interface VideoTextureSettings {
  95484. /**
  95485. * Applies `autoplay` to video, if specified
  95486. */
  95487. autoPlay?: boolean;
  95488. /**
  95489. * Applies `loop` to video, if specified
  95490. */
  95491. loop?: boolean;
  95492. /**
  95493. * Automatically updates internal texture from video at every frame in the render loop
  95494. */
  95495. autoUpdateTexture: boolean;
  95496. /**
  95497. * Image src displayed during the video loading or until the user interacts with the video.
  95498. */
  95499. poster?: string;
  95500. }
  95501. /**
  95502. * If you want to display a video in your scene, this is the special texture for that.
  95503. * This special texture works similar to other textures, with the exception of a few parameters.
  95504. * @see https://doc.babylonjs.com/how_to/video_texture
  95505. */
  95506. export class VideoTexture extends Texture {
  95507. /**
  95508. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95509. */
  95510. readonly autoUpdateTexture: boolean;
  95511. /**
  95512. * The video instance used by the texture internally
  95513. */
  95514. readonly video: HTMLVideoElement;
  95515. private _onUserActionRequestedObservable;
  95516. /**
  95517. * Event triggerd when a dom action is required by the user to play the video.
  95518. * This happens due to recent changes in browser policies preventing video to auto start.
  95519. */
  95520. readonly onUserActionRequestedObservable: Observable<Texture>;
  95521. private _generateMipMaps;
  95522. private _engine;
  95523. private _stillImageCaptured;
  95524. private _displayingPosterTexture;
  95525. private _settings;
  95526. private _createInternalTextureOnEvent;
  95527. private _frameId;
  95528. /**
  95529. * Creates a video texture.
  95530. * If you want to display a video in your scene, this is the special texture for that.
  95531. * This special texture works similar to other textures, with the exception of a few parameters.
  95532. * @see https://doc.babylonjs.com/how_to/video_texture
  95533. * @param name optional name, will detect from video source, if not defined
  95534. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95535. * @param scene is obviously the current scene.
  95536. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95537. * @param invertY is false by default but can be used to invert video on Y axis
  95538. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95539. * @param settings allows finer control over video usage
  95540. */
  95541. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95542. private _getName;
  95543. private _getVideo;
  95544. private _createInternalTexture;
  95545. private reset;
  95546. /**
  95547. * @hidden Internal method to initiate `update`.
  95548. */
  95549. _rebuild(): void;
  95550. /**
  95551. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95552. */
  95553. update(): void;
  95554. /**
  95555. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95556. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95557. */
  95558. updateTexture(isVisible: boolean): void;
  95559. protected _updateInternalTexture: () => void;
  95560. /**
  95561. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95562. * @param url New url.
  95563. */
  95564. updateURL(url: string): void;
  95565. /**
  95566. * Dispose the texture and release its associated resources.
  95567. */
  95568. dispose(): void;
  95569. /**
  95570. * Creates a video texture straight from a stream.
  95571. * @param scene Define the scene the texture should be created in
  95572. * @param stream Define the stream the texture should be created from
  95573. * @returns The created video texture as a promise
  95574. */
  95575. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95576. /**
  95577. * Creates a video texture straight from your WebCam video feed.
  95578. * @param scene Define the scene the texture should be created in
  95579. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95580. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95581. * @returns The created video texture as a promise
  95582. */
  95583. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95584. minWidth: number;
  95585. maxWidth: number;
  95586. minHeight: number;
  95587. maxHeight: number;
  95588. deviceId: string;
  95589. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95590. /**
  95591. * Creates a video texture straight from your WebCam video feed.
  95592. * @param scene Define the scene the texture should be created in
  95593. * @param onReady Define a callback to triggered once the texture will be ready
  95594. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95595. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95596. */
  95597. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95598. minWidth: number;
  95599. maxWidth: number;
  95600. minHeight: number;
  95601. maxHeight: number;
  95602. deviceId: string;
  95603. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95604. }
  95605. }
  95606. declare module BABYLON {
  95607. /**
  95608. * Defines the interface used by objects containing a viewport (like a camera)
  95609. */
  95610. interface IViewportOwnerLike {
  95611. /**
  95612. * Gets or sets the viewport
  95613. */
  95614. viewport: IViewportLike;
  95615. }
  95616. /**
  95617. * Interface for attribute information associated with buffer instanciation
  95618. */
  95619. export class InstancingAttributeInfo {
  95620. /**
  95621. * Index/offset of the attribute in the vertex shader
  95622. */
  95623. index: number;
  95624. /**
  95625. * size of the attribute, 1, 2, 3 or 4
  95626. */
  95627. attributeSize: number;
  95628. /**
  95629. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95630. * default is FLOAT
  95631. */
  95632. attribyteType: number;
  95633. /**
  95634. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95635. */
  95636. normalized: boolean;
  95637. /**
  95638. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95639. */
  95640. offset: number;
  95641. /**
  95642. * Name of the GLSL attribute, for debugging purpose only
  95643. */
  95644. attributeName: string;
  95645. }
  95646. /**
  95647. * Define options used to create a depth texture
  95648. */
  95649. export class DepthTextureCreationOptions {
  95650. /** Specifies whether or not a stencil should be allocated in the texture */
  95651. generateStencil?: boolean;
  95652. /** Specifies whether or not bilinear filtering is enable on the texture */
  95653. bilinearFiltering?: boolean;
  95654. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95655. comparisonFunction?: number;
  95656. /** Specifies if the created texture is a cube texture */
  95657. isCube?: boolean;
  95658. }
  95659. /**
  95660. * Class used to describe the capabilities of the engine relatively to the current browser
  95661. */
  95662. export class EngineCapabilities {
  95663. /** Maximum textures units per fragment shader */
  95664. maxTexturesImageUnits: number;
  95665. /** Maximum texture units per vertex shader */
  95666. maxVertexTextureImageUnits: number;
  95667. /** Maximum textures units in the entire pipeline */
  95668. maxCombinedTexturesImageUnits: number;
  95669. /** Maximum texture size */
  95670. maxTextureSize: number;
  95671. /** Maximum cube texture size */
  95672. maxCubemapTextureSize: number;
  95673. /** Maximum render texture size */
  95674. maxRenderTextureSize: number;
  95675. /** Maximum number of vertex attributes */
  95676. maxVertexAttribs: number;
  95677. /** Maximum number of varyings */
  95678. maxVaryingVectors: number;
  95679. /** Maximum number of uniforms per vertex shader */
  95680. maxVertexUniformVectors: number;
  95681. /** Maximum number of uniforms per fragment shader */
  95682. maxFragmentUniformVectors: number;
  95683. /** Defines if standard derivates (dx/dy) are supported */
  95684. standardDerivatives: boolean;
  95685. /** Defines if s3tc texture compression is supported */
  95686. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95687. /** Defines if pvrtc texture compression is supported */
  95688. pvrtc: any;
  95689. /** Defines if etc1 texture compression is supported */
  95690. etc1: any;
  95691. /** Defines if etc2 texture compression is supported */
  95692. etc2: any;
  95693. /** Defines if astc texture compression is supported */
  95694. astc: any;
  95695. /** Defines if float textures are supported */
  95696. textureFloat: boolean;
  95697. /** Defines if vertex array objects are supported */
  95698. vertexArrayObject: boolean;
  95699. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95700. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95701. /** Gets the maximum level of anisotropy supported */
  95702. maxAnisotropy: number;
  95703. /** Defines if instancing is supported */
  95704. instancedArrays: boolean;
  95705. /** Defines if 32 bits indices are supported */
  95706. uintIndices: boolean;
  95707. /** Defines if high precision shaders are supported */
  95708. highPrecisionShaderSupported: boolean;
  95709. /** Defines if depth reading in the fragment shader is supported */
  95710. fragmentDepthSupported: boolean;
  95711. /** Defines if float texture linear filtering is supported*/
  95712. textureFloatLinearFiltering: boolean;
  95713. /** Defines if rendering to float textures is supported */
  95714. textureFloatRender: boolean;
  95715. /** Defines if half float textures are supported*/
  95716. textureHalfFloat: boolean;
  95717. /** Defines if half float texture linear filtering is supported*/
  95718. textureHalfFloatLinearFiltering: boolean;
  95719. /** Defines if rendering to half float textures is supported */
  95720. textureHalfFloatRender: boolean;
  95721. /** Defines if textureLOD shader command is supported */
  95722. textureLOD: boolean;
  95723. /** Defines if draw buffers extension is supported */
  95724. drawBuffersExtension: boolean;
  95725. /** Defines if depth textures are supported */
  95726. depthTextureExtension: boolean;
  95727. /** Defines if float color buffer are supported */
  95728. colorBufferFloat: boolean;
  95729. /** Gets disjoint timer query extension (null if not supported) */
  95730. timerQuery: EXT_disjoint_timer_query;
  95731. /** Defines if timestamp can be used with timer query */
  95732. canUseTimestampForTimerQuery: boolean;
  95733. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95734. multiview: any;
  95735. /** Function used to let the system compiles shaders in background */
  95736. parallelShaderCompile: {
  95737. COMPLETION_STATUS_KHR: number;
  95738. };
  95739. /** Max number of texture samples for MSAA */
  95740. maxMSAASamples: number;
  95741. /** Defines if the blend min max extension is supported */
  95742. blendMinMax: boolean;
  95743. }
  95744. /** Interface defining initialization parameters for Engine class */
  95745. export interface EngineOptions extends WebGLContextAttributes {
  95746. /**
  95747. * Defines if the engine should no exceed a specified device ratio
  95748. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95749. */
  95750. limitDeviceRatio?: number;
  95751. /**
  95752. * Defines if webvr should be enabled automatically
  95753. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95754. */
  95755. autoEnableWebVR?: boolean;
  95756. /**
  95757. * Defines if webgl2 should be turned off even if supported
  95758. * @see http://doc.babylonjs.com/features/webgl2
  95759. */
  95760. disableWebGL2Support?: boolean;
  95761. /**
  95762. * Defines if webaudio should be initialized as well
  95763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95764. */
  95765. audioEngine?: boolean;
  95766. /**
  95767. * Defines if animations should run using a deterministic lock step
  95768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95769. */
  95770. deterministicLockstep?: boolean;
  95771. /** Defines the maximum steps to use with deterministic lock step mode */
  95772. lockstepMaxSteps?: number;
  95773. /**
  95774. * Defines that engine should ignore context lost events
  95775. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95776. */
  95777. doNotHandleContextLost?: boolean;
  95778. /**
  95779. * Defines that engine should ignore modifying touch action attribute and style
  95780. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95781. */
  95782. doNotHandleTouchAction?: boolean;
  95783. /**
  95784. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95785. */
  95786. useHighPrecisionFloats?: boolean;
  95787. }
  95788. /**
  95789. * Defines the interface used by display changed events
  95790. */
  95791. export interface IDisplayChangedEventArgs {
  95792. /** Gets the vrDisplay object (if any) */
  95793. vrDisplay: Nullable<any>;
  95794. /** Gets a boolean indicating if webVR is supported */
  95795. vrSupported: boolean;
  95796. }
  95797. /**
  95798. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95799. */
  95800. export class Engine {
  95801. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95802. static ExceptionList: ({
  95803. key: string;
  95804. capture: string;
  95805. captureConstraint: number;
  95806. targets: string[];
  95807. } | {
  95808. key: string;
  95809. capture: null;
  95810. captureConstraint: null;
  95811. targets: string[];
  95812. })[];
  95813. /** Gets the list of created engines */
  95814. static readonly Instances: Engine[];
  95815. /**
  95816. * Gets the latest created engine
  95817. */
  95818. static readonly LastCreatedEngine: Nullable<Engine>;
  95819. /**
  95820. * Gets the latest created scene
  95821. */
  95822. static readonly LastCreatedScene: Nullable<Scene>;
  95823. /**
  95824. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95825. * @param flag defines which part of the materials must be marked as dirty
  95826. * @param predicate defines a predicate used to filter which materials should be affected
  95827. */
  95828. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95829. /** @hidden */
  95830. static _TextureLoaders: IInternalTextureLoader[];
  95831. /** Defines that alpha blending is disabled */
  95832. static readonly ALPHA_DISABLE: number;
  95833. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95834. static readonly ALPHA_ADD: number;
  95835. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95836. static readonly ALPHA_COMBINE: number;
  95837. /** Defines that alpha blending to DEST - SRC * DEST */
  95838. static readonly ALPHA_SUBTRACT: number;
  95839. /** Defines that alpha blending to SRC * DEST */
  95840. static readonly ALPHA_MULTIPLY: number;
  95841. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95842. static readonly ALPHA_MAXIMIZED: number;
  95843. /** Defines that alpha blending to SRC + DEST */
  95844. static readonly ALPHA_ONEONE: number;
  95845. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95846. static readonly ALPHA_PREMULTIPLIED: number;
  95847. /**
  95848. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95849. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95850. */
  95851. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95852. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95853. static readonly ALPHA_INTERPOLATE: number;
  95854. /**
  95855. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95856. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95857. */
  95858. static readonly ALPHA_SCREENMODE: number;
  95859. /** Defines that the ressource is not delayed*/
  95860. static readonly DELAYLOADSTATE_NONE: number;
  95861. /** Defines that the ressource was successfully delay loaded */
  95862. static readonly DELAYLOADSTATE_LOADED: number;
  95863. /** Defines that the ressource is currently delay loading */
  95864. static readonly DELAYLOADSTATE_LOADING: number;
  95865. /** Defines that the ressource is delayed and has not started loading */
  95866. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95867. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95868. static readonly NEVER: number;
  95869. /** 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 */
  95870. static readonly ALWAYS: number;
  95871. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95872. static readonly LESS: number;
  95873. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95874. static readonly EQUAL: number;
  95875. /** 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 */
  95876. static readonly LEQUAL: number;
  95877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95878. static readonly GREATER: number;
  95879. /** 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 */
  95880. static readonly GEQUAL: number;
  95881. /** 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 */
  95882. static readonly NOTEQUAL: number;
  95883. /** Passed to stencilOperation to specify that stencil value must be kept */
  95884. static readonly KEEP: number;
  95885. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95886. static readonly REPLACE: number;
  95887. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95888. static readonly INCR: number;
  95889. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95890. static readonly DECR: number;
  95891. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95892. static readonly INVERT: number;
  95893. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95894. static readonly INCR_WRAP: number;
  95895. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95896. static readonly DECR_WRAP: number;
  95897. /** Texture is not repeating outside of 0..1 UVs */
  95898. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95899. /** Texture is repeating outside of 0..1 UVs */
  95900. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95901. /** Texture is repeating and mirrored */
  95902. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95903. /** ALPHA */
  95904. static readonly TEXTUREFORMAT_ALPHA: number;
  95905. /** LUMINANCE */
  95906. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95907. /** LUMINANCE_ALPHA */
  95908. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95909. /** RGB */
  95910. static readonly TEXTUREFORMAT_RGB: number;
  95911. /** RGBA */
  95912. static readonly TEXTUREFORMAT_RGBA: number;
  95913. /** RED */
  95914. static readonly TEXTUREFORMAT_RED: number;
  95915. /** RED (2nd reference) */
  95916. static readonly TEXTUREFORMAT_R: number;
  95917. /** RG */
  95918. static readonly TEXTUREFORMAT_RG: number;
  95919. /** RED_INTEGER */
  95920. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95921. /** RED_INTEGER (2nd reference) */
  95922. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95923. /** RG_INTEGER */
  95924. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95925. /** RGB_INTEGER */
  95926. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95927. /** RGBA_INTEGER */
  95928. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95929. /** UNSIGNED_BYTE */
  95930. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95931. /** UNSIGNED_BYTE (2nd reference) */
  95932. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95933. /** FLOAT */
  95934. static readonly TEXTURETYPE_FLOAT: number;
  95935. /** HALF_FLOAT */
  95936. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95937. /** BYTE */
  95938. static readonly TEXTURETYPE_BYTE: number;
  95939. /** SHORT */
  95940. static readonly TEXTURETYPE_SHORT: number;
  95941. /** UNSIGNED_SHORT */
  95942. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95943. /** INT */
  95944. static readonly TEXTURETYPE_INT: number;
  95945. /** UNSIGNED_INT */
  95946. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95947. /** UNSIGNED_SHORT_4_4_4_4 */
  95948. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95949. /** UNSIGNED_SHORT_5_5_5_1 */
  95950. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95951. /** UNSIGNED_SHORT_5_6_5 */
  95952. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95953. /** UNSIGNED_INT_2_10_10_10_REV */
  95954. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95955. /** UNSIGNED_INT_24_8 */
  95956. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95957. /** UNSIGNED_INT_10F_11F_11F_REV */
  95958. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95959. /** UNSIGNED_INT_5_9_9_9_REV */
  95960. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95961. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95962. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95963. /** nearest is mag = nearest and min = nearest and mip = linear */
  95964. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95965. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95966. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95967. /** Trilinear is mag = linear and min = linear and mip = linear */
  95968. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95969. /** nearest is mag = nearest and min = nearest and mip = linear */
  95970. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95972. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95973. /** Trilinear is mag = linear and min = linear and mip = linear */
  95974. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95975. /** mag = nearest and min = nearest and mip = nearest */
  95976. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95977. /** mag = nearest and min = linear and mip = nearest */
  95978. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95979. /** mag = nearest and min = linear and mip = linear */
  95980. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95981. /** mag = nearest and min = linear and mip = none */
  95982. static readonly TEXTURE_NEAREST_LINEAR: number;
  95983. /** mag = nearest and min = nearest and mip = none */
  95984. static readonly TEXTURE_NEAREST_NEAREST: number;
  95985. /** mag = linear and min = nearest and mip = nearest */
  95986. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95987. /** mag = linear and min = nearest and mip = linear */
  95988. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95989. /** mag = linear and min = linear and mip = none */
  95990. static readonly TEXTURE_LINEAR_LINEAR: number;
  95991. /** mag = linear and min = nearest and mip = none */
  95992. static readonly TEXTURE_LINEAR_NEAREST: number;
  95993. /** Explicit coordinates mode */
  95994. static readonly TEXTURE_EXPLICIT_MODE: number;
  95995. /** Spherical coordinates mode */
  95996. static readonly TEXTURE_SPHERICAL_MODE: number;
  95997. /** Planar coordinates mode */
  95998. static readonly TEXTURE_PLANAR_MODE: number;
  95999. /** Cubic coordinates mode */
  96000. static readonly TEXTURE_CUBIC_MODE: number;
  96001. /** Projection coordinates mode */
  96002. static readonly TEXTURE_PROJECTION_MODE: number;
  96003. /** Skybox coordinates mode */
  96004. static readonly TEXTURE_SKYBOX_MODE: number;
  96005. /** Inverse Cubic coordinates mode */
  96006. static readonly TEXTURE_INVCUBIC_MODE: number;
  96007. /** Equirectangular coordinates mode */
  96008. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  96009. /** Equirectangular Fixed coordinates mode */
  96010. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  96011. /** Equirectangular Fixed Mirrored coordinates mode */
  96012. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96013. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  96014. static readonly SCALEMODE_FLOOR: number;
  96015. /** Defines that texture rescaling will look for the nearest power of 2 size */
  96016. static readonly SCALEMODE_NEAREST: number;
  96017. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  96018. static readonly SCALEMODE_CEILING: number;
  96019. /**
  96020. * Returns the current npm package of the sdk
  96021. */
  96022. static readonly NpmPackage: string;
  96023. /**
  96024. * Returns the current version of the framework
  96025. */
  96026. static readonly Version: string;
  96027. /**
  96028. * Returns a string describing the current engine
  96029. */
  96030. readonly description: string;
  96031. /**
  96032. * Gets or sets the epsilon value used by collision engine
  96033. */
  96034. static CollisionsEpsilon: number;
  96035. /**
  96036. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96037. */
  96038. static ShadersRepository: string;
  96039. /**
  96040. * Method called to create the default loading screen.
  96041. * This can be overriden in your own app.
  96042. * @param canvas The rendering canvas element
  96043. * @returns The loading screen
  96044. */
  96045. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  96046. /**
  96047. * Method called to create the default rescale post process on each engine.
  96048. */
  96049. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  96050. /** @hidden */
  96051. _shaderProcessor: IShaderProcessor;
  96052. /**
  96053. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96054. */
  96055. forcePOTTextures: boolean;
  96056. /**
  96057. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96058. */
  96059. isFullscreen: boolean;
  96060. /**
  96061. * Gets a boolean indicating if the pointer is currently locked
  96062. */
  96063. isPointerLock: boolean;
  96064. /**
  96065. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96066. */
  96067. cullBackFaces: boolean;
  96068. /**
  96069. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96070. */
  96071. renderEvenInBackground: boolean;
  96072. /**
  96073. * Gets or sets a boolean indicating that cache can be kept between frames
  96074. */
  96075. preventCacheWipeBetweenFrames: boolean;
  96076. /**
  96077. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  96078. **/
  96079. enableOfflineSupport: boolean;
  96080. /**
  96081. * 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)
  96082. **/
  96083. disableManifestCheck: boolean;
  96084. /**
  96085. * Gets the list of created scenes
  96086. */
  96087. scenes: Scene[];
  96088. /**
  96089. * Event raised when a new scene is created
  96090. */
  96091. onNewSceneAddedObservable: Observable<Scene>;
  96092. /**
  96093. * Gets the list of created postprocesses
  96094. */
  96095. postProcesses: PostProcess[];
  96096. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96097. validateShaderPrograms: boolean;
  96098. /**
  96099. * Observable event triggered each time the rendering canvas is resized
  96100. */
  96101. onResizeObservable: Observable<Engine>;
  96102. /**
  96103. * Observable event triggered each time the canvas loses focus
  96104. */
  96105. onCanvasBlurObservable: Observable<Engine>;
  96106. /**
  96107. * Observable event triggered each time the canvas gains focus
  96108. */
  96109. onCanvasFocusObservable: Observable<Engine>;
  96110. /**
  96111. * Observable event triggered each time the canvas receives pointerout event
  96112. */
  96113. onCanvasPointerOutObservable: Observable<PointerEvent>;
  96114. /**
  96115. * Observable event triggered before each texture is initialized
  96116. */
  96117. onBeforeTextureInitObservable: Observable<Texture>;
  96118. /**
  96119. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96120. */
  96121. disableUniformBuffers: boolean;
  96122. /** @hidden */
  96123. _uniformBuffers: UniformBuffer[];
  96124. /**
  96125. * Gets a boolean indicating that the engine supports uniform buffers
  96126. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96127. */
  96128. readonly supportsUniformBuffers: boolean;
  96129. /**
  96130. * Observable raised when the engine begins a new frame
  96131. */
  96132. onBeginFrameObservable: Observable<Engine>;
  96133. /**
  96134. * If set, will be used to request the next animation frame for the render loop
  96135. */
  96136. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  96137. /**
  96138. * Observable raised when the engine ends the current frame
  96139. */
  96140. onEndFrameObservable: Observable<Engine>;
  96141. /**
  96142. * Observable raised when the engine is about to compile a shader
  96143. */
  96144. onBeforeShaderCompilationObservable: Observable<Engine>;
  96145. /**
  96146. * Observable raised when the engine has jsut compiled a shader
  96147. */
  96148. onAfterShaderCompilationObservable: Observable<Engine>;
  96149. /** @hidden */
  96150. _gl: WebGLRenderingContext;
  96151. private _renderingCanvas;
  96152. private _windowIsBackground;
  96153. protected _webGLVersion: number;
  96154. protected _highPrecisionShadersAllowed: boolean;
  96155. /** @hidden */
  96156. readonly _shouldUseHighPrecisionShader: boolean;
  96157. /**
  96158. * Gets a boolean indicating that only power of 2 textures are supported
  96159. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96160. */
  96161. readonly needPOTTextures: boolean;
  96162. /** @hidden */
  96163. _badOS: boolean;
  96164. /** @hidden */
  96165. _badDesktopOS: boolean;
  96166. /**
  96167. * Gets the audio engine
  96168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96169. * @ignorenaming
  96170. */
  96171. static audioEngine: IAudioEngine;
  96172. /**
  96173. * Default AudioEngine factory responsible of creating the Audio Engine.
  96174. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96175. */
  96176. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96177. /**
  96178. * Default offline support factory responsible of creating a tool used to store data locally.
  96179. * By default, this will create a Database object if the workload has been embedded.
  96180. */
  96181. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96182. private _onFocus;
  96183. private _onBlur;
  96184. private _onCanvasPointerOut;
  96185. private _onCanvasBlur;
  96186. private _onCanvasFocus;
  96187. private _onFullscreenChange;
  96188. private _onPointerLockChange;
  96189. private _hardwareScalingLevel;
  96190. /** @hidden */
  96191. _caps: EngineCapabilities;
  96192. private _pointerLockRequested;
  96193. private _isStencilEnable;
  96194. protected _colorWrite: boolean;
  96195. private _loadingScreen;
  96196. /** @hidden */
  96197. _drawCalls: PerfCounter;
  96198. private _glVersion;
  96199. private _glRenderer;
  96200. private _glVendor;
  96201. private _videoTextureSupported;
  96202. private _renderingQueueLaunched;
  96203. private _activeRenderLoops;
  96204. private _deterministicLockstep;
  96205. private _lockstepMaxSteps;
  96206. /**
  96207. * Observable signaled when a context lost event is raised
  96208. */
  96209. onContextLostObservable: Observable<Engine>;
  96210. /**
  96211. * Observable signaled when a context restored event is raised
  96212. */
  96213. onContextRestoredObservable: Observable<Engine>;
  96214. private _onContextLost;
  96215. private _onContextRestored;
  96216. private _contextWasLost;
  96217. /** @hidden */
  96218. _doNotHandleContextLost: boolean;
  96219. /**
  96220. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96221. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96222. */
  96223. doNotHandleContextLost: boolean;
  96224. private _performanceMonitor;
  96225. private _fps;
  96226. private _deltaTime;
  96227. /**
  96228. * Turn this value on if you want to pause FPS computation when in background
  96229. */
  96230. disablePerformanceMonitorInBackground: boolean;
  96231. /**
  96232. * Gets the performance monitor attached to this engine
  96233. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96234. */
  96235. readonly performanceMonitor: PerformanceMonitor;
  96236. /**
  96237. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96238. */
  96239. disableVertexArrayObjects: boolean;
  96240. /** @hidden */
  96241. protected _depthCullingState: _DepthCullingState;
  96242. /** @hidden */
  96243. protected _stencilState: _StencilState;
  96244. /** @hidden */
  96245. protected _alphaState: _AlphaState;
  96246. /** @hidden */
  96247. protected _alphaMode: number;
  96248. /** @hidden */
  96249. protected _alphaEquation: number;
  96250. /** @hidden */
  96251. _internalTexturesCache: InternalTexture[];
  96252. /** @hidden */
  96253. protected _activeChannel: number;
  96254. private _currentTextureChannel;
  96255. /** @hidden */
  96256. protected _boundTexturesCache: {
  96257. [key: string]: Nullable<InternalTexture>;
  96258. };
  96259. /** @hidden */
  96260. protected _currentEffect: Nullable<Effect>;
  96261. /** @hidden */
  96262. protected _currentProgram: Nullable<WebGLProgram>;
  96263. private _compiledEffects;
  96264. private _vertexAttribArraysEnabled;
  96265. /** @hidden */
  96266. protected _cachedViewport: Nullable<IViewportLike>;
  96267. private _cachedVertexArrayObject;
  96268. /** @hidden */
  96269. protected _cachedVertexBuffers: any;
  96270. /** @hidden */
  96271. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96272. /** @hidden */
  96273. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96274. /** @hidden */
  96275. _currentRenderTarget: Nullable<InternalTexture>;
  96276. private _uintIndicesCurrentlySet;
  96277. private _currentBoundBuffer;
  96278. /** @hidden */
  96279. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96280. private _currentBufferPointers;
  96281. private _currentInstanceLocations;
  96282. private _currentInstanceBuffers;
  96283. private _textureUnits;
  96284. /** @hidden */
  96285. _workingCanvas: Nullable<HTMLCanvasElement>;
  96286. /** @hidden */
  96287. _workingContext: Nullable<CanvasRenderingContext2D>;
  96288. private _rescalePostProcess;
  96289. private _dummyFramebuffer;
  96290. private _externalData;
  96291. /** @hidden */
  96292. _bindedRenderFunction: any;
  96293. private _vaoRecordInProgress;
  96294. private _mustWipeVertexAttributes;
  96295. private _emptyTexture;
  96296. private _emptyCubeTexture;
  96297. private _emptyTexture3D;
  96298. /** @hidden */
  96299. _frameHandler: number;
  96300. private _nextFreeTextureSlots;
  96301. private _maxSimultaneousTextures;
  96302. private _activeRequests;
  96303. private _texturesSupported;
  96304. /** @hidden */
  96305. _textureFormatInUse: Nullable<string>;
  96306. /**
  96307. * Gets the list of texture formats supported
  96308. */
  96309. readonly texturesSupported: Array<string>;
  96310. /**
  96311. * Gets the list of texture formats in use
  96312. */
  96313. readonly textureFormatInUse: Nullable<string>;
  96314. /**
  96315. * Gets the current viewport
  96316. */
  96317. readonly currentViewport: Nullable<IViewportLike>;
  96318. /**
  96319. * Gets the default empty texture
  96320. */
  96321. readonly emptyTexture: InternalTexture;
  96322. /**
  96323. * Gets the default empty 3D texture
  96324. */
  96325. readonly emptyTexture3D: InternalTexture;
  96326. /**
  96327. * Gets the default empty cube texture
  96328. */
  96329. readonly emptyCubeTexture: InternalTexture;
  96330. /**
  96331. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96332. */
  96333. readonly premultipliedAlpha: boolean;
  96334. /**
  96335. * Creates a new engine
  96336. * @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
  96337. * @param antialias defines enable antialiasing (default: false)
  96338. * @param options defines further options to be sent to the getContext() function
  96339. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96340. */
  96341. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96342. /**
  96343. * Initializes a webVR display and starts listening to display change events
  96344. * The onVRDisplayChangedObservable will be notified upon these changes
  96345. * @returns The onVRDisplayChangedObservable
  96346. */
  96347. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96348. /** @hidden */
  96349. _prepareVRComponent(): void;
  96350. /** @hidden */
  96351. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96352. /** @hidden */
  96353. _submitVRFrame(): void;
  96354. /**
  96355. * Call this function to leave webVR mode
  96356. * Will do nothing if webVR is not supported or if there is no webVR device
  96357. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96358. */
  96359. disableVR(): void;
  96360. /**
  96361. * Gets a boolean indicating that the system is in VR mode and is presenting
  96362. * @returns true if VR mode is engaged
  96363. */
  96364. isVRPresenting(): boolean;
  96365. /** @hidden */
  96366. _requestVRFrame(): void;
  96367. private _disableTouchAction;
  96368. private _rebuildInternalTextures;
  96369. private _rebuildEffects;
  96370. /**
  96371. * Gets a boolean indicating if all created effects are ready
  96372. * @returns true if all effects are ready
  96373. */
  96374. areAllEffectsReady(): boolean;
  96375. private _rebuildBuffers;
  96376. private _initGLContext;
  96377. /**
  96378. * Gets version of the current webGL context
  96379. */
  96380. readonly webGLVersion: number;
  96381. /**
  96382. * Gets a string idenfifying the name of the class
  96383. * @returns "Engine" string
  96384. */
  96385. getClassName(): string;
  96386. /**
  96387. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96388. */
  96389. readonly isStencilEnable: boolean;
  96390. /** @hidden */
  96391. _prepareWorkingCanvas(): void;
  96392. /**
  96393. * Reset the texture cache to empty state
  96394. */
  96395. resetTextureCache(): void;
  96396. /**
  96397. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96398. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96399. * @returns true if engine is in deterministic lock step mode
  96400. */
  96401. isDeterministicLockStep(): boolean;
  96402. /**
  96403. * Gets the max steps when engine is running in deterministic lock step
  96404. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96405. * @returns the max steps
  96406. */
  96407. getLockstepMaxSteps(): number;
  96408. /**
  96409. * Gets an object containing information about the current webGL context
  96410. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96411. */
  96412. getGlInfo(): {
  96413. vendor: string;
  96414. renderer: string;
  96415. version: string;
  96416. };
  96417. /**
  96418. * Gets current aspect ratio
  96419. * @param viewportOwner defines the camera to use to get the aspect ratio
  96420. * @param useScreen defines if screen size must be used (or the current render target if any)
  96421. * @returns a number defining the aspect ratio
  96422. */
  96423. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96424. /**
  96425. * Gets current screen aspect ratio
  96426. * @returns a number defining the aspect ratio
  96427. */
  96428. getScreenAspectRatio(): number;
  96429. /**
  96430. * Gets the current render width
  96431. * @param useScreen defines if screen size must be used (or the current render target if any)
  96432. * @returns a number defining the current render width
  96433. */
  96434. getRenderWidth(useScreen?: boolean): number;
  96435. /**
  96436. * Gets the current render height
  96437. * @param useScreen defines if screen size must be used (or the current render target if any)
  96438. * @returns a number defining the current render height
  96439. */
  96440. getRenderHeight(useScreen?: boolean): number;
  96441. /**
  96442. * Gets the HTML canvas attached with the current webGL context
  96443. * @returns a HTML canvas
  96444. */
  96445. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96446. /**
  96447. * Gets host window
  96448. * @returns the host window object
  96449. */
  96450. getHostWindow(): Window;
  96451. /**
  96452. * Gets host document
  96453. * @returns the host document object
  96454. */
  96455. getHostDocument(): Document;
  96456. /**
  96457. * Gets the client rect of the HTML canvas attached with the current webGL context
  96458. * @returns a client rectanglee
  96459. */
  96460. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96461. /**
  96462. * Defines the hardware scaling level.
  96463. * By default the hardware scaling level is computed from the window device ratio.
  96464. * 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.
  96465. * @param level defines the level to use
  96466. */
  96467. setHardwareScalingLevel(level: number): void;
  96468. /**
  96469. * Gets the current hardware scaling level.
  96470. * By default the hardware scaling level is computed from the window device ratio.
  96471. * 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.
  96472. * @returns a number indicating the current hardware scaling level
  96473. */
  96474. getHardwareScalingLevel(): number;
  96475. /**
  96476. * Gets the list of loaded textures
  96477. * @returns an array containing all loaded textures
  96478. */
  96479. getLoadedTexturesCache(): InternalTexture[];
  96480. /**
  96481. * Gets the object containing all engine capabilities
  96482. * @returns the EngineCapabilities object
  96483. */
  96484. getCaps(): EngineCapabilities;
  96485. /**
  96486. * Gets the current depth function
  96487. * @returns a number defining the depth function
  96488. */
  96489. getDepthFunction(): Nullable<number>;
  96490. /**
  96491. * Sets the current depth function
  96492. * @param depthFunc defines the function to use
  96493. */
  96494. setDepthFunction(depthFunc: number): void;
  96495. /**
  96496. * Sets the current depth function to GREATER
  96497. */
  96498. setDepthFunctionToGreater(): void;
  96499. /**
  96500. * Sets the current depth function to GEQUAL
  96501. */
  96502. setDepthFunctionToGreaterOrEqual(): void;
  96503. /**
  96504. * Sets the current depth function to LESS
  96505. */
  96506. setDepthFunctionToLess(): void;
  96507. private _cachedStencilBuffer;
  96508. private _cachedStencilFunction;
  96509. private _cachedStencilMask;
  96510. private _cachedStencilOperationPass;
  96511. private _cachedStencilOperationFail;
  96512. private _cachedStencilOperationDepthFail;
  96513. private _cachedStencilReference;
  96514. /**
  96515. * Caches the the state of the stencil buffer
  96516. */
  96517. cacheStencilState(): void;
  96518. /**
  96519. * Restores the state of the stencil buffer
  96520. */
  96521. restoreStencilState(): void;
  96522. /**
  96523. * Sets the current depth function to LEQUAL
  96524. */
  96525. setDepthFunctionToLessOrEqual(): void;
  96526. /**
  96527. * Gets a boolean indicating if stencil buffer is enabled
  96528. * @returns the current stencil buffer state
  96529. */
  96530. getStencilBuffer(): boolean;
  96531. /**
  96532. * Enable or disable the stencil buffer
  96533. * @param enable defines if the stencil buffer must be enabled or disabled
  96534. */
  96535. setStencilBuffer(enable: boolean): void;
  96536. /**
  96537. * Gets the current stencil mask
  96538. * @returns a number defining the new stencil mask to use
  96539. */
  96540. getStencilMask(): number;
  96541. /**
  96542. * Sets the current stencil mask
  96543. * @param mask defines the new stencil mask to use
  96544. */
  96545. setStencilMask(mask: number): void;
  96546. /**
  96547. * Gets the current stencil function
  96548. * @returns a number defining the stencil function to use
  96549. */
  96550. getStencilFunction(): number;
  96551. /**
  96552. * Gets the current stencil reference value
  96553. * @returns a number defining the stencil reference value to use
  96554. */
  96555. getStencilFunctionReference(): number;
  96556. /**
  96557. * Gets the current stencil mask
  96558. * @returns a number defining the stencil mask to use
  96559. */
  96560. getStencilFunctionMask(): number;
  96561. /**
  96562. * Sets the current stencil function
  96563. * @param stencilFunc defines the new stencil function to use
  96564. */
  96565. setStencilFunction(stencilFunc: number): void;
  96566. /**
  96567. * Sets the current stencil reference
  96568. * @param reference defines the new stencil reference to use
  96569. */
  96570. setStencilFunctionReference(reference: number): void;
  96571. /**
  96572. * Sets the current stencil mask
  96573. * @param mask defines the new stencil mask to use
  96574. */
  96575. setStencilFunctionMask(mask: number): void;
  96576. /**
  96577. * Gets the current stencil operation when stencil fails
  96578. * @returns a number defining stencil operation to use when stencil fails
  96579. */
  96580. getStencilOperationFail(): number;
  96581. /**
  96582. * Gets the current stencil operation when depth fails
  96583. * @returns a number defining stencil operation to use when depth fails
  96584. */
  96585. getStencilOperationDepthFail(): number;
  96586. /**
  96587. * Gets the current stencil operation when stencil passes
  96588. * @returns a number defining stencil operation to use when stencil passes
  96589. */
  96590. getStencilOperationPass(): number;
  96591. /**
  96592. * Sets the stencil operation to use when stencil fails
  96593. * @param operation defines the stencil operation to use when stencil fails
  96594. */
  96595. setStencilOperationFail(operation: number): void;
  96596. /**
  96597. * Sets the stencil operation to use when depth fails
  96598. * @param operation defines the stencil operation to use when depth fails
  96599. */
  96600. setStencilOperationDepthFail(operation: number): void;
  96601. /**
  96602. * Sets the stencil operation to use when stencil passes
  96603. * @param operation defines the stencil operation to use when stencil passes
  96604. */
  96605. setStencilOperationPass(operation: number): void;
  96606. /**
  96607. * Sets a boolean indicating if the dithering state is enabled or disabled
  96608. * @param value defines the dithering state
  96609. */
  96610. setDitheringState(value: boolean): void;
  96611. /**
  96612. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96613. * @param value defines the rasterizer state
  96614. */
  96615. setRasterizerState(value: boolean): void;
  96616. /**
  96617. * stop executing a render loop function and remove it from the execution array
  96618. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96619. */
  96620. stopRenderLoop(renderFunction?: () => void): void;
  96621. /** @hidden */
  96622. _renderLoop(): void;
  96623. /**
  96624. * Can be used to override the current requestAnimationFrame requester.
  96625. * @hidden
  96626. */
  96627. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96628. /**
  96629. * Register and execute a render loop. The engine can have more than one render function
  96630. * @param renderFunction defines the function to continuously execute
  96631. */
  96632. runRenderLoop(renderFunction: () => void): void;
  96633. /**
  96634. * Toggle full screen mode
  96635. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96636. */
  96637. switchFullscreen(requestPointerLock: boolean): void;
  96638. /**
  96639. * Enters full screen mode
  96640. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96641. */
  96642. enterFullscreen(requestPointerLock: boolean): void;
  96643. /**
  96644. * Exits full screen mode
  96645. */
  96646. exitFullscreen(): void;
  96647. /**
  96648. * Enters Pointerlock mode
  96649. */
  96650. enterPointerlock(): void;
  96651. /**
  96652. * Exits Pointerlock mode
  96653. */
  96654. exitPointerlock(): void;
  96655. /**
  96656. * Clear the current render buffer or the current render target (if any is set up)
  96657. * @param color defines the color to use
  96658. * @param backBuffer defines if the back buffer must be cleared
  96659. * @param depth defines if the depth buffer must be cleared
  96660. * @param stencil defines if the stencil buffer must be cleared
  96661. */
  96662. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96663. /**
  96664. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96665. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96666. * @param y defines the y-coordinate of the corner of the clear rectangle
  96667. * @param width defines the width of the clear rectangle
  96668. * @param height defines the height of the clear rectangle
  96669. * @param clearColor defines the clear color
  96670. */
  96671. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96672. /**
  96673. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96674. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96675. * @param y defines the y-coordinate of the corner of the clear rectangle
  96676. * @param width defines the width of the clear rectangle
  96677. * @param height defines the height of the clear rectangle
  96678. */
  96679. enableScissor(x: number, y: number, width: number, height: number): void;
  96680. /**
  96681. * Disable previously set scissor test rectangle
  96682. */
  96683. disableScissor(): void;
  96684. private _viewportCached;
  96685. /** @hidden */
  96686. _viewport(x: number, y: number, width: number, height: number): void;
  96687. /**
  96688. * Set the WebGL's viewport
  96689. * @param viewport defines the viewport element to be used
  96690. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96691. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96692. */
  96693. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96694. /**
  96695. * Directly set the WebGL Viewport
  96696. * @param x defines the x coordinate of the viewport (in screen space)
  96697. * @param y defines the y coordinate of the viewport (in screen space)
  96698. * @param width defines the width of the viewport (in screen space)
  96699. * @param height defines the height of the viewport (in screen space)
  96700. * @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
  96701. */
  96702. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96703. /**
  96704. * Begin a new frame
  96705. */
  96706. beginFrame(): void;
  96707. /**
  96708. * Enf the current frame
  96709. */
  96710. endFrame(): void;
  96711. /**
  96712. * Resize the view according to the canvas' size
  96713. */
  96714. resize(): void;
  96715. /**
  96716. * Force a specific size of the canvas
  96717. * @param width defines the new canvas' width
  96718. * @param height defines the new canvas' height
  96719. */
  96720. setSize(width: number, height: number): void;
  96721. /**
  96722. * Binds the frame buffer to the specified texture.
  96723. * @param texture The texture to render to or null for the default canvas
  96724. * @param faceIndex The face of the texture to render to in case of cube texture
  96725. * @param requiredWidth The width of the target to render to
  96726. * @param requiredHeight The height of the target to render to
  96727. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96728. * @param depthStencilTexture The depth stencil texture to use to render
  96729. * @param lodLevel defines le lod level to bind to the frame buffer
  96730. */
  96731. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96732. /** @hidden */
  96733. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96734. /**
  96735. * Unbind the current render target texture from the webGL context
  96736. * @param texture defines the render target texture to unbind
  96737. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96738. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96739. */
  96740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96741. /**
  96742. * Force the mipmap generation for the given render target texture
  96743. * @param texture defines the render target texture to use
  96744. */
  96745. generateMipMapsForCubemap(texture: InternalTexture): void;
  96746. /**
  96747. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96748. */
  96749. flushFramebuffer(): void;
  96750. /**
  96751. * Unbind the current render target and bind the default framebuffer
  96752. */
  96753. restoreDefaultFramebuffer(): void;
  96754. /**
  96755. * Create an uniform buffer
  96756. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96757. * @param elements defines the content of the uniform buffer
  96758. * @returns the webGL uniform buffer
  96759. */
  96760. createUniformBuffer(elements: FloatArray): DataBuffer;
  96761. /**
  96762. * Create a dynamic uniform buffer
  96763. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96764. * @param elements defines the content of the uniform buffer
  96765. * @returns the webGL uniform buffer
  96766. */
  96767. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96768. /**
  96769. * Update an existing uniform buffer
  96770. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96771. * @param uniformBuffer defines the target uniform buffer
  96772. * @param elements defines the content to update
  96773. * @param offset defines the offset in the uniform buffer where update should start
  96774. * @param count defines the size of the data to update
  96775. */
  96776. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96777. private _resetVertexBufferBinding;
  96778. /**
  96779. * Creates a vertex buffer
  96780. * @param data the data for the vertex buffer
  96781. * @returns the new WebGL static buffer
  96782. */
  96783. createVertexBuffer(data: DataArray): DataBuffer;
  96784. /**
  96785. * Creates a dynamic vertex buffer
  96786. * @param data the data for the dynamic vertex buffer
  96787. * @returns the new WebGL dynamic buffer
  96788. */
  96789. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96790. /**
  96791. * Update a dynamic index buffer
  96792. * @param indexBuffer defines the target index buffer
  96793. * @param indices defines the data to update
  96794. * @param offset defines the offset in the target index buffer where update should start
  96795. */
  96796. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96797. /**
  96798. * Updates a dynamic vertex buffer.
  96799. * @param vertexBuffer the vertex buffer to update
  96800. * @param data the data used to update the vertex buffer
  96801. * @param byteOffset the byte offset of the data
  96802. * @param byteLength the byte length of the data
  96803. */
  96804. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96805. private _resetIndexBufferBinding;
  96806. /**
  96807. * Creates a new index buffer
  96808. * @param indices defines the content of the index buffer
  96809. * @param updatable defines if the index buffer must be updatable
  96810. * @returns a new webGL buffer
  96811. */
  96812. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96813. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96814. /**
  96815. * Bind a webGL buffer to the webGL context
  96816. * @param buffer defines the buffer to bind
  96817. */
  96818. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96819. /**
  96820. * Bind an uniform buffer to the current webGL context
  96821. * @param buffer defines the buffer to bind
  96822. */
  96823. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96824. /**
  96825. * Bind a buffer to the current webGL context at a given location
  96826. * @param buffer defines the buffer to bind
  96827. * @param location defines the index where to bind the buffer
  96828. */
  96829. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96830. /**
  96831. * Bind a specific block at a given index in a specific shader program
  96832. * @param pipelineContext defines the pipeline context to use
  96833. * @param blockName defines the block name
  96834. * @param index defines the index where to bind the block
  96835. */
  96836. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96837. private bindIndexBuffer;
  96838. private bindBuffer;
  96839. /**
  96840. * update the bound buffer with the given data
  96841. * @param data defines the data to update
  96842. */
  96843. updateArrayBuffer(data: Float32Array): void;
  96844. private _vertexAttribPointer;
  96845. private _bindIndexBufferWithCache;
  96846. private _bindVertexBuffersAttributes;
  96847. /**
  96848. * Records a vertex array object
  96849. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96850. * @param vertexBuffers defines the list of vertex buffers to store
  96851. * @param indexBuffer defines the index buffer to store
  96852. * @param effect defines the effect to store
  96853. * @returns the new vertex array object
  96854. */
  96855. recordVertexArrayObject(vertexBuffers: {
  96856. [key: string]: VertexBuffer;
  96857. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96858. /**
  96859. * Bind a specific vertex array object
  96860. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96861. * @param vertexArrayObject defines the vertex array object to bind
  96862. * @param indexBuffer defines the index buffer to bind
  96863. */
  96864. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96865. /**
  96866. * Bind webGl buffers directly to the webGL context
  96867. * @param vertexBuffer defines the vertex buffer to bind
  96868. * @param indexBuffer defines the index buffer to bind
  96869. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96870. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96871. * @param effect defines the effect associated with the vertex buffer
  96872. */
  96873. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96874. private _unbindVertexArrayObject;
  96875. /**
  96876. * Bind a list of vertex buffers to the webGL context
  96877. * @param vertexBuffers defines the list of vertex buffers to bind
  96878. * @param indexBuffer defines the index buffer to bind
  96879. * @param effect defines the effect associated with the vertex buffers
  96880. */
  96881. bindBuffers(vertexBuffers: {
  96882. [key: string]: Nullable<VertexBuffer>;
  96883. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96884. /**
  96885. * Unbind all instance attributes
  96886. */
  96887. unbindInstanceAttributes(): void;
  96888. /**
  96889. * Release and free the memory of a vertex array object
  96890. * @param vao defines the vertex array object to delete
  96891. */
  96892. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96893. /** @hidden */
  96894. _releaseBuffer(buffer: DataBuffer): boolean;
  96895. protected _deleteBuffer(buffer: DataBuffer): void;
  96896. /**
  96897. * Creates a webGL buffer to use with instanciation
  96898. * @param capacity defines the size of the buffer
  96899. * @returns the webGL buffer
  96900. */
  96901. createInstancesBuffer(capacity: number): DataBuffer;
  96902. /**
  96903. * Delete a webGL buffer used with instanciation
  96904. * @param buffer defines the webGL buffer to delete
  96905. */
  96906. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96907. /**
  96908. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96909. * @param instancesBuffer defines the webGL buffer to update and bind
  96910. * @param data defines the data to store in the buffer
  96911. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96912. */
  96913. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96914. /**
  96915. * Apply all cached states (depth, culling, stencil and alpha)
  96916. */
  96917. applyStates(): void;
  96918. /**
  96919. * Send a draw order
  96920. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96921. * @param indexStart defines the starting index
  96922. * @param indexCount defines the number of index to draw
  96923. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96924. */
  96925. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96926. /**
  96927. * Draw a list of points
  96928. * @param verticesStart defines the index of first vertex to draw
  96929. * @param verticesCount defines the count of vertices to draw
  96930. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96931. */
  96932. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96933. /**
  96934. * Draw a list of unindexed primitives
  96935. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96936. * @param verticesStart defines the index of first vertex to draw
  96937. * @param verticesCount defines the count of vertices to draw
  96938. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96939. */
  96940. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96941. /**
  96942. * Draw a list of indexed primitives
  96943. * @param fillMode defines the primitive to use
  96944. * @param indexStart defines the starting index
  96945. * @param indexCount defines the number of index to draw
  96946. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96947. */
  96948. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96949. /**
  96950. * Draw a list of unindexed primitives
  96951. * @param fillMode defines the primitive to use
  96952. * @param verticesStart defines the index of first vertex to draw
  96953. * @param verticesCount defines the count of vertices to draw
  96954. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96955. */
  96956. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96957. private _drawMode;
  96958. /** @hidden */
  96959. _releaseEffect(effect: Effect): void;
  96960. /** @hidden */
  96961. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96962. /**
  96963. * Create a new effect (used to store vertex/fragment shaders)
  96964. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96965. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96966. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96967. * @param samplers defines an array of string used to represent textures
  96968. * @param defines defines the string containing the defines to use to compile the shaders
  96969. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96970. * @param onCompiled defines a function to call when the effect creation is successful
  96971. * @param onError defines a function to call when the effect creation has failed
  96972. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96973. * @returns the new Effect
  96974. */
  96975. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96976. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96977. private _compileShader;
  96978. private _compileRawShader;
  96979. /**
  96980. * Directly creates a webGL program
  96981. * @param pipelineContext defines the pipeline context to attach to
  96982. * @param vertexCode defines the vertex shader code to use
  96983. * @param fragmentCode defines the fragment shader code to use
  96984. * @param context defines the webGL context to use (if not set, the current one will be used)
  96985. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96986. * @returns the new webGL program
  96987. */
  96988. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96989. /**
  96990. * Creates a webGL program
  96991. * @param pipelineContext defines the pipeline context to attach to
  96992. * @param vertexCode defines the vertex shader code to use
  96993. * @param fragmentCode defines the fragment shader code to use
  96994. * @param defines defines the string containing the defines to use to compile the shaders
  96995. * @param context defines the webGL context to use (if not set, the current one will be used)
  96996. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96997. * @returns the new webGL program
  96998. */
  96999. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97000. /**
  97001. * Creates a new pipeline context
  97002. * @returns the new pipeline
  97003. */
  97004. createPipelineContext(): IPipelineContext;
  97005. private _createShaderProgram;
  97006. private _finalizePipelineContext;
  97007. /** @hidden */
  97008. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97009. /** @hidden */
  97010. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97011. /** @hidden */
  97012. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97013. /**
  97014. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97015. * @param pipelineContext defines the pipeline context to use
  97016. * @param uniformsNames defines the list of uniform names
  97017. * @returns an array of webGL uniform locations
  97018. */
  97019. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97020. /**
  97021. * Gets the lsit of active attributes for a given webGL program
  97022. * @param pipelineContext defines the pipeline context to use
  97023. * @param attributesNames defines the list of attribute names to get
  97024. * @returns an array of indices indicating the offset of each attribute
  97025. */
  97026. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97027. /**
  97028. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97029. * @param effect defines the effect to activate
  97030. */
  97031. enableEffect(effect: Nullable<Effect>): void;
  97032. /**
  97033. * Set the value of an uniform to an array of int32
  97034. * @param uniform defines the webGL uniform location where to store the value
  97035. * @param array defines the array of int32 to store
  97036. */
  97037. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97038. /**
  97039. * Set the value of an uniform to an array of int32 (stored as vec2)
  97040. * @param uniform defines the webGL uniform location where to store the value
  97041. * @param array defines the array of int32 to store
  97042. */
  97043. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97044. /**
  97045. * Set the value of an uniform to an array of int32 (stored as vec3)
  97046. * @param uniform defines the webGL uniform location where to store the value
  97047. * @param array defines the array of int32 to store
  97048. */
  97049. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97050. /**
  97051. * Set the value of an uniform to an array of int32 (stored as vec4)
  97052. * @param uniform defines the webGL uniform location where to store the value
  97053. * @param array defines the array of int32 to store
  97054. */
  97055. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97056. /**
  97057. * Set the value of an uniform to an array of float32
  97058. * @param uniform defines the webGL uniform location where to store the value
  97059. * @param array defines the array of float32 to store
  97060. */
  97061. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97062. /**
  97063. * Set the value of an uniform to an array of float32 (stored as vec2)
  97064. * @param uniform defines the webGL uniform location where to store the value
  97065. * @param array defines the array of float32 to store
  97066. */
  97067. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97068. /**
  97069. * Set the value of an uniform to an array of float32 (stored as vec3)
  97070. * @param uniform defines the webGL uniform location where to store the value
  97071. * @param array defines the array of float32 to store
  97072. */
  97073. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97074. /**
  97075. * Set the value of an uniform to an array of float32 (stored as vec4)
  97076. * @param uniform defines the webGL uniform location where to store the value
  97077. * @param array defines the array of float32 to store
  97078. */
  97079. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97080. /**
  97081. * Set the value of an uniform to an array of number
  97082. * @param uniform defines the webGL uniform location where to store the value
  97083. * @param array defines the array of number to store
  97084. */
  97085. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97086. /**
  97087. * Set the value of an uniform to an array of number (stored as vec2)
  97088. * @param uniform defines the webGL uniform location where to store the value
  97089. * @param array defines the array of number to store
  97090. */
  97091. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97092. /**
  97093. * Set the value of an uniform to an array of number (stored as vec3)
  97094. * @param uniform defines the webGL uniform location where to store the value
  97095. * @param array defines the array of number to store
  97096. */
  97097. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97098. /**
  97099. * Set the value of an uniform to an array of number (stored as vec4)
  97100. * @param uniform defines the webGL uniform location where to store the value
  97101. * @param array defines the array of number to store
  97102. */
  97103. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97104. /**
  97105. * Set the value of an uniform to an array of float32 (stored as matrices)
  97106. * @param uniform defines the webGL uniform location where to store the value
  97107. * @param matrices defines the array of float32 to store
  97108. */
  97109. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97110. /**
  97111. * Set the value of an uniform to a matrix (3x3)
  97112. * @param uniform defines the webGL uniform location where to store the value
  97113. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97114. */
  97115. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97116. /**
  97117. * Set the value of an uniform to a matrix (2x2)
  97118. * @param uniform defines the webGL uniform location where to store the value
  97119. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97120. */
  97121. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97122. /**
  97123. * Set the value of an uniform to a number (int)
  97124. * @param uniform defines the webGL uniform location where to store the value
  97125. * @param value defines the int number to store
  97126. */
  97127. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97128. /**
  97129. * Set the value of an uniform to a number (float)
  97130. * @param uniform defines the webGL uniform location where to store the value
  97131. * @param value defines the float number to store
  97132. */
  97133. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97134. /**
  97135. * Set the value of an uniform to a vec2
  97136. * @param uniform defines the webGL uniform location where to store the value
  97137. * @param x defines the 1st component of the value
  97138. * @param y defines the 2nd component of the value
  97139. */
  97140. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97141. /**
  97142. * Set the value of an uniform to a vec3
  97143. * @param uniform defines the webGL uniform location where to store the value
  97144. * @param x defines the 1st component of the value
  97145. * @param y defines the 2nd component of the value
  97146. * @param z defines the 3rd component of the value
  97147. */
  97148. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97149. /**
  97150. * Set the value of an uniform to a boolean
  97151. * @param uniform defines the webGL uniform location where to store the value
  97152. * @param bool defines the boolean to store
  97153. */
  97154. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97155. /**
  97156. * Set the value of an uniform to a vec4
  97157. * @param uniform defines the webGL uniform location where to store the value
  97158. * @param x defines the 1st component of the value
  97159. * @param y defines the 2nd component of the value
  97160. * @param z defines the 3rd component of the value
  97161. * @param w defines the 4th component of the value
  97162. */
  97163. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97164. /**
  97165. * Sets a Color4 on a uniform variable
  97166. * @param uniform defines the uniform location
  97167. * @param color4 defines the value to be set
  97168. */
  97169. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97170. /**
  97171. * Set various states to the webGL context
  97172. * @param culling defines backface culling state
  97173. * @param zOffset defines the value to apply to zOffset (0 by default)
  97174. * @param force defines if states must be applied even if cache is up to date
  97175. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97176. */
  97177. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97178. /**
  97179. * Set the z offset to apply to current rendering
  97180. * @param value defines the offset to apply
  97181. */
  97182. setZOffset(value: number): void;
  97183. /**
  97184. * Gets the current value of the zOffset
  97185. * @returns the current zOffset state
  97186. */
  97187. getZOffset(): number;
  97188. /**
  97189. * Enable or disable depth buffering
  97190. * @param enable defines the state to set
  97191. */
  97192. setDepthBuffer(enable: boolean): void;
  97193. /**
  97194. * Gets a boolean indicating if depth writing is enabled
  97195. * @returns the current depth writing state
  97196. */
  97197. getDepthWrite(): boolean;
  97198. /**
  97199. * Enable or disable depth writing
  97200. * @param enable defines the state to set
  97201. */
  97202. setDepthWrite(enable: boolean): void;
  97203. /**
  97204. * Enable or disable color writing
  97205. * @param enable defines the state to set
  97206. */
  97207. setColorWrite(enable: boolean): void;
  97208. /**
  97209. * Gets a boolean indicating if color writing is enabled
  97210. * @returns the current color writing state
  97211. */
  97212. getColorWrite(): boolean;
  97213. /**
  97214. * Sets alpha constants used by some alpha blending modes
  97215. * @param r defines the red component
  97216. * @param g defines the green component
  97217. * @param b defines the blue component
  97218. * @param a defines the alpha component
  97219. */
  97220. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97221. /**
  97222. * Sets the current alpha mode
  97223. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97224. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97225. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97226. */
  97227. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97228. /**
  97229. * Gets the current alpha mode
  97230. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97231. * @returns the current alpha mode
  97232. */
  97233. getAlphaMode(): number;
  97234. /**
  97235. * Sets the current alpha equation
  97236. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  97237. */
  97238. setAlphaEquation(equation: number): void;
  97239. /**
  97240. * Gets the current alpha equation.
  97241. * @returns the current alpha equation
  97242. */
  97243. getAlphaEquation(): number;
  97244. /**
  97245. * Clears the list of texture accessible through engine.
  97246. * This can help preventing texture load conflict due to name collision.
  97247. */
  97248. clearInternalTexturesCache(): void;
  97249. /**
  97250. * Force the entire cache to be cleared
  97251. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97252. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97253. */
  97254. wipeCaches(bruteForce?: boolean): void;
  97255. /**
  97256. * Set the compressed texture format to use, based on the formats you have, and the formats
  97257. * supported by the hardware / browser.
  97258. *
  97259. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97260. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97261. * to API arguments needed to compressed textures. This puts the burden on the container
  97262. * generator to house the arcane code for determining these for current & future formats.
  97263. *
  97264. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97265. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97266. *
  97267. * Note: The result of this call is not taken into account when a texture is base64.
  97268. *
  97269. * @param formatsAvailable defines the list of those format families you have created
  97270. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97271. *
  97272. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97273. * @returns The extension selected.
  97274. */
  97275. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97276. /** @hidden */
  97277. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97278. min: number;
  97279. mag: number;
  97280. };
  97281. /** @hidden */
  97282. _createTexture(): WebGLTexture;
  97283. /**
  97284. * Usually called from Texture.ts.
  97285. * Passed information to create a WebGLTexture
  97286. * @param urlArg defines a value which contains one of the following:
  97287. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97288. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97289. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97290. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97291. * @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)
  97292. * @param scene needed for loading to the correct scene
  97293. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97294. * @param onLoad optional callback to be called upon successful completion
  97295. * @param onError optional callback to be called upon failure
  97296. * @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
  97297. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97298. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97299. * @param forcedExtension defines the extension to use to pick the right loader
  97300. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97301. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97302. */
  97303. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97304. /**
  97305. * @hidden
  97306. * Rescales a texture
  97307. * @param source input texutre
  97308. * @param destination destination texture
  97309. * @param scene scene to use to render the resize
  97310. * @param internalFormat format to use when resizing
  97311. * @param onComplete callback to be called when resize has completed
  97312. */
  97313. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97314. private _unpackFlipYCached;
  97315. /**
  97316. * In case you are sharing the context with other applications, it might
  97317. * be interested to not cache the unpack flip y state to ensure a consistent
  97318. * value would be set.
  97319. */
  97320. enableUnpackFlipYCached: boolean;
  97321. /** @hidden */
  97322. _unpackFlipY(value: boolean): void;
  97323. /** @hidden */
  97324. _getUnpackAlignement(): number;
  97325. /**
  97326. * Creates a dynamic texture
  97327. * @param width defines the width of the texture
  97328. * @param height defines the height of the texture
  97329. * @param generateMipMaps defines if the engine should generate the mip levels
  97330. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97331. * @returns the dynamic texture inside an InternalTexture
  97332. */
  97333. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97334. /**
  97335. * Update the sampling mode of a given texture
  97336. * @param samplingMode defines the required sampling mode
  97337. * @param texture defines the texture to update
  97338. */
  97339. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97340. /**
  97341. * Update the content of a dynamic texture
  97342. * @param texture defines the texture to update
  97343. * @param canvas defines the canvas containing the source
  97344. * @param invertY defines if data must be stored with Y axis inverted
  97345. * @param premulAlpha defines if alpha is stored as premultiplied
  97346. * @param format defines the format of the data
  97347. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97348. */
  97349. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97350. /**
  97351. * Update a video texture
  97352. * @param texture defines the texture to update
  97353. * @param video defines the video element to use
  97354. * @param invertY defines if data must be stored with Y axis inverted
  97355. */
  97356. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97357. /**
  97358. * Updates a depth texture Comparison Mode and Function.
  97359. * If the comparison Function is equal to 0, the mode will be set to none.
  97360. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97361. * @param texture The texture to set the comparison function for
  97362. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97363. */
  97364. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97365. /** @hidden */
  97366. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97367. width: number;
  97368. height: number;
  97369. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97370. /**
  97371. * Creates a depth stencil texture.
  97372. * This is only available in WebGL 2 or with the depth texture extension available.
  97373. * @param size The size of face edge in the texture.
  97374. * @param options The options defining the texture.
  97375. * @returns The texture
  97376. */
  97377. createDepthStencilTexture(size: number | {
  97378. width: number;
  97379. height: number;
  97380. }, options: DepthTextureCreationOptions): InternalTexture;
  97381. /**
  97382. * Creates a depth stencil texture.
  97383. * This is only available in WebGL 2 or with the depth texture extension available.
  97384. * @param size The size of face edge in the texture.
  97385. * @param options The options defining the texture.
  97386. * @returns The texture
  97387. */
  97388. private _createDepthStencilTexture;
  97389. /**
  97390. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97391. * @param renderTarget The render target to set the frame buffer for
  97392. */
  97393. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97394. /**
  97395. * Creates a new render target texture
  97396. * @param size defines the size of the texture
  97397. * @param options defines the options used to create the texture
  97398. * @returns a new render target texture stored in an InternalTexture
  97399. */
  97400. createRenderTargetTexture(size: number | {
  97401. width: number;
  97402. height: number;
  97403. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97404. /** @hidden */
  97405. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97406. /**
  97407. * Updates the sample count of a render target texture
  97408. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97409. * @param texture defines the texture to update
  97410. * @param samples defines the sample count to set
  97411. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97412. */
  97413. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97414. /** @hidden */
  97415. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97416. /** @hidden */
  97417. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97418. /** @hidden */
  97419. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97420. /** @hidden */
  97421. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97422. /**
  97423. * @hidden
  97424. */
  97425. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97426. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97427. private _prepareWebGLTexture;
  97428. /** @hidden */
  97429. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97430. /** @hidden */
  97431. _releaseFramebufferObjects(texture: InternalTexture): void;
  97432. /** @hidden */
  97433. _releaseTexture(texture: InternalTexture): void;
  97434. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97435. protected _setProgram(program: WebGLProgram): void;
  97436. protected _boundUniforms: {
  97437. [key: number]: WebGLUniformLocation;
  97438. };
  97439. /**
  97440. * Binds an effect to the webGL context
  97441. * @param effect defines the effect to bind
  97442. */
  97443. bindSamplers(effect: Effect): void;
  97444. private _activateCurrentTexture;
  97445. /** @hidden */
  97446. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97447. /** @hidden */
  97448. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97449. /**
  97450. * Sets a texture to the webGL context from a postprocess
  97451. * @param channel defines the channel to use
  97452. * @param postProcess defines the source postprocess
  97453. */
  97454. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97455. /**
  97456. * Binds the output of the passed in post process to the texture channel specified
  97457. * @param channel The channel the texture should be bound to
  97458. * @param postProcess The post process which's output should be bound
  97459. */
  97460. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97461. /**
  97462. * Unbind all textures from the webGL context
  97463. */
  97464. unbindAllTextures(): void;
  97465. /**
  97466. * Sets a texture to the according uniform.
  97467. * @param channel The texture channel
  97468. * @param uniform The uniform to set
  97469. * @param texture The texture to apply
  97470. */
  97471. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97472. /**
  97473. * Sets a depth stencil texture from a render target to the according uniform.
  97474. * @param channel The texture channel
  97475. * @param uniform The uniform to set
  97476. * @param texture The render target texture containing the depth stencil texture to apply
  97477. */
  97478. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97479. private _bindSamplerUniformToChannel;
  97480. private _getTextureWrapMode;
  97481. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97482. /**
  97483. * Sets an array of texture to the webGL context
  97484. * @param channel defines the channel where the texture array must be set
  97485. * @param uniform defines the associated uniform location
  97486. * @param textures defines the array of textures to bind
  97487. */
  97488. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97489. /** @hidden */
  97490. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97491. private _setTextureParameterFloat;
  97492. private _setTextureParameterInteger;
  97493. /**
  97494. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97495. * @param x defines the x coordinate of the rectangle where pixels must be read
  97496. * @param y defines the y coordinate of the rectangle where pixels must be read
  97497. * @param width defines the width of the rectangle where pixels must be read
  97498. * @param height defines the height of the rectangle where pixels must be read
  97499. * @returns a Uint8Array containing RGBA colors
  97500. */
  97501. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97502. /**
  97503. * Add an externaly attached data from its key.
  97504. * This method call will fail and return false, if such key already exists.
  97505. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97506. * @param key the unique key that identifies the data
  97507. * @param data the data object to associate to the key for this Engine instance
  97508. * @return true if no such key were already present and the data was added successfully, false otherwise
  97509. */
  97510. addExternalData<T>(key: string, data: T): boolean;
  97511. /**
  97512. * Get an externaly attached data from its key
  97513. * @param key the unique key that identifies the data
  97514. * @return the associated data, if present (can be null), or undefined if not present
  97515. */
  97516. getExternalData<T>(key: string): T;
  97517. /**
  97518. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97519. * @param key the unique key that identifies the data
  97520. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97521. * @return the associated data, can be null if the factory returned null.
  97522. */
  97523. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97524. /**
  97525. * Remove an externaly attached data from the Engine instance
  97526. * @param key the unique key that identifies the data
  97527. * @return true if the data was successfully removed, false if it doesn't exist
  97528. */
  97529. removeExternalData(key: string): boolean;
  97530. /**
  97531. * Unbind all vertex attributes from the webGL context
  97532. */
  97533. unbindAllAttributes(): void;
  97534. /**
  97535. * 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
  97536. */
  97537. releaseEffects(): void;
  97538. /**
  97539. * Dispose and release all associated resources
  97540. */
  97541. dispose(): void;
  97542. /**
  97543. * Display the loading screen
  97544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97545. */
  97546. displayLoadingUI(): void;
  97547. /**
  97548. * Hide the loading screen
  97549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97550. */
  97551. hideLoadingUI(): void;
  97552. /**
  97553. * Gets the current loading screen object
  97554. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97555. */
  97556. /**
  97557. * Sets the current loading screen object
  97558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97559. */
  97560. loadingScreen: ILoadingScreen;
  97561. /**
  97562. * Sets the current loading screen text
  97563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97564. */
  97565. loadingUIText: string;
  97566. /**
  97567. * Sets the current loading screen background color
  97568. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97569. */
  97570. loadingUIBackgroundColor: string;
  97571. /**
  97572. * Attach a new callback raised when context lost event is fired
  97573. * @param callback defines the callback to call
  97574. */
  97575. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97576. /**
  97577. * Attach a new callback raised when context restored event is fired
  97578. * @param callback defines the callback to call
  97579. */
  97580. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97581. /**
  97582. * Gets the source code of the vertex shader associated with a specific webGL program
  97583. * @param program defines the program to use
  97584. * @returns a string containing the source code of the vertex shader associated with the program
  97585. */
  97586. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97587. /**
  97588. * Gets the source code of the fragment shader associated with a specific webGL program
  97589. * @param program defines the program to use
  97590. * @returns a string containing the source code of the fragment shader associated with the program
  97591. */
  97592. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97593. /**
  97594. * Get the current error code of the webGL context
  97595. * @returns the error code
  97596. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97597. */
  97598. getError(): number;
  97599. /**
  97600. * Gets the current framerate
  97601. * @returns a number representing the framerate
  97602. */
  97603. getFps(): number;
  97604. /**
  97605. * Gets the time spent between current and previous frame
  97606. * @returns a number representing the delta time in ms
  97607. */
  97608. getDeltaTime(): number;
  97609. private _measureFps;
  97610. /** @hidden */
  97611. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97612. private _canRenderToFloatFramebuffer;
  97613. private _canRenderToHalfFloatFramebuffer;
  97614. private _canRenderToFramebuffer;
  97615. /** @hidden */
  97616. _getWebGLTextureType(type: number): number;
  97617. /** @hidden */
  97618. _getInternalFormat(format: number): number;
  97619. /** @hidden */
  97620. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97621. /** @hidden */
  97622. _getRGBAMultiSampleBufferFormat(type: number): number;
  97623. /** @hidden */
  97624. _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;
  97625. /** @hidden */
  97626. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97627. /**
  97628. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97629. * @returns true if the engine can be created
  97630. * @ignorenaming
  97631. */
  97632. static isSupported(): boolean;
  97633. /**
  97634. * Find the next highest power of two.
  97635. * @param x Number to start search from.
  97636. * @return Next highest power of two.
  97637. */
  97638. static CeilingPOT(x: number): number;
  97639. /**
  97640. * Find the next lowest power of two.
  97641. * @param x Number to start search from.
  97642. * @return Next lowest power of two.
  97643. */
  97644. static FloorPOT(x: number): number;
  97645. /**
  97646. * Find the nearest power of two.
  97647. * @param x Number to start search from.
  97648. * @return Next nearest power of two.
  97649. */
  97650. static NearestPOT(x: number): number;
  97651. /**
  97652. * Get the closest exponent of two
  97653. * @param value defines the value to approximate
  97654. * @param max defines the maximum value to return
  97655. * @param mode defines how to define the closest value
  97656. * @returns closest exponent of two of the given value
  97657. */
  97658. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97659. /**
  97660. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97661. * @param func - the function to be called
  97662. * @param requester - the object that will request the next frame. Falls back to window.
  97663. * @returns frame number
  97664. */
  97665. static QueueNewFrame(func: () => void, requester?: any): number;
  97666. /**
  97667. * Ask the browser to promote the current element to pointerlock mode
  97668. * @param element defines the DOM element to promote
  97669. */
  97670. static _RequestPointerlock(element: HTMLElement): void;
  97671. /**
  97672. * Asks the browser to exit pointerlock mode
  97673. */
  97674. static _ExitPointerlock(): void;
  97675. /**
  97676. * Ask the browser to promote the current element to fullscreen rendering mode
  97677. * @param element defines the DOM element to promote
  97678. */
  97679. static _RequestFullscreen(element: HTMLElement): void;
  97680. /**
  97681. * Asks the browser to exit fullscreen mode
  97682. */
  97683. static _ExitFullscreen(): void;
  97684. }
  97685. }
  97686. declare module BABYLON {
  97687. /**
  97688. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97689. * during the life time of the application.
  97690. */
  97691. export class EngineStore {
  97692. /** Gets the list of created engines */
  97693. static Instances: Engine[];
  97694. /** @hidden */
  97695. static _LastCreatedScene: Nullable<Scene>;
  97696. /**
  97697. * Gets the latest created engine
  97698. */
  97699. static readonly LastCreatedEngine: Nullable<Engine>;
  97700. /**
  97701. * Gets the latest created scene
  97702. */
  97703. static readonly LastCreatedScene: Nullable<Scene>;
  97704. /**
  97705. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97706. * @ignorenaming
  97707. */
  97708. static UseFallbackTexture: boolean;
  97709. /**
  97710. * Texture content used if a texture cannot loaded
  97711. * @ignorenaming
  97712. */
  97713. static FallbackTexture: string;
  97714. }
  97715. }
  97716. declare module BABYLON {
  97717. /**
  97718. * Helper class that provides a small promise polyfill
  97719. */
  97720. export class PromisePolyfill {
  97721. /**
  97722. * Static function used to check if the polyfill is required
  97723. * If this is the case then the function will inject the polyfill to window.Promise
  97724. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97725. */
  97726. static Apply(force?: boolean): void;
  97727. }
  97728. }
  97729. declare module BABYLON {
  97730. /**
  97731. * Interface for screenshot methods with describe argument called `size` as object with options
  97732. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97733. */
  97734. export interface IScreenshotSize {
  97735. /**
  97736. * number in pixels for canvas height
  97737. */
  97738. height?: number;
  97739. /**
  97740. * multiplier allowing render at a higher or lower resolution
  97741. * If value is defined then height and width will be ignored and taken from camera
  97742. */
  97743. precision?: number;
  97744. /**
  97745. * number in pixels for canvas width
  97746. */
  97747. width?: number;
  97748. }
  97749. }
  97750. declare module BABYLON {
  97751. interface IColor4Like {
  97752. r: float;
  97753. g: float;
  97754. b: float;
  97755. a: float;
  97756. }
  97757. /**
  97758. * Class containing a set of static utilities functions
  97759. */
  97760. export class Tools {
  97761. /**
  97762. * Gets or sets the base URL to use to load assets
  97763. */
  97764. static BaseUrl: string;
  97765. /**
  97766. * Enable/Disable Custom HTTP Request Headers globally.
  97767. * default = false
  97768. * @see CustomRequestHeaders
  97769. */
  97770. static UseCustomRequestHeaders: boolean;
  97771. /**
  97772. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97773. * i.e. when loading files, where the server/service expects an Authorization header
  97774. */
  97775. static CustomRequestHeaders: {
  97776. [key: string]: string;
  97777. };
  97778. /**
  97779. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97780. */
  97781. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97782. /**
  97783. * Default behaviour for cors in the application.
  97784. * It can be a string if the expected behavior is identical in the entire app.
  97785. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97786. */
  97787. static CorsBehavior: string | ((url: string | string[]) => string);
  97788. /**
  97789. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97790. * @ignorenaming
  97791. */
  97792. static UseFallbackTexture: boolean;
  97793. /**
  97794. * Use this object to register external classes like custom textures or material
  97795. * to allow the laoders to instantiate them
  97796. */
  97797. static RegisteredExternalClasses: {
  97798. [key: string]: Object;
  97799. };
  97800. /**
  97801. * Texture content used if a texture cannot loaded
  97802. * @ignorenaming
  97803. */
  97804. static fallbackTexture: string;
  97805. /**
  97806. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97807. * @param u defines the coordinate on X axis
  97808. * @param v defines the coordinate on Y axis
  97809. * @param width defines the width of the source data
  97810. * @param height defines the height of the source data
  97811. * @param pixels defines the source byte array
  97812. * @param color defines the output color
  97813. */
  97814. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97815. /**
  97816. * Interpolates between a and b via alpha
  97817. * @param a The lower value (returned when alpha = 0)
  97818. * @param b The upper value (returned when alpha = 1)
  97819. * @param alpha The interpolation-factor
  97820. * @return The mixed value
  97821. */
  97822. static Mix(a: number, b: number, alpha: number): number;
  97823. /**
  97824. * Tries to instantiate a new object from a given class name
  97825. * @param className defines the class name to instantiate
  97826. * @returns the new object or null if the system was not able to do the instantiation
  97827. */
  97828. static Instantiate(className: string): any;
  97829. /**
  97830. * Provides a slice function that will work even on IE
  97831. * @param data defines the array to slice
  97832. * @param start defines the start of the data (optional)
  97833. * @param end defines the end of the data (optional)
  97834. * @returns the new sliced array
  97835. */
  97836. static Slice<T>(data: T, start?: number, end?: number): T;
  97837. /**
  97838. * Polyfill for setImmediate
  97839. * @param action defines the action to execute after the current execution block
  97840. */
  97841. static SetImmediate(action: () => void): void;
  97842. /**
  97843. * Function indicating if a number is an exponent of 2
  97844. * @param value defines the value to test
  97845. * @returns true if the value is an exponent of 2
  97846. */
  97847. static IsExponentOfTwo(value: number): boolean;
  97848. private static _tmpFloatArray;
  97849. /**
  97850. * Returns the nearest 32-bit single precision float representation of a Number
  97851. * @param value A Number. If the parameter is of a different type, it will get converted
  97852. * to a number or to NaN if it cannot be converted
  97853. * @returns number
  97854. */
  97855. static FloatRound(value: number): number;
  97856. /**
  97857. * Extracts the filename from a path
  97858. * @param path defines the path to use
  97859. * @returns the filename
  97860. */
  97861. static GetFilename(path: string): string;
  97862. /**
  97863. * Extracts the "folder" part of a path (everything before the filename).
  97864. * @param uri The URI to extract the info from
  97865. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97866. * @returns The "folder" part of the path
  97867. */
  97868. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97869. /**
  97870. * Extracts text content from a DOM element hierarchy
  97871. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97872. */
  97873. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97874. /**
  97875. * Convert an angle in radians to degrees
  97876. * @param angle defines the angle to convert
  97877. * @returns the angle in degrees
  97878. */
  97879. static ToDegrees(angle: number): number;
  97880. /**
  97881. * Convert an angle in degrees to radians
  97882. * @param angle defines the angle to convert
  97883. * @returns the angle in radians
  97884. */
  97885. static ToRadians(angle: number): number;
  97886. /**
  97887. * Encode a buffer to a base64 string
  97888. * @param buffer defines the buffer to encode
  97889. * @returns the encoded string
  97890. */
  97891. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97892. /**
  97893. * Returns an array if obj is not an array
  97894. * @param obj defines the object to evaluate as an array
  97895. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97896. * @returns either obj directly if obj is an array or a new array containing obj
  97897. */
  97898. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97899. /**
  97900. * Gets the pointer prefix to use
  97901. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97902. */
  97903. static GetPointerPrefix(): string;
  97904. /**
  97905. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97906. * @param url define the url we are trying
  97907. * @param element define the dom element where to configure the cors policy
  97908. */
  97909. static SetCorsBehavior(url: string | string[], element: {
  97910. crossOrigin: string | null;
  97911. }): void;
  97912. /**
  97913. * Removes unwanted characters from an url
  97914. * @param url defines the url to clean
  97915. * @returns the cleaned url
  97916. */
  97917. static CleanUrl(url: string): string;
  97918. /**
  97919. * Gets or sets a function used to pre-process url before using them to load assets
  97920. */
  97921. static PreprocessUrl: (url: string) => string;
  97922. /**
  97923. * Loads an image as an HTMLImageElement.
  97924. * @param input url string, ArrayBuffer, or Blob to load
  97925. * @param onLoad callback called when the image successfully loads
  97926. * @param onError callback called when the image fails to load
  97927. * @param offlineProvider offline provider for caching
  97928. * @returns the HTMLImageElement of the loaded image
  97929. */
  97930. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97931. /**
  97932. * Loads a file
  97933. * @param url url string, ArrayBuffer, or Blob to load
  97934. * @param onSuccess callback called when the file successfully loads
  97935. * @param onProgress callback called while file is loading (if the server supports this mode)
  97936. * @param offlineProvider defines the offline provider for caching
  97937. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97938. * @param onError callback called when the file fails to load
  97939. * @returns a file request object
  97940. */
  97941. 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;
  97942. /**
  97943. * Loads a file from a url
  97944. * @param url the file url to load
  97945. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97946. */
  97947. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97948. /**
  97949. * Load a script (identified by an url). When the url returns, the
  97950. * content of this file is added into a new script element, attached to the DOM (body element)
  97951. * @param scriptUrl defines the url of the script to laod
  97952. * @param onSuccess defines the callback called when the script is loaded
  97953. * @param onError defines the callback to call if an error occurs
  97954. * @param scriptId defines the id of the script element
  97955. */
  97956. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97957. /**
  97958. * Load an asynchronous script (identified by an url). When the url returns, the
  97959. * content of this file is added into a new script element, attached to the DOM (body element)
  97960. * @param scriptUrl defines the url of the script to laod
  97961. * @param scriptId defines the id of the script element
  97962. * @returns a promise request object
  97963. */
  97964. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97965. /**
  97966. * Loads a file from a blob
  97967. * @param fileToLoad defines the blob to use
  97968. * @param callback defines the callback to call when data is loaded
  97969. * @param progressCallback defines the callback to call during loading process
  97970. * @returns a file request object
  97971. */
  97972. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97973. /**
  97974. * Loads a file
  97975. * @param fileToLoad defines the file to load
  97976. * @param callback defines the callback to call when data is loaded
  97977. * @param progressCallBack defines the callback to call during loading process
  97978. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97979. * @returns a file request object
  97980. */
  97981. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97982. /**
  97983. * Creates a data url from a given string content
  97984. * @param content defines the content to convert
  97985. * @returns the new data url link
  97986. */
  97987. static FileAsURL(content: string): string;
  97988. /**
  97989. * Format the given number to a specific decimal format
  97990. * @param value defines the number to format
  97991. * @param decimals defines the number of decimals to use
  97992. * @returns the formatted string
  97993. */
  97994. static Format(value: number, decimals?: number): string;
  97995. /**
  97996. * Tries to copy an object by duplicating every property
  97997. * @param source defines the source object
  97998. * @param destination defines the target object
  97999. * @param doNotCopyList defines a list of properties to avoid
  98000. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98001. */
  98002. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98003. /**
  98004. * Gets a boolean indicating if the given object has no own property
  98005. * @param obj defines the object to test
  98006. * @returns true if object has no own property
  98007. */
  98008. static IsEmpty(obj: any): boolean;
  98009. /**
  98010. * Function used to register events at window level
  98011. * @param windowElement defines the Window object to use
  98012. * @param events defines the events to register
  98013. */
  98014. static RegisterTopRootEvents(windowElement: Window, events: {
  98015. name: string;
  98016. handler: Nullable<(e: FocusEvent) => any>;
  98017. }[]): void;
  98018. /**
  98019. * Function used to unregister events from window level
  98020. * @param windowElement defines the Window object to use
  98021. * @param events defines the events to unregister
  98022. */
  98023. static UnregisterTopRootEvents(windowElement: Window, events: {
  98024. name: string;
  98025. handler: Nullable<(e: FocusEvent) => any>;
  98026. }[]): void;
  98027. /**
  98028. * @ignore
  98029. */
  98030. static _ScreenshotCanvas: HTMLCanvasElement;
  98031. /**
  98032. * Dumps the current bound framebuffer
  98033. * @param width defines the rendering width
  98034. * @param height defines the rendering height
  98035. * @param engine defines the hosting engine
  98036. * @param successCallback defines the callback triggered once the data are available
  98037. * @param mimeType defines the mime type of the result
  98038. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98039. */
  98040. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98041. /**
  98042. * Converts the canvas data to blob.
  98043. * This acts as a polyfill for browsers not supporting the to blob function.
  98044. * @param canvas Defines the canvas to extract the data from
  98045. * @param successCallback Defines the callback triggered once the data are available
  98046. * @param mimeType Defines the mime type of the result
  98047. */
  98048. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98049. /**
  98050. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98051. * @param successCallback defines the callback triggered once the data are available
  98052. * @param mimeType defines the mime type of the result
  98053. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98054. */
  98055. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98056. /**
  98057. * Downloads a blob in the browser
  98058. * @param blob defines the blob to download
  98059. * @param fileName defines the name of the downloaded file
  98060. */
  98061. static Download(blob: Blob, fileName: string): void;
  98062. /**
  98063. * Captures a screenshot of the current rendering
  98064. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98065. * @param engine defines the rendering engine
  98066. * @param camera defines the source camera
  98067. * @param size This parameter can be set to a single number or to an object with the
  98068. * following (optional) properties: precision, width, height. If a single number is passed,
  98069. * it will be used for both width and height. If an object is passed, the screenshot size
  98070. * will be derived from the parameters. The precision property is a multiplier allowing
  98071. * rendering at a higher or lower resolution
  98072. * @param successCallback defines the callback receives a single parameter which contains the
  98073. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98074. * src parameter of an <img> to display it
  98075. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98076. * Check your browser for supported MIME types
  98077. */
  98078. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98079. /**
  98080. * Captures a screenshot of the current rendering
  98081. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98082. * @param engine defines the rendering engine
  98083. * @param camera defines the source camera
  98084. * @param size This parameter can be set to a single number or to an object with the
  98085. * following (optional) properties: precision, width, height. If a single number is passed,
  98086. * it will be used for both width and height. If an object is passed, the screenshot size
  98087. * will be derived from the parameters. The precision property is a multiplier allowing
  98088. * rendering at a higher or lower resolution
  98089. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98090. * Check your browser for supported MIME types
  98091. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98092. * to the src parameter of an <img> to display it
  98093. */
  98094. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98095. /**
  98096. * Generates an image screenshot from the specified camera.
  98097. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98098. * @param engine The engine to use for rendering
  98099. * @param camera The camera to use for rendering
  98100. * @param size This parameter can be set to a single number or to an object with the
  98101. * following (optional) properties: precision, width, height. If a single number is passed,
  98102. * it will be used for both width and height. If an object is passed, the screenshot size
  98103. * will be derived from the parameters. The precision property is a multiplier allowing
  98104. * rendering at a higher or lower resolution
  98105. * @param successCallback The callback receives a single parameter which contains the
  98106. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98107. * src parameter of an <img> to display it
  98108. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98109. * Check your browser for supported MIME types
  98110. * @param samples Texture samples (default: 1)
  98111. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98112. * @param fileName A name for for the downloaded file.
  98113. */
  98114. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98115. /**
  98116. * Generates an image screenshot from the specified camera.
  98117. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98118. * @param engine The engine to use for rendering
  98119. * @param camera The camera to use for rendering
  98120. * @param size This parameter can be set to a single number or to an object with the
  98121. * following (optional) properties: precision, width, height. If a single number is passed,
  98122. * it will be used for both width and height. If an object is passed, the screenshot size
  98123. * will be derived from the parameters. The precision property is a multiplier allowing
  98124. * rendering at a higher or lower resolution
  98125. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98126. * Check your browser for supported MIME types
  98127. * @param samples Texture samples (default: 1)
  98128. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98129. * @param fileName A name for for the downloaded file.
  98130. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98131. * to the src parameter of an <img> to display it
  98132. */
  98133. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98134. /**
  98135. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98136. * Be aware Math.random() could cause collisions, but:
  98137. * "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"
  98138. * @returns a pseudo random id
  98139. */
  98140. static RandomId(): string;
  98141. /**
  98142. * Test if the given uri is a base64 string
  98143. * @param uri The uri to test
  98144. * @return True if the uri is a base64 string or false otherwise
  98145. */
  98146. static IsBase64(uri: string): boolean;
  98147. /**
  98148. * Decode the given base64 uri.
  98149. * @param uri The uri to decode
  98150. * @return The decoded base64 data.
  98151. */
  98152. static DecodeBase64(uri: string): ArrayBuffer;
  98153. /**
  98154. * Gets the absolute url.
  98155. * @param url the input url
  98156. * @return the absolute url
  98157. */
  98158. static GetAbsoluteUrl(url: string): string;
  98159. /**
  98160. * No log
  98161. */
  98162. static readonly NoneLogLevel: number;
  98163. /**
  98164. * Only message logs
  98165. */
  98166. static readonly MessageLogLevel: number;
  98167. /**
  98168. * Only warning logs
  98169. */
  98170. static readonly WarningLogLevel: number;
  98171. /**
  98172. * Only error logs
  98173. */
  98174. static readonly ErrorLogLevel: number;
  98175. /**
  98176. * All logs
  98177. */
  98178. static readonly AllLogLevel: number;
  98179. /**
  98180. * Gets a value indicating the number of loading errors
  98181. * @ignorenaming
  98182. */
  98183. static readonly errorsCount: number;
  98184. /**
  98185. * Callback called when a new log is added
  98186. */
  98187. static OnNewCacheEntry: (entry: string) => void;
  98188. /**
  98189. * Log a message to the console
  98190. * @param message defines the message to log
  98191. */
  98192. static Log(message: string): void;
  98193. /**
  98194. * Write a warning message to the console
  98195. * @param message defines the message to log
  98196. */
  98197. static Warn(message: string): void;
  98198. /**
  98199. * Write an error message to the console
  98200. * @param message defines the message to log
  98201. */
  98202. static Error(message: string): void;
  98203. /**
  98204. * Gets current log cache (list of logs)
  98205. */
  98206. static readonly LogCache: string;
  98207. /**
  98208. * Clears the log cache
  98209. */
  98210. static ClearLogCache(): void;
  98211. /**
  98212. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98213. */
  98214. static LogLevels: number;
  98215. /**
  98216. * Checks if the window object exists
  98217. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98218. */
  98219. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98220. /**
  98221. * No performance log
  98222. */
  98223. static readonly PerformanceNoneLogLevel: number;
  98224. /**
  98225. * Use user marks to log performance
  98226. */
  98227. static readonly PerformanceUserMarkLogLevel: number;
  98228. /**
  98229. * Log performance to the console
  98230. */
  98231. static readonly PerformanceConsoleLogLevel: number;
  98232. private static _performance;
  98233. /**
  98234. * Sets the current performance log level
  98235. */
  98236. static PerformanceLogLevel: number;
  98237. private static _StartPerformanceCounterDisabled;
  98238. private static _EndPerformanceCounterDisabled;
  98239. private static _StartUserMark;
  98240. private static _EndUserMark;
  98241. private static _StartPerformanceConsole;
  98242. private static _EndPerformanceConsole;
  98243. /**
  98244. * Starts a performance counter
  98245. */
  98246. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98247. /**
  98248. * Ends a specific performance coutner
  98249. */
  98250. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98251. /**
  98252. * Gets either window.performance.now() if supported or Date.now() else
  98253. */
  98254. static readonly Now: number;
  98255. /**
  98256. * This method will return the name of the class used to create the instance of the given object.
  98257. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98258. * @param object the object to get the class name from
  98259. * @param isType defines if the object is actually a type
  98260. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98261. */
  98262. static GetClassName(object: any, isType?: boolean): string;
  98263. /**
  98264. * Gets the first element of an array satisfying a given predicate
  98265. * @param array defines the array to browse
  98266. * @param predicate defines the predicate to use
  98267. * @returns null if not found or the element
  98268. */
  98269. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98270. /**
  98271. * This method will return the name of the full name of the class, including its owning module (if any).
  98272. * 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).
  98273. * @param object the object to get the class name from
  98274. * @param isType defines if the object is actually a type
  98275. * @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.
  98276. * @ignorenaming
  98277. */
  98278. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98279. /**
  98280. * Returns a promise that resolves after the given amount of time.
  98281. * @param delay Number of milliseconds to delay
  98282. * @returns Promise that resolves after the given amount of time
  98283. */
  98284. static DelayAsync(delay: number): Promise<void>;
  98285. }
  98286. /**
  98287. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98288. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98289. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98290. * @param name The name of the class, case should be preserved
  98291. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98292. */
  98293. export function className(name: string, module?: string): (target: Object) => void;
  98294. /**
  98295. * An implementation of a loop for asynchronous functions.
  98296. */
  98297. export class AsyncLoop {
  98298. /**
  98299. * Defines the number of iterations for the loop
  98300. */
  98301. iterations: number;
  98302. /**
  98303. * Defines the current index of the loop.
  98304. */
  98305. index: number;
  98306. private _done;
  98307. private _fn;
  98308. private _successCallback;
  98309. /**
  98310. * Constructor.
  98311. * @param iterations the number of iterations.
  98312. * @param func the function to run each iteration
  98313. * @param successCallback the callback that will be called upon succesful execution
  98314. * @param offset starting offset.
  98315. */
  98316. constructor(
  98317. /**
  98318. * Defines the number of iterations for the loop
  98319. */
  98320. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98321. /**
  98322. * Execute the next iteration. Must be called after the last iteration was finished.
  98323. */
  98324. executeNext(): void;
  98325. /**
  98326. * Break the loop and run the success callback.
  98327. */
  98328. breakLoop(): void;
  98329. /**
  98330. * Create and run an async loop.
  98331. * @param iterations the number of iterations.
  98332. * @param fn the function to run each iteration
  98333. * @param successCallback the callback that will be called upon succesful execution
  98334. * @param offset starting offset.
  98335. * @returns the created async loop object
  98336. */
  98337. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98338. /**
  98339. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98340. * @param iterations total number of iterations
  98341. * @param syncedIterations number of synchronous iterations in each async iteration.
  98342. * @param fn the function to call each iteration.
  98343. * @param callback a success call back that will be called when iterating stops.
  98344. * @param breakFunction a break condition (optional)
  98345. * @param timeout timeout settings for the setTimeout function. default - 0.
  98346. * @returns the created async loop object
  98347. */
  98348. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98349. }
  98350. }
  98351. declare module BABYLON {
  98352. /** @hidden */
  98353. export interface ICollisionCoordinator {
  98354. createCollider(): Collider;
  98355. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98356. init(scene: Scene): void;
  98357. }
  98358. /** @hidden */
  98359. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98360. private _scene;
  98361. private _scaledPosition;
  98362. private _scaledVelocity;
  98363. private _finalPosition;
  98364. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98365. createCollider(): Collider;
  98366. init(scene: Scene): void;
  98367. private _collideWithWorld;
  98368. }
  98369. }
  98370. declare module BABYLON {
  98371. /**
  98372. * Class used to manage all inputs for the scene.
  98373. */
  98374. export class InputManager {
  98375. /** The distance in pixel that you have to move to prevent some events */
  98376. static DragMovementThreshold: number;
  98377. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98378. static LongPressDelay: number;
  98379. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98380. static DoubleClickDelay: number;
  98381. /** If you need to check double click without raising a single click at first click, enable this flag */
  98382. static ExclusiveDoubleClickMode: boolean;
  98383. private _wheelEventName;
  98384. private _onPointerMove;
  98385. private _onPointerDown;
  98386. private _onPointerUp;
  98387. private _initClickEvent;
  98388. private _initActionManager;
  98389. private _delayedSimpleClick;
  98390. private _delayedSimpleClickTimeout;
  98391. private _previousDelayedSimpleClickTimeout;
  98392. private _meshPickProceed;
  98393. private _previousButtonPressed;
  98394. private _currentPickResult;
  98395. private _previousPickResult;
  98396. private _totalPointersPressed;
  98397. private _doubleClickOccured;
  98398. private _pointerOverMesh;
  98399. private _pickedDownMesh;
  98400. private _pickedUpMesh;
  98401. private _pointerX;
  98402. private _pointerY;
  98403. private _unTranslatedPointerX;
  98404. private _unTranslatedPointerY;
  98405. private _startingPointerPosition;
  98406. private _previousStartingPointerPosition;
  98407. private _startingPointerTime;
  98408. private _previousStartingPointerTime;
  98409. private _pointerCaptures;
  98410. private _onKeyDown;
  98411. private _onKeyUp;
  98412. private _onCanvasFocusObserver;
  98413. private _onCanvasBlurObserver;
  98414. private _scene;
  98415. /**
  98416. * Creates a new InputManager
  98417. * @param scene defines the hosting scene
  98418. */
  98419. constructor(scene: Scene);
  98420. /**
  98421. * Gets the mesh that is currently under the pointer
  98422. */
  98423. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98424. /**
  98425. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98426. */
  98427. readonly unTranslatedPointer: Vector2;
  98428. /**
  98429. * Gets or sets the current on-screen X position of the pointer
  98430. */
  98431. pointerX: number;
  98432. /**
  98433. * Gets or sets the current on-screen Y position of the pointer
  98434. */
  98435. pointerY: number;
  98436. private _updatePointerPosition;
  98437. private _processPointerMove;
  98438. private _setRayOnPointerInfo;
  98439. private _checkPrePointerObservable;
  98440. /**
  98441. * Use this method to simulate a pointer move on a mesh
  98442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98445. */
  98446. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98447. /**
  98448. * Use this method to simulate a pointer down on a mesh
  98449. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98450. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98451. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98452. */
  98453. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98454. private _processPointerDown;
  98455. /** @hidden */
  98456. _isPointerSwiping(): boolean;
  98457. /**
  98458. * Use this method to simulate a pointer up on a mesh
  98459. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98460. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98461. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98462. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98463. */
  98464. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98465. private _processPointerUp;
  98466. /**
  98467. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98468. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98469. * @returns true if the pointer was captured
  98470. */
  98471. isPointerCaptured(pointerId?: number): boolean;
  98472. /**
  98473. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98474. * @param attachUp defines if you want to attach events to pointerup
  98475. * @param attachDown defines if you want to attach events to pointerdown
  98476. * @param attachMove defines if you want to attach events to pointermove
  98477. */
  98478. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98479. /**
  98480. * Detaches all event handlers
  98481. */
  98482. detachControl(): void;
  98483. /**
  98484. * Force the value of meshUnderPointer
  98485. * @param mesh defines the mesh to use
  98486. */
  98487. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98488. /**
  98489. * Gets the mesh under the pointer
  98490. * @returns a Mesh or null if no mesh is under the pointer
  98491. */
  98492. getPointerOverMesh(): Nullable<AbstractMesh>;
  98493. }
  98494. }
  98495. declare module BABYLON {
  98496. /**
  98497. * Helper class used to generate session unique ID
  98498. */
  98499. export class UniqueIdGenerator {
  98500. private static _UniqueIdCounter;
  98501. /**
  98502. * Gets an unique (relatively to the current scene) Id
  98503. */
  98504. static readonly UniqueId: number;
  98505. }
  98506. }
  98507. declare module BABYLON {
  98508. /**
  98509. * This class defines the direct association between an animation and a target
  98510. */
  98511. export class TargetedAnimation {
  98512. /**
  98513. * Animation to perform
  98514. */
  98515. animation: Animation;
  98516. /**
  98517. * Target to animate
  98518. */
  98519. target: any;
  98520. /**
  98521. * Serialize the object
  98522. * @returns the JSON object representing the current entity
  98523. */
  98524. serialize(): any;
  98525. }
  98526. /**
  98527. * Use this class to create coordinated animations on multiple targets
  98528. */
  98529. export class AnimationGroup implements IDisposable {
  98530. /** The name of the animation group */
  98531. name: string;
  98532. private _scene;
  98533. private _targetedAnimations;
  98534. private _animatables;
  98535. private _from;
  98536. private _to;
  98537. private _isStarted;
  98538. private _isPaused;
  98539. private _speedRatio;
  98540. private _loopAnimation;
  98541. /**
  98542. * Gets or sets the unique id of the node
  98543. */
  98544. uniqueId: number;
  98545. /**
  98546. * This observable will notify when one animation have ended
  98547. */
  98548. onAnimationEndObservable: Observable<TargetedAnimation>;
  98549. /**
  98550. * Observer raised when one animation loops
  98551. */
  98552. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98553. /**
  98554. * This observable will notify when all animations have ended.
  98555. */
  98556. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98557. /**
  98558. * This observable will notify when all animations have paused.
  98559. */
  98560. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98561. /**
  98562. * This observable will notify when all animations are playing.
  98563. */
  98564. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98565. /**
  98566. * Gets the first frame
  98567. */
  98568. readonly from: number;
  98569. /**
  98570. * Gets the last frame
  98571. */
  98572. readonly to: number;
  98573. /**
  98574. * Define if the animations are started
  98575. */
  98576. readonly isStarted: boolean;
  98577. /**
  98578. * Gets a value indicating that the current group is playing
  98579. */
  98580. readonly isPlaying: boolean;
  98581. /**
  98582. * Gets or sets the speed ratio to use for all animations
  98583. */
  98584. /**
  98585. * Gets or sets the speed ratio to use for all animations
  98586. */
  98587. speedRatio: number;
  98588. /**
  98589. * Gets or sets if all animations should loop or not
  98590. */
  98591. loopAnimation: boolean;
  98592. /**
  98593. * Gets the targeted animations for this animation group
  98594. */
  98595. readonly targetedAnimations: Array<TargetedAnimation>;
  98596. /**
  98597. * returning the list of animatables controlled by this animation group.
  98598. */
  98599. readonly animatables: Array<Animatable>;
  98600. /**
  98601. * Instantiates a new Animation Group.
  98602. * This helps managing several animations at once.
  98603. * @see http://doc.babylonjs.com/how_to/group
  98604. * @param name Defines the name of the group
  98605. * @param scene Defines the scene the group belongs to
  98606. */
  98607. constructor(
  98608. /** The name of the animation group */
  98609. name: string, scene?: Nullable<Scene>);
  98610. /**
  98611. * Add an animation (with its target) in the group
  98612. * @param animation defines the animation we want to add
  98613. * @param target defines the target of the animation
  98614. * @returns the TargetedAnimation object
  98615. */
  98616. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98617. /**
  98618. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98619. * It can add constant keys at begin or end
  98620. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98621. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98622. * @returns the animation group
  98623. */
  98624. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98625. /**
  98626. * Start all animations on given targets
  98627. * @param loop defines if animations must loop
  98628. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98629. * @param from defines the from key (optional)
  98630. * @param to defines the to key (optional)
  98631. * @returns the current animation group
  98632. */
  98633. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98634. /**
  98635. * Pause all animations
  98636. * @returns the animation group
  98637. */
  98638. pause(): AnimationGroup;
  98639. /**
  98640. * Play all animations to initial state
  98641. * This function will start() the animations if they were not started or will restart() them if they were paused
  98642. * @param loop defines if animations must loop
  98643. * @returns the animation group
  98644. */
  98645. play(loop?: boolean): AnimationGroup;
  98646. /**
  98647. * Reset all animations to initial state
  98648. * @returns the animation group
  98649. */
  98650. reset(): AnimationGroup;
  98651. /**
  98652. * Restart animations from key 0
  98653. * @returns the animation group
  98654. */
  98655. restart(): AnimationGroup;
  98656. /**
  98657. * Stop all animations
  98658. * @returns the animation group
  98659. */
  98660. stop(): AnimationGroup;
  98661. /**
  98662. * Set animation weight for all animatables
  98663. * @param weight defines the weight to use
  98664. * @return the animationGroup
  98665. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98666. */
  98667. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98668. /**
  98669. * Synchronize and normalize all animatables with a source animatable
  98670. * @param root defines the root animatable to synchronize with
  98671. * @return the animationGroup
  98672. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98673. */
  98674. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98675. /**
  98676. * Goes to a specific frame in this animation group
  98677. * @param frame the frame number to go to
  98678. * @return the animationGroup
  98679. */
  98680. goToFrame(frame: number): AnimationGroup;
  98681. /**
  98682. * Dispose all associated resources
  98683. */
  98684. dispose(): void;
  98685. private _checkAnimationGroupEnded;
  98686. /**
  98687. * Clone the current animation group and returns a copy
  98688. * @param newName defines the name of the new group
  98689. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98690. * @returns the new aniamtion group
  98691. */
  98692. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98693. /**
  98694. * Serializes the animationGroup to an object
  98695. * @returns Serialized object
  98696. */
  98697. serialize(): any;
  98698. /**
  98699. * Returns a new AnimationGroup object parsed from the source provided.
  98700. * @param parsedAnimationGroup defines the source
  98701. * @param scene defines the scene that will receive the animationGroup
  98702. * @returns a new AnimationGroup
  98703. */
  98704. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98705. /**
  98706. * Returns the string "AnimationGroup"
  98707. * @returns "AnimationGroup"
  98708. */
  98709. getClassName(): string;
  98710. /**
  98711. * Creates a detailled string about the object
  98712. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98713. * @returns a string representing the object
  98714. */
  98715. toString(fullDetails?: boolean): string;
  98716. }
  98717. }
  98718. declare module BABYLON {
  98719. /**
  98720. * Define an interface for all classes that will hold resources
  98721. */
  98722. export interface IDisposable {
  98723. /**
  98724. * Releases all held resources
  98725. */
  98726. dispose(): void;
  98727. }
  98728. /** Interface defining initialization parameters for Scene class */
  98729. export interface SceneOptions {
  98730. /**
  98731. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98732. * It will improve performance when the number of geometries becomes important.
  98733. */
  98734. useGeometryUniqueIdsMap?: boolean;
  98735. /**
  98736. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98738. */
  98739. useMaterialMeshMap?: boolean;
  98740. /**
  98741. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98743. */
  98744. useClonedMeshhMap?: boolean;
  98745. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98746. virtual?: boolean;
  98747. }
  98748. /**
  98749. * Represents a scene to be rendered by the engine.
  98750. * @see http://doc.babylonjs.com/features/scene
  98751. */
  98752. export class Scene extends AbstractScene implements IAnimatable {
  98753. /** The fog is deactivated */
  98754. static readonly FOGMODE_NONE: number;
  98755. /** The fog density is following an exponential function */
  98756. static readonly FOGMODE_EXP: number;
  98757. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98758. static readonly FOGMODE_EXP2: number;
  98759. /** The fog density is following a linear function. */
  98760. static readonly FOGMODE_LINEAR: number;
  98761. /**
  98762. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98764. */
  98765. static MinDeltaTime: number;
  98766. /**
  98767. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98769. */
  98770. static MaxDeltaTime: number;
  98771. /**
  98772. * Factory used to create the default material.
  98773. * @param name The name of the material to create
  98774. * @param scene The scene to create the material for
  98775. * @returns The default material
  98776. */
  98777. static DefaultMaterialFactory(scene: Scene): Material;
  98778. /**
  98779. * Factory used to create the a collision coordinator.
  98780. * @returns The collision coordinator
  98781. */
  98782. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98783. /** @hidden */
  98784. _inputManager: InputManager;
  98785. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98786. cameraToUseForPointers: Nullable<Camera>;
  98787. /** @hidden */
  98788. readonly _isScene: boolean;
  98789. /**
  98790. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98791. */
  98792. autoClear: boolean;
  98793. /**
  98794. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98795. */
  98796. autoClearDepthAndStencil: boolean;
  98797. /**
  98798. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98799. */
  98800. clearColor: Color4;
  98801. /**
  98802. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98803. */
  98804. ambientColor: Color3;
  98805. /**
  98806. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98807. * It should only be one of the following (if not the default embedded one):
  98808. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98809. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98810. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98811. * The material properties need to be setup according to the type of texture in use.
  98812. */
  98813. environmentBRDFTexture: BaseTexture;
  98814. /** @hidden */
  98815. protected _environmentTexture: Nullable<BaseTexture>;
  98816. /**
  98817. * Texture used in all pbr material as the reflection texture.
  98818. * As in the majority of the scene they are the same (exception for multi room and so on),
  98819. * this is easier to reference from here than from all the materials.
  98820. */
  98821. /**
  98822. * Texture used in all pbr material as the reflection texture.
  98823. * As in the majority of the scene they are the same (exception for multi room and so on),
  98824. * this is easier to set here than in all the materials.
  98825. */
  98826. environmentTexture: Nullable<BaseTexture>;
  98827. /** @hidden */
  98828. protected _environmentIntensity: number;
  98829. /**
  98830. * Intensity of the environment in all pbr material.
  98831. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98832. * As in the majority of the scene they are the same (exception for multi room and so on),
  98833. * this is easier to reference from here than from all the materials.
  98834. */
  98835. /**
  98836. * Intensity of the environment in all pbr material.
  98837. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98838. * As in the majority of the scene they are the same (exception for multi room and so on),
  98839. * this is easier to set here than in all the materials.
  98840. */
  98841. environmentIntensity: number;
  98842. /** @hidden */
  98843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98844. /**
  98845. * Default image processing configuration used either in the rendering
  98846. * Forward main pass or through the imageProcessingPostProcess if present.
  98847. * As in the majority of the scene they are the same (exception for multi camera),
  98848. * this is easier to reference from here than from all the materials and post process.
  98849. *
  98850. * No setter as we it is a shared configuration, you can set the values instead.
  98851. */
  98852. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98853. private _forceWireframe;
  98854. /**
  98855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98856. */
  98857. forceWireframe: boolean;
  98858. private _forcePointsCloud;
  98859. /**
  98860. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98861. */
  98862. forcePointsCloud: boolean;
  98863. /**
  98864. * Gets or sets the active clipplane 1
  98865. */
  98866. clipPlane: Nullable<Plane>;
  98867. /**
  98868. * Gets or sets the active clipplane 2
  98869. */
  98870. clipPlane2: Nullable<Plane>;
  98871. /**
  98872. * Gets or sets the active clipplane 3
  98873. */
  98874. clipPlane3: Nullable<Plane>;
  98875. /**
  98876. * Gets or sets the active clipplane 4
  98877. */
  98878. clipPlane4: Nullable<Plane>;
  98879. /**
  98880. * Gets or sets a boolean indicating if animations are enabled
  98881. */
  98882. animationsEnabled: boolean;
  98883. private _animationPropertiesOverride;
  98884. /**
  98885. * Gets or sets the animation properties override
  98886. */
  98887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98888. /**
  98889. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98890. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98891. */
  98892. useConstantAnimationDeltaTime: boolean;
  98893. /**
  98894. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98895. * Please note that it requires to run a ray cast through the scene on every frame
  98896. */
  98897. constantlyUpdateMeshUnderPointer: boolean;
  98898. /**
  98899. * Defines the HTML cursor to use when hovering over interactive elements
  98900. */
  98901. hoverCursor: string;
  98902. /**
  98903. * Defines the HTML default cursor to use (empty by default)
  98904. */
  98905. defaultCursor: string;
  98906. /**
  98907. * This is used to call preventDefault() on pointer down
  98908. * in order to block unwanted artifacts like system double clicks
  98909. */
  98910. preventDefaultOnPointerDown: boolean;
  98911. /**
  98912. * This is used to call preventDefault() on pointer up
  98913. * in order to block unwanted artifacts like system double clicks
  98914. */
  98915. preventDefaultOnPointerUp: boolean;
  98916. /**
  98917. * Gets or sets user defined metadata
  98918. */
  98919. metadata: any;
  98920. /**
  98921. * For internal use only. Please do not use.
  98922. */
  98923. reservedDataStore: any;
  98924. /**
  98925. * Gets the name of the plugin used to load this scene (null by default)
  98926. */
  98927. loadingPluginName: string;
  98928. /**
  98929. * Use this array to add regular expressions used to disable offline support for specific urls
  98930. */
  98931. disableOfflineSupportExceptionRules: RegExp[];
  98932. /**
  98933. * An event triggered when the scene is disposed.
  98934. */
  98935. onDisposeObservable: Observable<Scene>;
  98936. private _onDisposeObserver;
  98937. /** Sets a function to be executed when this scene is disposed. */
  98938. onDispose: () => void;
  98939. /**
  98940. * An event triggered before rendering the scene (right after animations and physics)
  98941. */
  98942. onBeforeRenderObservable: Observable<Scene>;
  98943. private _onBeforeRenderObserver;
  98944. /** Sets a function to be executed before rendering this scene */
  98945. beforeRender: Nullable<() => void>;
  98946. /**
  98947. * An event triggered after rendering the scene
  98948. */
  98949. onAfterRenderObservable: Observable<Scene>;
  98950. /**
  98951. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98952. */
  98953. onAfterRenderCameraObservable: Observable<Camera>;
  98954. private _onAfterRenderObserver;
  98955. /** Sets a function to be executed after rendering this scene */
  98956. afterRender: Nullable<() => void>;
  98957. /**
  98958. * An event triggered before animating the scene
  98959. */
  98960. onBeforeAnimationsObservable: Observable<Scene>;
  98961. /**
  98962. * An event triggered after animations processing
  98963. */
  98964. onAfterAnimationsObservable: Observable<Scene>;
  98965. /**
  98966. * An event triggered before draw calls are ready to be sent
  98967. */
  98968. onBeforeDrawPhaseObservable: Observable<Scene>;
  98969. /**
  98970. * An event triggered after draw calls have been sent
  98971. */
  98972. onAfterDrawPhaseObservable: Observable<Scene>;
  98973. /**
  98974. * An event triggered when the scene is ready
  98975. */
  98976. onReadyObservable: Observable<Scene>;
  98977. /**
  98978. * An event triggered before rendering a camera
  98979. */
  98980. onBeforeCameraRenderObservable: Observable<Camera>;
  98981. private _onBeforeCameraRenderObserver;
  98982. /** Sets a function to be executed before rendering a camera*/
  98983. beforeCameraRender: () => void;
  98984. /**
  98985. * An event triggered after rendering a camera
  98986. */
  98987. onAfterCameraRenderObservable: Observable<Camera>;
  98988. private _onAfterCameraRenderObserver;
  98989. /** Sets a function to be executed after rendering a camera*/
  98990. afterCameraRender: () => void;
  98991. /**
  98992. * An event triggered when active meshes evaluation is about to start
  98993. */
  98994. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98995. /**
  98996. * An event triggered when active meshes evaluation is done
  98997. */
  98998. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98999. /**
  99000. * An event triggered when particles rendering is about to start
  99001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99002. */
  99003. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99004. /**
  99005. * An event triggered when particles rendering is done
  99006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99007. */
  99008. onAfterParticlesRenderingObservable: Observable<Scene>;
  99009. /**
  99010. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99011. */
  99012. onDataLoadedObservable: Observable<Scene>;
  99013. /**
  99014. * An event triggered when a camera is created
  99015. */
  99016. onNewCameraAddedObservable: Observable<Camera>;
  99017. /**
  99018. * An event triggered when a camera is removed
  99019. */
  99020. onCameraRemovedObservable: Observable<Camera>;
  99021. /**
  99022. * An event triggered when a light is created
  99023. */
  99024. onNewLightAddedObservable: Observable<Light>;
  99025. /**
  99026. * An event triggered when a light is removed
  99027. */
  99028. onLightRemovedObservable: Observable<Light>;
  99029. /**
  99030. * An event triggered when a geometry is created
  99031. */
  99032. onNewGeometryAddedObservable: Observable<Geometry>;
  99033. /**
  99034. * An event triggered when a geometry is removed
  99035. */
  99036. onGeometryRemovedObservable: Observable<Geometry>;
  99037. /**
  99038. * An event triggered when a transform node is created
  99039. */
  99040. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99041. /**
  99042. * An event triggered when a transform node is removed
  99043. */
  99044. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99045. /**
  99046. * An event triggered when a mesh is created
  99047. */
  99048. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99049. /**
  99050. * An event triggered when a mesh is removed
  99051. */
  99052. onMeshRemovedObservable: Observable<AbstractMesh>;
  99053. /**
  99054. * An event triggered when a skeleton is created
  99055. */
  99056. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99057. /**
  99058. * An event triggered when a skeleton is removed
  99059. */
  99060. onSkeletonRemovedObservable: Observable<Skeleton>;
  99061. /**
  99062. * An event triggered when a material is created
  99063. */
  99064. onNewMaterialAddedObservable: Observable<Material>;
  99065. /**
  99066. * An event triggered when a material is removed
  99067. */
  99068. onMaterialRemovedObservable: Observable<Material>;
  99069. /**
  99070. * An event triggered when a texture is created
  99071. */
  99072. onNewTextureAddedObservable: Observable<BaseTexture>;
  99073. /**
  99074. * An event triggered when a texture is removed
  99075. */
  99076. onTextureRemovedObservable: Observable<BaseTexture>;
  99077. /**
  99078. * An event triggered when render targets are about to be rendered
  99079. * Can happen multiple times per frame.
  99080. */
  99081. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99082. /**
  99083. * An event triggered when render targets were rendered.
  99084. * Can happen multiple times per frame.
  99085. */
  99086. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99087. /**
  99088. * An event triggered before calculating deterministic simulation step
  99089. */
  99090. onBeforeStepObservable: Observable<Scene>;
  99091. /**
  99092. * An event triggered after calculating deterministic simulation step
  99093. */
  99094. onAfterStepObservable: Observable<Scene>;
  99095. /**
  99096. * An event triggered when the activeCamera property is updated
  99097. */
  99098. onActiveCameraChanged: Observable<Scene>;
  99099. /**
  99100. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99102. * 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)
  99103. */
  99104. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99105. /**
  99106. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99108. * 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)
  99109. */
  99110. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99111. /**
  99112. * This Observable will when a mesh has been imported into the scene.
  99113. */
  99114. onMeshImportedObservable: Observable<AbstractMesh>;
  99115. /**
  99116. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99117. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99118. */
  99119. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99120. /** @hidden */
  99121. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99122. /**
  99123. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99124. */
  99125. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99126. /**
  99127. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99128. */
  99129. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99130. /**
  99131. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99132. */
  99133. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99134. /** Callback called when a pointer move is detected */
  99135. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99136. /** Callback called when a pointer down is detected */
  99137. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99138. /** Callback called when a pointer up is detected */
  99139. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99140. /** Callback called when a pointer pick is detected */
  99141. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99142. /**
  99143. * 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).
  99144. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99145. */
  99146. onPrePointerObservable: Observable<PointerInfoPre>;
  99147. /**
  99148. * Observable event triggered each time an input event is received from the rendering canvas
  99149. */
  99150. onPointerObservable: Observable<PointerInfo>;
  99151. /**
  99152. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99153. */
  99154. readonly unTranslatedPointer: Vector2;
  99155. /**
  99156. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99157. */
  99158. static DragMovementThreshold: number;
  99159. /**
  99160. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99161. */
  99162. static LongPressDelay: number;
  99163. /**
  99164. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99165. */
  99166. static DoubleClickDelay: number;
  99167. /** If you need to check double click without raising a single click at first click, enable this flag */
  99168. static ExclusiveDoubleClickMode: boolean;
  99169. /** @hidden */
  99170. _mirroredCameraPosition: Nullable<Vector3>;
  99171. /**
  99172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99174. */
  99175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99176. /**
  99177. * Observable event triggered each time an keyboard event is received from the hosting window
  99178. */
  99179. onKeyboardObservable: Observable<KeyboardInfo>;
  99180. private _useRightHandedSystem;
  99181. /**
  99182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99183. */
  99184. useRightHandedSystem: boolean;
  99185. private _timeAccumulator;
  99186. private _currentStepId;
  99187. private _currentInternalStep;
  99188. /**
  99189. * Sets the step Id used by deterministic lock step
  99190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99191. * @param newStepId defines the step Id
  99192. */
  99193. setStepId(newStepId: number): void;
  99194. /**
  99195. * Gets the step Id used by deterministic lock step
  99196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99197. * @returns the step Id
  99198. */
  99199. getStepId(): number;
  99200. /**
  99201. * Gets the internal step used by deterministic lock step
  99202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99203. * @returns the internal step
  99204. */
  99205. getInternalStep(): number;
  99206. private _fogEnabled;
  99207. /**
  99208. * Gets or sets a boolean indicating if fog is enabled on this scene
  99209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99210. * (Default is true)
  99211. */
  99212. fogEnabled: boolean;
  99213. private _fogMode;
  99214. /**
  99215. * Gets or sets the fog mode to use
  99216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99217. * | mode | value |
  99218. * | --- | --- |
  99219. * | FOGMODE_NONE | 0 |
  99220. * | FOGMODE_EXP | 1 |
  99221. * | FOGMODE_EXP2 | 2 |
  99222. * | FOGMODE_LINEAR | 3 |
  99223. */
  99224. fogMode: number;
  99225. /**
  99226. * Gets or sets the fog color to use
  99227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99228. * (Default is Color3(0.2, 0.2, 0.3))
  99229. */
  99230. fogColor: Color3;
  99231. /**
  99232. * Gets or sets the fog density to use
  99233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99234. * (Default is 0.1)
  99235. */
  99236. fogDensity: number;
  99237. /**
  99238. * Gets or sets the fog start distance to use
  99239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99240. * (Default is 0)
  99241. */
  99242. fogStart: number;
  99243. /**
  99244. * Gets or sets the fog end distance to use
  99245. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99246. * (Default is 1000)
  99247. */
  99248. fogEnd: number;
  99249. private _shadowsEnabled;
  99250. /**
  99251. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99252. */
  99253. shadowsEnabled: boolean;
  99254. private _lightsEnabled;
  99255. /**
  99256. * Gets or sets a boolean indicating if lights are enabled on this scene
  99257. */
  99258. lightsEnabled: boolean;
  99259. /** All of the active cameras added to this scene. */
  99260. activeCameras: Camera[];
  99261. /** @hidden */
  99262. _activeCamera: Nullable<Camera>;
  99263. /** Gets or sets the current active camera */
  99264. activeCamera: Nullable<Camera>;
  99265. private _defaultMaterial;
  99266. /** The default material used on meshes when no material is affected */
  99267. /** The default material used on meshes when no material is affected */
  99268. defaultMaterial: Material;
  99269. private _texturesEnabled;
  99270. /**
  99271. * Gets or sets a boolean indicating if textures are enabled on this scene
  99272. */
  99273. texturesEnabled: boolean;
  99274. /**
  99275. * Gets or sets a boolean indicating if particles are enabled on this scene
  99276. */
  99277. particlesEnabled: boolean;
  99278. /**
  99279. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99280. */
  99281. spritesEnabled: boolean;
  99282. private _skeletonsEnabled;
  99283. /**
  99284. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99285. */
  99286. skeletonsEnabled: boolean;
  99287. /**
  99288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99289. */
  99290. lensFlaresEnabled: boolean;
  99291. /**
  99292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99294. */
  99295. collisionsEnabled: boolean;
  99296. private _collisionCoordinator;
  99297. /** @hidden */
  99298. readonly collisionCoordinator: ICollisionCoordinator;
  99299. /**
  99300. * Defines the gravity applied to this scene (used only for collisions)
  99301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99302. */
  99303. gravity: Vector3;
  99304. /**
  99305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99306. */
  99307. postProcessesEnabled: boolean;
  99308. /**
  99309. * The list of postprocesses added to the scene
  99310. */
  99311. postProcesses: PostProcess[];
  99312. /**
  99313. * Gets the current postprocess manager
  99314. */
  99315. postProcessManager: PostProcessManager;
  99316. /**
  99317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99318. */
  99319. renderTargetsEnabled: boolean;
  99320. /**
  99321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99323. */
  99324. dumpNextRenderTargets: boolean;
  99325. /**
  99326. * The list of user defined render targets added to the scene
  99327. */
  99328. customRenderTargets: RenderTargetTexture[];
  99329. /**
  99330. * Defines if texture loading must be delayed
  99331. * If true, textures will only be loaded when they need to be rendered
  99332. */
  99333. useDelayedTextureLoading: boolean;
  99334. /**
  99335. * Gets the list of meshes imported to the scene through SceneLoader
  99336. */
  99337. importedMeshesFiles: String[];
  99338. /**
  99339. * Gets or sets a boolean indicating if probes are enabled on this scene
  99340. */
  99341. probesEnabled: boolean;
  99342. /**
  99343. * Gets or sets the current offline provider to use to store scene data
  99344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99345. */
  99346. offlineProvider: IOfflineProvider;
  99347. /**
  99348. * Gets or sets the action manager associated with the scene
  99349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99350. */
  99351. actionManager: AbstractActionManager;
  99352. private _meshesForIntersections;
  99353. /**
  99354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99355. */
  99356. proceduralTexturesEnabled: boolean;
  99357. private _engine;
  99358. private _totalVertices;
  99359. /** @hidden */
  99360. _activeIndices: PerfCounter;
  99361. /** @hidden */
  99362. _activeParticles: PerfCounter;
  99363. /** @hidden */
  99364. _activeBones: PerfCounter;
  99365. private _animationRatio;
  99366. /** @hidden */
  99367. _animationTimeLast: number;
  99368. /** @hidden */
  99369. _animationTime: number;
  99370. /**
  99371. * Gets or sets a general scale for animation speed
  99372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99373. */
  99374. animationTimeScale: number;
  99375. /** @hidden */
  99376. _cachedMaterial: Nullable<Material>;
  99377. /** @hidden */
  99378. _cachedEffect: Nullable<Effect>;
  99379. /** @hidden */
  99380. _cachedVisibility: Nullable<number>;
  99381. private _renderId;
  99382. private _frameId;
  99383. private _executeWhenReadyTimeoutId;
  99384. private _intermediateRendering;
  99385. private _viewUpdateFlag;
  99386. private _projectionUpdateFlag;
  99387. /** @hidden */
  99388. _toBeDisposed: Nullable<IDisposable>[];
  99389. private _activeRequests;
  99390. /** @hidden */
  99391. _pendingData: any[];
  99392. private _isDisposed;
  99393. /**
  99394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99396. */
  99397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99398. private _activeMeshes;
  99399. private _processedMaterials;
  99400. private _renderTargets;
  99401. /** @hidden */
  99402. _activeParticleSystems: SmartArray<IParticleSystem>;
  99403. private _activeSkeletons;
  99404. private _softwareSkinnedMeshes;
  99405. private _renderingManager;
  99406. /** @hidden */
  99407. _activeAnimatables: Animatable[];
  99408. private _transformMatrix;
  99409. private _sceneUbo;
  99410. /** @hidden */
  99411. _viewMatrix: Matrix;
  99412. private _projectionMatrix;
  99413. /** @hidden */
  99414. _forcedViewPosition: Nullable<Vector3>;
  99415. /** @hidden */
  99416. _frustumPlanes: Plane[];
  99417. /**
  99418. * Gets the list of frustum planes (built from the active camera)
  99419. */
  99420. readonly frustumPlanes: Plane[];
  99421. /**
  99422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99423. * This is useful if there are more lights that the maximum simulteanous authorized
  99424. */
  99425. requireLightSorting: boolean;
  99426. /** @hidden */
  99427. readonly useMaterialMeshMap: boolean;
  99428. /** @hidden */
  99429. readonly useClonedMeshhMap: boolean;
  99430. private _externalData;
  99431. private _uid;
  99432. /**
  99433. * @hidden
  99434. * Backing store of defined scene components.
  99435. */
  99436. _components: ISceneComponent[];
  99437. /**
  99438. * @hidden
  99439. * Backing store of defined scene components.
  99440. */
  99441. _serializableComponents: ISceneSerializableComponent[];
  99442. /**
  99443. * List of components to register on the next registration step.
  99444. */
  99445. private _transientComponents;
  99446. /**
  99447. * Registers the transient components if needed.
  99448. */
  99449. private _registerTransientComponents;
  99450. /**
  99451. * @hidden
  99452. * Add a component to the scene.
  99453. * Note that the ccomponent could be registered on th next frame if this is called after
  99454. * the register component stage.
  99455. * @param component Defines the component to add to the scene
  99456. */
  99457. _addComponent(component: ISceneComponent): void;
  99458. /**
  99459. * @hidden
  99460. * Gets a component from the scene.
  99461. * @param name defines the name of the component to retrieve
  99462. * @returns the component or null if not present
  99463. */
  99464. _getComponent(name: string): Nullable<ISceneComponent>;
  99465. /**
  99466. * @hidden
  99467. * Defines the actions happening before camera updates.
  99468. */
  99469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99470. /**
  99471. * @hidden
  99472. * Defines the actions happening before clear the canvas.
  99473. */
  99474. _beforeClearStage: Stage<SimpleStageAction>;
  99475. /**
  99476. * @hidden
  99477. * Defines the actions when collecting render targets for the frame.
  99478. */
  99479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99480. /**
  99481. * @hidden
  99482. * Defines the actions happening for one camera in the frame.
  99483. */
  99484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99485. /**
  99486. * @hidden
  99487. * Defines the actions happening during the per mesh ready checks.
  99488. */
  99489. _isReadyForMeshStage: Stage<MeshStageAction>;
  99490. /**
  99491. * @hidden
  99492. * Defines the actions happening before evaluate active mesh checks.
  99493. */
  99494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99495. /**
  99496. * @hidden
  99497. * Defines the actions happening during the evaluate sub mesh checks.
  99498. */
  99499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99500. /**
  99501. * @hidden
  99502. * Defines the actions happening during the active mesh stage.
  99503. */
  99504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99505. /**
  99506. * @hidden
  99507. * Defines the actions happening during the per camera render target step.
  99508. */
  99509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99510. /**
  99511. * @hidden
  99512. * Defines the actions happening just before the active camera is drawing.
  99513. */
  99514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99515. /**
  99516. * @hidden
  99517. * Defines the actions happening just before a render target is drawing.
  99518. */
  99519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99520. /**
  99521. * @hidden
  99522. * Defines the actions happening just before a rendering group is drawing.
  99523. */
  99524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99525. /**
  99526. * @hidden
  99527. * Defines the actions happening just before a mesh is drawing.
  99528. */
  99529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99530. /**
  99531. * @hidden
  99532. * Defines the actions happening just after a mesh has been drawn.
  99533. */
  99534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99535. /**
  99536. * @hidden
  99537. * Defines the actions happening just after a rendering group has been drawn.
  99538. */
  99539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99540. /**
  99541. * @hidden
  99542. * Defines the actions happening just after the active camera has been drawn.
  99543. */
  99544. _afterCameraDrawStage: Stage<CameraStageAction>;
  99545. /**
  99546. * @hidden
  99547. * Defines the actions happening just after a render target has been drawn.
  99548. */
  99549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99550. /**
  99551. * @hidden
  99552. * Defines the actions happening just after rendering all cameras and computing intersections.
  99553. */
  99554. _afterRenderStage: Stage<SimpleStageAction>;
  99555. /**
  99556. * @hidden
  99557. * Defines the actions happening when a pointer move event happens.
  99558. */
  99559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99560. /**
  99561. * @hidden
  99562. * Defines the actions happening when a pointer down event happens.
  99563. */
  99564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99565. /**
  99566. * @hidden
  99567. * Defines the actions happening when a pointer up event happens.
  99568. */
  99569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99570. /**
  99571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99572. */
  99573. private geometriesByUniqueId;
  99574. /**
  99575. * Creates a new Scene
  99576. * @param engine defines the engine to use to render this scene
  99577. * @param options defines the scene options
  99578. */
  99579. constructor(engine: Engine, options?: SceneOptions);
  99580. /**
  99581. * Gets a string idenfifying the name of the class
  99582. * @returns "Scene" string
  99583. */
  99584. getClassName(): string;
  99585. private _defaultMeshCandidates;
  99586. /**
  99587. * @hidden
  99588. */
  99589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99590. private _defaultSubMeshCandidates;
  99591. /**
  99592. * @hidden
  99593. */
  99594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99595. /**
  99596. * Sets the default candidate providers for the scene.
  99597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99598. * and getCollidingSubMeshCandidates to their default function
  99599. */
  99600. setDefaultCandidateProviders(): void;
  99601. /**
  99602. * Gets the mesh that is currently under the pointer
  99603. */
  99604. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99605. /**
  99606. * Gets or sets the current on-screen X position of the pointer
  99607. */
  99608. pointerX: number;
  99609. /**
  99610. * Gets or sets the current on-screen Y position of the pointer
  99611. */
  99612. pointerY: number;
  99613. /**
  99614. * Gets the cached material (ie. the latest rendered one)
  99615. * @returns the cached material
  99616. */
  99617. getCachedMaterial(): Nullable<Material>;
  99618. /**
  99619. * Gets the cached effect (ie. the latest rendered one)
  99620. * @returns the cached effect
  99621. */
  99622. getCachedEffect(): Nullable<Effect>;
  99623. /**
  99624. * Gets the cached visibility state (ie. the latest rendered one)
  99625. * @returns the cached visibility state
  99626. */
  99627. getCachedVisibility(): Nullable<number>;
  99628. /**
  99629. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99630. * @param material defines the current material
  99631. * @param effect defines the current effect
  99632. * @param visibility defines the current visibility state
  99633. * @returns true if one parameter is not cached
  99634. */
  99635. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99636. /**
  99637. * Gets the engine associated with the scene
  99638. * @returns an Engine
  99639. */
  99640. getEngine(): Engine;
  99641. /**
  99642. * Gets the total number of vertices rendered per frame
  99643. * @returns the total number of vertices rendered per frame
  99644. */
  99645. getTotalVertices(): number;
  99646. /**
  99647. * Gets the performance counter for total vertices
  99648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99649. */
  99650. readonly totalVerticesPerfCounter: PerfCounter;
  99651. /**
  99652. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99653. * @returns the total number of active indices rendered per frame
  99654. */
  99655. getActiveIndices(): number;
  99656. /**
  99657. * Gets the performance counter for active indices
  99658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99659. */
  99660. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99661. /**
  99662. * Gets the total number of active particles rendered per frame
  99663. * @returns the total number of active particles rendered per frame
  99664. */
  99665. getActiveParticles(): number;
  99666. /**
  99667. * Gets the performance counter for active particles
  99668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99669. */
  99670. readonly activeParticlesPerfCounter: PerfCounter;
  99671. /**
  99672. * Gets the total number of active bones rendered per frame
  99673. * @returns the total number of active bones rendered per frame
  99674. */
  99675. getActiveBones(): number;
  99676. /**
  99677. * Gets the performance counter for active bones
  99678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99679. */
  99680. readonly activeBonesPerfCounter: PerfCounter;
  99681. /**
  99682. * Gets the array of active meshes
  99683. * @returns an array of AbstractMesh
  99684. */
  99685. getActiveMeshes(): SmartArray<AbstractMesh>;
  99686. /**
  99687. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99688. * @returns a number
  99689. */
  99690. getAnimationRatio(): number;
  99691. /**
  99692. * Gets an unique Id for the current render phase
  99693. * @returns a number
  99694. */
  99695. getRenderId(): number;
  99696. /**
  99697. * Gets an unique Id for the current frame
  99698. * @returns a number
  99699. */
  99700. getFrameId(): number;
  99701. /** Call this function if you want to manually increment the render Id*/
  99702. incrementRenderId(): void;
  99703. private _createUbo;
  99704. /**
  99705. * Use this method to simulate a pointer move on a mesh
  99706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99709. * @returns the current scene
  99710. */
  99711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99712. /**
  99713. * Use this method to simulate a pointer down on a mesh
  99714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99717. * @returns the current scene
  99718. */
  99719. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99720. /**
  99721. * Use this method to simulate a pointer up on a mesh
  99722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99725. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99726. * @returns the current scene
  99727. */
  99728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99729. /**
  99730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99732. * @returns true if the pointer was captured
  99733. */
  99734. isPointerCaptured(pointerId?: number): boolean;
  99735. /**
  99736. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99737. * @param attachUp defines if you want to attach events to pointerup
  99738. * @param attachDown defines if you want to attach events to pointerdown
  99739. * @param attachMove defines if you want to attach events to pointermove
  99740. */
  99741. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99742. /** Detaches all event handlers*/
  99743. detachControl(): void;
  99744. /**
  99745. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99746. * Delay loaded resources are not taking in account
  99747. * @return true if all required resources are ready
  99748. */
  99749. isReady(): boolean;
  99750. /** Resets all cached information relative to material (including effect and visibility) */
  99751. resetCachedMaterial(): void;
  99752. /**
  99753. * Registers a function to be called before every frame render
  99754. * @param func defines the function to register
  99755. */
  99756. registerBeforeRender(func: () => void): void;
  99757. /**
  99758. * Unregisters a function called before every frame render
  99759. * @param func defines the function to unregister
  99760. */
  99761. unregisterBeforeRender(func: () => void): void;
  99762. /**
  99763. * Registers a function to be called after every frame render
  99764. * @param func defines the function to register
  99765. */
  99766. registerAfterRender(func: () => void): void;
  99767. /**
  99768. * Unregisters a function called after every frame render
  99769. * @param func defines the function to unregister
  99770. */
  99771. unregisterAfterRender(func: () => void): void;
  99772. private _executeOnceBeforeRender;
  99773. /**
  99774. * The provided function will run before render once and will be disposed afterwards.
  99775. * A timeout delay can be provided so that the function will be executed in N ms.
  99776. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99777. * @param func The function to be executed.
  99778. * @param timeout optional delay in ms
  99779. */
  99780. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99781. /** @hidden */
  99782. _addPendingData(data: any): void;
  99783. /** @hidden */
  99784. _removePendingData(data: any): void;
  99785. /**
  99786. * Returns the number of items waiting to be loaded
  99787. * @returns the number of items waiting to be loaded
  99788. */
  99789. getWaitingItemsCount(): number;
  99790. /**
  99791. * Returns a boolean indicating if the scene is still loading data
  99792. */
  99793. readonly isLoading: boolean;
  99794. /**
  99795. * Registers a function to be executed when the scene is ready
  99796. * @param {Function} func - the function to be executed
  99797. */
  99798. executeWhenReady(func: () => void): void;
  99799. /**
  99800. * Returns a promise that resolves when the scene is ready
  99801. * @returns A promise that resolves when the scene is ready
  99802. */
  99803. whenReadyAsync(): Promise<void>;
  99804. /** @hidden */
  99805. _checkIsReady(): void;
  99806. /**
  99807. * Gets all animatable attached to the scene
  99808. */
  99809. readonly animatables: Animatable[];
  99810. /**
  99811. * Resets the last animation time frame.
  99812. * Useful to override when animations start running when loading a scene for the first time.
  99813. */
  99814. resetLastAnimationTimeFrame(): void;
  99815. /**
  99816. * Gets the current view matrix
  99817. * @returns a Matrix
  99818. */
  99819. getViewMatrix(): Matrix;
  99820. /**
  99821. * Gets the current projection matrix
  99822. * @returns a Matrix
  99823. */
  99824. getProjectionMatrix(): Matrix;
  99825. /**
  99826. * Gets the current transform matrix
  99827. * @returns a Matrix made of View * Projection
  99828. */
  99829. getTransformMatrix(): Matrix;
  99830. /**
  99831. * Sets the current transform matrix
  99832. * @param viewL defines the View matrix to use
  99833. * @param projectionL defines the Projection matrix to use
  99834. * @param viewR defines the right View matrix to use (if provided)
  99835. * @param projectionR defines the right Projection matrix to use (if provided)
  99836. */
  99837. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99838. /**
  99839. * Gets the uniform buffer used to store scene data
  99840. * @returns a UniformBuffer
  99841. */
  99842. getSceneUniformBuffer(): UniformBuffer;
  99843. /**
  99844. * Gets an unique (relatively to the current scene) Id
  99845. * @returns an unique number for the scene
  99846. */
  99847. getUniqueId(): number;
  99848. /**
  99849. * Add a mesh to the list of scene's meshes
  99850. * @param newMesh defines the mesh to add
  99851. * @param recursive if all child meshes should also be added to the scene
  99852. */
  99853. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99854. /**
  99855. * Remove a mesh for the list of scene's meshes
  99856. * @param toRemove defines the mesh to remove
  99857. * @param recursive if all child meshes should also be removed from the scene
  99858. * @returns the index where the mesh was in the mesh list
  99859. */
  99860. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99861. /**
  99862. * Add a transform node to the list of scene's transform nodes
  99863. * @param newTransformNode defines the transform node to add
  99864. */
  99865. addTransformNode(newTransformNode: TransformNode): void;
  99866. /**
  99867. * Remove a transform node for the list of scene's transform nodes
  99868. * @param toRemove defines the transform node to remove
  99869. * @returns the index where the transform node was in the transform node list
  99870. */
  99871. removeTransformNode(toRemove: TransformNode): number;
  99872. /**
  99873. * Remove a skeleton for the list of scene's skeletons
  99874. * @param toRemove defines the skeleton to remove
  99875. * @returns the index where the skeleton was in the skeleton list
  99876. */
  99877. removeSkeleton(toRemove: Skeleton): number;
  99878. /**
  99879. * Remove a morph target for the list of scene's morph targets
  99880. * @param toRemove defines the morph target to remove
  99881. * @returns the index where the morph target was in the morph target list
  99882. */
  99883. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99884. /**
  99885. * Remove a light for the list of scene's lights
  99886. * @param toRemove defines the light to remove
  99887. * @returns the index where the light was in the light list
  99888. */
  99889. removeLight(toRemove: Light): number;
  99890. /**
  99891. * Remove a camera for the list of scene's cameras
  99892. * @param toRemove defines the camera to remove
  99893. * @returns the index where the camera was in the camera list
  99894. */
  99895. removeCamera(toRemove: Camera): number;
  99896. /**
  99897. * Remove a particle system for the list of scene's particle systems
  99898. * @param toRemove defines the particle system to remove
  99899. * @returns the index where the particle system was in the particle system list
  99900. */
  99901. removeParticleSystem(toRemove: IParticleSystem): number;
  99902. /**
  99903. * Remove a animation for the list of scene's animations
  99904. * @param toRemove defines the animation to remove
  99905. * @returns the index where the animation was in the animation list
  99906. */
  99907. removeAnimation(toRemove: Animation): number;
  99908. /**
  99909. * Will stop the animation of the given target
  99910. * @param target - the target
  99911. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99912. * @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)
  99913. */
  99914. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99915. /**
  99916. * Removes the given animation group from this scene.
  99917. * @param toRemove The animation group to remove
  99918. * @returns The index of the removed animation group
  99919. */
  99920. removeAnimationGroup(toRemove: AnimationGroup): number;
  99921. /**
  99922. * Removes the given multi-material from this scene.
  99923. * @param toRemove The multi-material to remove
  99924. * @returns The index of the removed multi-material
  99925. */
  99926. removeMultiMaterial(toRemove: MultiMaterial): number;
  99927. /**
  99928. * Removes the given material from this scene.
  99929. * @param toRemove The material to remove
  99930. * @returns The index of the removed material
  99931. */
  99932. removeMaterial(toRemove: Material): number;
  99933. /**
  99934. * Removes the given action manager from this scene.
  99935. * @param toRemove The action manager to remove
  99936. * @returns The index of the removed action manager
  99937. */
  99938. removeActionManager(toRemove: AbstractActionManager): number;
  99939. /**
  99940. * Removes the given texture from this scene.
  99941. * @param toRemove The texture to remove
  99942. * @returns The index of the removed texture
  99943. */
  99944. removeTexture(toRemove: BaseTexture): number;
  99945. /**
  99946. * Adds the given light to this scene
  99947. * @param newLight The light to add
  99948. */
  99949. addLight(newLight: Light): void;
  99950. /**
  99951. * Sorts the list list based on light priorities
  99952. */
  99953. sortLightsByPriority(): void;
  99954. /**
  99955. * Adds the given camera to this scene
  99956. * @param newCamera The camera to add
  99957. */
  99958. addCamera(newCamera: Camera): void;
  99959. /**
  99960. * Adds the given skeleton to this scene
  99961. * @param newSkeleton The skeleton to add
  99962. */
  99963. addSkeleton(newSkeleton: Skeleton): void;
  99964. /**
  99965. * Adds the given particle system to this scene
  99966. * @param newParticleSystem The particle system to add
  99967. */
  99968. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99969. /**
  99970. * Adds the given animation to this scene
  99971. * @param newAnimation The animation to add
  99972. */
  99973. addAnimation(newAnimation: Animation): void;
  99974. /**
  99975. * Adds the given animation group to this scene.
  99976. * @param newAnimationGroup The animation group to add
  99977. */
  99978. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99979. /**
  99980. * Adds the given multi-material to this scene
  99981. * @param newMultiMaterial The multi-material to add
  99982. */
  99983. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99984. /**
  99985. * Adds the given material to this scene
  99986. * @param newMaterial The material to add
  99987. */
  99988. addMaterial(newMaterial: Material): void;
  99989. /**
  99990. * Adds the given morph target to this scene
  99991. * @param newMorphTargetManager The morph target to add
  99992. */
  99993. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99994. /**
  99995. * Adds the given geometry to this scene
  99996. * @param newGeometry The geometry to add
  99997. */
  99998. addGeometry(newGeometry: Geometry): void;
  99999. /**
  100000. * Adds the given action manager to this scene
  100001. * @param newActionManager The action manager to add
  100002. */
  100003. addActionManager(newActionManager: AbstractActionManager): void;
  100004. /**
  100005. * Adds the given texture to this scene.
  100006. * @param newTexture The texture to add
  100007. */
  100008. addTexture(newTexture: BaseTexture): void;
  100009. /**
  100010. * Switch active camera
  100011. * @param newCamera defines the new active camera
  100012. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100013. */
  100014. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100015. /**
  100016. * sets the active camera of the scene using its ID
  100017. * @param id defines the camera's ID
  100018. * @return the new active camera or null if none found.
  100019. */
  100020. setActiveCameraByID(id: string): Nullable<Camera>;
  100021. /**
  100022. * sets the active camera of the scene using its name
  100023. * @param name defines the camera's name
  100024. * @returns the new active camera or null if none found.
  100025. */
  100026. setActiveCameraByName(name: string): Nullable<Camera>;
  100027. /**
  100028. * get an animation group using its name
  100029. * @param name defines the material's name
  100030. * @return the animation group or null if none found.
  100031. */
  100032. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100033. /**
  100034. * Get a material using its unique id
  100035. * @param uniqueId defines the material's unique id
  100036. * @return the material or null if none found.
  100037. */
  100038. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100039. /**
  100040. * get a material using its id
  100041. * @param id defines the material's ID
  100042. * @return the material or null if none found.
  100043. */
  100044. getMaterialByID(id: string): Nullable<Material>;
  100045. /**
  100046. * Gets a the last added material using a given id
  100047. * @param id defines the material's ID
  100048. * @return the last material with the given id or null if none found.
  100049. */
  100050. getLastMaterialByID(id: string): Nullable<Material>;
  100051. /**
  100052. * Gets a material using its name
  100053. * @param name defines the material's name
  100054. * @return the material or null if none found.
  100055. */
  100056. getMaterialByName(name: string): Nullable<Material>;
  100057. /**
  100058. * Get a texture using its unique id
  100059. * @param uniqueId defines the texture's unique id
  100060. * @return the texture or null if none found.
  100061. */
  100062. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100063. /**
  100064. * Gets a camera using its id
  100065. * @param id defines the id to look for
  100066. * @returns the camera or null if not found
  100067. */
  100068. getCameraByID(id: string): Nullable<Camera>;
  100069. /**
  100070. * Gets a camera using its unique id
  100071. * @param uniqueId defines the unique id to look for
  100072. * @returns the camera or null if not found
  100073. */
  100074. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100075. /**
  100076. * Gets a camera using its name
  100077. * @param name defines the camera's name
  100078. * @return the camera or null if none found.
  100079. */
  100080. getCameraByName(name: string): Nullable<Camera>;
  100081. /**
  100082. * Gets a bone using its id
  100083. * @param id defines the bone's id
  100084. * @return the bone or null if not found
  100085. */
  100086. getBoneByID(id: string): Nullable<Bone>;
  100087. /**
  100088. * Gets a bone using its id
  100089. * @param name defines the bone's name
  100090. * @return the bone or null if not found
  100091. */
  100092. getBoneByName(name: string): Nullable<Bone>;
  100093. /**
  100094. * Gets a light node using its name
  100095. * @param name defines the the light's name
  100096. * @return the light or null if none found.
  100097. */
  100098. getLightByName(name: string): Nullable<Light>;
  100099. /**
  100100. * Gets a light node using its id
  100101. * @param id defines the light's id
  100102. * @return the light or null if none found.
  100103. */
  100104. getLightByID(id: string): Nullable<Light>;
  100105. /**
  100106. * Gets a light node using its scene-generated unique ID
  100107. * @param uniqueId defines the light's unique id
  100108. * @return the light or null if none found.
  100109. */
  100110. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100111. /**
  100112. * Gets a particle system by id
  100113. * @param id defines the particle system id
  100114. * @return the corresponding system or null if none found
  100115. */
  100116. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100117. /**
  100118. * Gets a geometry using its ID
  100119. * @param id defines the geometry's id
  100120. * @return the geometry or null if none found.
  100121. */
  100122. getGeometryByID(id: string): Nullable<Geometry>;
  100123. private _getGeometryByUniqueID;
  100124. /**
  100125. * Add a new geometry to this scene
  100126. * @param geometry defines the geometry to be added to the scene.
  100127. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100128. * @return a boolean defining if the geometry was added or not
  100129. */
  100130. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100131. /**
  100132. * Removes an existing geometry
  100133. * @param geometry defines the geometry to be removed from the scene
  100134. * @return a boolean defining if the geometry was removed or not
  100135. */
  100136. removeGeometry(geometry: Geometry): boolean;
  100137. /**
  100138. * Gets the list of geometries attached to the scene
  100139. * @returns an array of Geometry
  100140. */
  100141. getGeometries(): Geometry[];
  100142. /**
  100143. * Gets the first added mesh found of a given ID
  100144. * @param id defines the id to search for
  100145. * @return the mesh found or null if not found at all
  100146. */
  100147. getMeshByID(id: string): Nullable<AbstractMesh>;
  100148. /**
  100149. * Gets a list of meshes using their id
  100150. * @param id defines the id to search for
  100151. * @returns a list of meshes
  100152. */
  100153. getMeshesByID(id: string): Array<AbstractMesh>;
  100154. /**
  100155. * Gets the first added transform node found of a given ID
  100156. * @param id defines the id to search for
  100157. * @return the found transform node or null if not found at all.
  100158. */
  100159. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100160. /**
  100161. * Gets a transform node with its auto-generated unique id
  100162. * @param uniqueId efines the unique id to search for
  100163. * @return the found transform node or null if not found at all.
  100164. */
  100165. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100166. /**
  100167. * Gets a list of transform nodes using their id
  100168. * @param id defines the id to search for
  100169. * @returns a list of transform nodes
  100170. */
  100171. getTransformNodesByID(id: string): Array<TransformNode>;
  100172. /**
  100173. * Gets a mesh with its auto-generated unique id
  100174. * @param uniqueId defines the unique id to search for
  100175. * @return the found mesh or null if not found at all.
  100176. */
  100177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100178. /**
  100179. * Gets a the last added mesh using a given id
  100180. * @param id defines the id to search for
  100181. * @return the found mesh or null if not found at all.
  100182. */
  100183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100184. /**
  100185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100186. * @param id defines the id to search for
  100187. * @return the found node or null if not found at all
  100188. */
  100189. getLastEntryByID(id: string): Nullable<Node>;
  100190. /**
  100191. * Gets a node (Mesh, Camera, Light) using a given id
  100192. * @param id defines the id to search for
  100193. * @return the found node or null if not found at all
  100194. */
  100195. getNodeByID(id: string): Nullable<Node>;
  100196. /**
  100197. * Gets a node (Mesh, Camera, Light) using a given name
  100198. * @param name defines the name to search for
  100199. * @return the found node or null if not found at all.
  100200. */
  100201. getNodeByName(name: string): Nullable<Node>;
  100202. /**
  100203. * Gets a mesh using a given name
  100204. * @param name defines the name to search for
  100205. * @return the found mesh or null if not found at all.
  100206. */
  100207. getMeshByName(name: string): Nullable<AbstractMesh>;
  100208. /**
  100209. * Gets a transform node using a given name
  100210. * @param name defines the name to search for
  100211. * @return the found transform node or null if not found at all.
  100212. */
  100213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100214. /**
  100215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100216. * @param id defines the id to search for
  100217. * @return the found skeleton or null if not found at all.
  100218. */
  100219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100220. /**
  100221. * Gets a skeleton using a given auto generated unique id
  100222. * @param uniqueId defines the unique id to search for
  100223. * @return the found skeleton or null if not found at all.
  100224. */
  100225. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100226. /**
  100227. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100228. * @param id defines the id to search for
  100229. * @return the found skeleton or null if not found at all.
  100230. */
  100231. getSkeletonById(id: string): Nullable<Skeleton>;
  100232. /**
  100233. * Gets a skeleton using a given name
  100234. * @param name defines the name to search for
  100235. * @return the found skeleton or null if not found at all.
  100236. */
  100237. getSkeletonByName(name: string): Nullable<Skeleton>;
  100238. /**
  100239. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100240. * @param id defines the id to search for
  100241. * @return the found morph target manager or null if not found at all.
  100242. */
  100243. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100244. /**
  100245. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100246. * @param id defines the id to search for
  100247. * @return the found morph target or null if not found at all.
  100248. */
  100249. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100250. /**
  100251. * Gets a boolean indicating if the given mesh is active
  100252. * @param mesh defines the mesh to look for
  100253. * @returns true if the mesh is in the active list
  100254. */
  100255. isActiveMesh(mesh: AbstractMesh): boolean;
  100256. /**
  100257. * Return a unique id as a string which can serve as an identifier for the scene
  100258. */
  100259. readonly uid: string;
  100260. /**
  100261. * Add an externaly attached data from its key.
  100262. * This method call will fail and return false, if such key already exists.
  100263. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100264. * @param key the unique key that identifies the data
  100265. * @param data the data object to associate to the key for this Engine instance
  100266. * @return true if no such key were already present and the data was added successfully, false otherwise
  100267. */
  100268. addExternalData<T>(key: string, data: T): boolean;
  100269. /**
  100270. * Get an externaly attached data from its key
  100271. * @param key the unique key that identifies the data
  100272. * @return the associated data, if present (can be null), or undefined if not present
  100273. */
  100274. getExternalData<T>(key: string): Nullable<T>;
  100275. /**
  100276. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100277. * @param key the unique key that identifies the data
  100278. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100279. * @return the associated data, can be null if the factory returned null.
  100280. */
  100281. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100282. /**
  100283. * Remove an externaly attached data from the Engine instance
  100284. * @param key the unique key that identifies the data
  100285. * @return true if the data was successfully removed, false if it doesn't exist
  100286. */
  100287. removeExternalData(key: string): boolean;
  100288. private _evaluateSubMesh;
  100289. /**
  100290. * Clear the processed materials smart array preventing retention point in material dispose.
  100291. */
  100292. freeProcessedMaterials(): void;
  100293. private _preventFreeActiveMeshesAndRenderingGroups;
  100294. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100295. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100296. * when disposing several meshes in a row or a hierarchy of meshes.
  100297. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100298. */
  100299. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100300. /**
  100301. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100302. */
  100303. freeActiveMeshes(): void;
  100304. /**
  100305. * Clear the info related to rendering groups preventing retention points during dispose.
  100306. */
  100307. freeRenderingGroups(): void;
  100308. /** @hidden */
  100309. _isInIntermediateRendering(): boolean;
  100310. /**
  100311. * Lambda returning the list of potentially active meshes.
  100312. */
  100313. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100314. /**
  100315. * Lambda returning the list of potentially active sub meshes.
  100316. */
  100317. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100318. /**
  100319. * Lambda returning the list of potentially intersecting sub meshes.
  100320. */
  100321. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100322. /**
  100323. * Lambda returning the list of potentially colliding sub meshes.
  100324. */
  100325. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100326. private _activeMeshesFrozen;
  100327. /**
  100328. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100329. * @returns the current scene
  100330. */
  100331. freezeActiveMeshes(): Scene;
  100332. /**
  100333. * Use this function to restart evaluating active meshes on every frame
  100334. * @returns the current scene
  100335. */
  100336. unfreezeActiveMeshes(): Scene;
  100337. private _evaluateActiveMeshes;
  100338. private _activeMesh;
  100339. /**
  100340. * Update the transform matrix to update from the current active camera
  100341. * @param force defines a boolean used to force the update even if cache is up to date
  100342. */
  100343. updateTransformMatrix(force?: boolean): void;
  100344. private _bindFrameBuffer;
  100345. /** @hidden */
  100346. _allowPostProcessClearColor: boolean;
  100347. /** @hidden */
  100348. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100349. private _processSubCameras;
  100350. private _checkIntersections;
  100351. /** @hidden */
  100352. _advancePhysicsEngineStep(step: number): void;
  100353. /**
  100354. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100355. */
  100356. getDeterministicFrameTime: () => number;
  100357. /** @hidden */
  100358. _animate(): void;
  100359. /** Execute all animations (for a frame) */
  100360. animate(): void;
  100361. /**
  100362. * Render the scene
  100363. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100364. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100365. */
  100366. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100367. /**
  100368. * Freeze all materials
  100369. * A frozen material will not be updatable but should be faster to render
  100370. */
  100371. freezeMaterials(): void;
  100372. /**
  100373. * Unfreeze all materials
  100374. * A frozen material will not be updatable but should be faster to render
  100375. */
  100376. unfreezeMaterials(): void;
  100377. /**
  100378. * Releases all held ressources
  100379. */
  100380. dispose(): void;
  100381. /**
  100382. * Gets if the scene is already disposed
  100383. */
  100384. readonly isDisposed: boolean;
  100385. /**
  100386. * Call this function to reduce memory footprint of the scene.
  100387. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100388. */
  100389. clearCachedVertexData(): void;
  100390. /**
  100391. * This function will remove the local cached buffer data from texture.
  100392. * It will save memory but will prevent the texture from being rebuilt
  100393. */
  100394. cleanCachedTextureBuffer(): void;
  100395. /**
  100396. * Get the world extend vectors with an optional filter
  100397. *
  100398. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100399. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100400. */
  100401. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100402. min: Vector3;
  100403. max: Vector3;
  100404. };
  100405. /**
  100406. * Creates a ray that can be used to pick in the scene
  100407. * @param x defines the x coordinate of the origin (on-screen)
  100408. * @param y defines the y coordinate of the origin (on-screen)
  100409. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100410. * @param camera defines the camera to use for the picking
  100411. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100412. * @returns a Ray
  100413. */
  100414. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100415. /**
  100416. * Creates a ray that can be used to pick in the scene
  100417. * @param x defines the x coordinate of the origin (on-screen)
  100418. * @param y defines the y coordinate of the origin (on-screen)
  100419. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100420. * @param result defines the ray where to store the picking ray
  100421. * @param camera defines the camera to use for the picking
  100422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100423. * @returns the current scene
  100424. */
  100425. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100426. /**
  100427. * Creates a ray that can be used to pick in the scene
  100428. * @param x defines the x coordinate of the origin (on-screen)
  100429. * @param y defines the y coordinate of the origin (on-screen)
  100430. * @param camera defines the camera to use for the picking
  100431. * @returns a Ray
  100432. */
  100433. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100434. /**
  100435. * Creates a ray that can be used to pick in the scene
  100436. * @param x defines the x coordinate of the origin (on-screen)
  100437. * @param y defines the y coordinate of the origin (on-screen)
  100438. * @param result defines the ray where to store the picking ray
  100439. * @param camera defines the camera to use for the picking
  100440. * @returns the current scene
  100441. */
  100442. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100443. /** Launch a ray to try to pick a mesh in the scene
  100444. * @param x position on screen
  100445. * @param y position on screen
  100446. * @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
  100447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100448. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100450. * @returns a PickingInfo
  100451. */
  100452. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100453. /** Use the given ray to pick a mesh in the scene
  100454. * @param ray The ray to use to pick meshes
  100455. * @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
  100456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100458. * @returns a PickingInfo
  100459. */
  100460. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100461. /**
  100462. * Launch a ray to try to pick a mesh in the scene
  100463. * @param x X position on screen
  100464. * @param y Y position on screen
  100465. * @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
  100466. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100468. * @returns an array of PickingInfo
  100469. */
  100470. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100471. /**
  100472. * Launch a ray to try to pick a mesh in the scene
  100473. * @param ray Ray to use
  100474. * @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
  100475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100476. * @returns an array of PickingInfo
  100477. */
  100478. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100479. /**
  100480. * Force the value of meshUnderPointer
  100481. * @param mesh defines the mesh to use
  100482. */
  100483. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100484. /**
  100485. * Gets the mesh under the pointer
  100486. * @returns a Mesh or null if no mesh is under the pointer
  100487. */
  100488. getPointerOverMesh(): Nullable<AbstractMesh>;
  100489. /** @hidden */
  100490. _rebuildGeometries(): void;
  100491. /** @hidden */
  100492. _rebuildTextures(): void;
  100493. private _getByTags;
  100494. /**
  100495. * Get a list of meshes by tags
  100496. * @param tagsQuery defines the tags query to use
  100497. * @param forEach defines a predicate used to filter results
  100498. * @returns an array of Mesh
  100499. */
  100500. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100501. /**
  100502. * Get a list of cameras by tags
  100503. * @param tagsQuery defines the tags query to use
  100504. * @param forEach defines a predicate used to filter results
  100505. * @returns an array of Camera
  100506. */
  100507. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100508. /**
  100509. * Get a list of lights by tags
  100510. * @param tagsQuery defines the tags query to use
  100511. * @param forEach defines a predicate used to filter results
  100512. * @returns an array of Light
  100513. */
  100514. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100515. /**
  100516. * Get a list of materials by tags
  100517. * @param tagsQuery defines the tags query to use
  100518. * @param forEach defines a predicate used to filter results
  100519. * @returns an array of Material
  100520. */
  100521. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100522. /**
  100523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100524. * This allowed control for front to back rendering or reversly depending of the special needs.
  100525. *
  100526. * @param renderingGroupId The rendering group id corresponding to its index
  100527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100530. */
  100531. 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;
  100532. /**
  100533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100534. *
  100535. * @param renderingGroupId The rendering group id corresponding to its index
  100536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100539. */
  100540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100541. /**
  100542. * Gets the current auto clear configuration for one rendering group of the rendering
  100543. * manager.
  100544. * @param index the rendering group index to get the information for
  100545. * @returns The auto clear setup for the requested rendering group
  100546. */
  100547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100548. private _blockMaterialDirtyMechanism;
  100549. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100550. blockMaterialDirtyMechanism: boolean;
  100551. /**
  100552. * Will flag all materials as dirty to trigger new shader compilation
  100553. * @param flag defines the flag used to specify which material part must be marked as dirty
  100554. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100555. */
  100556. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100557. /** @hidden */
  100558. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  100559. /** @hidden */
  100560. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100561. }
  100562. }
  100563. declare module BABYLON {
  100564. /**
  100565. * Set of assets to keep when moving a scene into an asset container.
  100566. */
  100567. export class KeepAssets extends AbstractScene {
  100568. }
  100569. /**
  100570. * Container with a set of assets that can be added or removed from a scene.
  100571. */
  100572. export class AssetContainer extends AbstractScene {
  100573. /**
  100574. * The scene the AssetContainer belongs to.
  100575. */
  100576. scene: Scene;
  100577. /**
  100578. * Instantiates an AssetContainer.
  100579. * @param scene The scene the AssetContainer belongs to.
  100580. */
  100581. constructor(scene: Scene);
  100582. /**
  100583. * Adds all the assets from the container to the scene.
  100584. */
  100585. addAllToScene(): void;
  100586. /**
  100587. * Removes all the assets in the container from the scene
  100588. */
  100589. removeAllFromScene(): void;
  100590. /**
  100591. * Disposes all the assets in the container
  100592. */
  100593. dispose(): void;
  100594. private _moveAssets;
  100595. /**
  100596. * Removes all the assets contained in the scene and adds them to the container.
  100597. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100598. */
  100599. moveAllFromScene(keepAssets?: KeepAssets): void;
  100600. /**
  100601. * 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.
  100602. * @returns the root mesh
  100603. */
  100604. createRootMesh(): Mesh;
  100605. }
  100606. }
  100607. declare module BABYLON {
  100608. /**
  100609. * Defines how the parser contract is defined.
  100610. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100611. */
  100612. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100613. /**
  100614. * Defines how the individual parser contract is defined.
  100615. * These parser can parse an individual asset
  100616. */
  100617. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100618. /**
  100619. * Base class of the scene acting as a container for the different elements composing a scene.
  100620. * This class is dynamically extended by the different components of the scene increasing
  100621. * flexibility and reducing coupling
  100622. */
  100623. export abstract class AbstractScene {
  100624. /**
  100625. * Stores the list of available parsers in the application.
  100626. */
  100627. private static _BabylonFileParsers;
  100628. /**
  100629. * Stores the list of available individual parsers in the application.
  100630. */
  100631. private static _IndividualBabylonFileParsers;
  100632. /**
  100633. * Adds a parser in the list of available ones
  100634. * @param name Defines the name of the parser
  100635. * @param parser Defines the parser to add
  100636. */
  100637. static AddParser(name: string, parser: BabylonFileParser): void;
  100638. /**
  100639. * Gets a general parser from the list of avaialble ones
  100640. * @param name Defines the name of the parser
  100641. * @returns the requested parser or null
  100642. */
  100643. static GetParser(name: string): Nullable<BabylonFileParser>;
  100644. /**
  100645. * Adds n individual parser in the list of available ones
  100646. * @param name Defines the name of the parser
  100647. * @param parser Defines the parser to add
  100648. */
  100649. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100650. /**
  100651. * Gets an individual parser from the list of avaialble ones
  100652. * @param name Defines the name of the parser
  100653. * @returns the requested parser or null
  100654. */
  100655. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100656. /**
  100657. * Parser json data and populate both a scene and its associated container object
  100658. * @param jsonData Defines the data to parse
  100659. * @param scene Defines the scene to parse the data for
  100660. * @param container Defines the container attached to the parsing sequence
  100661. * @param rootUrl Defines the root url of the data
  100662. */
  100663. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100664. /**
  100665. * Gets the list of root nodes (ie. nodes with no parent)
  100666. */
  100667. rootNodes: Node[];
  100668. /** All of the cameras added to this scene
  100669. * @see http://doc.babylonjs.com/babylon101/cameras
  100670. */
  100671. cameras: Camera[];
  100672. /**
  100673. * All of the lights added to this scene
  100674. * @see http://doc.babylonjs.com/babylon101/lights
  100675. */
  100676. lights: Light[];
  100677. /**
  100678. * All of the (abstract) meshes added to this scene
  100679. */
  100680. meshes: AbstractMesh[];
  100681. /**
  100682. * The list of skeletons added to the scene
  100683. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100684. */
  100685. skeletons: Skeleton[];
  100686. /**
  100687. * All of the particle systems added to this scene
  100688. * @see http://doc.babylonjs.com/babylon101/particles
  100689. */
  100690. particleSystems: IParticleSystem[];
  100691. /**
  100692. * Gets a list of Animations associated with the scene
  100693. */
  100694. animations: Animation[];
  100695. /**
  100696. * All of the animation groups added to this scene
  100697. * @see http://doc.babylonjs.com/how_to/group
  100698. */
  100699. animationGroups: AnimationGroup[];
  100700. /**
  100701. * All of the multi-materials added to this scene
  100702. * @see http://doc.babylonjs.com/how_to/multi_materials
  100703. */
  100704. multiMaterials: MultiMaterial[];
  100705. /**
  100706. * All of the materials added to this scene
  100707. * In the context of a Scene, it is not supposed to be modified manually.
  100708. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100709. * Note also that the order of the Material wihin the array is not significant and might change.
  100710. * @see http://doc.babylonjs.com/babylon101/materials
  100711. */
  100712. materials: Material[];
  100713. /**
  100714. * The list of morph target managers added to the scene
  100715. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100716. */
  100717. morphTargetManagers: MorphTargetManager[];
  100718. /**
  100719. * The list of geometries used in the scene.
  100720. */
  100721. geometries: Geometry[];
  100722. /**
  100723. * All of the tranform nodes added to this scene
  100724. * In the context of a Scene, it is not supposed to be modified manually.
  100725. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100726. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100727. * @see http://doc.babylonjs.com/how_to/transformnode
  100728. */
  100729. transformNodes: TransformNode[];
  100730. /**
  100731. * ActionManagers available on the scene.
  100732. */
  100733. actionManagers: AbstractActionManager[];
  100734. /**
  100735. * Textures to keep.
  100736. */
  100737. textures: BaseTexture[];
  100738. /**
  100739. * Environment texture for the scene
  100740. */
  100741. environmentTexture: Nullable<BaseTexture>;
  100742. }
  100743. }
  100744. declare module BABYLON {
  100745. /**
  100746. * Interface used to define options for Sound class
  100747. */
  100748. export interface ISoundOptions {
  100749. /**
  100750. * Does the sound autoplay once loaded.
  100751. */
  100752. autoplay?: boolean;
  100753. /**
  100754. * Does the sound loop after it finishes playing once.
  100755. */
  100756. loop?: boolean;
  100757. /**
  100758. * Sound's volume
  100759. */
  100760. volume?: number;
  100761. /**
  100762. * Is it a spatial sound?
  100763. */
  100764. spatialSound?: boolean;
  100765. /**
  100766. * Maximum distance to hear that sound
  100767. */
  100768. maxDistance?: number;
  100769. /**
  100770. * Uses user defined attenuation function
  100771. */
  100772. useCustomAttenuation?: boolean;
  100773. /**
  100774. * Define the roll off factor of spatial sounds.
  100775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100776. */
  100777. rolloffFactor?: number;
  100778. /**
  100779. * Define the reference distance the sound should be heard perfectly.
  100780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100781. */
  100782. refDistance?: number;
  100783. /**
  100784. * Define the distance attenuation model the sound will follow.
  100785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100786. */
  100787. distanceModel?: string;
  100788. /**
  100789. * Defines the playback speed (1 by default)
  100790. */
  100791. playbackRate?: number;
  100792. /**
  100793. * Defines if the sound is from a streaming source
  100794. */
  100795. streaming?: boolean;
  100796. /**
  100797. * Defines an optional length (in seconds) inside the sound file
  100798. */
  100799. length?: number;
  100800. /**
  100801. * Defines an optional offset (in seconds) inside the sound file
  100802. */
  100803. offset?: number;
  100804. /**
  100805. * If true, URLs will not be required to state the audio file codec to use.
  100806. */
  100807. skipCodecCheck?: boolean;
  100808. }
  100809. /**
  100810. * Defines a sound that can be played in the application.
  100811. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100813. */
  100814. export class Sound {
  100815. /**
  100816. * The name of the sound in the scene.
  100817. */
  100818. name: string;
  100819. /**
  100820. * Does the sound autoplay once loaded.
  100821. */
  100822. autoplay: boolean;
  100823. /**
  100824. * Does the sound loop after it finishes playing once.
  100825. */
  100826. loop: boolean;
  100827. /**
  100828. * Does the sound use a custom attenuation curve to simulate the falloff
  100829. * happening when the source gets further away from the camera.
  100830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100831. */
  100832. useCustomAttenuation: boolean;
  100833. /**
  100834. * The sound track id this sound belongs to.
  100835. */
  100836. soundTrackId: number;
  100837. /**
  100838. * Is this sound currently played.
  100839. */
  100840. isPlaying: boolean;
  100841. /**
  100842. * Is this sound currently paused.
  100843. */
  100844. isPaused: boolean;
  100845. /**
  100846. * Does this sound enables spatial sound.
  100847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100848. */
  100849. spatialSound: boolean;
  100850. /**
  100851. * Define the reference distance the sound should be heard perfectly.
  100852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100853. */
  100854. refDistance: number;
  100855. /**
  100856. * Define the roll off factor of spatial sounds.
  100857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100858. */
  100859. rolloffFactor: number;
  100860. /**
  100861. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100863. */
  100864. maxDistance: number;
  100865. /**
  100866. * Define the distance attenuation model the sound will follow.
  100867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100868. */
  100869. distanceModel: string;
  100870. /**
  100871. * @hidden
  100872. * Back Compat
  100873. **/
  100874. onended: () => any;
  100875. /**
  100876. * Observable event when the current playing sound finishes.
  100877. */
  100878. onEndedObservable: Observable<Sound>;
  100879. private _panningModel;
  100880. private _playbackRate;
  100881. private _streaming;
  100882. private _startTime;
  100883. private _startOffset;
  100884. private _position;
  100885. /** @hidden */
  100886. _positionInEmitterSpace: boolean;
  100887. private _localDirection;
  100888. private _volume;
  100889. private _isReadyToPlay;
  100890. private _isDirectional;
  100891. private _readyToPlayCallback;
  100892. private _audioBuffer;
  100893. private _soundSource;
  100894. private _streamingSource;
  100895. private _soundPanner;
  100896. private _soundGain;
  100897. private _inputAudioNode;
  100898. private _outputAudioNode;
  100899. private _coneInnerAngle;
  100900. private _coneOuterAngle;
  100901. private _coneOuterGain;
  100902. private _scene;
  100903. private _connectedTransformNode;
  100904. private _customAttenuationFunction;
  100905. private _registerFunc;
  100906. private _isOutputConnected;
  100907. private _htmlAudioElement;
  100908. private _urlType;
  100909. private _length?;
  100910. private _offset?;
  100911. /** @hidden */
  100912. static _SceneComponentInitialization: (scene: Scene) => void;
  100913. /**
  100914. * Create a sound and attach it to a scene
  100915. * @param name Name of your sound
  100916. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100917. * @param scene defines the scene the sound belongs to
  100918. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100919. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100920. */
  100921. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100922. /**
  100923. * Release the sound and its associated resources
  100924. */
  100925. dispose(): void;
  100926. /**
  100927. * Gets if the sounds is ready to be played or not.
  100928. * @returns true if ready, otherwise false
  100929. */
  100930. isReady(): boolean;
  100931. private _soundLoaded;
  100932. /**
  100933. * Sets the data of the sound from an audiobuffer
  100934. * @param audioBuffer The audioBuffer containing the data
  100935. */
  100936. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100937. /**
  100938. * Updates the current sounds options such as maxdistance, loop...
  100939. * @param options A JSON object containing values named as the object properties
  100940. */
  100941. updateOptions(options: ISoundOptions): void;
  100942. private _createSpatialParameters;
  100943. private _updateSpatialParameters;
  100944. /**
  100945. * Switch the panning model to HRTF:
  100946. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100948. */
  100949. switchPanningModelToHRTF(): void;
  100950. /**
  100951. * Switch the panning model to Equal Power:
  100952. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100954. */
  100955. switchPanningModelToEqualPower(): void;
  100956. private _switchPanningModel;
  100957. /**
  100958. * Connect this sound to a sound track audio node like gain...
  100959. * @param soundTrackAudioNode the sound track audio node to connect to
  100960. */
  100961. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100962. /**
  100963. * Transform this sound into a directional source
  100964. * @param coneInnerAngle Size of the inner cone in degree
  100965. * @param coneOuterAngle Size of the outer cone in degree
  100966. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100967. */
  100968. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100969. /**
  100970. * Gets or sets the inner angle for the directional cone.
  100971. */
  100972. /**
  100973. * Gets or sets the inner angle for the directional cone.
  100974. */
  100975. directionalConeInnerAngle: number;
  100976. /**
  100977. * Gets or sets the outer angle for the directional cone.
  100978. */
  100979. /**
  100980. * Gets or sets the outer angle for the directional cone.
  100981. */
  100982. directionalConeOuterAngle: number;
  100983. /**
  100984. * Sets the position of the emitter if spatial sound is enabled
  100985. * @param newPosition Defines the new posisiton
  100986. */
  100987. setPosition(newPosition: Vector3): void;
  100988. /**
  100989. * Sets the local direction of the emitter if spatial sound is enabled
  100990. * @param newLocalDirection Defines the new local direction
  100991. */
  100992. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100993. private _updateDirection;
  100994. /** @hidden */
  100995. updateDistanceFromListener(): void;
  100996. /**
  100997. * Sets a new custom attenuation function for the sound.
  100998. * @param callback Defines the function used for the attenuation
  100999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101000. */
  101001. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101002. /**
  101003. * Play the sound
  101004. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101005. * @param offset (optional) Start the sound at a specific time in seconds
  101006. * @param length (optional) Sound duration (in seconds)
  101007. */
  101008. play(time?: number, offset?: number, length?: number): void;
  101009. private _onended;
  101010. /**
  101011. * Stop the sound
  101012. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101013. */
  101014. stop(time?: number): void;
  101015. /**
  101016. * Put the sound in pause
  101017. */
  101018. pause(): void;
  101019. /**
  101020. * Sets a dedicated volume for this sounds
  101021. * @param newVolume Define the new volume of the sound
  101022. * @param time Define time for gradual change to new volume
  101023. */
  101024. setVolume(newVolume: number, time?: number): void;
  101025. /**
  101026. * Set the sound play back rate
  101027. * @param newPlaybackRate Define the playback rate the sound should be played at
  101028. */
  101029. setPlaybackRate(newPlaybackRate: number): void;
  101030. /**
  101031. * Gets the volume of the sound.
  101032. * @returns the volume of the sound
  101033. */
  101034. getVolume(): number;
  101035. /**
  101036. * Attach the sound to a dedicated mesh
  101037. * @param transformNode The transform node to connect the sound with
  101038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101039. */
  101040. attachToMesh(transformNode: TransformNode): void;
  101041. /**
  101042. * Detach the sound from the previously attached mesh
  101043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101044. */
  101045. detachFromMesh(): void;
  101046. private _onRegisterAfterWorldMatrixUpdate;
  101047. /**
  101048. * Clone the current sound in the scene.
  101049. * @returns the new sound clone
  101050. */
  101051. clone(): Nullable<Sound>;
  101052. /**
  101053. * Gets the current underlying audio buffer containing the data
  101054. * @returns the audio buffer
  101055. */
  101056. getAudioBuffer(): Nullable<AudioBuffer>;
  101057. /**
  101058. * Serializes the Sound in a JSON representation
  101059. * @returns the JSON representation of the sound
  101060. */
  101061. serialize(): any;
  101062. /**
  101063. * Parse a JSON representation of a sound to innstantiate in a given scene
  101064. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101065. * @param scene Define the scene the new parsed sound should be created in
  101066. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101067. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101068. * @returns the newly parsed sound
  101069. */
  101070. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101071. }
  101072. }
  101073. declare module BABYLON {
  101074. /**
  101075. * This defines an action helpful to play a defined sound on a triggered action.
  101076. */
  101077. export class PlaySoundAction extends Action {
  101078. private _sound;
  101079. /**
  101080. * Instantiate the action
  101081. * @param triggerOptions defines the trigger options
  101082. * @param sound defines the sound to play
  101083. * @param condition defines the trigger related conditions
  101084. */
  101085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101086. /** @hidden */
  101087. _prepare(): void;
  101088. /**
  101089. * Execute the action and play the sound.
  101090. */
  101091. execute(): void;
  101092. /**
  101093. * Serializes the actions and its related information.
  101094. * @param parent defines the object to serialize in
  101095. * @returns the serialized object
  101096. */
  101097. serialize(parent: any): any;
  101098. }
  101099. /**
  101100. * This defines an action helpful to stop a defined sound on a triggered action.
  101101. */
  101102. export class StopSoundAction extends Action {
  101103. private _sound;
  101104. /**
  101105. * Instantiate the action
  101106. * @param triggerOptions defines the trigger options
  101107. * @param sound defines the sound to stop
  101108. * @param condition defines the trigger related conditions
  101109. */
  101110. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101111. /** @hidden */
  101112. _prepare(): void;
  101113. /**
  101114. * Execute the action and stop the sound.
  101115. */
  101116. execute(): void;
  101117. /**
  101118. * Serializes the actions and its related information.
  101119. * @param parent defines the object to serialize in
  101120. * @returns the serialized object
  101121. */
  101122. serialize(parent: any): any;
  101123. }
  101124. }
  101125. declare module BABYLON {
  101126. /**
  101127. * This defines an action responsible to change the value of a property
  101128. * by interpolating between its current value and the newly set one once triggered.
  101129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101130. */
  101131. export class InterpolateValueAction extends Action {
  101132. /**
  101133. * Defines the path of the property where the value should be interpolated
  101134. */
  101135. propertyPath: string;
  101136. /**
  101137. * Defines the target value at the end of the interpolation.
  101138. */
  101139. value: any;
  101140. /**
  101141. * Defines the time it will take for the property to interpolate to the value.
  101142. */
  101143. duration: number;
  101144. /**
  101145. * Defines if the other scene animations should be stopped when the action has been triggered
  101146. */
  101147. stopOtherAnimations?: boolean;
  101148. /**
  101149. * Defines a callback raised once the interpolation animation has been done.
  101150. */
  101151. onInterpolationDone?: () => void;
  101152. /**
  101153. * Observable triggered once the interpolation animation has been done.
  101154. */
  101155. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101156. private _target;
  101157. private _effectiveTarget;
  101158. private _property;
  101159. /**
  101160. * Instantiate the action
  101161. * @param triggerOptions defines the trigger options
  101162. * @param target defines the object containing the value to interpolate
  101163. * @param propertyPath defines the path to the property in the target object
  101164. * @param value defines the target value at the end of the interpolation
  101165. * @param duration deines the time it will take for the property to interpolate to the value.
  101166. * @param condition defines the trigger related conditions
  101167. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101168. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101169. */
  101170. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101171. /** @hidden */
  101172. _prepare(): void;
  101173. /**
  101174. * Execute the action starts the value interpolation.
  101175. */
  101176. execute(): void;
  101177. /**
  101178. * Serializes the actions and its related information.
  101179. * @param parent defines the object to serialize in
  101180. * @returns the serialized object
  101181. */
  101182. serialize(parent: any): any;
  101183. }
  101184. }
  101185. declare module BABYLON {
  101186. /**
  101187. * Options allowed during the creation of a sound track.
  101188. */
  101189. export interface ISoundTrackOptions {
  101190. /**
  101191. * The volume the sound track should take during creation
  101192. */
  101193. volume?: number;
  101194. /**
  101195. * Define if the sound track is the main sound track of the scene
  101196. */
  101197. mainTrack?: boolean;
  101198. }
  101199. /**
  101200. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101201. * It will be also used in a future release to apply effects on a specific track.
  101202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101203. */
  101204. export class SoundTrack {
  101205. /**
  101206. * The unique identifier of the sound track in the scene.
  101207. */
  101208. id: number;
  101209. /**
  101210. * The list of sounds included in the sound track.
  101211. */
  101212. soundCollection: Array<Sound>;
  101213. private _outputAudioNode;
  101214. private _scene;
  101215. private _isMainTrack;
  101216. private _connectedAnalyser;
  101217. private _options;
  101218. private _isInitialized;
  101219. /**
  101220. * Creates a new sound track.
  101221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101222. * @param scene Define the scene the sound track belongs to
  101223. * @param options
  101224. */
  101225. constructor(scene: Scene, options?: ISoundTrackOptions);
  101226. private _initializeSoundTrackAudioGraph;
  101227. /**
  101228. * Release the sound track and its associated resources
  101229. */
  101230. dispose(): void;
  101231. /**
  101232. * Adds a sound to this sound track
  101233. * @param sound define the cound to add
  101234. * @ignoreNaming
  101235. */
  101236. AddSound(sound: Sound): void;
  101237. /**
  101238. * Removes a sound to this sound track
  101239. * @param sound define the cound to remove
  101240. * @ignoreNaming
  101241. */
  101242. RemoveSound(sound: Sound): void;
  101243. /**
  101244. * Set a global volume for the full sound track.
  101245. * @param newVolume Define the new volume of the sound track
  101246. */
  101247. setVolume(newVolume: number): void;
  101248. /**
  101249. * Switch the panning model to HRTF:
  101250. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101252. */
  101253. switchPanningModelToHRTF(): void;
  101254. /**
  101255. * Switch the panning model to Equal Power:
  101256. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101258. */
  101259. switchPanningModelToEqualPower(): void;
  101260. /**
  101261. * Connect the sound track to an audio analyser allowing some amazing
  101262. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101264. * @param analyser The analyser to connect to the engine
  101265. */
  101266. connectToAnalyser(analyser: Analyser): void;
  101267. }
  101268. }
  101269. declare module BABYLON {
  101270. interface AbstractScene {
  101271. /**
  101272. * The list of sounds used in the scene.
  101273. */
  101274. sounds: Nullable<Array<Sound>>;
  101275. }
  101276. interface Scene {
  101277. /**
  101278. * @hidden
  101279. * Backing field
  101280. */
  101281. _mainSoundTrack: SoundTrack;
  101282. /**
  101283. * The main sound track played by the scene.
  101284. * It cotains your primary collection of sounds.
  101285. */
  101286. mainSoundTrack: SoundTrack;
  101287. /**
  101288. * The list of sound tracks added to the scene
  101289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101290. */
  101291. soundTracks: Nullable<Array<SoundTrack>>;
  101292. /**
  101293. * Gets a sound using a given name
  101294. * @param name defines the name to search for
  101295. * @return the found sound or null if not found at all.
  101296. */
  101297. getSoundByName(name: string): Nullable<Sound>;
  101298. /**
  101299. * Gets or sets if audio support is enabled
  101300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101301. */
  101302. audioEnabled: boolean;
  101303. /**
  101304. * Gets or sets if audio will be output to headphones
  101305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101306. */
  101307. headphone: boolean;
  101308. /**
  101309. * Gets or sets custom audio listener position provider
  101310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101311. */
  101312. audioListenerPositionProvider: Nullable<() => Vector3>;
  101313. }
  101314. /**
  101315. * Defines the sound scene component responsible to manage any sounds
  101316. * in a given scene.
  101317. */
  101318. export class AudioSceneComponent implements ISceneSerializableComponent {
  101319. /**
  101320. * The component name helpfull to identify the component in the list of scene components.
  101321. */
  101322. readonly name: string;
  101323. /**
  101324. * The scene the component belongs to.
  101325. */
  101326. scene: Scene;
  101327. private _audioEnabled;
  101328. /**
  101329. * Gets whether audio is enabled or not.
  101330. * Please use related enable/disable method to switch state.
  101331. */
  101332. readonly audioEnabled: boolean;
  101333. private _headphone;
  101334. /**
  101335. * Gets whether audio is outputing to headphone or not.
  101336. * Please use the according Switch methods to change output.
  101337. */
  101338. readonly headphone: boolean;
  101339. private _audioListenerPositionProvider;
  101340. /**
  101341. * Gets the current audio listener position provider
  101342. */
  101343. /**
  101344. * Sets a custom listener position for all sounds in the scene
  101345. * By default, this is the position of the first active camera
  101346. */
  101347. audioListenerPositionProvider: Nullable<() => Vector3>;
  101348. /**
  101349. * Creates a new instance of the component for the given scene
  101350. * @param scene Defines the scene to register the component in
  101351. */
  101352. constructor(scene: Scene);
  101353. /**
  101354. * Registers the component in a given scene
  101355. */
  101356. register(): void;
  101357. /**
  101358. * Rebuilds the elements related to this component in case of
  101359. * context lost for instance.
  101360. */
  101361. rebuild(): void;
  101362. /**
  101363. * Serializes the component data to the specified json object
  101364. * @param serializationObject The object to serialize to
  101365. */
  101366. serialize(serializationObject: any): void;
  101367. /**
  101368. * Adds all the elements from the container to the scene
  101369. * @param container the container holding the elements
  101370. */
  101371. addFromContainer(container: AbstractScene): void;
  101372. /**
  101373. * Removes all the elements in the container from the scene
  101374. * @param container contains the elements to remove
  101375. * @param dispose if the removed element should be disposed (default: false)
  101376. */
  101377. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101378. /**
  101379. * Disposes the component and the associated ressources.
  101380. */
  101381. dispose(): void;
  101382. /**
  101383. * Disables audio in the associated scene.
  101384. */
  101385. disableAudio(): void;
  101386. /**
  101387. * Enables audio in the associated scene.
  101388. */
  101389. enableAudio(): void;
  101390. /**
  101391. * Switch audio to headphone output.
  101392. */
  101393. switchAudioModeForHeadphones(): void;
  101394. /**
  101395. * Switch audio to normal speakers.
  101396. */
  101397. switchAudioModeForNormalSpeakers(): void;
  101398. private _afterRender;
  101399. }
  101400. }
  101401. declare module BABYLON {
  101402. /**
  101403. * Wraps one or more Sound objects and selects one with random weight for playback.
  101404. */
  101405. export class WeightedSound {
  101406. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101407. loop: boolean;
  101408. private _coneInnerAngle;
  101409. private _coneOuterAngle;
  101410. private _volume;
  101411. /** A Sound is currently playing. */
  101412. isPlaying: boolean;
  101413. /** A Sound is currently paused. */
  101414. isPaused: boolean;
  101415. private _sounds;
  101416. private _weights;
  101417. private _currentIndex?;
  101418. /**
  101419. * Creates a new WeightedSound from the list of sounds given.
  101420. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101421. * @param sounds Array of Sounds that will be selected from.
  101422. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101423. */
  101424. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101425. /**
  101426. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101427. */
  101428. /**
  101429. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101430. */
  101431. directionalConeInnerAngle: number;
  101432. /**
  101433. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101434. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101435. */
  101436. /**
  101437. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101438. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101439. */
  101440. directionalConeOuterAngle: number;
  101441. /**
  101442. * Playback volume.
  101443. */
  101444. /**
  101445. * Playback volume.
  101446. */
  101447. volume: number;
  101448. private _onended;
  101449. /**
  101450. * Suspend playback
  101451. */
  101452. pause(): void;
  101453. /**
  101454. * Stop playback
  101455. */
  101456. stop(): void;
  101457. /**
  101458. * Start playback.
  101459. * @param startOffset Position the clip head at a specific time in seconds.
  101460. */
  101461. play(startOffset?: number): void;
  101462. }
  101463. }
  101464. declare module BABYLON {
  101465. /**
  101466. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101467. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101468. */
  101469. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101470. /**
  101471. * Gets the name of the behavior.
  101472. */
  101473. readonly name: string;
  101474. /**
  101475. * The easing function used by animations
  101476. */
  101477. static EasingFunction: BackEase;
  101478. /**
  101479. * The easing mode used by animations
  101480. */
  101481. static EasingMode: number;
  101482. /**
  101483. * The duration of the animation, in milliseconds
  101484. */
  101485. transitionDuration: number;
  101486. /**
  101487. * Length of the distance animated by the transition when lower radius is reached
  101488. */
  101489. lowerRadiusTransitionRange: number;
  101490. /**
  101491. * Length of the distance animated by the transition when upper radius is reached
  101492. */
  101493. upperRadiusTransitionRange: number;
  101494. private _autoTransitionRange;
  101495. /**
  101496. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101497. */
  101498. /**
  101499. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101500. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101501. */
  101502. autoTransitionRange: boolean;
  101503. private _attachedCamera;
  101504. private _onAfterCheckInputsObserver;
  101505. private _onMeshTargetChangedObserver;
  101506. /**
  101507. * Initializes the behavior.
  101508. */
  101509. init(): void;
  101510. /**
  101511. * Attaches the behavior to its arc rotate camera.
  101512. * @param camera Defines the camera to attach the behavior to
  101513. */
  101514. attach(camera: ArcRotateCamera): void;
  101515. /**
  101516. * Detaches the behavior from its current arc rotate camera.
  101517. */
  101518. detach(): void;
  101519. private _radiusIsAnimating;
  101520. private _radiusBounceTransition;
  101521. private _animatables;
  101522. private _cachedWheelPrecision;
  101523. /**
  101524. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101525. * @param radiusLimit The limit to check against.
  101526. * @return Bool to indicate if at limit.
  101527. */
  101528. private _isRadiusAtLimit;
  101529. /**
  101530. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101531. * @param radiusDelta The delta by which to animate to. Can be negative.
  101532. */
  101533. private _applyBoundRadiusAnimation;
  101534. /**
  101535. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101536. */
  101537. protected _clearAnimationLocks(): void;
  101538. /**
  101539. * Stops and removes all animations that have been applied to the camera
  101540. */
  101541. stopAllAnimations(): void;
  101542. }
  101543. }
  101544. declare module BABYLON {
  101545. /**
  101546. * 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.
  101547. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101548. */
  101549. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101550. /**
  101551. * Gets the name of the behavior.
  101552. */
  101553. readonly name: string;
  101554. private _mode;
  101555. private _radiusScale;
  101556. private _positionScale;
  101557. private _defaultElevation;
  101558. private _elevationReturnTime;
  101559. private _elevationReturnWaitTime;
  101560. private _zoomStopsAnimation;
  101561. private _framingTime;
  101562. /**
  101563. * The easing function used by animations
  101564. */
  101565. static EasingFunction: ExponentialEase;
  101566. /**
  101567. * The easing mode used by animations
  101568. */
  101569. static EasingMode: number;
  101570. /**
  101571. * Sets the current mode used by the behavior
  101572. */
  101573. /**
  101574. * Gets current mode used by the behavior.
  101575. */
  101576. mode: number;
  101577. /**
  101578. * Sets the scale applied to the radius (1 by default)
  101579. */
  101580. /**
  101581. * Gets the scale applied to the radius
  101582. */
  101583. radiusScale: number;
  101584. /**
  101585. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101586. */
  101587. /**
  101588. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101589. */
  101590. positionScale: number;
  101591. /**
  101592. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101593. * behaviour is triggered, in radians.
  101594. */
  101595. /**
  101596. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101597. * behaviour is triggered, in radians.
  101598. */
  101599. defaultElevation: number;
  101600. /**
  101601. * Sets the time (in milliseconds) taken to return to the default beta position.
  101602. * Negative value indicates camera should not return to default.
  101603. */
  101604. /**
  101605. * Gets the time (in milliseconds) taken to return to the default beta position.
  101606. * Negative value indicates camera should not return to default.
  101607. */
  101608. elevationReturnTime: number;
  101609. /**
  101610. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101611. */
  101612. /**
  101613. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101614. */
  101615. elevationReturnWaitTime: number;
  101616. /**
  101617. * Sets the flag that indicates if user zooming should stop animation.
  101618. */
  101619. /**
  101620. * Gets the flag that indicates if user zooming should stop animation.
  101621. */
  101622. zoomStopsAnimation: boolean;
  101623. /**
  101624. * Sets the transition time when framing the mesh, in milliseconds
  101625. */
  101626. /**
  101627. * Gets the transition time when framing the mesh, in milliseconds
  101628. */
  101629. framingTime: number;
  101630. /**
  101631. * Define if the behavior should automatically change the configured
  101632. * camera limits and sensibilities.
  101633. */
  101634. autoCorrectCameraLimitsAndSensibility: boolean;
  101635. private _onPrePointerObservableObserver;
  101636. private _onAfterCheckInputsObserver;
  101637. private _onMeshTargetChangedObserver;
  101638. private _attachedCamera;
  101639. private _isPointerDown;
  101640. private _lastInteractionTime;
  101641. /**
  101642. * Initializes the behavior.
  101643. */
  101644. init(): void;
  101645. /**
  101646. * Attaches the behavior to its arc rotate camera.
  101647. * @param camera Defines the camera to attach the behavior to
  101648. */
  101649. attach(camera: ArcRotateCamera): void;
  101650. /**
  101651. * Detaches the behavior from its current arc rotate camera.
  101652. */
  101653. detach(): void;
  101654. private _animatables;
  101655. private _betaIsAnimating;
  101656. private _betaTransition;
  101657. private _radiusTransition;
  101658. private _vectorTransition;
  101659. /**
  101660. * Targets the given mesh and updates zoom level accordingly.
  101661. * @param mesh The mesh to target.
  101662. * @param radius Optional. If a cached radius position already exists, overrides default.
  101663. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101664. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101665. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101666. */
  101667. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101668. /**
  101669. * Targets the given mesh with its children and updates zoom level accordingly.
  101670. * @param mesh The mesh to target.
  101671. * @param radius Optional. If a cached radius position already exists, overrides default.
  101672. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101673. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101674. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101675. */
  101676. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101677. /**
  101678. * Targets the given meshes with their children and updates zoom level accordingly.
  101679. * @param meshes The mesh to target.
  101680. * @param radius Optional. If a cached radius position already exists, overrides default.
  101681. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101684. */
  101685. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101686. /**
  101687. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101688. * @param minimumWorld Determines the smaller position of the bounding box extend
  101689. * @param maximumWorld Determines the bigger position of the bounding box extend
  101690. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101691. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101692. */
  101693. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101694. /**
  101695. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101696. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101697. * frustum width.
  101698. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101699. * to fully enclose the mesh in the viewing frustum.
  101700. */
  101701. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101702. /**
  101703. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101704. * is automatically returned to its default position (expected to be above ground plane).
  101705. */
  101706. private _maintainCameraAboveGround;
  101707. /**
  101708. * Returns the frustum slope based on the canvas ratio and camera FOV
  101709. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101710. */
  101711. private _getFrustumSlope;
  101712. /**
  101713. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101714. */
  101715. private _clearAnimationLocks;
  101716. /**
  101717. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101718. */
  101719. private _applyUserInteraction;
  101720. /**
  101721. * Stops and removes all animations that have been applied to the camera
  101722. */
  101723. stopAllAnimations(): void;
  101724. /**
  101725. * Gets a value indicating if the user is moving the camera
  101726. */
  101727. readonly isUserIsMoving: boolean;
  101728. /**
  101729. * The camera can move all the way towards the mesh.
  101730. */
  101731. static IgnoreBoundsSizeMode: number;
  101732. /**
  101733. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101734. */
  101735. static FitFrustumSidesMode: number;
  101736. }
  101737. }
  101738. declare module BABYLON {
  101739. /**
  101740. * Base class for Camera Pointer Inputs.
  101741. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101742. * for example usage.
  101743. */
  101744. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101745. /**
  101746. * Defines the camera the input is attached to.
  101747. */
  101748. abstract camera: Camera;
  101749. /**
  101750. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101751. */
  101752. protected _altKey: boolean;
  101753. protected _ctrlKey: boolean;
  101754. protected _metaKey: boolean;
  101755. protected _shiftKey: boolean;
  101756. /**
  101757. * Which mouse buttons were pressed at time of last mouse event.
  101758. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101759. */
  101760. protected _buttonsPressed: number;
  101761. /**
  101762. * Defines the buttons associated with the input to handle camera move.
  101763. */
  101764. buttons: number[];
  101765. /**
  101766. * Attach the input controls to a specific dom element to get the input from.
  101767. * @param element Defines the element the controls should be listened from
  101768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101769. */
  101770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101771. /**
  101772. * Detach the current controls from the specified dom element.
  101773. * @param element Defines the element to stop listening the inputs from
  101774. */
  101775. detachControl(element: Nullable<HTMLElement>): void;
  101776. /**
  101777. * Gets the class name of the current input.
  101778. * @returns the class name
  101779. */
  101780. getClassName(): string;
  101781. /**
  101782. * Get the friendly name associated with the input class.
  101783. * @returns the input friendly name
  101784. */
  101785. getSimpleName(): string;
  101786. /**
  101787. * Called on pointer POINTERDOUBLETAP event.
  101788. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101789. */
  101790. protected onDoubleTap(type: string): void;
  101791. /**
  101792. * Called on pointer POINTERMOVE event if only a single touch is active.
  101793. * Override this method to provide functionality.
  101794. */
  101795. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101796. /**
  101797. * Called on pointer POINTERMOVE event if multiple touches are active.
  101798. * Override this method to provide functionality.
  101799. */
  101800. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101801. /**
  101802. * Called on JS contextmenu event.
  101803. * Override this method to provide functionality.
  101804. */
  101805. protected onContextMenu(evt: PointerEvent): void;
  101806. /**
  101807. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101808. * press.
  101809. * Override this method to provide functionality.
  101810. */
  101811. protected onButtonDown(evt: PointerEvent): void;
  101812. /**
  101813. * Called each time a new POINTERUP event occurs. Ie, for each button
  101814. * release.
  101815. * Override this method to provide functionality.
  101816. */
  101817. protected onButtonUp(evt: PointerEvent): void;
  101818. /**
  101819. * Called when window becomes inactive.
  101820. * Override this method to provide functionality.
  101821. */
  101822. protected onLostFocus(): void;
  101823. private _pointerInput;
  101824. private _observer;
  101825. private _onLostFocus;
  101826. private pointA;
  101827. private pointB;
  101828. }
  101829. }
  101830. declare module BABYLON {
  101831. /**
  101832. * Manage the pointers inputs to control an arc rotate camera.
  101833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101834. */
  101835. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101836. /**
  101837. * Defines the camera the input is attached to.
  101838. */
  101839. camera: ArcRotateCamera;
  101840. /**
  101841. * Gets the class name of the current input.
  101842. * @returns the class name
  101843. */
  101844. getClassName(): string;
  101845. /**
  101846. * Defines the buttons associated with the input to handle camera move.
  101847. */
  101848. buttons: number[];
  101849. /**
  101850. * Defines the pointer angular sensibility along the X axis or how fast is
  101851. * the camera rotating.
  101852. */
  101853. angularSensibilityX: number;
  101854. /**
  101855. * Defines the pointer angular sensibility along the Y axis or how fast is
  101856. * the camera rotating.
  101857. */
  101858. angularSensibilityY: number;
  101859. /**
  101860. * Defines the pointer pinch precision or how fast is the camera zooming.
  101861. */
  101862. pinchPrecision: number;
  101863. /**
  101864. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101865. * from 0.
  101866. * It defines the percentage of current camera.radius to use as delta when
  101867. * pinch zoom is used.
  101868. */
  101869. pinchDeltaPercentage: number;
  101870. /**
  101871. * Defines the pointer panning sensibility or how fast is the camera moving.
  101872. */
  101873. panningSensibility: number;
  101874. /**
  101875. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101876. */
  101877. multiTouchPanning: boolean;
  101878. /**
  101879. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101880. * zoom (pinch) through multitouch.
  101881. */
  101882. multiTouchPanAndZoom: boolean;
  101883. /**
  101884. * Revers pinch action direction.
  101885. */
  101886. pinchInwards: boolean;
  101887. private _isPanClick;
  101888. private _twoFingerActivityCount;
  101889. private _isPinching;
  101890. /**
  101891. * Called on pointer POINTERMOVE event if only a single touch is active.
  101892. */
  101893. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101894. /**
  101895. * Called on pointer POINTERDOUBLETAP event.
  101896. */
  101897. protected onDoubleTap(type: string): void;
  101898. /**
  101899. * Called on pointer POINTERMOVE event if multiple touches are active.
  101900. */
  101901. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101902. /**
  101903. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101904. * press.
  101905. */
  101906. protected onButtonDown(evt: PointerEvent): void;
  101907. /**
  101908. * Called each time a new POINTERUP event occurs. Ie, for each button
  101909. * release.
  101910. */
  101911. protected onButtonUp(evt: PointerEvent): void;
  101912. /**
  101913. * Called when window becomes inactive.
  101914. */
  101915. protected onLostFocus(): void;
  101916. }
  101917. }
  101918. declare module BABYLON {
  101919. /**
  101920. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101922. */
  101923. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101924. /**
  101925. * Defines the camera the input is attached to.
  101926. */
  101927. camera: ArcRotateCamera;
  101928. /**
  101929. * Defines the list of key codes associated with the up action (increase alpha)
  101930. */
  101931. keysUp: number[];
  101932. /**
  101933. * Defines the list of key codes associated with the down action (decrease alpha)
  101934. */
  101935. keysDown: number[];
  101936. /**
  101937. * Defines the list of key codes associated with the left action (increase beta)
  101938. */
  101939. keysLeft: number[];
  101940. /**
  101941. * Defines the list of key codes associated with the right action (decrease beta)
  101942. */
  101943. keysRight: number[];
  101944. /**
  101945. * Defines the list of key codes associated with the reset action.
  101946. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101947. */
  101948. keysReset: number[];
  101949. /**
  101950. * Defines the panning sensibility of the inputs.
  101951. * (How fast is the camera paning)
  101952. */
  101953. panningSensibility: number;
  101954. /**
  101955. * Defines the zooming sensibility of the inputs.
  101956. * (How fast is the camera zooming)
  101957. */
  101958. zoomingSensibility: number;
  101959. /**
  101960. * Defines wether maintaining the alt key down switch the movement mode from
  101961. * orientation to zoom.
  101962. */
  101963. useAltToZoom: boolean;
  101964. /**
  101965. * Rotation speed of the camera
  101966. */
  101967. angularSpeed: number;
  101968. private _keys;
  101969. private _ctrlPressed;
  101970. private _altPressed;
  101971. private _onCanvasBlurObserver;
  101972. private _onKeyboardObserver;
  101973. private _engine;
  101974. private _scene;
  101975. /**
  101976. * Attach the input controls to a specific dom element to get the input from.
  101977. * @param element Defines the element the controls should be listened from
  101978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101979. */
  101980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101981. /**
  101982. * Detach the current controls from the specified dom element.
  101983. * @param element Defines the element to stop listening the inputs from
  101984. */
  101985. detachControl(element: Nullable<HTMLElement>): void;
  101986. /**
  101987. * Update the current camera state depending on the inputs that have been used this frame.
  101988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101989. */
  101990. checkInputs(): void;
  101991. /**
  101992. * Gets the class name of the current intput.
  101993. * @returns the class name
  101994. */
  101995. getClassName(): string;
  101996. /**
  101997. * Get the friendly name associated with the input class.
  101998. * @returns the input friendly name
  101999. */
  102000. getSimpleName(): string;
  102001. }
  102002. }
  102003. declare module BABYLON {
  102004. /**
  102005. * Manage the mouse wheel inputs to control an arc rotate camera.
  102006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102007. */
  102008. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102009. /**
  102010. * Defines the camera the input is attached to.
  102011. */
  102012. camera: ArcRotateCamera;
  102013. /**
  102014. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102015. */
  102016. wheelPrecision: number;
  102017. /**
  102018. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102019. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102020. */
  102021. wheelDeltaPercentage: number;
  102022. private _wheel;
  102023. private _observer;
  102024. private computeDeltaFromMouseWheelLegacyEvent;
  102025. /**
  102026. * Attach the input controls to a specific dom element to get the input from.
  102027. * @param element Defines the element the controls should be listened from
  102028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102029. */
  102030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102031. /**
  102032. * Detach the current controls from the specified dom element.
  102033. * @param element Defines the element to stop listening the inputs from
  102034. */
  102035. detachControl(element: Nullable<HTMLElement>): void;
  102036. /**
  102037. * Gets the class name of the current intput.
  102038. * @returns the class name
  102039. */
  102040. getClassName(): string;
  102041. /**
  102042. * Get the friendly name associated with the input class.
  102043. * @returns the input friendly name
  102044. */
  102045. getSimpleName(): string;
  102046. }
  102047. }
  102048. declare module BABYLON {
  102049. /**
  102050. * Default Inputs manager for the ArcRotateCamera.
  102051. * It groups all the default supported inputs for ease of use.
  102052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102053. */
  102054. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102055. /**
  102056. * Instantiates a new ArcRotateCameraInputsManager.
  102057. * @param camera Defines the camera the inputs belong to
  102058. */
  102059. constructor(camera: ArcRotateCamera);
  102060. /**
  102061. * Add mouse wheel input support to the input manager.
  102062. * @returns the current input manager
  102063. */
  102064. addMouseWheel(): ArcRotateCameraInputsManager;
  102065. /**
  102066. * Add pointers input support to the input manager.
  102067. * @returns the current input manager
  102068. */
  102069. addPointers(): ArcRotateCameraInputsManager;
  102070. /**
  102071. * Add keyboard input support to the input manager.
  102072. * @returns the current input manager
  102073. */
  102074. addKeyboard(): ArcRotateCameraInputsManager;
  102075. }
  102076. }
  102077. declare module BABYLON {
  102078. /**
  102079. * This represents an orbital type of camera.
  102080. *
  102081. * 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.
  102082. * 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.
  102083. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102084. */
  102085. export class ArcRotateCamera extends TargetCamera {
  102086. /**
  102087. * Defines the rotation angle of the camera along the longitudinal axis.
  102088. */
  102089. alpha: number;
  102090. /**
  102091. * Defines the rotation angle of the camera along the latitudinal axis.
  102092. */
  102093. beta: number;
  102094. /**
  102095. * Defines the radius of the camera from it s target point.
  102096. */
  102097. radius: number;
  102098. protected _target: Vector3;
  102099. protected _targetHost: Nullable<AbstractMesh>;
  102100. /**
  102101. * Defines the target point of the camera.
  102102. * The camera looks towards it form the radius distance.
  102103. */
  102104. target: Vector3;
  102105. /**
  102106. * Define the current local position of the camera in the scene
  102107. */
  102108. position: Vector3;
  102109. protected _upVector: Vector3;
  102110. protected _upToYMatrix: Matrix;
  102111. protected _YToUpMatrix: Matrix;
  102112. /**
  102113. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102114. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102115. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102116. */
  102117. upVector: Vector3;
  102118. /**
  102119. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102120. */
  102121. setMatUp(): void;
  102122. /**
  102123. * Current inertia value on the longitudinal axis.
  102124. * The bigger this number the longer it will take for the camera to stop.
  102125. */
  102126. inertialAlphaOffset: number;
  102127. /**
  102128. * Current inertia value on the latitudinal axis.
  102129. * The bigger this number the longer it will take for the camera to stop.
  102130. */
  102131. inertialBetaOffset: number;
  102132. /**
  102133. * Current inertia value on the radius axis.
  102134. * The bigger this number the longer it will take for the camera to stop.
  102135. */
  102136. inertialRadiusOffset: number;
  102137. /**
  102138. * Minimum allowed angle on the longitudinal axis.
  102139. * This can help limiting how the Camera is able to move in the scene.
  102140. */
  102141. lowerAlphaLimit: Nullable<number>;
  102142. /**
  102143. * Maximum allowed angle on the longitudinal axis.
  102144. * This can help limiting how the Camera is able to move in the scene.
  102145. */
  102146. upperAlphaLimit: Nullable<number>;
  102147. /**
  102148. * Minimum allowed angle on the latitudinal axis.
  102149. * This can help limiting how the Camera is able to move in the scene.
  102150. */
  102151. lowerBetaLimit: number;
  102152. /**
  102153. * Maximum allowed angle on the latitudinal axis.
  102154. * This can help limiting how the Camera is able to move in the scene.
  102155. */
  102156. upperBetaLimit: number;
  102157. /**
  102158. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102159. * This can help limiting how the Camera is able to move in the scene.
  102160. */
  102161. lowerRadiusLimit: Nullable<number>;
  102162. /**
  102163. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102164. * This can help limiting how the Camera is able to move in the scene.
  102165. */
  102166. upperRadiusLimit: Nullable<number>;
  102167. /**
  102168. * Defines the current inertia value used during panning of the camera along the X axis.
  102169. */
  102170. inertialPanningX: number;
  102171. /**
  102172. * Defines the current inertia value used during panning of the camera along the Y axis.
  102173. */
  102174. inertialPanningY: number;
  102175. /**
  102176. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102177. * Basically if your fingers moves away from more than this distance you will be considered
  102178. * in pinch mode.
  102179. */
  102180. pinchToPanMaxDistance: number;
  102181. /**
  102182. * Defines the maximum distance the camera can pan.
  102183. * This could help keeping the cammera always in your scene.
  102184. */
  102185. panningDistanceLimit: Nullable<number>;
  102186. /**
  102187. * Defines the target of the camera before paning.
  102188. */
  102189. panningOriginTarget: Vector3;
  102190. /**
  102191. * Defines the value of the inertia used during panning.
  102192. * 0 would mean stop inertia and one would mean no decelleration at all.
  102193. */
  102194. panningInertia: number;
  102195. /**
  102196. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102197. */
  102198. angularSensibilityX: number;
  102199. /**
  102200. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102201. */
  102202. angularSensibilityY: number;
  102203. /**
  102204. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102205. */
  102206. pinchPrecision: number;
  102207. /**
  102208. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102209. * It will be used instead of pinchDeltaPrecision if different from 0.
  102210. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102211. */
  102212. pinchDeltaPercentage: number;
  102213. /**
  102214. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102215. */
  102216. panningSensibility: number;
  102217. /**
  102218. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102219. */
  102220. keysUp: number[];
  102221. /**
  102222. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102223. */
  102224. keysDown: number[];
  102225. /**
  102226. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102227. */
  102228. keysLeft: number[];
  102229. /**
  102230. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102231. */
  102232. keysRight: number[];
  102233. /**
  102234. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102235. */
  102236. wheelPrecision: number;
  102237. /**
  102238. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102239. * It will be used instead of pinchDeltaPrecision if different from 0.
  102240. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102241. */
  102242. wheelDeltaPercentage: number;
  102243. /**
  102244. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102245. */
  102246. zoomOnFactor: number;
  102247. /**
  102248. * Defines a screen offset for the camera position.
  102249. */
  102250. targetScreenOffset: Vector2;
  102251. /**
  102252. * Allows the camera to be completely reversed.
  102253. * If false the camera can not arrive upside down.
  102254. */
  102255. allowUpsideDown: boolean;
  102256. /**
  102257. * Define if double tap/click is used to restore the previously saved state of the camera.
  102258. */
  102259. useInputToRestoreState: boolean;
  102260. /** @hidden */
  102261. _viewMatrix: Matrix;
  102262. /** @hidden */
  102263. _useCtrlForPanning: boolean;
  102264. /** @hidden */
  102265. _panningMouseButton: number;
  102266. /**
  102267. * Defines the input associated to the camera.
  102268. */
  102269. inputs: ArcRotateCameraInputsManager;
  102270. /** @hidden */
  102271. _reset: () => void;
  102272. /**
  102273. * Defines the allowed panning axis.
  102274. */
  102275. panningAxis: Vector3;
  102276. protected _localDirection: Vector3;
  102277. protected _transformedDirection: Vector3;
  102278. private _bouncingBehavior;
  102279. /**
  102280. * Gets the bouncing behavior of the camera if it has been enabled.
  102281. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102282. */
  102283. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102284. /**
  102285. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102287. */
  102288. useBouncingBehavior: boolean;
  102289. private _framingBehavior;
  102290. /**
  102291. * Gets the framing behavior of the camera if it has been enabled.
  102292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102293. */
  102294. readonly framingBehavior: Nullable<FramingBehavior>;
  102295. /**
  102296. * Defines if the framing behavior of the camera is enabled on the camera.
  102297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102298. */
  102299. useFramingBehavior: boolean;
  102300. private _autoRotationBehavior;
  102301. /**
  102302. * Gets the auto rotation behavior of the camera if it has been enabled.
  102303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102304. */
  102305. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102306. /**
  102307. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102309. */
  102310. useAutoRotationBehavior: boolean;
  102311. /**
  102312. * Observable triggered when the mesh target has been changed on the camera.
  102313. */
  102314. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102315. /**
  102316. * Event raised when the camera is colliding with a mesh.
  102317. */
  102318. onCollide: (collidedMesh: AbstractMesh) => void;
  102319. /**
  102320. * Defines whether the camera should check collision with the objects oh the scene.
  102321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102322. */
  102323. checkCollisions: boolean;
  102324. /**
  102325. * Defines the collision radius of the camera.
  102326. * This simulates a sphere around the camera.
  102327. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102328. */
  102329. collisionRadius: Vector3;
  102330. protected _collider: Collider;
  102331. protected _previousPosition: Vector3;
  102332. protected _collisionVelocity: Vector3;
  102333. protected _newPosition: Vector3;
  102334. protected _previousAlpha: number;
  102335. protected _previousBeta: number;
  102336. protected _previousRadius: number;
  102337. protected _collisionTriggered: boolean;
  102338. protected _targetBoundingCenter: Nullable<Vector3>;
  102339. private _computationVector;
  102340. /**
  102341. * Instantiates a new ArcRotateCamera in a given scene
  102342. * @param name Defines the name of the camera
  102343. * @param alpha Defines the camera rotation along the logitudinal axis
  102344. * @param beta Defines the camera rotation along the latitudinal axis
  102345. * @param radius Defines the camera distance from its target
  102346. * @param target Defines the camera target
  102347. * @param scene Defines the scene the camera belongs to
  102348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102349. */
  102350. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102351. /** @hidden */
  102352. _initCache(): void;
  102353. /** @hidden */
  102354. _updateCache(ignoreParentClass?: boolean): void;
  102355. protected _getTargetPosition(): Vector3;
  102356. private _storedAlpha;
  102357. private _storedBeta;
  102358. private _storedRadius;
  102359. private _storedTarget;
  102360. private _storedTargetScreenOffset;
  102361. /**
  102362. * Stores the current state of the camera (alpha, beta, radius and target)
  102363. * @returns the camera itself
  102364. */
  102365. storeState(): Camera;
  102366. /**
  102367. * @hidden
  102368. * Restored camera state. You must call storeState() first
  102369. */
  102370. _restoreStateValues(): boolean;
  102371. /** @hidden */
  102372. _isSynchronizedViewMatrix(): boolean;
  102373. /**
  102374. * Attached controls to the current camera.
  102375. * @param element Defines the element the controls should be listened from
  102376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102377. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102378. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102379. */
  102380. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102381. /**
  102382. * Detach the current controls from the camera.
  102383. * The camera will stop reacting to inputs.
  102384. * @param element Defines the element to stop listening the inputs from
  102385. */
  102386. detachControl(element: HTMLElement): void;
  102387. /** @hidden */
  102388. _checkInputs(): void;
  102389. protected _checkLimits(): void;
  102390. /**
  102391. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102392. */
  102393. rebuildAnglesAndRadius(): void;
  102394. /**
  102395. * Use a position to define the current camera related information like aplha, beta and radius
  102396. * @param position Defines the position to set the camera at
  102397. */
  102398. setPosition(position: Vector3): void;
  102399. /**
  102400. * Defines the target the camera should look at.
  102401. * This will automatically adapt alpha beta and radius to fit within the new target.
  102402. * @param target Defines the new target as a Vector or a mesh
  102403. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102404. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102405. */
  102406. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102407. /** @hidden */
  102408. _getViewMatrix(): Matrix;
  102409. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102410. /**
  102411. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102412. * @param meshes Defines the mesh to zoom on
  102413. * @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)
  102414. */
  102415. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102416. /**
  102417. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102418. * The target will be changed but the radius
  102419. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102420. * @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)
  102421. */
  102422. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102423. min: Vector3;
  102424. max: Vector3;
  102425. distance: number;
  102426. }, doNotUpdateMaxZ?: boolean): void;
  102427. /**
  102428. * @override
  102429. * Override Camera.createRigCamera
  102430. */
  102431. createRigCamera(name: string, cameraIndex: number): Camera;
  102432. /**
  102433. * @hidden
  102434. * @override
  102435. * Override Camera._updateRigCameras
  102436. */
  102437. _updateRigCameras(): void;
  102438. /**
  102439. * Destroy the camera and release the current resources hold by it.
  102440. */
  102441. dispose(): void;
  102442. /**
  102443. * Gets the current object class name.
  102444. * @return the class name
  102445. */
  102446. getClassName(): string;
  102447. }
  102448. }
  102449. declare module BABYLON {
  102450. /**
  102451. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102452. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102453. */
  102454. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102455. /**
  102456. * Gets the name of the behavior.
  102457. */
  102458. readonly name: string;
  102459. private _zoomStopsAnimation;
  102460. private _idleRotationSpeed;
  102461. private _idleRotationWaitTime;
  102462. private _idleRotationSpinupTime;
  102463. /**
  102464. * Sets the flag that indicates if user zooming should stop animation.
  102465. */
  102466. /**
  102467. * Gets the flag that indicates if user zooming should stop animation.
  102468. */
  102469. zoomStopsAnimation: boolean;
  102470. /**
  102471. * Sets the default speed at which the camera rotates around the model.
  102472. */
  102473. /**
  102474. * Gets the default speed at which the camera rotates around the model.
  102475. */
  102476. idleRotationSpeed: number;
  102477. /**
  102478. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102479. */
  102480. /**
  102481. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102482. */
  102483. idleRotationWaitTime: number;
  102484. /**
  102485. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102486. */
  102487. /**
  102488. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102489. */
  102490. idleRotationSpinupTime: number;
  102491. /**
  102492. * Gets a value indicating if the camera is currently rotating because of this behavior
  102493. */
  102494. readonly rotationInProgress: boolean;
  102495. private _onPrePointerObservableObserver;
  102496. private _onAfterCheckInputsObserver;
  102497. private _attachedCamera;
  102498. private _isPointerDown;
  102499. private _lastFrameTime;
  102500. private _lastInteractionTime;
  102501. private _cameraRotationSpeed;
  102502. /**
  102503. * Initializes the behavior.
  102504. */
  102505. init(): void;
  102506. /**
  102507. * Attaches the behavior to its arc rotate camera.
  102508. * @param camera Defines the camera to attach the behavior to
  102509. */
  102510. attach(camera: ArcRotateCamera): void;
  102511. /**
  102512. * Detaches the behavior from its current arc rotate camera.
  102513. */
  102514. detach(): void;
  102515. /**
  102516. * Returns true if user is scrolling.
  102517. * @return true if user is scrolling.
  102518. */
  102519. private _userIsZooming;
  102520. private _lastFrameRadius;
  102521. private _shouldAnimationStopForInteraction;
  102522. /**
  102523. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102524. */
  102525. private _applyUserInteraction;
  102526. private _userIsMoving;
  102527. }
  102528. }
  102529. declare module BABYLON {
  102530. /**
  102531. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102532. */
  102533. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102534. private ui;
  102535. /**
  102536. * The name of the behavior
  102537. */
  102538. name: string;
  102539. /**
  102540. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102541. */
  102542. distanceAwayFromFace: number;
  102543. /**
  102544. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102545. */
  102546. distanceAwayFromBottomOfFace: number;
  102547. private _faceVectors;
  102548. private _target;
  102549. private _scene;
  102550. private _onRenderObserver;
  102551. private _tmpMatrix;
  102552. private _tmpVector;
  102553. /**
  102554. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102555. * @param ui The transform node that should be attched to the mesh
  102556. */
  102557. constructor(ui: TransformNode);
  102558. /**
  102559. * Initializes the behavior
  102560. */
  102561. init(): void;
  102562. private _closestFace;
  102563. private _zeroVector;
  102564. private _lookAtTmpMatrix;
  102565. private _lookAtToRef;
  102566. /**
  102567. * Attaches the AttachToBoxBehavior to the passed in mesh
  102568. * @param target The mesh that the specified node will be attached to
  102569. */
  102570. attach(target: Mesh): void;
  102571. /**
  102572. * Detaches the behavior from the mesh
  102573. */
  102574. detach(): void;
  102575. }
  102576. }
  102577. declare module BABYLON {
  102578. /**
  102579. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102580. */
  102581. export class FadeInOutBehavior implements Behavior<Mesh> {
  102582. /**
  102583. * Time in milliseconds to delay before fading in (Default: 0)
  102584. */
  102585. delay: number;
  102586. /**
  102587. * Time in milliseconds for the mesh to fade in (Default: 300)
  102588. */
  102589. fadeInTime: number;
  102590. private _millisecondsPerFrame;
  102591. private _hovered;
  102592. private _hoverValue;
  102593. private _ownerNode;
  102594. /**
  102595. * Instatiates the FadeInOutBehavior
  102596. */
  102597. constructor();
  102598. /**
  102599. * The name of the behavior
  102600. */
  102601. readonly name: string;
  102602. /**
  102603. * Initializes the behavior
  102604. */
  102605. init(): void;
  102606. /**
  102607. * Attaches the fade behavior on the passed in mesh
  102608. * @param ownerNode The mesh that will be faded in/out once attached
  102609. */
  102610. attach(ownerNode: Mesh): void;
  102611. /**
  102612. * Detaches the behavior from the mesh
  102613. */
  102614. detach(): void;
  102615. /**
  102616. * Triggers the mesh to begin fading in or out
  102617. * @param value if the object should fade in or out (true to fade in)
  102618. */
  102619. fadeIn(value: boolean): void;
  102620. private _update;
  102621. private _setAllVisibility;
  102622. }
  102623. }
  102624. declare module BABYLON {
  102625. /**
  102626. * Class containing a set of static utilities functions for managing Pivots
  102627. * @hidden
  102628. */
  102629. export class PivotTools {
  102630. private static _PivotCached;
  102631. private static _OldPivotPoint;
  102632. private static _PivotTranslation;
  102633. private static _PivotTmpVector;
  102634. /** @hidden */
  102635. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102636. /** @hidden */
  102637. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102638. }
  102639. }
  102640. declare module BABYLON {
  102641. /**
  102642. * Class containing static functions to help procedurally build meshes
  102643. */
  102644. export class PlaneBuilder {
  102645. /**
  102646. * Creates a plane mesh
  102647. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102648. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102649. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102653. * @param name defines the name of the mesh
  102654. * @param options defines the options used to create the mesh
  102655. * @param scene defines the hosting scene
  102656. * @returns the plane mesh
  102657. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102658. */
  102659. static CreatePlane(name: string, options: {
  102660. size?: number;
  102661. width?: number;
  102662. height?: number;
  102663. sideOrientation?: number;
  102664. frontUVs?: Vector4;
  102665. backUVs?: Vector4;
  102666. updatable?: boolean;
  102667. sourcePlane?: Plane;
  102668. }, scene?: Nullable<Scene>): Mesh;
  102669. }
  102670. }
  102671. declare module BABYLON {
  102672. /**
  102673. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102674. */
  102675. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102676. private static _AnyMouseID;
  102677. /**
  102678. * Abstract mesh the behavior is set on
  102679. */
  102680. attachedNode: AbstractMesh;
  102681. private _dragPlane;
  102682. private _scene;
  102683. private _pointerObserver;
  102684. private _beforeRenderObserver;
  102685. private static _planeScene;
  102686. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102687. /**
  102688. * 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)
  102689. */
  102690. maxDragAngle: number;
  102691. /**
  102692. * @hidden
  102693. */
  102694. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102695. /**
  102696. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102697. */
  102698. currentDraggingPointerID: number;
  102699. /**
  102700. * The last position where the pointer hit the drag plane in world space
  102701. */
  102702. lastDragPosition: Vector3;
  102703. /**
  102704. * If the behavior is currently in a dragging state
  102705. */
  102706. dragging: boolean;
  102707. /**
  102708. * 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)
  102709. */
  102710. dragDeltaRatio: number;
  102711. /**
  102712. * If the drag plane orientation should be updated during the dragging (Default: true)
  102713. */
  102714. updateDragPlane: boolean;
  102715. private _debugMode;
  102716. private _moving;
  102717. /**
  102718. * Fires each time the attached mesh is dragged with the pointer
  102719. * * delta between last drag position and current drag position in world space
  102720. * * dragDistance along the drag axis
  102721. * * dragPlaneNormal normal of the current drag plane used during the drag
  102722. * * dragPlanePoint in world space where the drag intersects the drag plane
  102723. */
  102724. onDragObservable: Observable<{
  102725. delta: Vector3;
  102726. dragPlanePoint: Vector3;
  102727. dragPlaneNormal: Vector3;
  102728. dragDistance: number;
  102729. pointerId: number;
  102730. }>;
  102731. /**
  102732. * Fires each time a drag begins (eg. mouse down on mesh)
  102733. */
  102734. onDragStartObservable: Observable<{
  102735. dragPlanePoint: Vector3;
  102736. pointerId: number;
  102737. }>;
  102738. /**
  102739. * Fires each time a drag ends (eg. mouse release after drag)
  102740. */
  102741. onDragEndObservable: Observable<{
  102742. dragPlanePoint: Vector3;
  102743. pointerId: number;
  102744. }>;
  102745. /**
  102746. * If the attached mesh should be moved when dragged
  102747. */
  102748. moveAttached: boolean;
  102749. /**
  102750. * If the drag behavior will react to drag events (Default: true)
  102751. */
  102752. enabled: boolean;
  102753. /**
  102754. * If pointer events should start and release the drag (Default: true)
  102755. */
  102756. startAndReleaseDragOnPointerEvents: boolean;
  102757. /**
  102758. * If camera controls should be detached during the drag
  102759. */
  102760. detachCameraControls: boolean;
  102761. /**
  102762. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102763. */
  102764. useObjectOrienationForDragging: boolean;
  102765. private _options;
  102766. /**
  102767. * Creates a pointer drag behavior that can be attached to a mesh
  102768. * @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)
  102769. */
  102770. constructor(options?: {
  102771. dragAxis?: Vector3;
  102772. dragPlaneNormal?: Vector3;
  102773. });
  102774. /**
  102775. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102776. */
  102777. validateDrag: (targetPosition: Vector3) => boolean;
  102778. /**
  102779. * The name of the behavior
  102780. */
  102781. readonly name: string;
  102782. /**
  102783. * Initializes the behavior
  102784. */
  102785. init(): void;
  102786. private _tmpVector;
  102787. private _alternatePickedPoint;
  102788. private _worldDragAxis;
  102789. private _targetPosition;
  102790. private _attachedElement;
  102791. /**
  102792. * Attaches the drag behavior the passed in mesh
  102793. * @param ownerNode The mesh that will be dragged around once attached
  102794. * @param predicate Predicate to use for pick filtering
  102795. */
  102796. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102797. /**
  102798. * Force relase the drag action by code.
  102799. */
  102800. releaseDrag(): void;
  102801. private _startDragRay;
  102802. private _lastPointerRay;
  102803. /**
  102804. * Simulates the start of a pointer drag event on the behavior
  102805. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102806. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102807. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102808. */
  102809. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102810. private _startDrag;
  102811. private _dragDelta;
  102812. private _moveDrag;
  102813. private _pickWithRayOnDragPlane;
  102814. private _pointA;
  102815. private _pointB;
  102816. private _pointC;
  102817. private _lineA;
  102818. private _lineB;
  102819. private _localAxis;
  102820. private _lookAt;
  102821. private _updateDragPlanePosition;
  102822. /**
  102823. * Detaches the behavior from the mesh
  102824. */
  102825. detach(): void;
  102826. }
  102827. }
  102828. declare module BABYLON {
  102829. /**
  102830. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102831. */
  102832. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102833. private _dragBehaviorA;
  102834. private _dragBehaviorB;
  102835. private _startDistance;
  102836. private _initialScale;
  102837. private _targetScale;
  102838. private _ownerNode;
  102839. private _sceneRenderObserver;
  102840. /**
  102841. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102842. */
  102843. constructor();
  102844. /**
  102845. * The name of the behavior
  102846. */
  102847. readonly name: string;
  102848. /**
  102849. * Initializes the behavior
  102850. */
  102851. init(): void;
  102852. private _getCurrentDistance;
  102853. /**
  102854. * Attaches the scale behavior the passed in mesh
  102855. * @param ownerNode The mesh that will be scaled around once attached
  102856. */
  102857. attach(ownerNode: Mesh): void;
  102858. /**
  102859. * Detaches the behavior from the mesh
  102860. */
  102861. detach(): void;
  102862. }
  102863. }
  102864. declare module BABYLON {
  102865. /**
  102866. * 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
  102867. */
  102868. export class SixDofDragBehavior implements Behavior<Mesh> {
  102869. private static _virtualScene;
  102870. private _ownerNode;
  102871. private _sceneRenderObserver;
  102872. private _scene;
  102873. private _targetPosition;
  102874. private _virtualOriginMesh;
  102875. private _virtualDragMesh;
  102876. private _pointerObserver;
  102877. private _moving;
  102878. private _startingOrientation;
  102879. /**
  102880. * 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)
  102881. */
  102882. private zDragFactor;
  102883. /**
  102884. * If the object should rotate to face the drag origin
  102885. */
  102886. rotateDraggedObject: boolean;
  102887. /**
  102888. * If the behavior is currently in a dragging state
  102889. */
  102890. dragging: boolean;
  102891. /**
  102892. * 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)
  102893. */
  102894. dragDeltaRatio: number;
  102895. /**
  102896. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102897. */
  102898. currentDraggingPointerID: number;
  102899. /**
  102900. * If camera controls should be detached during the drag
  102901. */
  102902. detachCameraControls: boolean;
  102903. /**
  102904. * Fires each time a drag starts
  102905. */
  102906. onDragStartObservable: Observable<{}>;
  102907. /**
  102908. * Fires each time a drag ends (eg. mouse release after drag)
  102909. */
  102910. onDragEndObservable: Observable<{}>;
  102911. /**
  102912. * 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
  102913. */
  102914. constructor();
  102915. /**
  102916. * The name of the behavior
  102917. */
  102918. readonly name: string;
  102919. /**
  102920. * Initializes the behavior
  102921. */
  102922. init(): void;
  102923. /**
  102924. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102925. */
  102926. private readonly _pointerCamera;
  102927. /**
  102928. * Attaches the scale behavior the passed in mesh
  102929. * @param ownerNode The mesh that will be scaled around once attached
  102930. */
  102931. attach(ownerNode: Mesh): void;
  102932. /**
  102933. * Detaches the behavior from the mesh
  102934. */
  102935. detach(): void;
  102936. }
  102937. }
  102938. declare module BABYLON {
  102939. /**
  102940. * Class used to apply inverse kinematics to bones
  102941. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102942. */
  102943. export class BoneIKController {
  102944. private static _tmpVecs;
  102945. private static _tmpQuat;
  102946. private static _tmpMats;
  102947. /**
  102948. * Gets or sets the target mesh
  102949. */
  102950. targetMesh: AbstractMesh;
  102951. /** Gets or sets the mesh used as pole */
  102952. poleTargetMesh: AbstractMesh;
  102953. /**
  102954. * Gets or sets the bone used as pole
  102955. */
  102956. poleTargetBone: Nullable<Bone>;
  102957. /**
  102958. * Gets or sets the target position
  102959. */
  102960. targetPosition: Vector3;
  102961. /**
  102962. * Gets or sets the pole target position
  102963. */
  102964. poleTargetPosition: Vector3;
  102965. /**
  102966. * Gets or sets the pole target local offset
  102967. */
  102968. poleTargetLocalOffset: Vector3;
  102969. /**
  102970. * Gets or sets the pole angle
  102971. */
  102972. poleAngle: number;
  102973. /**
  102974. * Gets or sets the mesh associated with the controller
  102975. */
  102976. mesh: AbstractMesh;
  102977. /**
  102978. * 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)
  102979. */
  102980. slerpAmount: number;
  102981. private _bone1Quat;
  102982. private _bone1Mat;
  102983. private _bone2Ang;
  102984. private _bone1;
  102985. private _bone2;
  102986. private _bone1Length;
  102987. private _bone2Length;
  102988. private _maxAngle;
  102989. private _maxReach;
  102990. private _rightHandedSystem;
  102991. private _bendAxis;
  102992. private _slerping;
  102993. private _adjustRoll;
  102994. /**
  102995. * Gets or sets maximum allowed angle
  102996. */
  102997. maxAngle: number;
  102998. /**
  102999. * Creates a new BoneIKController
  103000. * @param mesh defines the mesh to control
  103001. * @param bone defines the bone to control
  103002. * @param options defines options to set up the controller
  103003. */
  103004. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103005. targetMesh?: AbstractMesh;
  103006. poleTargetMesh?: AbstractMesh;
  103007. poleTargetBone?: Bone;
  103008. poleTargetLocalOffset?: Vector3;
  103009. poleAngle?: number;
  103010. bendAxis?: Vector3;
  103011. maxAngle?: number;
  103012. slerpAmount?: number;
  103013. });
  103014. private _setMaxAngle;
  103015. /**
  103016. * Force the controller to update the bones
  103017. */
  103018. update(): void;
  103019. }
  103020. }
  103021. declare module BABYLON {
  103022. /**
  103023. * Class used to make a bone look toward a point in space
  103024. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103025. */
  103026. export class BoneLookController {
  103027. private static _tmpVecs;
  103028. private static _tmpQuat;
  103029. private static _tmpMats;
  103030. /**
  103031. * The target Vector3 that the bone will look at
  103032. */
  103033. target: Vector3;
  103034. /**
  103035. * The mesh that the bone is attached to
  103036. */
  103037. mesh: AbstractMesh;
  103038. /**
  103039. * The bone that will be looking to the target
  103040. */
  103041. bone: Bone;
  103042. /**
  103043. * The up axis of the coordinate system that is used when the bone is rotated
  103044. */
  103045. upAxis: Vector3;
  103046. /**
  103047. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103048. */
  103049. upAxisSpace: Space;
  103050. /**
  103051. * Used to make an adjustment to the yaw of the bone
  103052. */
  103053. adjustYaw: number;
  103054. /**
  103055. * Used to make an adjustment to the pitch of the bone
  103056. */
  103057. adjustPitch: number;
  103058. /**
  103059. * Used to make an adjustment to the roll of the bone
  103060. */
  103061. adjustRoll: number;
  103062. /**
  103063. * 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)
  103064. */
  103065. slerpAmount: number;
  103066. private _minYaw;
  103067. private _maxYaw;
  103068. private _minPitch;
  103069. private _maxPitch;
  103070. private _minYawSin;
  103071. private _minYawCos;
  103072. private _maxYawSin;
  103073. private _maxYawCos;
  103074. private _midYawConstraint;
  103075. private _minPitchTan;
  103076. private _maxPitchTan;
  103077. private _boneQuat;
  103078. private _slerping;
  103079. private _transformYawPitch;
  103080. private _transformYawPitchInv;
  103081. private _firstFrameSkipped;
  103082. private _yawRange;
  103083. private _fowardAxis;
  103084. /**
  103085. * Gets or sets the minimum yaw angle that the bone can look to
  103086. */
  103087. minYaw: number;
  103088. /**
  103089. * Gets or sets the maximum yaw angle that the bone can look to
  103090. */
  103091. maxYaw: number;
  103092. /**
  103093. * Gets or sets the minimum pitch angle that the bone can look to
  103094. */
  103095. minPitch: number;
  103096. /**
  103097. * Gets or sets the maximum pitch angle that the bone can look to
  103098. */
  103099. maxPitch: number;
  103100. /**
  103101. * Create a BoneLookController
  103102. * @param mesh the mesh that the bone belongs to
  103103. * @param bone the bone that will be looking to the target
  103104. * @param target the target Vector3 to look at
  103105. * @param options optional settings:
  103106. * * maxYaw: the maximum angle the bone will yaw to
  103107. * * minYaw: the minimum angle the bone will yaw to
  103108. * * maxPitch: the maximum angle the bone will pitch to
  103109. * * minPitch: the minimum angle the bone will yaw to
  103110. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103111. * * upAxis: the up axis of the coordinate system
  103112. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103113. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103114. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103115. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103116. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103117. * * adjustRoll: used to make an adjustment to the roll of the bone
  103118. **/
  103119. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103120. maxYaw?: number;
  103121. minYaw?: number;
  103122. maxPitch?: number;
  103123. minPitch?: number;
  103124. slerpAmount?: number;
  103125. upAxis?: Vector3;
  103126. upAxisSpace?: Space;
  103127. yawAxis?: Vector3;
  103128. pitchAxis?: Vector3;
  103129. adjustYaw?: number;
  103130. adjustPitch?: number;
  103131. adjustRoll?: number;
  103132. });
  103133. /**
  103134. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103135. */
  103136. update(): void;
  103137. private _getAngleDiff;
  103138. private _getAngleBetween;
  103139. private _isAngleBetween;
  103140. }
  103141. }
  103142. declare module BABYLON {
  103143. /**
  103144. * Manage the gamepad inputs to control an arc rotate camera.
  103145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103146. */
  103147. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103148. /**
  103149. * Defines the camera the input is attached to.
  103150. */
  103151. camera: ArcRotateCamera;
  103152. /**
  103153. * Defines the gamepad the input is gathering event from.
  103154. */
  103155. gamepad: Nullable<Gamepad>;
  103156. /**
  103157. * Defines the gamepad rotation sensiblity.
  103158. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103159. */
  103160. gamepadRotationSensibility: number;
  103161. /**
  103162. * Defines the gamepad move sensiblity.
  103163. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103164. */
  103165. gamepadMoveSensibility: number;
  103166. private _onGamepadConnectedObserver;
  103167. private _onGamepadDisconnectedObserver;
  103168. /**
  103169. * Attach the input controls to a specific dom element to get the input from.
  103170. * @param element Defines the element the controls should be listened from
  103171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103172. */
  103173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103174. /**
  103175. * Detach the current controls from the specified dom element.
  103176. * @param element Defines the element to stop listening the inputs from
  103177. */
  103178. detachControl(element: Nullable<HTMLElement>): void;
  103179. /**
  103180. * Update the current camera state depending on the inputs that have been used this frame.
  103181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103182. */
  103183. checkInputs(): void;
  103184. /**
  103185. * Gets the class name of the current intput.
  103186. * @returns the class name
  103187. */
  103188. getClassName(): string;
  103189. /**
  103190. * Get the friendly name associated with the input class.
  103191. * @returns the input friendly name
  103192. */
  103193. getSimpleName(): string;
  103194. }
  103195. }
  103196. declare module BABYLON {
  103197. interface ArcRotateCameraInputsManager {
  103198. /**
  103199. * Add orientation input support to the input manager.
  103200. * @returns the current input manager
  103201. */
  103202. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103203. }
  103204. /**
  103205. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103207. */
  103208. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103209. /**
  103210. * Defines the camera the input is attached to.
  103211. */
  103212. camera: ArcRotateCamera;
  103213. /**
  103214. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103215. */
  103216. alphaCorrection: number;
  103217. /**
  103218. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103219. */
  103220. gammaCorrection: number;
  103221. private _alpha;
  103222. private _gamma;
  103223. private _dirty;
  103224. private _deviceOrientationHandler;
  103225. /**
  103226. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103227. */
  103228. constructor();
  103229. /**
  103230. * Attach the input controls to a specific dom element to get the input from.
  103231. * @param element Defines the element the controls should be listened from
  103232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103233. */
  103234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103235. /** @hidden */
  103236. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103237. /**
  103238. * Update the current camera state depending on the inputs that have been used this frame.
  103239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103240. */
  103241. checkInputs(): void;
  103242. /**
  103243. * Detach the current controls from the specified dom element.
  103244. * @param element Defines the element to stop listening the inputs from
  103245. */
  103246. detachControl(element: Nullable<HTMLElement>): void;
  103247. /**
  103248. * Gets the class name of the current intput.
  103249. * @returns the class name
  103250. */
  103251. getClassName(): string;
  103252. /**
  103253. * Get the friendly name associated with the input class.
  103254. * @returns the input friendly name
  103255. */
  103256. getSimpleName(): string;
  103257. }
  103258. }
  103259. declare module BABYLON {
  103260. /**
  103261. * Listen to mouse events to control the camera.
  103262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103263. */
  103264. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103265. /**
  103266. * Defines the camera the input is attached to.
  103267. */
  103268. camera: FlyCamera;
  103269. /**
  103270. * Defines if touch is enabled. (Default is true.)
  103271. */
  103272. touchEnabled: boolean;
  103273. /**
  103274. * Defines the buttons associated with the input to handle camera rotation.
  103275. */
  103276. buttons: number[];
  103277. /**
  103278. * Assign buttons for Yaw control.
  103279. */
  103280. buttonsYaw: number[];
  103281. /**
  103282. * Assign buttons for Pitch control.
  103283. */
  103284. buttonsPitch: number[];
  103285. /**
  103286. * Assign buttons for Roll control.
  103287. */
  103288. buttonsRoll: number[];
  103289. /**
  103290. * Detect if any button is being pressed while mouse is moved.
  103291. * -1 = Mouse locked.
  103292. * 0 = Left button.
  103293. * 1 = Middle Button.
  103294. * 2 = Right Button.
  103295. */
  103296. activeButton: number;
  103297. /**
  103298. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103299. * Higher values reduce its sensitivity.
  103300. */
  103301. angularSensibility: number;
  103302. private _mousemoveCallback;
  103303. private _observer;
  103304. private _rollObserver;
  103305. private previousPosition;
  103306. private noPreventDefault;
  103307. private element;
  103308. /**
  103309. * Listen to mouse events to control the camera.
  103310. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103312. */
  103313. constructor(touchEnabled?: boolean);
  103314. /**
  103315. * Attach the mouse control to the HTML DOM element.
  103316. * @param element Defines the element that listens to the input events.
  103317. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103318. */
  103319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103320. /**
  103321. * Detach the current controls from the specified dom element.
  103322. * @param element Defines the element to stop listening the inputs from
  103323. */
  103324. detachControl(element: Nullable<HTMLElement>): void;
  103325. /**
  103326. * Gets the class name of the current input.
  103327. * @returns the class name.
  103328. */
  103329. getClassName(): string;
  103330. /**
  103331. * Get the friendly name associated with the input class.
  103332. * @returns the input's friendly name.
  103333. */
  103334. getSimpleName(): string;
  103335. private _pointerInput;
  103336. private _onMouseMove;
  103337. /**
  103338. * Rotate camera by mouse offset.
  103339. */
  103340. private rotateCamera;
  103341. }
  103342. }
  103343. declare module BABYLON {
  103344. /**
  103345. * Default Inputs manager for the FlyCamera.
  103346. * It groups all the default supported inputs for ease of use.
  103347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103348. */
  103349. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103350. /**
  103351. * Instantiates a new FlyCameraInputsManager.
  103352. * @param camera Defines the camera the inputs belong to.
  103353. */
  103354. constructor(camera: FlyCamera);
  103355. /**
  103356. * Add keyboard input support to the input manager.
  103357. * @returns the new FlyCameraKeyboardMoveInput().
  103358. */
  103359. addKeyboard(): FlyCameraInputsManager;
  103360. /**
  103361. * Add mouse input support to the input manager.
  103362. * @param touchEnabled Enable touch screen support.
  103363. * @returns the new FlyCameraMouseInput().
  103364. */
  103365. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103366. }
  103367. }
  103368. declare module BABYLON {
  103369. /**
  103370. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103371. * such as in a 3D Space Shooter or a Flight Simulator.
  103372. */
  103373. export class FlyCamera extends TargetCamera {
  103374. /**
  103375. * Define the collision ellipsoid of the camera.
  103376. * This is helpful for simulating a camera body, like a player's body.
  103377. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103378. */
  103379. ellipsoid: Vector3;
  103380. /**
  103381. * Define an offset for the position of the ellipsoid around the camera.
  103382. * This can be helpful if the camera is attached away from the player's body center,
  103383. * such as at its head.
  103384. */
  103385. ellipsoidOffset: Vector3;
  103386. /**
  103387. * Enable or disable collisions of the camera with the rest of the scene objects.
  103388. */
  103389. checkCollisions: boolean;
  103390. /**
  103391. * Enable or disable gravity on the camera.
  103392. */
  103393. applyGravity: boolean;
  103394. /**
  103395. * Define the current direction the camera is moving to.
  103396. */
  103397. cameraDirection: Vector3;
  103398. /**
  103399. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103400. * This overrides and empties cameraRotation.
  103401. */
  103402. rotationQuaternion: Quaternion;
  103403. /**
  103404. * Track Roll to maintain the wanted Rolling when looking around.
  103405. */
  103406. _trackRoll: number;
  103407. /**
  103408. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103409. */
  103410. rollCorrect: number;
  103411. /**
  103412. * Mimic a banked turn, Rolling the camera when Yawing.
  103413. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103414. */
  103415. bankedTurn: boolean;
  103416. /**
  103417. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103418. */
  103419. bankedTurnLimit: number;
  103420. /**
  103421. * Value of 0 disables the banked Roll.
  103422. * Value of 1 is equal to the Yaw angle in radians.
  103423. */
  103424. bankedTurnMultiplier: number;
  103425. /**
  103426. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103427. */
  103428. inputs: FlyCameraInputsManager;
  103429. /**
  103430. * Gets the input sensibility for mouse input.
  103431. * Higher values reduce sensitivity.
  103432. */
  103433. /**
  103434. * Sets the input sensibility for a mouse input.
  103435. * Higher values reduce sensitivity.
  103436. */
  103437. angularSensibility: number;
  103438. /**
  103439. * Get the keys for camera movement forward.
  103440. */
  103441. /**
  103442. * Set the keys for camera movement forward.
  103443. */
  103444. keysForward: number[];
  103445. /**
  103446. * Get the keys for camera movement backward.
  103447. */
  103448. keysBackward: number[];
  103449. /**
  103450. * Get the keys for camera movement up.
  103451. */
  103452. /**
  103453. * Set the keys for camera movement up.
  103454. */
  103455. keysUp: number[];
  103456. /**
  103457. * Get the keys for camera movement down.
  103458. */
  103459. /**
  103460. * Set the keys for camera movement down.
  103461. */
  103462. keysDown: number[];
  103463. /**
  103464. * Get the keys for camera movement left.
  103465. */
  103466. /**
  103467. * Set the keys for camera movement left.
  103468. */
  103469. keysLeft: number[];
  103470. /**
  103471. * Set the keys for camera movement right.
  103472. */
  103473. /**
  103474. * Set the keys for camera movement right.
  103475. */
  103476. keysRight: number[];
  103477. /**
  103478. * Event raised when the camera collides with a mesh in the scene.
  103479. */
  103480. onCollide: (collidedMesh: AbstractMesh) => void;
  103481. private _collider;
  103482. private _needMoveForGravity;
  103483. private _oldPosition;
  103484. private _diffPosition;
  103485. private _newPosition;
  103486. /** @hidden */
  103487. _localDirection: Vector3;
  103488. /** @hidden */
  103489. _transformedDirection: Vector3;
  103490. /**
  103491. * Instantiates a FlyCamera.
  103492. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103493. * such as in a 3D Space Shooter or a Flight Simulator.
  103494. * @param name Define the name of the camera in the scene.
  103495. * @param position Define the starting position of the camera in the scene.
  103496. * @param scene Define the scene the camera belongs to.
  103497. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103498. */
  103499. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103500. /**
  103501. * Attach a control to the HTML DOM element.
  103502. * @param element Defines the element that listens to the input events.
  103503. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103504. */
  103505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103506. /**
  103507. * Detach a control from the HTML DOM element.
  103508. * The camera will stop reacting to that input.
  103509. * @param element Defines the element that listens to the input events.
  103510. */
  103511. detachControl(element: HTMLElement): void;
  103512. private _collisionMask;
  103513. /**
  103514. * Get the mask that the camera ignores in collision events.
  103515. */
  103516. /**
  103517. * Set the mask that the camera ignores in collision events.
  103518. */
  103519. collisionMask: number;
  103520. /** @hidden */
  103521. _collideWithWorld(displacement: Vector3): void;
  103522. /** @hidden */
  103523. private _onCollisionPositionChange;
  103524. /** @hidden */
  103525. _checkInputs(): void;
  103526. /** @hidden */
  103527. _decideIfNeedsToMove(): boolean;
  103528. /** @hidden */
  103529. _updatePosition(): void;
  103530. /**
  103531. * Restore the Roll to its target value at the rate specified.
  103532. * @param rate - Higher means slower restoring.
  103533. * @hidden
  103534. */
  103535. restoreRoll(rate: number): void;
  103536. /**
  103537. * Destroy the camera and release the current resources held by it.
  103538. */
  103539. dispose(): void;
  103540. /**
  103541. * Get the current object class name.
  103542. * @returns the class name.
  103543. */
  103544. getClassName(): string;
  103545. }
  103546. }
  103547. declare module BABYLON {
  103548. /**
  103549. * Listen to keyboard events to control the camera.
  103550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103551. */
  103552. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103553. /**
  103554. * Defines the camera the input is attached to.
  103555. */
  103556. camera: FlyCamera;
  103557. /**
  103558. * The list of keyboard keys used to control the forward move of the camera.
  103559. */
  103560. keysForward: number[];
  103561. /**
  103562. * The list of keyboard keys used to control the backward move of the camera.
  103563. */
  103564. keysBackward: number[];
  103565. /**
  103566. * The list of keyboard keys used to control the forward move of the camera.
  103567. */
  103568. keysUp: number[];
  103569. /**
  103570. * The list of keyboard keys used to control the backward move of the camera.
  103571. */
  103572. keysDown: number[];
  103573. /**
  103574. * The list of keyboard keys used to control the right strafe move of the camera.
  103575. */
  103576. keysRight: number[];
  103577. /**
  103578. * The list of keyboard keys used to control the left strafe move of the camera.
  103579. */
  103580. keysLeft: number[];
  103581. private _keys;
  103582. private _onCanvasBlurObserver;
  103583. private _onKeyboardObserver;
  103584. private _engine;
  103585. private _scene;
  103586. /**
  103587. * Attach the input controls to a specific dom element to get the input from.
  103588. * @param element Defines the element the controls should be listened from
  103589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103590. */
  103591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103592. /**
  103593. * Detach the current controls from the specified dom element.
  103594. * @param element Defines the element to stop listening the inputs from
  103595. */
  103596. detachControl(element: Nullable<HTMLElement>): void;
  103597. /**
  103598. * Gets the class name of the current intput.
  103599. * @returns the class name
  103600. */
  103601. getClassName(): string;
  103602. /** @hidden */
  103603. _onLostFocus(e: FocusEvent): void;
  103604. /**
  103605. * Get the friendly name associated with the input class.
  103606. * @returns the input friendly name
  103607. */
  103608. getSimpleName(): string;
  103609. /**
  103610. * Update the current camera state depending on the inputs that have been used this frame.
  103611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103612. */
  103613. checkInputs(): void;
  103614. }
  103615. }
  103616. declare module BABYLON {
  103617. /**
  103618. * Manage the mouse wheel inputs to control a follow camera.
  103619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103620. */
  103621. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103622. /**
  103623. * Defines the camera the input is attached to.
  103624. */
  103625. camera: FollowCamera;
  103626. /**
  103627. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103628. */
  103629. axisControlRadius: boolean;
  103630. /**
  103631. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103632. */
  103633. axisControlHeight: boolean;
  103634. /**
  103635. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103636. */
  103637. axisControlRotation: boolean;
  103638. /**
  103639. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103640. * relation to mouseWheel events.
  103641. */
  103642. wheelPrecision: number;
  103643. /**
  103644. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103645. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103646. */
  103647. wheelDeltaPercentage: number;
  103648. private _wheel;
  103649. private _observer;
  103650. /**
  103651. * Attach the input controls to a specific dom element to get the input from.
  103652. * @param element Defines the element the controls should be listened from
  103653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103654. */
  103655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103656. /**
  103657. * Detach the current controls from the specified dom element.
  103658. * @param element Defines the element to stop listening the inputs from
  103659. */
  103660. detachControl(element: Nullable<HTMLElement>): void;
  103661. /**
  103662. * Gets the class name of the current intput.
  103663. * @returns the class name
  103664. */
  103665. getClassName(): string;
  103666. /**
  103667. * Get the friendly name associated with the input class.
  103668. * @returns the input friendly name
  103669. */
  103670. getSimpleName(): string;
  103671. }
  103672. }
  103673. declare module BABYLON {
  103674. /**
  103675. * Manage the pointers inputs to control an follow camera.
  103676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103677. */
  103678. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103679. /**
  103680. * Defines the camera the input is attached to.
  103681. */
  103682. camera: FollowCamera;
  103683. /**
  103684. * Gets the class name of the current input.
  103685. * @returns the class name
  103686. */
  103687. getClassName(): string;
  103688. /**
  103689. * Defines the pointer angular sensibility along the X axis or how fast is
  103690. * the camera rotating.
  103691. * A negative number will reverse the axis direction.
  103692. */
  103693. angularSensibilityX: number;
  103694. /**
  103695. * Defines the pointer angular sensibility along the Y axis or how fast is
  103696. * the camera rotating.
  103697. * A negative number will reverse the axis direction.
  103698. */
  103699. angularSensibilityY: number;
  103700. /**
  103701. * Defines the pointer pinch precision or how fast is the camera zooming.
  103702. * A negative number will reverse the axis direction.
  103703. */
  103704. pinchPrecision: number;
  103705. /**
  103706. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103707. * from 0.
  103708. * It defines the percentage of current camera.radius to use as delta when
  103709. * pinch zoom is used.
  103710. */
  103711. pinchDeltaPercentage: number;
  103712. /**
  103713. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103714. */
  103715. axisXControlRadius: boolean;
  103716. /**
  103717. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103718. */
  103719. axisXControlHeight: boolean;
  103720. /**
  103721. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103722. */
  103723. axisXControlRotation: boolean;
  103724. /**
  103725. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103726. */
  103727. axisYControlRadius: boolean;
  103728. /**
  103729. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103730. */
  103731. axisYControlHeight: boolean;
  103732. /**
  103733. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103734. */
  103735. axisYControlRotation: boolean;
  103736. /**
  103737. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103738. */
  103739. axisPinchControlRadius: boolean;
  103740. /**
  103741. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103742. */
  103743. axisPinchControlHeight: boolean;
  103744. /**
  103745. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103746. */
  103747. axisPinchControlRotation: boolean;
  103748. /**
  103749. * Log error messages if basic misconfiguration has occurred.
  103750. */
  103751. warningEnable: boolean;
  103752. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103753. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103754. private _warningCounter;
  103755. private _warning;
  103756. }
  103757. }
  103758. declare module BABYLON {
  103759. /**
  103760. * Default Inputs manager for the FollowCamera.
  103761. * It groups all the default supported inputs for ease of use.
  103762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103763. */
  103764. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103765. /**
  103766. * Instantiates a new FollowCameraInputsManager.
  103767. * @param camera Defines the camera the inputs belong to
  103768. */
  103769. constructor(camera: FollowCamera);
  103770. /**
  103771. * Add keyboard input support to the input manager.
  103772. * @returns the current input manager
  103773. */
  103774. addKeyboard(): FollowCameraInputsManager;
  103775. /**
  103776. * Add mouse wheel input support to the input manager.
  103777. * @returns the current input manager
  103778. */
  103779. addMouseWheel(): FollowCameraInputsManager;
  103780. /**
  103781. * Add pointers input support to the input manager.
  103782. * @returns the current input manager
  103783. */
  103784. addPointers(): FollowCameraInputsManager;
  103785. /**
  103786. * Add orientation input support to the input manager.
  103787. * @returns the current input manager
  103788. */
  103789. addVRDeviceOrientation(): FollowCameraInputsManager;
  103790. }
  103791. }
  103792. declare module BABYLON {
  103793. /**
  103794. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103795. * an arc rotate version arcFollowCamera are available.
  103796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103797. */
  103798. export class FollowCamera extends TargetCamera {
  103799. /**
  103800. * Distance the follow camera should follow an object at
  103801. */
  103802. radius: number;
  103803. /**
  103804. * Minimum allowed distance of the camera to the axis of rotation
  103805. * (The camera can not get closer).
  103806. * This can help limiting how the Camera is able to move in the scene.
  103807. */
  103808. lowerRadiusLimit: Nullable<number>;
  103809. /**
  103810. * Maximum allowed distance of the camera to the axis of rotation
  103811. * (The camera can not get further).
  103812. * This can help limiting how the Camera is able to move in the scene.
  103813. */
  103814. upperRadiusLimit: Nullable<number>;
  103815. /**
  103816. * Define a rotation offset between the camera and the object it follows
  103817. */
  103818. rotationOffset: number;
  103819. /**
  103820. * Minimum allowed angle to camera position relative to target object.
  103821. * This can help limiting how the Camera is able to move in the scene.
  103822. */
  103823. lowerRotationOffsetLimit: Nullable<number>;
  103824. /**
  103825. * Maximum allowed angle to camera position relative to target object.
  103826. * This can help limiting how the Camera is able to move in the scene.
  103827. */
  103828. upperRotationOffsetLimit: Nullable<number>;
  103829. /**
  103830. * Define a height offset between the camera and the object it follows.
  103831. * It can help following an object from the top (like a car chaing a plane)
  103832. */
  103833. heightOffset: number;
  103834. /**
  103835. * Minimum allowed height of camera position relative to target object.
  103836. * This can help limiting how the Camera is able to move in the scene.
  103837. */
  103838. lowerHeightOffsetLimit: Nullable<number>;
  103839. /**
  103840. * Maximum allowed height of camera position relative to target object.
  103841. * This can help limiting how the Camera is able to move in the scene.
  103842. */
  103843. upperHeightOffsetLimit: Nullable<number>;
  103844. /**
  103845. * Define how fast the camera can accelerate to follow it s target.
  103846. */
  103847. cameraAcceleration: number;
  103848. /**
  103849. * Define the speed limit of the camera following an object.
  103850. */
  103851. maxCameraSpeed: number;
  103852. /**
  103853. * Define the target of the camera.
  103854. */
  103855. lockedTarget: Nullable<AbstractMesh>;
  103856. /**
  103857. * Defines the input associated with the camera.
  103858. */
  103859. inputs: FollowCameraInputsManager;
  103860. /**
  103861. * Instantiates the follow camera.
  103862. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103863. * @param name Define the name of the camera in the scene
  103864. * @param position Define the position of the camera
  103865. * @param scene Define the scene the camera belong to
  103866. * @param lockedTarget Define the target of the camera
  103867. */
  103868. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103869. private _follow;
  103870. /**
  103871. * Attached controls to the current camera.
  103872. * @param element Defines the element the controls should be listened from
  103873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103874. */
  103875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103876. /**
  103877. * Detach the current controls from the camera.
  103878. * The camera will stop reacting to inputs.
  103879. * @param element Defines the element to stop listening the inputs from
  103880. */
  103881. detachControl(element: HTMLElement): void;
  103882. /** @hidden */
  103883. _checkInputs(): void;
  103884. private _checkLimits;
  103885. /**
  103886. * Gets the camera class name.
  103887. * @returns the class name
  103888. */
  103889. getClassName(): string;
  103890. }
  103891. /**
  103892. * Arc Rotate version of the follow camera.
  103893. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103894. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103895. */
  103896. export class ArcFollowCamera extends TargetCamera {
  103897. /** The longitudinal angle of the camera */
  103898. alpha: number;
  103899. /** The latitudinal angle of the camera */
  103900. beta: number;
  103901. /** The radius of the camera from its target */
  103902. radius: number;
  103903. /** Define the camera target (the messh it should follow) */
  103904. target: Nullable<AbstractMesh>;
  103905. private _cartesianCoordinates;
  103906. /**
  103907. * Instantiates a new ArcFollowCamera
  103908. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103909. * @param name Define the name of the camera
  103910. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103911. * @param beta Define the rotation angle of the camera around the elevation axis
  103912. * @param radius Define the radius of the camera from its target point
  103913. * @param target Define the target of the camera
  103914. * @param scene Define the scene the camera belongs to
  103915. */
  103916. constructor(name: string,
  103917. /** The longitudinal angle of the camera */
  103918. alpha: number,
  103919. /** The latitudinal angle of the camera */
  103920. beta: number,
  103921. /** The radius of the camera from its target */
  103922. radius: number,
  103923. /** Define the camera target (the messh it should follow) */
  103924. target: Nullable<AbstractMesh>, scene: Scene);
  103925. private _follow;
  103926. /** @hidden */
  103927. _checkInputs(): void;
  103928. /**
  103929. * Returns the class name of the object.
  103930. * It is mostly used internally for serialization purposes.
  103931. */
  103932. getClassName(): string;
  103933. }
  103934. }
  103935. declare module BABYLON {
  103936. /**
  103937. * Manage the keyboard inputs to control the movement of a follow camera.
  103938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103939. */
  103940. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103941. /**
  103942. * Defines the camera the input is attached to.
  103943. */
  103944. camera: FollowCamera;
  103945. /**
  103946. * Defines the list of key codes associated with the up action (increase heightOffset)
  103947. */
  103948. keysHeightOffsetIncr: number[];
  103949. /**
  103950. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103951. */
  103952. keysHeightOffsetDecr: number[];
  103953. /**
  103954. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103955. */
  103956. keysHeightOffsetModifierAlt: boolean;
  103957. /**
  103958. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103959. */
  103960. keysHeightOffsetModifierCtrl: boolean;
  103961. /**
  103962. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103963. */
  103964. keysHeightOffsetModifierShift: boolean;
  103965. /**
  103966. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103967. */
  103968. keysRotationOffsetIncr: number[];
  103969. /**
  103970. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103971. */
  103972. keysRotationOffsetDecr: number[];
  103973. /**
  103974. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103975. */
  103976. keysRotationOffsetModifierAlt: boolean;
  103977. /**
  103978. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103979. */
  103980. keysRotationOffsetModifierCtrl: boolean;
  103981. /**
  103982. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103983. */
  103984. keysRotationOffsetModifierShift: boolean;
  103985. /**
  103986. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103987. */
  103988. keysRadiusIncr: number[];
  103989. /**
  103990. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103991. */
  103992. keysRadiusDecr: number[];
  103993. /**
  103994. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103995. */
  103996. keysRadiusModifierAlt: boolean;
  103997. /**
  103998. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103999. */
  104000. keysRadiusModifierCtrl: boolean;
  104001. /**
  104002. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104003. */
  104004. keysRadiusModifierShift: boolean;
  104005. /**
  104006. * Defines the rate of change of heightOffset.
  104007. */
  104008. heightSensibility: number;
  104009. /**
  104010. * Defines the rate of change of rotationOffset.
  104011. */
  104012. rotationSensibility: number;
  104013. /**
  104014. * Defines the rate of change of radius.
  104015. */
  104016. radiusSensibility: number;
  104017. private _keys;
  104018. private _ctrlPressed;
  104019. private _altPressed;
  104020. private _shiftPressed;
  104021. private _onCanvasBlurObserver;
  104022. private _onKeyboardObserver;
  104023. private _engine;
  104024. private _scene;
  104025. /**
  104026. * Attach the input controls to a specific dom element to get the input from.
  104027. * @param element Defines the element the controls should be listened from
  104028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104029. */
  104030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104031. /**
  104032. * Detach the current controls from the specified dom element.
  104033. * @param element Defines the element to stop listening the inputs from
  104034. */
  104035. detachControl(element: Nullable<HTMLElement>): void;
  104036. /**
  104037. * Update the current camera state depending on the inputs that have been used this frame.
  104038. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104039. */
  104040. checkInputs(): void;
  104041. /**
  104042. * Gets the class name of the current input.
  104043. * @returns the class name
  104044. */
  104045. getClassName(): string;
  104046. /**
  104047. * Get the friendly name associated with the input class.
  104048. * @returns the input friendly name
  104049. */
  104050. getSimpleName(): string;
  104051. /**
  104052. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104053. * allow modification of the heightOffset value.
  104054. */
  104055. private _modifierHeightOffset;
  104056. /**
  104057. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104058. * allow modification of the rotationOffset value.
  104059. */
  104060. private _modifierRotationOffset;
  104061. /**
  104062. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104063. * allow modification of the radius value.
  104064. */
  104065. private _modifierRadius;
  104066. }
  104067. }
  104068. declare module BABYLON {
  104069. interface FreeCameraInputsManager {
  104070. /**
  104071. * @hidden
  104072. */
  104073. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104074. /**
  104075. * Add orientation input support to the input manager.
  104076. * @returns the current input manager
  104077. */
  104078. addDeviceOrientation(): FreeCameraInputsManager;
  104079. }
  104080. /**
  104081. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104082. * Screen rotation is taken into account.
  104083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104084. */
  104085. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104086. private _camera;
  104087. private _screenOrientationAngle;
  104088. private _constantTranform;
  104089. private _screenQuaternion;
  104090. private _alpha;
  104091. private _beta;
  104092. private _gamma;
  104093. /**
  104094. * Can be used to detect if a device orientation sensor is availible on a device
  104095. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104096. * @returns a promise that will resolve on orientation change
  104097. */
  104098. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104099. /**
  104100. * @hidden
  104101. */
  104102. _onDeviceOrientationChangedObservable: Observable<void>;
  104103. /**
  104104. * Instantiates a new input
  104105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104106. */
  104107. constructor();
  104108. /**
  104109. * Define the camera controlled by the input.
  104110. */
  104111. camera: FreeCamera;
  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. private _orientationChanged;
  104119. private _deviceOrientation;
  104120. /**
  104121. * Detach the current controls from the specified dom element.
  104122. * @param element Defines the element to stop listening the inputs from
  104123. */
  104124. detachControl(element: Nullable<HTMLElement>): void;
  104125. /**
  104126. * Update the current camera state depending on the inputs that have been used this frame.
  104127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104128. */
  104129. checkInputs(): void;
  104130. /**
  104131. * Gets the class name of the current intput.
  104132. * @returns the class name
  104133. */
  104134. getClassName(): string;
  104135. /**
  104136. * Get the friendly name associated with the input class.
  104137. * @returns the input friendly name
  104138. */
  104139. getSimpleName(): string;
  104140. }
  104141. }
  104142. declare module BABYLON {
  104143. /**
  104144. * Manage the gamepad inputs to control a free camera.
  104145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104146. */
  104147. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104148. /**
  104149. * Define the camera the input is attached to.
  104150. */
  104151. camera: FreeCamera;
  104152. /**
  104153. * Define the Gamepad controlling the input
  104154. */
  104155. gamepad: Nullable<Gamepad>;
  104156. /**
  104157. * Defines the gamepad rotation sensiblity.
  104158. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104159. */
  104160. gamepadAngularSensibility: number;
  104161. /**
  104162. * Defines the gamepad move sensiblity.
  104163. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104164. */
  104165. gamepadMoveSensibility: number;
  104166. private _onGamepadConnectedObserver;
  104167. private _onGamepadDisconnectedObserver;
  104168. private _cameraTransform;
  104169. private _deltaTransform;
  104170. private _vector3;
  104171. private _vector2;
  104172. /**
  104173. * Attach the input controls to a specific dom element to get the input from.
  104174. * @param element Defines the element the controls should be listened from
  104175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104176. */
  104177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104178. /**
  104179. * Detach the current controls from the specified dom element.
  104180. * @param element Defines the element to stop listening the inputs from
  104181. */
  104182. detachControl(element: Nullable<HTMLElement>): void;
  104183. /**
  104184. * Update the current camera state depending on the inputs that have been used this frame.
  104185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104186. */
  104187. checkInputs(): void;
  104188. /**
  104189. * Gets the class name of the current intput.
  104190. * @returns the class name
  104191. */
  104192. getClassName(): string;
  104193. /**
  104194. * Get the friendly name associated with the input class.
  104195. * @returns the input friendly name
  104196. */
  104197. getSimpleName(): string;
  104198. }
  104199. }
  104200. declare module BABYLON {
  104201. /**
  104202. * Defines the potential axis of a Joystick
  104203. */
  104204. export enum JoystickAxis {
  104205. /** X axis */
  104206. X = 0,
  104207. /** Y axis */
  104208. Y = 1,
  104209. /** Z axis */
  104210. Z = 2
  104211. }
  104212. /**
  104213. * Class used to define virtual joystick (used in touch mode)
  104214. */
  104215. export class VirtualJoystick {
  104216. /**
  104217. * Gets or sets a boolean indicating that left and right values must be inverted
  104218. */
  104219. reverseLeftRight: boolean;
  104220. /**
  104221. * Gets or sets a boolean indicating that up and down values must be inverted
  104222. */
  104223. reverseUpDown: boolean;
  104224. /**
  104225. * Gets the offset value for the position (ie. the change of the position value)
  104226. */
  104227. deltaPosition: Vector3;
  104228. /**
  104229. * Gets a boolean indicating if the virtual joystick was pressed
  104230. */
  104231. pressed: boolean;
  104232. /**
  104233. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104234. */
  104235. static Canvas: Nullable<HTMLCanvasElement>;
  104236. private static _globalJoystickIndex;
  104237. private static vjCanvasContext;
  104238. private static vjCanvasWidth;
  104239. private static vjCanvasHeight;
  104240. private static halfWidth;
  104241. private _action;
  104242. private _axisTargetedByLeftAndRight;
  104243. private _axisTargetedByUpAndDown;
  104244. private _joystickSensibility;
  104245. private _inversedSensibility;
  104246. private _joystickPointerID;
  104247. private _joystickColor;
  104248. private _joystickPointerPos;
  104249. private _joystickPreviousPointerPos;
  104250. private _joystickPointerStartPos;
  104251. private _deltaJoystickVector;
  104252. private _leftJoystick;
  104253. private _touches;
  104254. private _onPointerDownHandlerRef;
  104255. private _onPointerMoveHandlerRef;
  104256. private _onPointerUpHandlerRef;
  104257. private _onResize;
  104258. /**
  104259. * Creates a new virtual joystick
  104260. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104261. */
  104262. constructor(leftJoystick?: boolean);
  104263. /**
  104264. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104265. * @param newJoystickSensibility defines the new sensibility
  104266. */
  104267. setJoystickSensibility(newJoystickSensibility: number): void;
  104268. private _onPointerDown;
  104269. private _onPointerMove;
  104270. private _onPointerUp;
  104271. /**
  104272. * Change the color of the virtual joystick
  104273. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104274. */
  104275. setJoystickColor(newColor: string): void;
  104276. /**
  104277. * Defines a callback to call when the joystick is touched
  104278. * @param action defines the callback
  104279. */
  104280. setActionOnTouch(action: () => any): void;
  104281. /**
  104282. * Defines which axis you'd like to control for left & right
  104283. * @param axis defines the axis to use
  104284. */
  104285. setAxisForLeftRight(axis: JoystickAxis): void;
  104286. /**
  104287. * Defines which axis you'd like to control for up & down
  104288. * @param axis defines the axis to use
  104289. */
  104290. setAxisForUpDown(axis: JoystickAxis): void;
  104291. private _drawVirtualJoystick;
  104292. /**
  104293. * Release internal HTML canvas
  104294. */
  104295. releaseCanvas(): void;
  104296. }
  104297. }
  104298. declare module BABYLON {
  104299. interface FreeCameraInputsManager {
  104300. /**
  104301. * Add virtual joystick input support to the input manager.
  104302. * @returns the current input manager
  104303. */
  104304. addVirtualJoystick(): FreeCameraInputsManager;
  104305. }
  104306. /**
  104307. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104309. */
  104310. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104311. /**
  104312. * Defines the camera the input is attached to.
  104313. */
  104314. camera: FreeCamera;
  104315. private _leftjoystick;
  104316. private _rightjoystick;
  104317. /**
  104318. * Gets the left stick of the virtual joystick.
  104319. * @returns The virtual Joystick
  104320. */
  104321. getLeftJoystick(): VirtualJoystick;
  104322. /**
  104323. * Gets the right stick of the virtual joystick.
  104324. * @returns The virtual Joystick
  104325. */
  104326. getRightJoystick(): VirtualJoystick;
  104327. /**
  104328. * Update the current camera state depending on the inputs that have been used this frame.
  104329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104330. */
  104331. checkInputs(): void;
  104332. /**
  104333. * Attach the input controls to a specific dom element to get the input from.
  104334. * @param element Defines the element the controls should be listened from
  104335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104336. */
  104337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104338. /**
  104339. * Detach the current controls from the specified dom element.
  104340. * @param element Defines the element to stop listening the inputs from
  104341. */
  104342. detachControl(element: Nullable<HTMLElement>): void;
  104343. /**
  104344. * Gets the class name of the current intput.
  104345. * @returns the class name
  104346. */
  104347. getClassName(): string;
  104348. /**
  104349. * Get the friendly name associated with the input class.
  104350. * @returns the input friendly name
  104351. */
  104352. getSimpleName(): string;
  104353. }
  104354. }
  104355. declare module BABYLON {
  104356. /**
  104357. * This represents a FPS type of camera controlled by touch.
  104358. * This is like a universal camera minus the Gamepad controls.
  104359. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104360. */
  104361. export class TouchCamera extends FreeCamera {
  104362. /**
  104363. * Defines the touch sensibility for rotation.
  104364. * The higher the faster.
  104365. */
  104366. touchAngularSensibility: number;
  104367. /**
  104368. * Defines the touch sensibility for move.
  104369. * The higher the faster.
  104370. */
  104371. touchMoveSensibility: number;
  104372. /**
  104373. * Instantiates a new touch camera.
  104374. * This represents a FPS type of camera controlled by touch.
  104375. * This is like a universal camera minus the Gamepad controls.
  104376. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104377. * @param name Define the name of the camera in the scene
  104378. * @param position Define the start position of the camera in the scene
  104379. * @param scene Define the scene the camera belongs to
  104380. */
  104381. constructor(name: string, position: Vector3, scene: Scene);
  104382. /**
  104383. * Gets the current object class name.
  104384. * @return the class name
  104385. */
  104386. getClassName(): string;
  104387. /** @hidden */
  104388. _setupInputs(): void;
  104389. }
  104390. }
  104391. declare module BABYLON {
  104392. /**
  104393. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104394. * being tilted forward or back and left or right.
  104395. */
  104396. export class DeviceOrientationCamera extends FreeCamera {
  104397. private _initialQuaternion;
  104398. private _quaternionCache;
  104399. private _tmpDragQuaternion;
  104400. private _disablePointerInputWhenUsingDeviceOrientation;
  104401. /**
  104402. * Creates a new device orientation camera
  104403. * @param name The name of the camera
  104404. * @param position The start position camera
  104405. * @param scene The scene the camera belongs to
  104406. */
  104407. constructor(name: string, position: Vector3, scene: Scene);
  104408. /**
  104409. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104410. */
  104411. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104412. private _dragFactor;
  104413. /**
  104414. * Enabled turning on the y axis when the orientation sensor is active
  104415. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104416. */
  104417. enableHorizontalDragging(dragFactor?: number): void;
  104418. /**
  104419. * Gets the current instance class name ("DeviceOrientationCamera").
  104420. * This helps avoiding instanceof at run time.
  104421. * @returns the class name
  104422. */
  104423. getClassName(): string;
  104424. /**
  104425. * @hidden
  104426. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104427. */
  104428. _checkInputs(): void;
  104429. /**
  104430. * Reset the camera to its default orientation on the specified axis only.
  104431. * @param axis The axis to reset
  104432. */
  104433. resetToCurrentRotation(axis?: Axis): void;
  104434. }
  104435. }
  104436. declare module BABYLON {
  104437. /**
  104438. * Defines supported buttons for XBox360 compatible gamepads
  104439. */
  104440. export enum Xbox360Button {
  104441. /** A */
  104442. A = 0,
  104443. /** B */
  104444. B = 1,
  104445. /** X */
  104446. X = 2,
  104447. /** Y */
  104448. Y = 3,
  104449. /** Start */
  104450. Start = 4,
  104451. /** Back */
  104452. Back = 5,
  104453. /** Left button */
  104454. LB = 6,
  104455. /** Right button */
  104456. RB = 7,
  104457. /** Left stick */
  104458. LeftStick = 8,
  104459. /** Right stick */
  104460. RightStick = 9
  104461. }
  104462. /** Defines values for XBox360 DPad */
  104463. export enum Xbox360Dpad {
  104464. /** Up */
  104465. Up = 0,
  104466. /** Down */
  104467. Down = 1,
  104468. /** Left */
  104469. Left = 2,
  104470. /** Right */
  104471. Right = 3
  104472. }
  104473. /**
  104474. * Defines a XBox360 gamepad
  104475. */
  104476. export class Xbox360Pad extends Gamepad {
  104477. private _leftTrigger;
  104478. private _rightTrigger;
  104479. private _onlefttriggerchanged;
  104480. private _onrighttriggerchanged;
  104481. private _onbuttondown;
  104482. private _onbuttonup;
  104483. private _ondpaddown;
  104484. private _ondpadup;
  104485. /** Observable raised when a button is pressed */
  104486. onButtonDownObservable: Observable<Xbox360Button>;
  104487. /** Observable raised when a button is released */
  104488. onButtonUpObservable: Observable<Xbox360Button>;
  104489. /** Observable raised when a pad is pressed */
  104490. onPadDownObservable: Observable<Xbox360Dpad>;
  104491. /** Observable raised when a pad is released */
  104492. onPadUpObservable: Observable<Xbox360Dpad>;
  104493. private _buttonA;
  104494. private _buttonB;
  104495. private _buttonX;
  104496. private _buttonY;
  104497. private _buttonBack;
  104498. private _buttonStart;
  104499. private _buttonLB;
  104500. private _buttonRB;
  104501. private _buttonLeftStick;
  104502. private _buttonRightStick;
  104503. private _dPadUp;
  104504. private _dPadDown;
  104505. private _dPadLeft;
  104506. private _dPadRight;
  104507. private _isXboxOnePad;
  104508. /**
  104509. * Creates a new XBox360 gamepad object
  104510. * @param id defines the id of this gamepad
  104511. * @param index defines its index
  104512. * @param gamepad defines the internal HTML gamepad object
  104513. * @param xboxOne defines if it is a XBox One gamepad
  104514. */
  104515. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104516. /**
  104517. * Defines the callback to call when left trigger is pressed
  104518. * @param callback defines the callback to use
  104519. */
  104520. onlefttriggerchanged(callback: (value: number) => void): void;
  104521. /**
  104522. * Defines the callback to call when right trigger is pressed
  104523. * @param callback defines the callback to use
  104524. */
  104525. onrighttriggerchanged(callback: (value: number) => void): void;
  104526. /**
  104527. * Gets the left trigger value
  104528. */
  104529. /**
  104530. * Sets the left trigger value
  104531. */
  104532. leftTrigger: number;
  104533. /**
  104534. * Gets the right trigger value
  104535. */
  104536. /**
  104537. * Sets the right trigger value
  104538. */
  104539. rightTrigger: number;
  104540. /**
  104541. * Defines the callback to call when a button is pressed
  104542. * @param callback defines the callback to use
  104543. */
  104544. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104545. /**
  104546. * Defines the callback to call when a button is released
  104547. * @param callback defines the callback to use
  104548. */
  104549. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104550. /**
  104551. * Defines the callback to call when a pad is pressed
  104552. * @param callback defines the callback to use
  104553. */
  104554. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104555. /**
  104556. * Defines the callback to call when a pad is released
  104557. * @param callback defines the callback to use
  104558. */
  104559. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104560. private _setButtonValue;
  104561. private _setDPadValue;
  104562. /**
  104563. * Gets the value of the `A` button
  104564. */
  104565. /**
  104566. * Sets the value of the `A` button
  104567. */
  104568. buttonA: number;
  104569. /**
  104570. * Gets the value of the `B` button
  104571. */
  104572. /**
  104573. * Sets the value of the `B` button
  104574. */
  104575. buttonB: number;
  104576. /**
  104577. * Gets the value of the `X` button
  104578. */
  104579. /**
  104580. * Sets the value of the `X` button
  104581. */
  104582. buttonX: number;
  104583. /**
  104584. * Gets the value of the `Y` button
  104585. */
  104586. /**
  104587. * Sets the value of the `Y` button
  104588. */
  104589. buttonY: number;
  104590. /**
  104591. * Gets the value of the `Start` button
  104592. */
  104593. /**
  104594. * Sets the value of the `Start` button
  104595. */
  104596. buttonStart: number;
  104597. /**
  104598. * Gets the value of the `Back` button
  104599. */
  104600. /**
  104601. * Sets the value of the `Back` button
  104602. */
  104603. buttonBack: number;
  104604. /**
  104605. * Gets the value of the `Left` button
  104606. */
  104607. /**
  104608. * Sets the value of the `Left` button
  104609. */
  104610. buttonLB: number;
  104611. /**
  104612. * Gets the value of the `Right` button
  104613. */
  104614. /**
  104615. * Sets the value of the `Right` button
  104616. */
  104617. buttonRB: number;
  104618. /**
  104619. * Gets the value of the Left joystick
  104620. */
  104621. /**
  104622. * Sets the value of the Left joystick
  104623. */
  104624. buttonLeftStick: number;
  104625. /**
  104626. * Gets the value of the Right joystick
  104627. */
  104628. /**
  104629. * Sets the value of the Right joystick
  104630. */
  104631. buttonRightStick: number;
  104632. /**
  104633. * Gets the value of D-pad up
  104634. */
  104635. /**
  104636. * Sets the value of D-pad up
  104637. */
  104638. dPadUp: number;
  104639. /**
  104640. * Gets the value of D-pad down
  104641. */
  104642. /**
  104643. * Sets the value of D-pad down
  104644. */
  104645. dPadDown: number;
  104646. /**
  104647. * Gets the value of D-pad left
  104648. */
  104649. /**
  104650. * Sets the value of D-pad left
  104651. */
  104652. dPadLeft: number;
  104653. /**
  104654. * Gets the value of D-pad right
  104655. */
  104656. /**
  104657. * Sets the value of D-pad right
  104658. */
  104659. dPadRight: number;
  104660. /**
  104661. * Force the gamepad to synchronize with device values
  104662. */
  104663. update(): void;
  104664. /**
  104665. * Disposes the gamepad
  104666. */
  104667. dispose(): void;
  104668. }
  104669. }
  104670. declare module BABYLON {
  104671. /**
  104672. * Defines supported buttons for DualShock compatible gamepads
  104673. */
  104674. export enum DualShockButton {
  104675. /** Cross */
  104676. Cross = 0,
  104677. /** Circle */
  104678. Circle = 1,
  104679. /** Square */
  104680. Square = 2,
  104681. /** Triangle */
  104682. Triangle = 3,
  104683. /** Options */
  104684. Options = 4,
  104685. /** Share */
  104686. Share = 5,
  104687. /** L1 */
  104688. L1 = 6,
  104689. /** R1 */
  104690. R1 = 7,
  104691. /** Left stick */
  104692. LeftStick = 8,
  104693. /** Right stick */
  104694. RightStick = 9
  104695. }
  104696. /** Defines values for DualShock DPad */
  104697. export enum DualShockDpad {
  104698. /** Up */
  104699. Up = 0,
  104700. /** Down */
  104701. Down = 1,
  104702. /** Left */
  104703. Left = 2,
  104704. /** Right */
  104705. Right = 3
  104706. }
  104707. /**
  104708. * Defines a DualShock gamepad
  104709. */
  104710. export class DualShockPad extends Gamepad {
  104711. private _leftTrigger;
  104712. private _rightTrigger;
  104713. private _onlefttriggerchanged;
  104714. private _onrighttriggerchanged;
  104715. private _onbuttondown;
  104716. private _onbuttonup;
  104717. private _ondpaddown;
  104718. private _ondpadup;
  104719. /** Observable raised when a button is pressed */
  104720. onButtonDownObservable: Observable<DualShockButton>;
  104721. /** Observable raised when a button is released */
  104722. onButtonUpObservable: Observable<DualShockButton>;
  104723. /** Observable raised when a pad is pressed */
  104724. onPadDownObservable: Observable<DualShockDpad>;
  104725. /** Observable raised when a pad is released */
  104726. onPadUpObservable: Observable<DualShockDpad>;
  104727. private _buttonCross;
  104728. private _buttonCircle;
  104729. private _buttonSquare;
  104730. private _buttonTriangle;
  104731. private _buttonShare;
  104732. private _buttonOptions;
  104733. private _buttonL1;
  104734. private _buttonR1;
  104735. private _buttonLeftStick;
  104736. private _buttonRightStick;
  104737. private _dPadUp;
  104738. private _dPadDown;
  104739. private _dPadLeft;
  104740. private _dPadRight;
  104741. /**
  104742. * Creates a new DualShock gamepad object
  104743. * @param id defines the id of this gamepad
  104744. * @param index defines its index
  104745. * @param gamepad defines the internal HTML gamepad object
  104746. */
  104747. constructor(id: string, index: number, gamepad: any);
  104748. /**
  104749. * Defines the callback to call when left trigger is pressed
  104750. * @param callback defines the callback to use
  104751. */
  104752. onlefttriggerchanged(callback: (value: number) => void): void;
  104753. /**
  104754. * Defines the callback to call when right trigger is pressed
  104755. * @param callback defines the callback to use
  104756. */
  104757. onrighttriggerchanged(callback: (value: number) => void): void;
  104758. /**
  104759. * Gets the left trigger value
  104760. */
  104761. /**
  104762. * Sets the left trigger value
  104763. */
  104764. leftTrigger: number;
  104765. /**
  104766. * Gets the right trigger value
  104767. */
  104768. /**
  104769. * Sets the right trigger value
  104770. */
  104771. rightTrigger: number;
  104772. /**
  104773. * Defines the callback to call when a button is pressed
  104774. * @param callback defines the callback to use
  104775. */
  104776. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104777. /**
  104778. * Defines the callback to call when a button is released
  104779. * @param callback defines the callback to use
  104780. */
  104781. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104782. /**
  104783. * Defines the callback to call when a pad is pressed
  104784. * @param callback defines the callback to use
  104785. */
  104786. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104787. /**
  104788. * Defines the callback to call when a pad is released
  104789. * @param callback defines the callback to use
  104790. */
  104791. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104792. private _setButtonValue;
  104793. private _setDPadValue;
  104794. /**
  104795. * Gets the value of the `Cross` button
  104796. */
  104797. /**
  104798. * Sets the value of the `Cross` button
  104799. */
  104800. buttonCross: number;
  104801. /**
  104802. * Gets the value of the `Circle` button
  104803. */
  104804. /**
  104805. * Sets the value of the `Circle` button
  104806. */
  104807. buttonCircle: number;
  104808. /**
  104809. * Gets the value of the `Square` button
  104810. */
  104811. /**
  104812. * Sets the value of the `Square` button
  104813. */
  104814. buttonSquare: number;
  104815. /**
  104816. * Gets the value of the `Triangle` button
  104817. */
  104818. /**
  104819. * Sets the value of the `Triangle` button
  104820. */
  104821. buttonTriangle: number;
  104822. /**
  104823. * Gets the value of the `Options` button
  104824. */
  104825. /**
  104826. * Sets the value of the `Options` button
  104827. */
  104828. buttonOptions: number;
  104829. /**
  104830. * Gets the value of the `Share` button
  104831. */
  104832. /**
  104833. * Sets the value of the `Share` button
  104834. */
  104835. buttonShare: number;
  104836. /**
  104837. * Gets the value of the `L1` button
  104838. */
  104839. /**
  104840. * Sets the value of the `L1` button
  104841. */
  104842. buttonL1: number;
  104843. /**
  104844. * Gets the value of the `R1` button
  104845. */
  104846. /**
  104847. * Sets the value of the `R1` button
  104848. */
  104849. buttonR1: number;
  104850. /**
  104851. * Gets the value of the Left joystick
  104852. */
  104853. /**
  104854. * Sets the value of the Left joystick
  104855. */
  104856. buttonLeftStick: number;
  104857. /**
  104858. * Gets the value of the Right joystick
  104859. */
  104860. /**
  104861. * Sets the value of the Right joystick
  104862. */
  104863. buttonRightStick: number;
  104864. /**
  104865. * Gets the value of D-pad up
  104866. */
  104867. /**
  104868. * Sets the value of D-pad up
  104869. */
  104870. dPadUp: number;
  104871. /**
  104872. * Gets the value of D-pad down
  104873. */
  104874. /**
  104875. * Sets the value of D-pad down
  104876. */
  104877. dPadDown: number;
  104878. /**
  104879. * Gets the value of D-pad left
  104880. */
  104881. /**
  104882. * Sets the value of D-pad left
  104883. */
  104884. dPadLeft: number;
  104885. /**
  104886. * Gets the value of D-pad right
  104887. */
  104888. /**
  104889. * Sets the value of D-pad right
  104890. */
  104891. dPadRight: number;
  104892. /**
  104893. * Force the gamepad to synchronize with device values
  104894. */
  104895. update(): void;
  104896. /**
  104897. * Disposes the gamepad
  104898. */
  104899. dispose(): void;
  104900. }
  104901. }
  104902. declare module BABYLON {
  104903. /**
  104904. * Manager for handling gamepads
  104905. */
  104906. export class GamepadManager {
  104907. private _scene?;
  104908. private _babylonGamepads;
  104909. private _oneGamepadConnected;
  104910. /** @hidden */
  104911. _isMonitoring: boolean;
  104912. private _gamepadEventSupported;
  104913. private _gamepadSupport;
  104914. /**
  104915. * observable to be triggered when the gamepad controller has been connected
  104916. */
  104917. onGamepadConnectedObservable: Observable<Gamepad>;
  104918. /**
  104919. * observable to be triggered when the gamepad controller has been disconnected
  104920. */
  104921. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104922. private _onGamepadConnectedEvent;
  104923. private _onGamepadDisconnectedEvent;
  104924. /**
  104925. * Initializes the gamepad manager
  104926. * @param _scene BabylonJS scene
  104927. */
  104928. constructor(_scene?: Scene | undefined);
  104929. /**
  104930. * The gamepads in the game pad manager
  104931. */
  104932. readonly gamepads: Gamepad[];
  104933. /**
  104934. * Get the gamepad controllers based on type
  104935. * @param type The type of gamepad controller
  104936. * @returns Nullable gamepad
  104937. */
  104938. getGamepadByType(type?: number): Nullable<Gamepad>;
  104939. /**
  104940. * Disposes the gamepad manager
  104941. */
  104942. dispose(): void;
  104943. private _addNewGamepad;
  104944. private _startMonitoringGamepads;
  104945. private _stopMonitoringGamepads;
  104946. /** @hidden */
  104947. _checkGamepadsStatus(): void;
  104948. private _updateGamepadObjects;
  104949. }
  104950. }
  104951. declare module BABYLON {
  104952. interface Scene {
  104953. /** @hidden */
  104954. _gamepadManager: Nullable<GamepadManager>;
  104955. /**
  104956. * Gets the gamepad manager associated with the scene
  104957. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104958. */
  104959. gamepadManager: GamepadManager;
  104960. }
  104961. /**
  104962. * Interface representing a free camera inputs manager
  104963. */
  104964. interface FreeCameraInputsManager {
  104965. /**
  104966. * Adds gamepad input support to the FreeCameraInputsManager.
  104967. * @returns the FreeCameraInputsManager
  104968. */
  104969. addGamepad(): FreeCameraInputsManager;
  104970. }
  104971. /**
  104972. * Interface representing an arc rotate camera inputs manager
  104973. */
  104974. interface ArcRotateCameraInputsManager {
  104975. /**
  104976. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104977. * @returns the camera inputs manager
  104978. */
  104979. addGamepad(): ArcRotateCameraInputsManager;
  104980. }
  104981. /**
  104982. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104983. */
  104984. export class GamepadSystemSceneComponent implements ISceneComponent {
  104985. /**
  104986. * The component name helpfull to identify the component in the list of scene components.
  104987. */
  104988. readonly name: string;
  104989. /**
  104990. * The scene the component belongs to.
  104991. */
  104992. scene: Scene;
  104993. /**
  104994. * Creates a new instance of the component for the given scene
  104995. * @param scene Defines the scene to register the component in
  104996. */
  104997. constructor(scene: Scene);
  104998. /**
  104999. * Registers the component in a given scene
  105000. */
  105001. register(): void;
  105002. /**
  105003. * Rebuilds the elements related to this component in case of
  105004. * context lost for instance.
  105005. */
  105006. rebuild(): void;
  105007. /**
  105008. * Disposes the component and the associated ressources
  105009. */
  105010. dispose(): void;
  105011. private _beforeCameraUpdate;
  105012. }
  105013. }
  105014. declare module BABYLON {
  105015. /**
  105016. * 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,
  105017. * which still works and will still be found in many Playgrounds.
  105018. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105019. */
  105020. export class UniversalCamera extends TouchCamera {
  105021. /**
  105022. * Defines the gamepad rotation sensiblity.
  105023. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105024. */
  105025. gamepadAngularSensibility: number;
  105026. /**
  105027. * Defines the gamepad move sensiblity.
  105028. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105029. */
  105030. gamepadMoveSensibility: number;
  105031. /**
  105032. * 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,
  105033. * which still works and will still be found in many Playgrounds.
  105034. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105035. * @param name Define the name of the camera in the scene
  105036. * @param position Define the start position of the camera in the scene
  105037. * @param scene Define the scene the camera belongs to
  105038. */
  105039. constructor(name: string, position: Vector3, scene: Scene);
  105040. /**
  105041. * Gets the current object class name.
  105042. * @return the class name
  105043. */
  105044. getClassName(): string;
  105045. }
  105046. }
  105047. declare module BABYLON {
  105048. /**
  105049. * This represents a FPS type of camera. This is only here for back compat purpose.
  105050. * Please use the UniversalCamera instead as both are identical.
  105051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105052. */
  105053. export class GamepadCamera extends UniversalCamera {
  105054. /**
  105055. * Instantiates a new Gamepad Camera
  105056. * This represents a FPS type of camera. This is only here for back compat purpose.
  105057. * Please use the UniversalCamera instead as both are identical.
  105058. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105059. * @param name Define the name of the camera in the scene
  105060. * @param position Define the start position of the camera in the scene
  105061. * @param scene Define the scene the camera belongs to
  105062. */
  105063. constructor(name: string, position: Vector3, scene: Scene);
  105064. /**
  105065. * Gets the current object class name.
  105066. * @return the class name
  105067. */
  105068. getClassName(): string;
  105069. }
  105070. }
  105071. declare module BABYLON {
  105072. /** @hidden */
  105073. export var passPixelShader: {
  105074. name: string;
  105075. shader: string;
  105076. };
  105077. }
  105078. declare module BABYLON {
  105079. /** @hidden */
  105080. export var passCubePixelShader: {
  105081. name: string;
  105082. shader: string;
  105083. };
  105084. }
  105085. declare module BABYLON {
  105086. /**
  105087. * PassPostProcess which produces an output the same as it's input
  105088. */
  105089. export class PassPostProcess extends PostProcess {
  105090. /**
  105091. * Creates the PassPostProcess
  105092. * @param name The name of the effect.
  105093. * @param options The required width/height ratio to downsize to before computing the render pass.
  105094. * @param camera The camera to apply the render pass to.
  105095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105096. * @param engine The engine which the post process will be applied. (default: current engine)
  105097. * @param reusable If the post process can be reused on the same frame. (default: false)
  105098. * @param textureType The type of texture to be used when performing the post processing.
  105099. * @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)
  105100. */
  105101. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105102. }
  105103. /**
  105104. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105105. */
  105106. export class PassCubePostProcess extends PostProcess {
  105107. private _face;
  105108. /**
  105109. * Gets or sets the cube face to display.
  105110. * * 0 is +X
  105111. * * 1 is -X
  105112. * * 2 is +Y
  105113. * * 3 is -Y
  105114. * * 4 is +Z
  105115. * * 5 is -Z
  105116. */
  105117. face: number;
  105118. /**
  105119. * Creates the PassCubePostProcess
  105120. * @param name The name of the effect.
  105121. * @param options The required width/height ratio to downsize to before computing the render pass.
  105122. * @param camera The camera to apply the render pass to.
  105123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105124. * @param engine The engine which the post process will be applied. (default: current engine)
  105125. * @param reusable If the post process can be reused on the same frame. (default: false)
  105126. * @param textureType The type of texture to be used when performing the post processing.
  105127. * @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)
  105128. */
  105129. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105130. }
  105131. }
  105132. declare module BABYLON {
  105133. /** @hidden */
  105134. export var anaglyphPixelShader: {
  105135. name: string;
  105136. shader: string;
  105137. };
  105138. }
  105139. declare module BABYLON {
  105140. /**
  105141. * Postprocess used to generate anaglyphic rendering
  105142. */
  105143. export class AnaglyphPostProcess extends PostProcess {
  105144. private _passedProcess;
  105145. /**
  105146. * Creates a new AnaglyphPostProcess
  105147. * @param name defines postprocess name
  105148. * @param options defines creation options or target ratio scale
  105149. * @param rigCameras defines cameras using this postprocess
  105150. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105151. * @param engine defines hosting engine
  105152. * @param reusable defines if the postprocess will be reused multiple times per frame
  105153. */
  105154. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105155. }
  105156. }
  105157. declare module BABYLON {
  105158. /**
  105159. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105160. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105161. */
  105162. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105163. /**
  105164. * Creates a new AnaglyphArcRotateCamera
  105165. * @param name defines camera name
  105166. * @param alpha defines alpha angle (in radians)
  105167. * @param beta defines beta angle (in radians)
  105168. * @param radius defines radius
  105169. * @param target defines camera target
  105170. * @param interaxialDistance defines distance between each color axis
  105171. * @param scene defines the hosting scene
  105172. */
  105173. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105174. /**
  105175. * Gets camera class name
  105176. * @returns AnaglyphArcRotateCamera
  105177. */
  105178. getClassName(): string;
  105179. }
  105180. }
  105181. declare module BABYLON {
  105182. /**
  105183. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105184. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105185. */
  105186. export class AnaglyphFreeCamera extends FreeCamera {
  105187. /**
  105188. * Creates a new AnaglyphFreeCamera
  105189. * @param name defines camera name
  105190. * @param position defines initial position
  105191. * @param interaxialDistance defines distance between each color axis
  105192. * @param scene defines the hosting scene
  105193. */
  105194. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105195. /**
  105196. * Gets camera class name
  105197. * @returns AnaglyphFreeCamera
  105198. */
  105199. getClassName(): string;
  105200. }
  105201. }
  105202. declare module BABYLON {
  105203. /**
  105204. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105205. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105206. */
  105207. export class AnaglyphGamepadCamera extends GamepadCamera {
  105208. /**
  105209. * Creates a new AnaglyphGamepadCamera
  105210. * @param name defines camera name
  105211. * @param position defines initial position
  105212. * @param interaxialDistance defines distance between each color axis
  105213. * @param scene defines the hosting scene
  105214. */
  105215. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105216. /**
  105217. * Gets camera class name
  105218. * @returns AnaglyphGamepadCamera
  105219. */
  105220. getClassName(): string;
  105221. }
  105222. }
  105223. declare module BABYLON {
  105224. /**
  105225. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105226. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105227. */
  105228. export class AnaglyphUniversalCamera extends UniversalCamera {
  105229. /**
  105230. * Creates a new AnaglyphUniversalCamera
  105231. * @param name defines camera name
  105232. * @param position defines initial position
  105233. * @param interaxialDistance defines distance between each color axis
  105234. * @param scene defines the hosting scene
  105235. */
  105236. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105237. /**
  105238. * Gets camera class name
  105239. * @returns AnaglyphUniversalCamera
  105240. */
  105241. getClassName(): string;
  105242. }
  105243. }
  105244. declare module BABYLON {
  105245. /** @hidden */
  105246. export var stereoscopicInterlacePixelShader: {
  105247. name: string;
  105248. shader: string;
  105249. };
  105250. }
  105251. declare module BABYLON {
  105252. /**
  105253. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105254. */
  105255. export class StereoscopicInterlacePostProcess extends PostProcess {
  105256. private _stepSize;
  105257. private _passedProcess;
  105258. /**
  105259. * Initializes a StereoscopicInterlacePostProcess
  105260. * @param name The name of the effect.
  105261. * @param rigCameras The rig cameras to be appled to the post process
  105262. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105264. * @param engine The engine which the post process will be applied. (default: current engine)
  105265. * @param reusable If the post process can be reused on the same frame. (default: false)
  105266. */
  105267. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105268. }
  105269. }
  105270. declare module BABYLON {
  105271. /**
  105272. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105273. * @see http://doc.babylonjs.com/features/cameras
  105274. */
  105275. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105276. /**
  105277. * Creates a new StereoscopicArcRotateCamera
  105278. * @param name defines camera name
  105279. * @param alpha defines alpha angle (in radians)
  105280. * @param beta defines beta angle (in radians)
  105281. * @param radius defines radius
  105282. * @param target defines camera target
  105283. * @param interaxialDistance defines distance between each color axis
  105284. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105285. * @param scene defines the hosting scene
  105286. */
  105287. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105288. /**
  105289. * Gets camera class name
  105290. * @returns StereoscopicArcRotateCamera
  105291. */
  105292. getClassName(): string;
  105293. }
  105294. }
  105295. declare module BABYLON {
  105296. /**
  105297. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105298. * @see http://doc.babylonjs.com/features/cameras
  105299. */
  105300. export class StereoscopicFreeCamera extends FreeCamera {
  105301. /**
  105302. * Creates a new StereoscopicFreeCamera
  105303. * @param name defines camera name
  105304. * @param position defines initial position
  105305. * @param interaxialDistance defines distance between each color axis
  105306. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105307. * @param scene defines the hosting scene
  105308. */
  105309. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105310. /**
  105311. * Gets camera class name
  105312. * @returns StereoscopicFreeCamera
  105313. */
  105314. getClassName(): string;
  105315. }
  105316. }
  105317. declare module BABYLON {
  105318. /**
  105319. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105320. * @see http://doc.babylonjs.com/features/cameras
  105321. */
  105322. export class StereoscopicGamepadCamera extends GamepadCamera {
  105323. /**
  105324. * Creates a new StereoscopicGamepadCamera
  105325. * @param name defines camera name
  105326. * @param position defines initial position
  105327. * @param interaxialDistance defines distance between each color axis
  105328. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105329. * @param scene defines the hosting scene
  105330. */
  105331. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105332. /**
  105333. * Gets camera class name
  105334. * @returns StereoscopicGamepadCamera
  105335. */
  105336. getClassName(): string;
  105337. }
  105338. }
  105339. declare module BABYLON {
  105340. /**
  105341. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105342. * @see http://doc.babylonjs.com/features/cameras
  105343. */
  105344. export class StereoscopicUniversalCamera extends UniversalCamera {
  105345. /**
  105346. * Creates a new StereoscopicUniversalCamera
  105347. * @param name defines camera name
  105348. * @param position defines initial position
  105349. * @param interaxialDistance defines distance between each color axis
  105350. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105351. * @param scene defines the hosting scene
  105352. */
  105353. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105354. /**
  105355. * Gets camera class name
  105356. * @returns StereoscopicUniversalCamera
  105357. */
  105358. getClassName(): string;
  105359. }
  105360. }
  105361. declare module BABYLON {
  105362. /**
  105363. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105364. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105365. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105366. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105367. */
  105368. export class VirtualJoysticksCamera extends FreeCamera {
  105369. /**
  105370. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105371. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105372. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105373. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105374. * @param name Define the name of the camera in the scene
  105375. * @param position Define the start position of the camera in the scene
  105376. * @param scene Define the scene the camera belongs to
  105377. */
  105378. constructor(name: string, position: Vector3, scene: Scene);
  105379. /**
  105380. * Gets the current object class name.
  105381. * @return the class name
  105382. */
  105383. getClassName(): string;
  105384. }
  105385. }
  105386. declare module BABYLON {
  105387. /**
  105388. * This represents all the required metrics to create a VR camera.
  105389. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105390. */
  105391. export class VRCameraMetrics {
  105392. /**
  105393. * Define the horizontal resolution off the screen.
  105394. */
  105395. hResolution: number;
  105396. /**
  105397. * Define the vertical resolution off the screen.
  105398. */
  105399. vResolution: number;
  105400. /**
  105401. * Define the horizontal screen size.
  105402. */
  105403. hScreenSize: number;
  105404. /**
  105405. * Define the vertical screen size.
  105406. */
  105407. vScreenSize: number;
  105408. /**
  105409. * Define the vertical screen center position.
  105410. */
  105411. vScreenCenter: number;
  105412. /**
  105413. * Define the distance of the eyes to the screen.
  105414. */
  105415. eyeToScreenDistance: number;
  105416. /**
  105417. * Define the distance between both lenses
  105418. */
  105419. lensSeparationDistance: number;
  105420. /**
  105421. * Define the distance between both viewer's eyes.
  105422. */
  105423. interpupillaryDistance: number;
  105424. /**
  105425. * Define the distortion factor of the VR postprocess.
  105426. * Please, touch with care.
  105427. */
  105428. distortionK: number[];
  105429. /**
  105430. * Define the chromatic aberration correction factors for the VR post process.
  105431. */
  105432. chromaAbCorrection: number[];
  105433. /**
  105434. * Define the scale factor of the post process.
  105435. * The smaller the better but the slower.
  105436. */
  105437. postProcessScaleFactor: number;
  105438. /**
  105439. * Define an offset for the lens center.
  105440. */
  105441. lensCenterOffset: number;
  105442. /**
  105443. * Define if the current vr camera should compensate the distortion of the lense or not.
  105444. */
  105445. compensateDistortion: boolean;
  105446. /**
  105447. * Defines if multiview should be enabled when rendering (Default: false)
  105448. */
  105449. multiviewEnabled: boolean;
  105450. /**
  105451. * Gets the rendering aspect ratio based on the provided resolutions.
  105452. */
  105453. readonly aspectRatio: number;
  105454. /**
  105455. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105456. */
  105457. readonly aspectRatioFov: number;
  105458. /**
  105459. * @hidden
  105460. */
  105461. readonly leftHMatrix: Matrix;
  105462. /**
  105463. * @hidden
  105464. */
  105465. readonly rightHMatrix: Matrix;
  105466. /**
  105467. * @hidden
  105468. */
  105469. readonly leftPreViewMatrix: Matrix;
  105470. /**
  105471. * @hidden
  105472. */
  105473. readonly rightPreViewMatrix: Matrix;
  105474. /**
  105475. * Get the default VRMetrics based on the most generic setup.
  105476. * @returns the default vr metrics
  105477. */
  105478. static GetDefault(): VRCameraMetrics;
  105479. }
  105480. }
  105481. declare module BABYLON {
  105482. /** @hidden */
  105483. export var vrDistortionCorrectionPixelShader: {
  105484. name: string;
  105485. shader: string;
  105486. };
  105487. }
  105488. declare module BABYLON {
  105489. /**
  105490. * VRDistortionCorrectionPostProcess used for mobile VR
  105491. */
  105492. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105493. private _isRightEye;
  105494. private _distortionFactors;
  105495. private _postProcessScaleFactor;
  105496. private _lensCenterOffset;
  105497. private _scaleIn;
  105498. private _scaleFactor;
  105499. private _lensCenter;
  105500. /**
  105501. * Initializes the VRDistortionCorrectionPostProcess
  105502. * @param name The name of the effect.
  105503. * @param camera The camera to apply the render pass to.
  105504. * @param isRightEye If this is for the right eye distortion
  105505. * @param vrMetrics All the required metrics for the VR camera
  105506. */
  105507. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105508. }
  105509. }
  105510. declare module BABYLON {
  105511. /**
  105512. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105513. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105514. */
  105515. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105516. /**
  105517. * Creates a new VRDeviceOrientationArcRotateCamera
  105518. * @param name defines camera name
  105519. * @param alpha defines the camera rotation along the logitudinal axis
  105520. * @param beta defines the camera rotation along the latitudinal axis
  105521. * @param radius defines the camera distance from its target
  105522. * @param target defines the camera target
  105523. * @param scene defines the scene the camera belongs to
  105524. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105525. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105526. */
  105527. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105528. /**
  105529. * Gets camera class name
  105530. * @returns VRDeviceOrientationArcRotateCamera
  105531. */
  105532. getClassName(): string;
  105533. }
  105534. }
  105535. declare module BABYLON {
  105536. /**
  105537. * Camera used to simulate VR rendering (based on FreeCamera)
  105538. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105539. */
  105540. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105541. /**
  105542. * Creates a new VRDeviceOrientationFreeCamera
  105543. * @param name defines camera name
  105544. * @param position defines the start position of the camera
  105545. * @param scene defines the scene the camera belongs to
  105546. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105547. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105548. */
  105549. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105550. /**
  105551. * Gets camera class name
  105552. * @returns VRDeviceOrientationFreeCamera
  105553. */
  105554. getClassName(): string;
  105555. }
  105556. }
  105557. declare module BABYLON {
  105558. /**
  105559. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105560. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105561. */
  105562. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105563. /**
  105564. * Creates a new VRDeviceOrientationGamepadCamera
  105565. * @param name defines camera name
  105566. * @param position defines the start position of the camera
  105567. * @param scene defines the scene the camera belongs to
  105568. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105569. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105570. */
  105571. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105572. /**
  105573. * Gets camera class name
  105574. * @returns VRDeviceOrientationGamepadCamera
  105575. */
  105576. getClassName(): string;
  105577. }
  105578. }
  105579. declare module BABYLON {
  105580. /**
  105581. * Base class of materials working in push mode in babylon JS
  105582. * @hidden
  105583. */
  105584. export class PushMaterial extends Material {
  105585. protected _activeEffect: Effect;
  105586. protected _normalMatrix: Matrix;
  105587. /**
  105588. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105589. * This means that the material can keep using a previous shader while a new one is being compiled.
  105590. * This is mostly used when shader parallel compilation is supported (true by default)
  105591. */
  105592. allowShaderHotSwapping: boolean;
  105593. constructor(name: string, scene: Scene);
  105594. getEffect(): Effect;
  105595. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105596. /**
  105597. * Binds the given world matrix to the active effect
  105598. *
  105599. * @param world the matrix to bind
  105600. */
  105601. bindOnlyWorldMatrix(world: Matrix): void;
  105602. /**
  105603. * Binds the given normal matrix to the active effect
  105604. *
  105605. * @param normalMatrix the matrix to bind
  105606. */
  105607. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105608. bind(world: Matrix, mesh?: Mesh): void;
  105609. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105610. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105611. }
  105612. }
  105613. declare module BABYLON {
  105614. /**
  105615. * This groups all the flags used to control the materials channel.
  105616. */
  105617. export class MaterialFlags {
  105618. private static _DiffuseTextureEnabled;
  105619. /**
  105620. * Are diffuse textures enabled in the application.
  105621. */
  105622. static DiffuseTextureEnabled: boolean;
  105623. private static _AmbientTextureEnabled;
  105624. /**
  105625. * Are ambient textures enabled in the application.
  105626. */
  105627. static AmbientTextureEnabled: boolean;
  105628. private static _OpacityTextureEnabled;
  105629. /**
  105630. * Are opacity textures enabled in the application.
  105631. */
  105632. static OpacityTextureEnabled: boolean;
  105633. private static _ReflectionTextureEnabled;
  105634. /**
  105635. * Are reflection textures enabled in the application.
  105636. */
  105637. static ReflectionTextureEnabled: boolean;
  105638. private static _EmissiveTextureEnabled;
  105639. /**
  105640. * Are emissive textures enabled in the application.
  105641. */
  105642. static EmissiveTextureEnabled: boolean;
  105643. private static _SpecularTextureEnabled;
  105644. /**
  105645. * Are specular textures enabled in the application.
  105646. */
  105647. static SpecularTextureEnabled: boolean;
  105648. private static _BumpTextureEnabled;
  105649. /**
  105650. * Are bump textures enabled in the application.
  105651. */
  105652. static BumpTextureEnabled: boolean;
  105653. private static _LightmapTextureEnabled;
  105654. /**
  105655. * Are lightmap textures enabled in the application.
  105656. */
  105657. static LightmapTextureEnabled: boolean;
  105658. private static _RefractionTextureEnabled;
  105659. /**
  105660. * Are refraction textures enabled in the application.
  105661. */
  105662. static RefractionTextureEnabled: boolean;
  105663. private static _ColorGradingTextureEnabled;
  105664. /**
  105665. * Are color grading textures enabled in the application.
  105666. */
  105667. static ColorGradingTextureEnabled: boolean;
  105668. private static _FresnelEnabled;
  105669. /**
  105670. * Are fresnels enabled in the application.
  105671. */
  105672. static FresnelEnabled: boolean;
  105673. private static _ClearCoatTextureEnabled;
  105674. /**
  105675. * Are clear coat textures enabled in the application.
  105676. */
  105677. static ClearCoatTextureEnabled: boolean;
  105678. private static _ClearCoatBumpTextureEnabled;
  105679. /**
  105680. * Are clear coat bump textures enabled in the application.
  105681. */
  105682. static ClearCoatBumpTextureEnabled: boolean;
  105683. private static _ClearCoatTintTextureEnabled;
  105684. /**
  105685. * Are clear coat tint textures enabled in the application.
  105686. */
  105687. static ClearCoatTintTextureEnabled: boolean;
  105688. private static _SheenTextureEnabled;
  105689. /**
  105690. * Are sheen textures enabled in the application.
  105691. */
  105692. static SheenTextureEnabled: boolean;
  105693. private static _AnisotropicTextureEnabled;
  105694. /**
  105695. * Are anisotropic textures enabled in the application.
  105696. */
  105697. static AnisotropicTextureEnabled: boolean;
  105698. private static _ThicknessTextureEnabled;
  105699. /**
  105700. * Are thickness textures enabled in the application.
  105701. */
  105702. static ThicknessTextureEnabled: boolean;
  105703. }
  105704. }
  105705. declare module BABYLON {
  105706. /** @hidden */
  105707. export var defaultFragmentDeclaration: {
  105708. name: string;
  105709. shader: string;
  105710. };
  105711. }
  105712. declare module BABYLON {
  105713. /** @hidden */
  105714. export var defaultUboDeclaration: {
  105715. name: string;
  105716. shader: string;
  105717. };
  105718. }
  105719. declare module BABYLON {
  105720. /** @hidden */
  105721. export var lightFragmentDeclaration: {
  105722. name: string;
  105723. shader: string;
  105724. };
  105725. }
  105726. declare module BABYLON {
  105727. /** @hidden */
  105728. export var lightUboDeclaration: {
  105729. name: string;
  105730. shader: string;
  105731. };
  105732. }
  105733. declare module BABYLON {
  105734. /** @hidden */
  105735. export var lightsFragmentFunctions: {
  105736. name: string;
  105737. shader: string;
  105738. };
  105739. }
  105740. declare module BABYLON {
  105741. /** @hidden */
  105742. export var shadowsFragmentFunctions: {
  105743. name: string;
  105744. shader: string;
  105745. };
  105746. }
  105747. declare module BABYLON {
  105748. /** @hidden */
  105749. export var fresnelFunction: {
  105750. name: string;
  105751. shader: string;
  105752. };
  105753. }
  105754. declare module BABYLON {
  105755. /** @hidden */
  105756. export var reflectionFunction: {
  105757. name: string;
  105758. shader: string;
  105759. };
  105760. }
  105761. declare module BABYLON {
  105762. /** @hidden */
  105763. export var bumpFragmentFunctions: {
  105764. name: string;
  105765. shader: string;
  105766. };
  105767. }
  105768. declare module BABYLON {
  105769. /** @hidden */
  105770. export var logDepthDeclaration: {
  105771. name: string;
  105772. shader: string;
  105773. };
  105774. }
  105775. declare module BABYLON {
  105776. /** @hidden */
  105777. export var bumpFragment: {
  105778. name: string;
  105779. shader: string;
  105780. };
  105781. }
  105782. declare module BABYLON {
  105783. /** @hidden */
  105784. export var depthPrePass: {
  105785. name: string;
  105786. shader: string;
  105787. };
  105788. }
  105789. declare module BABYLON {
  105790. /** @hidden */
  105791. export var lightFragment: {
  105792. name: string;
  105793. shader: string;
  105794. };
  105795. }
  105796. declare module BABYLON {
  105797. /** @hidden */
  105798. export var logDepthFragment: {
  105799. name: string;
  105800. shader: string;
  105801. };
  105802. }
  105803. declare module BABYLON {
  105804. /** @hidden */
  105805. export var defaultPixelShader: {
  105806. name: string;
  105807. shader: string;
  105808. };
  105809. }
  105810. declare module BABYLON {
  105811. /** @hidden */
  105812. export var defaultVertexDeclaration: {
  105813. name: string;
  105814. shader: string;
  105815. };
  105816. }
  105817. declare module BABYLON {
  105818. /** @hidden */
  105819. export var bumpVertexDeclaration: {
  105820. name: string;
  105821. shader: string;
  105822. };
  105823. }
  105824. declare module BABYLON {
  105825. /** @hidden */
  105826. export var bumpVertex: {
  105827. name: string;
  105828. shader: string;
  105829. };
  105830. }
  105831. declare module BABYLON {
  105832. /** @hidden */
  105833. export var fogVertex: {
  105834. name: string;
  105835. shader: string;
  105836. };
  105837. }
  105838. declare module BABYLON {
  105839. /** @hidden */
  105840. export var shadowsVertex: {
  105841. name: string;
  105842. shader: string;
  105843. };
  105844. }
  105845. declare module BABYLON {
  105846. /** @hidden */
  105847. export var pointCloudVertex: {
  105848. name: string;
  105849. shader: string;
  105850. };
  105851. }
  105852. declare module BABYLON {
  105853. /** @hidden */
  105854. export var logDepthVertex: {
  105855. name: string;
  105856. shader: string;
  105857. };
  105858. }
  105859. declare module BABYLON {
  105860. /** @hidden */
  105861. export var defaultVertexShader: {
  105862. name: string;
  105863. shader: string;
  105864. };
  105865. }
  105866. declare module BABYLON {
  105867. /** @hidden */
  105868. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105869. MAINUV1: boolean;
  105870. MAINUV2: boolean;
  105871. DIFFUSE: boolean;
  105872. DIFFUSEDIRECTUV: number;
  105873. AMBIENT: boolean;
  105874. AMBIENTDIRECTUV: number;
  105875. OPACITY: boolean;
  105876. OPACITYDIRECTUV: number;
  105877. OPACITYRGB: boolean;
  105878. REFLECTION: boolean;
  105879. EMISSIVE: boolean;
  105880. EMISSIVEDIRECTUV: number;
  105881. SPECULAR: boolean;
  105882. SPECULARDIRECTUV: number;
  105883. BUMP: boolean;
  105884. BUMPDIRECTUV: number;
  105885. PARALLAX: boolean;
  105886. PARALLAXOCCLUSION: boolean;
  105887. SPECULAROVERALPHA: boolean;
  105888. CLIPPLANE: boolean;
  105889. CLIPPLANE2: boolean;
  105890. CLIPPLANE3: boolean;
  105891. CLIPPLANE4: boolean;
  105892. ALPHATEST: boolean;
  105893. DEPTHPREPASS: boolean;
  105894. ALPHAFROMDIFFUSE: boolean;
  105895. POINTSIZE: boolean;
  105896. FOG: boolean;
  105897. SPECULARTERM: boolean;
  105898. DIFFUSEFRESNEL: boolean;
  105899. OPACITYFRESNEL: boolean;
  105900. REFLECTIONFRESNEL: boolean;
  105901. REFRACTIONFRESNEL: boolean;
  105902. EMISSIVEFRESNEL: boolean;
  105903. FRESNEL: boolean;
  105904. NORMAL: boolean;
  105905. UV1: boolean;
  105906. UV2: boolean;
  105907. VERTEXCOLOR: boolean;
  105908. VERTEXALPHA: boolean;
  105909. NUM_BONE_INFLUENCERS: number;
  105910. BonesPerMesh: number;
  105911. BONETEXTURE: boolean;
  105912. INSTANCES: boolean;
  105913. GLOSSINESS: boolean;
  105914. ROUGHNESS: boolean;
  105915. EMISSIVEASILLUMINATION: boolean;
  105916. LINKEMISSIVEWITHDIFFUSE: boolean;
  105917. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105918. LIGHTMAP: boolean;
  105919. LIGHTMAPDIRECTUV: number;
  105920. OBJECTSPACE_NORMALMAP: boolean;
  105921. USELIGHTMAPASSHADOWMAP: boolean;
  105922. REFLECTIONMAP_3D: boolean;
  105923. REFLECTIONMAP_SPHERICAL: boolean;
  105924. REFLECTIONMAP_PLANAR: boolean;
  105925. REFLECTIONMAP_CUBIC: boolean;
  105926. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105927. REFLECTIONMAP_PROJECTION: boolean;
  105928. REFLECTIONMAP_SKYBOX: boolean;
  105929. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105930. REFLECTIONMAP_EXPLICIT: boolean;
  105931. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105932. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105933. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105934. INVERTCUBICMAP: boolean;
  105935. LOGARITHMICDEPTH: boolean;
  105936. REFRACTION: boolean;
  105937. REFRACTIONMAP_3D: boolean;
  105938. REFLECTIONOVERALPHA: boolean;
  105939. TWOSIDEDLIGHTING: boolean;
  105940. SHADOWFLOAT: boolean;
  105941. MORPHTARGETS: boolean;
  105942. MORPHTARGETS_NORMAL: boolean;
  105943. MORPHTARGETS_TANGENT: boolean;
  105944. MORPHTARGETS_UV: boolean;
  105945. NUM_MORPH_INFLUENCERS: number;
  105946. NONUNIFORMSCALING: boolean;
  105947. PREMULTIPLYALPHA: boolean;
  105948. IMAGEPROCESSING: boolean;
  105949. VIGNETTE: boolean;
  105950. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105951. VIGNETTEBLENDMODEOPAQUE: boolean;
  105952. TONEMAPPING: boolean;
  105953. TONEMAPPING_ACES: boolean;
  105954. CONTRAST: boolean;
  105955. COLORCURVES: boolean;
  105956. COLORGRADING: boolean;
  105957. COLORGRADING3D: boolean;
  105958. SAMPLER3DGREENDEPTH: boolean;
  105959. SAMPLER3DBGRMAP: boolean;
  105960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105961. MULTIVIEW: boolean;
  105962. /**
  105963. * If the reflection texture on this material is in linear color space
  105964. * @hidden
  105965. */
  105966. IS_REFLECTION_LINEAR: boolean;
  105967. /**
  105968. * If the refraction texture on this material is in linear color space
  105969. * @hidden
  105970. */
  105971. IS_REFRACTION_LINEAR: boolean;
  105972. EXPOSURE: boolean;
  105973. constructor();
  105974. setReflectionMode(modeToEnable: string): void;
  105975. }
  105976. /**
  105977. * This is the default material used in Babylon. It is the best trade off between quality
  105978. * and performances.
  105979. * @see http://doc.babylonjs.com/babylon101/materials
  105980. */
  105981. export class StandardMaterial extends PushMaterial {
  105982. private _diffuseTexture;
  105983. /**
  105984. * The basic texture of the material as viewed under a light.
  105985. */
  105986. diffuseTexture: Nullable<BaseTexture>;
  105987. private _ambientTexture;
  105988. /**
  105989. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105990. */
  105991. ambientTexture: Nullable<BaseTexture>;
  105992. private _opacityTexture;
  105993. /**
  105994. * Define the transparency of the material from a texture.
  105995. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105996. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105997. */
  105998. opacityTexture: Nullable<BaseTexture>;
  105999. private _reflectionTexture;
  106000. /**
  106001. * Define the texture used to display the reflection.
  106002. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106003. */
  106004. reflectionTexture: Nullable<BaseTexture>;
  106005. private _emissiveTexture;
  106006. /**
  106007. * Define texture of the material as if self lit.
  106008. * This will be mixed in the final result even in the absence of light.
  106009. */
  106010. emissiveTexture: Nullable<BaseTexture>;
  106011. private _specularTexture;
  106012. /**
  106013. * Define how the color and intensity of the highlight given by the light in the material.
  106014. */
  106015. specularTexture: Nullable<BaseTexture>;
  106016. private _bumpTexture;
  106017. /**
  106018. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106019. * 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.
  106020. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106021. */
  106022. bumpTexture: Nullable<BaseTexture>;
  106023. private _lightmapTexture;
  106024. /**
  106025. * Complex lighting can be computationally expensive to compute at runtime.
  106026. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106027. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106028. */
  106029. lightmapTexture: Nullable<BaseTexture>;
  106030. private _refractionTexture;
  106031. /**
  106032. * Define the texture used to display the refraction.
  106033. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106034. */
  106035. refractionTexture: Nullable<BaseTexture>;
  106036. /**
  106037. * The color of the material lit by the environmental background lighting.
  106038. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106039. */
  106040. ambientColor: Color3;
  106041. /**
  106042. * The basic color of the material as viewed under a light.
  106043. */
  106044. diffuseColor: Color3;
  106045. /**
  106046. * Define how the color and intensity of the highlight given by the light in the material.
  106047. */
  106048. specularColor: Color3;
  106049. /**
  106050. * Define the color of the material as if self lit.
  106051. * This will be mixed in the final result even in the absence of light.
  106052. */
  106053. emissiveColor: Color3;
  106054. /**
  106055. * Defines how sharp are the highlights in the material.
  106056. * The bigger the value the sharper giving a more glossy feeling to the result.
  106057. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106058. */
  106059. specularPower: number;
  106060. private _useAlphaFromDiffuseTexture;
  106061. /**
  106062. * Does the transparency come from the diffuse texture alpha channel.
  106063. */
  106064. useAlphaFromDiffuseTexture: boolean;
  106065. private _useEmissiveAsIllumination;
  106066. /**
  106067. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106068. */
  106069. useEmissiveAsIllumination: boolean;
  106070. private _linkEmissiveWithDiffuse;
  106071. /**
  106072. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106073. * the emissive level when the final color is close to one.
  106074. */
  106075. linkEmissiveWithDiffuse: boolean;
  106076. private _useSpecularOverAlpha;
  106077. /**
  106078. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106079. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106080. */
  106081. useSpecularOverAlpha: boolean;
  106082. private _useReflectionOverAlpha;
  106083. /**
  106084. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106085. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106086. */
  106087. useReflectionOverAlpha: boolean;
  106088. private _disableLighting;
  106089. /**
  106090. * Does lights from the scene impacts this material.
  106091. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106092. */
  106093. disableLighting: boolean;
  106094. private _useObjectSpaceNormalMap;
  106095. /**
  106096. * Allows using an object space normal map (instead of tangent space).
  106097. */
  106098. useObjectSpaceNormalMap: boolean;
  106099. private _useParallax;
  106100. /**
  106101. * Is parallax enabled or not.
  106102. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106103. */
  106104. useParallax: boolean;
  106105. private _useParallaxOcclusion;
  106106. /**
  106107. * Is parallax occlusion enabled or not.
  106108. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106109. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106110. */
  106111. useParallaxOcclusion: boolean;
  106112. /**
  106113. * 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.
  106114. */
  106115. parallaxScaleBias: number;
  106116. private _roughness;
  106117. /**
  106118. * Helps to define how blurry the reflections should appears in the material.
  106119. */
  106120. roughness: number;
  106121. /**
  106122. * In case of refraction, define the value of the index of refraction.
  106123. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106124. */
  106125. indexOfRefraction: number;
  106126. /**
  106127. * Invert the refraction texture alongside the y axis.
  106128. * It can be useful with procedural textures or probe for instance.
  106129. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106130. */
  106131. invertRefractionY: boolean;
  106132. /**
  106133. * Defines the alpha limits in alpha test mode.
  106134. */
  106135. alphaCutOff: number;
  106136. private _useLightmapAsShadowmap;
  106137. /**
  106138. * In case of light mapping, define whether the map contains light or shadow informations.
  106139. */
  106140. useLightmapAsShadowmap: boolean;
  106141. private _diffuseFresnelParameters;
  106142. /**
  106143. * Define the diffuse fresnel parameters of the material.
  106144. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106145. */
  106146. diffuseFresnelParameters: FresnelParameters;
  106147. private _opacityFresnelParameters;
  106148. /**
  106149. * Define the opacity fresnel parameters of the material.
  106150. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106151. */
  106152. opacityFresnelParameters: FresnelParameters;
  106153. private _reflectionFresnelParameters;
  106154. /**
  106155. * Define the reflection fresnel parameters of the material.
  106156. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106157. */
  106158. reflectionFresnelParameters: FresnelParameters;
  106159. private _refractionFresnelParameters;
  106160. /**
  106161. * Define the refraction fresnel parameters of the material.
  106162. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106163. */
  106164. refractionFresnelParameters: FresnelParameters;
  106165. private _emissiveFresnelParameters;
  106166. /**
  106167. * Define the emissive fresnel parameters of the material.
  106168. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106169. */
  106170. emissiveFresnelParameters: FresnelParameters;
  106171. private _useReflectionFresnelFromSpecular;
  106172. /**
  106173. * If true automatically deducts the fresnels values from the material specularity.
  106174. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106175. */
  106176. useReflectionFresnelFromSpecular: boolean;
  106177. private _useGlossinessFromSpecularMapAlpha;
  106178. /**
  106179. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106180. */
  106181. useGlossinessFromSpecularMapAlpha: boolean;
  106182. private _maxSimultaneousLights;
  106183. /**
  106184. * Defines the maximum number of lights that can be used in the material
  106185. */
  106186. maxSimultaneousLights: number;
  106187. private _invertNormalMapX;
  106188. /**
  106189. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106190. */
  106191. invertNormalMapX: boolean;
  106192. private _invertNormalMapY;
  106193. /**
  106194. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106195. */
  106196. invertNormalMapY: boolean;
  106197. private _twoSidedLighting;
  106198. /**
  106199. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106200. */
  106201. twoSidedLighting: boolean;
  106202. /**
  106203. * Default configuration related to image processing available in the standard Material.
  106204. */
  106205. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106206. /**
  106207. * Gets the image processing configuration used either in this material.
  106208. */
  106209. /**
  106210. * Sets the Default image processing configuration used either in the this material.
  106211. *
  106212. * If sets to null, the scene one is in use.
  106213. */
  106214. imageProcessingConfiguration: ImageProcessingConfiguration;
  106215. /**
  106216. * Keep track of the image processing observer to allow dispose and replace.
  106217. */
  106218. private _imageProcessingObserver;
  106219. /**
  106220. * Attaches a new image processing configuration to the Standard Material.
  106221. * @param configuration
  106222. */
  106223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106224. /**
  106225. * Gets wether the color curves effect is enabled.
  106226. */
  106227. /**
  106228. * Sets wether the color curves effect is enabled.
  106229. */
  106230. cameraColorCurvesEnabled: boolean;
  106231. /**
  106232. * Gets wether the color grading effect is enabled.
  106233. */
  106234. /**
  106235. * Gets wether the color grading effect is enabled.
  106236. */
  106237. cameraColorGradingEnabled: boolean;
  106238. /**
  106239. * Gets wether tonemapping is enabled or not.
  106240. */
  106241. /**
  106242. * Sets wether tonemapping is enabled or not
  106243. */
  106244. cameraToneMappingEnabled: boolean;
  106245. /**
  106246. * The camera exposure used on this material.
  106247. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106248. * This corresponds to a photographic exposure.
  106249. */
  106250. /**
  106251. * The camera exposure used on this material.
  106252. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106253. * This corresponds to a photographic exposure.
  106254. */
  106255. cameraExposure: number;
  106256. /**
  106257. * Gets The camera contrast used on this material.
  106258. */
  106259. /**
  106260. * Sets The camera contrast used on this material.
  106261. */
  106262. cameraContrast: number;
  106263. /**
  106264. * Gets the Color Grading 2D Lookup Texture.
  106265. */
  106266. /**
  106267. * Sets the Color Grading 2D Lookup Texture.
  106268. */
  106269. cameraColorGradingTexture: Nullable<BaseTexture>;
  106270. /**
  106271. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106272. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106273. * 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;
  106274. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106275. */
  106276. /**
  106277. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106278. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106279. * 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;
  106280. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106281. */
  106282. cameraColorCurves: Nullable<ColorCurves>;
  106283. /**
  106284. * Custom callback helping to override the default shader used in the material.
  106285. */
  106286. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106287. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106288. protected _worldViewProjectionMatrix: Matrix;
  106289. protected _globalAmbientColor: Color3;
  106290. protected _useLogarithmicDepth: boolean;
  106291. protected _rebuildInParallel: boolean;
  106292. /**
  106293. * Instantiates a new standard material.
  106294. * This is the default material used in Babylon. It is the best trade off between quality
  106295. * and performances.
  106296. * @see http://doc.babylonjs.com/babylon101/materials
  106297. * @param name Define the name of the material in the scene
  106298. * @param scene Define the scene the material belong to
  106299. */
  106300. constructor(name: string, scene: Scene);
  106301. /**
  106302. * Gets a boolean indicating that current material needs to register RTT
  106303. */
  106304. readonly hasRenderTargetTextures: boolean;
  106305. /**
  106306. * Gets the current class name of the material e.g. "StandardMaterial"
  106307. * Mainly use in serialization.
  106308. * @returns the class name
  106309. */
  106310. getClassName(): string;
  106311. /**
  106312. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106313. * You can try switching to logarithmic depth.
  106314. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106315. */
  106316. useLogarithmicDepth: boolean;
  106317. /**
  106318. * Specifies if the material will require alpha blending
  106319. * @returns a boolean specifying if alpha blending is needed
  106320. */
  106321. needAlphaBlending(): boolean;
  106322. /**
  106323. * Specifies if this material should be rendered in alpha test mode
  106324. * @returns a boolean specifying if an alpha test is needed.
  106325. */
  106326. needAlphaTesting(): boolean;
  106327. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106328. /**
  106329. * Get the texture used for alpha test purpose.
  106330. * @returns the diffuse texture in case of the standard material.
  106331. */
  106332. getAlphaTestTexture(): Nullable<BaseTexture>;
  106333. /**
  106334. * Get if the submesh is ready to be used and all its information available.
  106335. * Child classes can use it to update shaders
  106336. * @param mesh defines the mesh to check
  106337. * @param subMesh defines which submesh to check
  106338. * @param useInstances specifies that instances should be used
  106339. * @returns a boolean indicating that the submesh is ready or not
  106340. */
  106341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106342. /**
  106343. * Builds the material UBO layouts.
  106344. * Used internally during the effect preparation.
  106345. */
  106346. buildUniformLayout(): void;
  106347. /**
  106348. * Unbinds the material from the mesh
  106349. */
  106350. unbind(): void;
  106351. /**
  106352. * Binds the submesh to this material by preparing the effect and shader to draw
  106353. * @param world defines the world transformation matrix
  106354. * @param mesh defines the mesh containing the submesh
  106355. * @param subMesh defines the submesh to bind the material to
  106356. */
  106357. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106358. /**
  106359. * Get the list of animatables in the material.
  106360. * @returns the list of animatables object used in the material
  106361. */
  106362. getAnimatables(): IAnimatable[];
  106363. /**
  106364. * Gets the active textures from the material
  106365. * @returns an array of textures
  106366. */
  106367. getActiveTextures(): BaseTexture[];
  106368. /**
  106369. * Specifies if the material uses a texture
  106370. * @param texture defines the texture to check against the material
  106371. * @returns a boolean specifying if the material uses the texture
  106372. */
  106373. hasTexture(texture: BaseTexture): boolean;
  106374. /**
  106375. * Disposes the material
  106376. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106377. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106378. */
  106379. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106380. /**
  106381. * Makes a duplicate of the material, and gives it a new name
  106382. * @param name defines the new name for the duplicated material
  106383. * @returns the cloned material
  106384. */
  106385. clone(name: string): StandardMaterial;
  106386. /**
  106387. * Serializes this material in a JSON representation
  106388. * @returns the serialized material object
  106389. */
  106390. serialize(): any;
  106391. /**
  106392. * Creates a standard material from parsed material data
  106393. * @param source defines the JSON representation of the material
  106394. * @param scene defines the hosting scene
  106395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106396. * @returns a new standard material
  106397. */
  106398. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106399. /**
  106400. * Are diffuse textures enabled in the application.
  106401. */
  106402. static DiffuseTextureEnabled: boolean;
  106403. /**
  106404. * Are ambient textures enabled in the application.
  106405. */
  106406. static AmbientTextureEnabled: boolean;
  106407. /**
  106408. * Are opacity textures enabled in the application.
  106409. */
  106410. static OpacityTextureEnabled: boolean;
  106411. /**
  106412. * Are reflection textures enabled in the application.
  106413. */
  106414. static ReflectionTextureEnabled: boolean;
  106415. /**
  106416. * Are emissive textures enabled in the application.
  106417. */
  106418. static EmissiveTextureEnabled: boolean;
  106419. /**
  106420. * Are specular textures enabled in the application.
  106421. */
  106422. static SpecularTextureEnabled: boolean;
  106423. /**
  106424. * Are bump textures enabled in the application.
  106425. */
  106426. static BumpTextureEnabled: boolean;
  106427. /**
  106428. * Are lightmap textures enabled in the application.
  106429. */
  106430. static LightmapTextureEnabled: boolean;
  106431. /**
  106432. * Are refraction textures enabled in the application.
  106433. */
  106434. static RefractionTextureEnabled: boolean;
  106435. /**
  106436. * Are color grading textures enabled in the application.
  106437. */
  106438. static ColorGradingTextureEnabled: boolean;
  106439. /**
  106440. * Are fresnels enabled in the application.
  106441. */
  106442. static FresnelEnabled: boolean;
  106443. }
  106444. }
  106445. declare module BABYLON {
  106446. /** @hidden */
  106447. export var imageProcessingPixelShader: {
  106448. name: string;
  106449. shader: string;
  106450. };
  106451. }
  106452. declare module BABYLON {
  106453. /**
  106454. * ImageProcessingPostProcess
  106455. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106456. */
  106457. export class ImageProcessingPostProcess extends PostProcess {
  106458. /**
  106459. * Default configuration related to image processing available in the PBR Material.
  106460. */
  106461. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106462. /**
  106463. * Gets the image processing configuration used either in this material.
  106464. */
  106465. /**
  106466. * Sets the Default image processing configuration used either in the this material.
  106467. *
  106468. * If sets to null, the scene one is in use.
  106469. */
  106470. imageProcessingConfiguration: ImageProcessingConfiguration;
  106471. /**
  106472. * Keep track of the image processing observer to allow dispose and replace.
  106473. */
  106474. private _imageProcessingObserver;
  106475. /**
  106476. * Attaches a new image processing configuration to the PBR Material.
  106477. * @param configuration
  106478. */
  106479. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106480. /**
  106481. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106482. */
  106483. /**
  106484. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106485. */
  106486. colorCurves: Nullable<ColorCurves>;
  106487. /**
  106488. * Gets wether the color curves effect is enabled.
  106489. */
  106490. /**
  106491. * Sets wether the color curves effect is enabled.
  106492. */
  106493. colorCurvesEnabled: boolean;
  106494. /**
  106495. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106496. */
  106497. /**
  106498. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106499. */
  106500. colorGradingTexture: Nullable<BaseTexture>;
  106501. /**
  106502. * Gets wether the color grading effect is enabled.
  106503. */
  106504. /**
  106505. * Gets wether the color grading effect is enabled.
  106506. */
  106507. colorGradingEnabled: boolean;
  106508. /**
  106509. * Gets exposure used in the effect.
  106510. */
  106511. /**
  106512. * Sets exposure used in the effect.
  106513. */
  106514. exposure: number;
  106515. /**
  106516. * Gets wether tonemapping is enabled or not.
  106517. */
  106518. /**
  106519. * Sets wether tonemapping is enabled or not
  106520. */
  106521. toneMappingEnabled: boolean;
  106522. /**
  106523. * Gets the type of tone mapping effect.
  106524. */
  106525. /**
  106526. * Sets the type of tone mapping effect.
  106527. */
  106528. toneMappingType: number;
  106529. /**
  106530. * Gets contrast used in the effect.
  106531. */
  106532. /**
  106533. * Sets contrast used in the effect.
  106534. */
  106535. contrast: number;
  106536. /**
  106537. * Gets Vignette stretch size.
  106538. */
  106539. /**
  106540. * Sets Vignette stretch size.
  106541. */
  106542. vignetteStretch: number;
  106543. /**
  106544. * Gets Vignette centre X Offset.
  106545. */
  106546. /**
  106547. * Sets Vignette centre X Offset.
  106548. */
  106549. vignetteCentreX: number;
  106550. /**
  106551. * Gets Vignette centre Y Offset.
  106552. */
  106553. /**
  106554. * Sets Vignette centre Y Offset.
  106555. */
  106556. vignetteCentreY: number;
  106557. /**
  106558. * Gets Vignette weight or intensity of the vignette effect.
  106559. */
  106560. /**
  106561. * Sets Vignette weight or intensity of the vignette effect.
  106562. */
  106563. vignetteWeight: number;
  106564. /**
  106565. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106566. * if vignetteEnabled is set to true.
  106567. */
  106568. /**
  106569. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106570. * if vignetteEnabled is set to true.
  106571. */
  106572. vignetteColor: Color4;
  106573. /**
  106574. * Gets Camera field of view used by the Vignette effect.
  106575. */
  106576. /**
  106577. * Sets Camera field of view used by the Vignette effect.
  106578. */
  106579. vignetteCameraFov: number;
  106580. /**
  106581. * Gets the vignette blend mode allowing different kind of effect.
  106582. */
  106583. /**
  106584. * Sets the vignette blend mode allowing different kind of effect.
  106585. */
  106586. vignetteBlendMode: number;
  106587. /**
  106588. * Gets wether the vignette effect is enabled.
  106589. */
  106590. /**
  106591. * Sets wether the vignette effect is enabled.
  106592. */
  106593. vignetteEnabled: boolean;
  106594. private _fromLinearSpace;
  106595. /**
  106596. * Gets wether the input of the processing is in Gamma or Linear Space.
  106597. */
  106598. /**
  106599. * Sets wether the input of the processing is in Gamma or Linear Space.
  106600. */
  106601. fromLinearSpace: boolean;
  106602. /**
  106603. * Defines cache preventing GC.
  106604. */
  106605. private _defines;
  106606. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106607. /**
  106608. * "ImageProcessingPostProcess"
  106609. * @returns "ImageProcessingPostProcess"
  106610. */
  106611. getClassName(): string;
  106612. protected _updateParameters(): void;
  106613. dispose(camera?: Camera): void;
  106614. }
  106615. }
  106616. declare module BABYLON {
  106617. /**
  106618. * Class containing static functions to help procedurally build meshes
  106619. */
  106620. export class GroundBuilder {
  106621. /**
  106622. * Creates a ground mesh
  106623. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106624. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106626. * @param name defines the name of the mesh
  106627. * @param options defines the options used to create the mesh
  106628. * @param scene defines the hosting scene
  106629. * @returns the ground mesh
  106630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106631. */
  106632. static CreateGround(name: string, options: {
  106633. width?: number;
  106634. height?: number;
  106635. subdivisions?: number;
  106636. subdivisionsX?: number;
  106637. subdivisionsY?: number;
  106638. updatable?: boolean;
  106639. }, scene: any): Mesh;
  106640. /**
  106641. * Creates a tiled ground mesh
  106642. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106643. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106644. * * 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
  106645. * * 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
  106646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106647. * @param name defines the name of the mesh
  106648. * @param options defines the options used to create the mesh
  106649. * @param scene defines the hosting scene
  106650. * @returns the tiled ground mesh
  106651. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106652. */
  106653. static CreateTiledGround(name: string, options: {
  106654. xmin: number;
  106655. zmin: number;
  106656. xmax: number;
  106657. zmax: number;
  106658. subdivisions?: {
  106659. w: number;
  106660. h: number;
  106661. };
  106662. precision?: {
  106663. w: number;
  106664. h: number;
  106665. };
  106666. updatable?: boolean;
  106667. }, scene?: Nullable<Scene>): Mesh;
  106668. /**
  106669. * Creates a ground mesh from a height map
  106670. * * The parameter `url` sets the URL of the height map image resource.
  106671. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106672. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106673. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106674. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106675. * * 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.
  106676. * * 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).
  106677. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106679. * @param name defines the name of the mesh
  106680. * @param url defines the url to the height map
  106681. * @param options defines the options used to create the mesh
  106682. * @param scene defines the hosting scene
  106683. * @returns the ground mesh
  106684. * @see https://doc.babylonjs.com/babylon101/height_map
  106685. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106686. */
  106687. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106688. width?: number;
  106689. height?: number;
  106690. subdivisions?: number;
  106691. minHeight?: number;
  106692. maxHeight?: number;
  106693. colorFilter?: Color3;
  106694. alphaFilter?: number;
  106695. updatable?: boolean;
  106696. onReady?: (mesh: GroundMesh) => void;
  106697. }, scene?: Nullable<Scene>): GroundMesh;
  106698. }
  106699. }
  106700. declare module BABYLON {
  106701. /**
  106702. * Class containing static functions to help procedurally build meshes
  106703. */
  106704. export class TorusBuilder {
  106705. /**
  106706. * Creates a torus mesh
  106707. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106708. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106709. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106713. * @param name defines the name of the mesh
  106714. * @param options defines the options used to create the mesh
  106715. * @param scene defines the hosting scene
  106716. * @returns the torus mesh
  106717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106718. */
  106719. static CreateTorus(name: string, options: {
  106720. diameter?: number;
  106721. thickness?: number;
  106722. tessellation?: number;
  106723. updatable?: boolean;
  106724. sideOrientation?: number;
  106725. frontUVs?: Vector4;
  106726. backUVs?: Vector4;
  106727. }, scene: any): Mesh;
  106728. }
  106729. }
  106730. declare module BABYLON {
  106731. /**
  106732. * Class containing static functions to help procedurally build meshes
  106733. */
  106734. export class CylinderBuilder {
  106735. /**
  106736. * Creates a cylinder or a cone mesh
  106737. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106738. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106739. * * 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.
  106740. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106741. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106742. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106743. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106744. * * 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).
  106745. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106746. * * 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).
  106747. * * 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
  106748. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106749. * * 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
  106750. * * 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.
  106751. * * If `enclose` is false, a ring surface is one element.
  106752. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106753. * * 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
  106754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106757. * @param name defines the name of the mesh
  106758. * @param options defines the options used to create the mesh
  106759. * @param scene defines the hosting scene
  106760. * @returns the cylinder mesh
  106761. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106762. */
  106763. static CreateCylinder(name: string, options: {
  106764. height?: number;
  106765. diameterTop?: number;
  106766. diameterBottom?: number;
  106767. diameter?: number;
  106768. tessellation?: number;
  106769. subdivisions?: number;
  106770. arc?: number;
  106771. faceColors?: Color4[];
  106772. faceUV?: Vector4[];
  106773. updatable?: boolean;
  106774. hasRings?: boolean;
  106775. enclose?: boolean;
  106776. cap?: number;
  106777. sideOrientation?: number;
  106778. frontUVs?: Vector4;
  106779. backUVs?: Vector4;
  106780. }, scene: any): Mesh;
  106781. }
  106782. }
  106783. declare module BABYLON {
  106784. /**
  106785. * Options to modify the vr teleportation behavior.
  106786. */
  106787. export interface VRTeleportationOptions {
  106788. /**
  106789. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106790. */
  106791. floorMeshName?: string;
  106792. /**
  106793. * A list of meshes to be used as the teleportation floor. (default: empty)
  106794. */
  106795. floorMeshes?: Mesh[];
  106796. }
  106797. /**
  106798. * Options to modify the vr experience helper's behavior.
  106799. */
  106800. export interface VRExperienceHelperOptions extends WebVROptions {
  106801. /**
  106802. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106803. */
  106804. createDeviceOrientationCamera?: boolean;
  106805. /**
  106806. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106807. */
  106808. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106809. /**
  106810. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106811. */
  106812. laserToggle?: boolean;
  106813. /**
  106814. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106815. */
  106816. floorMeshes?: Mesh[];
  106817. /**
  106818. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106819. */
  106820. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106821. }
  106822. /**
  106823. * Event containing information after VR has been entered
  106824. */
  106825. export class OnAfterEnteringVRObservableEvent {
  106826. /**
  106827. * If entering vr was successful
  106828. */
  106829. success: boolean;
  106830. }
  106831. /**
  106832. * Helps to quickly add VR support to an existing scene.
  106833. * See http://doc.babylonjs.com/how_to/webvr_helper
  106834. */
  106835. export class VRExperienceHelper {
  106836. /** Options to modify the vr experience helper's behavior. */
  106837. webVROptions: VRExperienceHelperOptions;
  106838. private _scene;
  106839. private _position;
  106840. private _btnVR;
  106841. private _btnVRDisplayed;
  106842. private _webVRsupported;
  106843. private _webVRready;
  106844. private _webVRrequesting;
  106845. private _webVRpresenting;
  106846. private _hasEnteredVR;
  106847. private _fullscreenVRpresenting;
  106848. private _canvas;
  106849. private _webVRCamera;
  106850. private _vrDeviceOrientationCamera;
  106851. private _deviceOrientationCamera;
  106852. private _existingCamera;
  106853. private _onKeyDown;
  106854. private _onVrDisplayPresentChange;
  106855. private _onVRDisplayChanged;
  106856. private _onVRRequestPresentStart;
  106857. private _onVRRequestPresentComplete;
  106858. /**
  106859. * 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)
  106860. */
  106861. enableGazeEvenWhenNoPointerLock: boolean;
  106862. /**
  106863. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106864. */
  106865. exitVROnDoubleTap: boolean;
  106866. /**
  106867. * Observable raised right before entering VR.
  106868. */
  106869. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106870. /**
  106871. * Observable raised when entering VR has completed.
  106872. */
  106873. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106874. /**
  106875. * Observable raised when exiting VR.
  106876. */
  106877. onExitingVRObservable: Observable<VRExperienceHelper>;
  106878. /**
  106879. * Observable raised when controller mesh is loaded.
  106880. */
  106881. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106882. /** Return this.onEnteringVRObservable
  106883. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106884. */
  106885. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106886. /** Return this.onExitingVRObservable
  106887. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106888. */
  106889. readonly onExitingVR: Observable<VRExperienceHelper>;
  106890. /** Return this.onControllerMeshLoadedObservable
  106891. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106892. */
  106893. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106894. private _rayLength;
  106895. private _useCustomVRButton;
  106896. private _teleportationRequested;
  106897. private _teleportActive;
  106898. private _floorMeshName;
  106899. private _floorMeshesCollection;
  106900. private _rotationAllowed;
  106901. private _teleportBackwardsVector;
  106902. private _teleportationTarget;
  106903. private _isDefaultTeleportationTarget;
  106904. private _postProcessMove;
  106905. private _teleportationFillColor;
  106906. private _teleportationBorderColor;
  106907. private _rotationAngle;
  106908. private _haloCenter;
  106909. private _cameraGazer;
  106910. private _padSensibilityUp;
  106911. private _padSensibilityDown;
  106912. private _leftController;
  106913. private _rightController;
  106914. /**
  106915. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106916. */
  106917. onNewMeshSelected: Observable<AbstractMesh>;
  106918. /**
  106919. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106920. * This observable will provide the mesh and the controller used to select the mesh
  106921. */
  106922. onMeshSelectedWithController: Observable<{
  106923. mesh: AbstractMesh;
  106924. controller: WebVRController;
  106925. }>;
  106926. /**
  106927. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106928. */
  106929. onNewMeshPicked: Observable<PickingInfo>;
  106930. private _circleEase;
  106931. /**
  106932. * Observable raised before camera teleportation
  106933. */
  106934. onBeforeCameraTeleport: Observable<Vector3>;
  106935. /**
  106936. * Observable raised after camera teleportation
  106937. */
  106938. onAfterCameraTeleport: Observable<Vector3>;
  106939. /**
  106940. * Observable raised when current selected mesh gets unselected
  106941. */
  106942. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106943. private _raySelectionPredicate;
  106944. /**
  106945. * To be optionaly changed by user to define custom ray selection
  106946. */
  106947. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106948. /**
  106949. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106950. */
  106951. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106952. /**
  106953. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106954. */
  106955. teleportationEnabled: boolean;
  106956. private _defaultHeight;
  106957. private _teleportationInitialized;
  106958. private _interactionsEnabled;
  106959. private _interactionsRequested;
  106960. private _displayGaze;
  106961. private _displayLaserPointer;
  106962. /**
  106963. * The mesh used to display where the user is going to teleport.
  106964. */
  106965. /**
  106966. * Sets the mesh to be used to display where the user is going to teleport.
  106967. */
  106968. teleportationTarget: Mesh;
  106969. /**
  106970. * 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
  106971. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106972. * See http://doc.babylonjs.com/resources/baking_transformations
  106973. */
  106974. gazeTrackerMesh: Mesh;
  106975. /**
  106976. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106977. */
  106978. updateGazeTrackerScale: boolean;
  106979. /**
  106980. * If the gaze trackers color should be updated when selecting meshes
  106981. */
  106982. updateGazeTrackerColor: boolean;
  106983. /**
  106984. * If the controller laser color should be updated when selecting meshes
  106985. */
  106986. updateControllerLaserColor: boolean;
  106987. /**
  106988. * The gaze tracking mesh corresponding to the left controller
  106989. */
  106990. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106991. /**
  106992. * The gaze tracking mesh corresponding to the right controller
  106993. */
  106994. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106995. /**
  106996. * If the ray of the gaze should be displayed.
  106997. */
  106998. /**
  106999. * Sets if the ray of the gaze should be displayed.
  107000. */
  107001. displayGaze: boolean;
  107002. /**
  107003. * If the ray of the LaserPointer should be displayed.
  107004. */
  107005. /**
  107006. * Sets if the ray of the LaserPointer should be displayed.
  107007. */
  107008. displayLaserPointer: boolean;
  107009. /**
  107010. * The deviceOrientationCamera used as the camera when not in VR.
  107011. */
  107012. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107013. /**
  107014. * Based on the current WebVR support, returns the current VR camera used.
  107015. */
  107016. readonly currentVRCamera: Nullable<Camera>;
  107017. /**
  107018. * The webVRCamera which is used when in VR.
  107019. */
  107020. readonly webVRCamera: WebVRFreeCamera;
  107021. /**
  107022. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107023. */
  107024. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107025. /**
  107026. * The html button that is used to trigger entering into VR.
  107027. */
  107028. readonly vrButton: Nullable<HTMLButtonElement>;
  107029. private readonly _teleportationRequestInitiated;
  107030. /**
  107031. * Defines wether or not Pointer lock should be requested when switching to
  107032. * full screen.
  107033. */
  107034. requestPointerLockOnFullScreen: boolean;
  107035. /**
  107036. * Instantiates a VRExperienceHelper.
  107037. * Helps to quickly add VR support to an existing scene.
  107038. * @param scene The scene the VRExperienceHelper belongs to.
  107039. * @param webVROptions Options to modify the vr experience helper's behavior.
  107040. */
  107041. constructor(scene: Scene,
  107042. /** Options to modify the vr experience helper's behavior. */
  107043. webVROptions?: VRExperienceHelperOptions);
  107044. private _onDefaultMeshLoaded;
  107045. private _onResize;
  107046. private _onFullscreenChange;
  107047. /**
  107048. * Gets a value indicating if we are currently in VR mode.
  107049. */
  107050. readonly isInVRMode: boolean;
  107051. private onVrDisplayPresentChange;
  107052. private onVRDisplayChanged;
  107053. private moveButtonToBottomRight;
  107054. private displayVRButton;
  107055. private updateButtonVisibility;
  107056. private _cachedAngularSensibility;
  107057. /**
  107058. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107059. * Otherwise, will use the fullscreen API.
  107060. */
  107061. enterVR(): void;
  107062. /**
  107063. * Attempt to exit VR, or fullscreen.
  107064. */
  107065. exitVR(): void;
  107066. /**
  107067. * The position of the vr experience helper.
  107068. */
  107069. /**
  107070. * Sets the position of the vr experience helper.
  107071. */
  107072. position: Vector3;
  107073. /**
  107074. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107075. */
  107076. enableInteractions(): void;
  107077. private readonly _noControllerIsActive;
  107078. private beforeRender;
  107079. private _isTeleportationFloor;
  107080. /**
  107081. * Adds a floor mesh to be used for teleportation.
  107082. * @param floorMesh the mesh to be used for teleportation.
  107083. */
  107084. addFloorMesh(floorMesh: Mesh): void;
  107085. /**
  107086. * Removes a floor mesh from being used for teleportation.
  107087. * @param floorMesh the mesh to be removed.
  107088. */
  107089. removeFloorMesh(floorMesh: Mesh): void;
  107090. /**
  107091. * Enables interactions and teleportation using the VR controllers and gaze.
  107092. * @param vrTeleportationOptions options to modify teleportation behavior.
  107093. */
  107094. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107095. private _onNewGamepadConnected;
  107096. private _tryEnableInteractionOnController;
  107097. private _onNewGamepadDisconnected;
  107098. private _enableInteractionOnController;
  107099. private _checkTeleportWithRay;
  107100. private _checkRotate;
  107101. private _checkTeleportBackwards;
  107102. private _enableTeleportationOnController;
  107103. private _createTeleportationCircles;
  107104. private _displayTeleportationTarget;
  107105. private _hideTeleportationTarget;
  107106. private _rotateCamera;
  107107. private _moveTeleportationSelectorTo;
  107108. private _workingVector;
  107109. private _workingQuaternion;
  107110. private _workingMatrix;
  107111. /**
  107112. * Teleports the users feet to the desired location
  107113. * @param location The location where the user's feet should be placed
  107114. */
  107115. teleportCamera(location: Vector3): void;
  107116. private _convertNormalToDirectionOfRay;
  107117. private _castRayAndSelectObject;
  107118. private _notifySelectedMeshUnselected;
  107119. /**
  107120. * Sets the color of the laser ray from the vr controllers.
  107121. * @param color new color for the ray.
  107122. */
  107123. changeLaserColor(color: Color3): void;
  107124. /**
  107125. * Sets the color of the ray from the vr headsets gaze.
  107126. * @param color new color for the ray.
  107127. */
  107128. changeGazeColor(color: Color3): void;
  107129. /**
  107130. * Exits VR and disposes of the vr experience helper
  107131. */
  107132. dispose(): void;
  107133. /**
  107134. * Gets the name of the VRExperienceHelper class
  107135. * @returns "VRExperienceHelper"
  107136. */
  107137. getClassName(): string;
  107138. }
  107139. }
  107140. declare module BABYLON {
  107141. /**
  107142. * Manages an XRSession to work with Babylon's engine
  107143. * @see https://doc.babylonjs.com/how_to/webxr
  107144. */
  107145. export class WebXRSessionManager implements IDisposable {
  107146. private scene;
  107147. /**
  107148. * Fires every time a new xrFrame arrives which can be used to update the camera
  107149. */
  107150. onXRFrameObservable: Observable<any>;
  107151. /**
  107152. * Fires when the xr session is ended either by the device or manually done
  107153. */
  107154. onXRSessionEnded: Observable<any>;
  107155. /**
  107156. * Underlying xr session
  107157. */
  107158. session: XRSession;
  107159. /**
  107160. * Type of reference space used when creating the session
  107161. */
  107162. referenceSpace: XRReferenceSpace;
  107163. /** @hidden */
  107164. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107165. /**
  107166. * Current XR frame
  107167. */
  107168. currentFrame: Nullable<XRFrame>;
  107169. private _xrNavigator;
  107170. private baseLayer;
  107171. /**
  107172. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107173. * @param scene The scene which the session should be created for
  107174. */
  107175. constructor(scene: Scene);
  107176. /**
  107177. * Initializes the manager
  107178. * After initialization enterXR can be called to start an XR session
  107179. * @returns Promise which resolves after it is initialized
  107180. */
  107181. initializeAsync(): Promise<void>;
  107182. /**
  107183. * Initializes an xr session
  107184. * @param xrSessionMode mode to initialize
  107185. * @returns a promise which will resolve once the session has been initialized
  107186. */
  107187. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107188. /**
  107189. * Sets the reference space on the xr session
  107190. * @param referenceSpace space to set
  107191. * @returns a promise that will resolve once the reference space has been set
  107192. */
  107193. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107194. /**
  107195. * Updates the render state of the session
  107196. * @param state state to set
  107197. * @returns a promise that resolves once the render state has been updated
  107198. */
  107199. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107200. /**
  107201. * Starts rendering to the xr layer
  107202. * @returns a promise that will resolve once rendering has started
  107203. */
  107204. startRenderingToXRAsync(): Promise<void>;
  107205. /**
  107206. * Stops the xrSession and restores the renderloop
  107207. * @returns Promise which resolves after it exits XR
  107208. */
  107209. exitXRAsync(): Promise<unknown>;
  107210. /**
  107211. * Checks if a session would be supported for the creation options specified
  107212. * @param sessionMode session mode to check if supported eg. immersive-vr
  107213. * @returns true if supported
  107214. */
  107215. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107216. /**
  107217. * @hidden
  107218. * Converts the render layer of xrSession to a render target
  107219. * @param session session to create render target for
  107220. * @param scene scene the new render target should be created for
  107221. */
  107222. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107223. /**
  107224. * Disposes of the session manager
  107225. */
  107226. dispose(): void;
  107227. }
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * WebXR Camera which holds the views for the xrSession
  107232. * @see https://doc.babylonjs.com/how_to/webxr
  107233. */
  107234. export class WebXRCamera extends FreeCamera {
  107235. private static _TmpMatrix;
  107236. /**
  107237. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107238. * @param name the name of the camera
  107239. * @param scene the scene to add the camera to
  107240. */
  107241. constructor(name: string, scene: Scene);
  107242. private _updateNumberOfRigCameras;
  107243. /** @hidden */
  107244. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107245. /**
  107246. * Updates the cameras position from the current pose information of the XR session
  107247. * @param xrSessionManager the session containing pose information
  107248. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107249. */
  107250. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107251. }
  107252. }
  107253. declare module BABYLON {
  107254. /**
  107255. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107256. */
  107257. export class WebXRManagedOutputCanvas implements IDisposable {
  107258. private helper;
  107259. private _canvas;
  107260. /**
  107261. * xrpresent context of the canvas which can be used to display/mirror xr content
  107262. */
  107263. canvasContext: WebGLRenderingContext;
  107264. /**
  107265. * xr layer for the canvas
  107266. */
  107267. xrLayer: Nullable<XRWebGLLayer>;
  107268. /**
  107269. * Initializes the xr layer for the session
  107270. * @param xrSession xr session
  107271. * @returns a promise that will resolve once the XR Layer has been created
  107272. */
  107273. initializeXRLayerAsync(xrSession: any): any;
  107274. /**
  107275. * Initializes the canvas to be added/removed upon entering/exiting xr
  107276. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107277. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107278. */
  107279. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107280. /**
  107281. * Disposes of the object
  107282. */
  107283. dispose(): void;
  107284. private _setManagedOutputCanvas;
  107285. private _addCanvas;
  107286. private _removeCanvas;
  107287. }
  107288. }
  107289. declare module BABYLON {
  107290. /**
  107291. * States of the webXR experience
  107292. */
  107293. export enum WebXRState {
  107294. /**
  107295. * Transitioning to being in XR mode
  107296. */
  107297. ENTERING_XR = 0,
  107298. /**
  107299. * Transitioning to non XR mode
  107300. */
  107301. EXITING_XR = 1,
  107302. /**
  107303. * In XR mode and presenting
  107304. */
  107305. IN_XR = 2,
  107306. /**
  107307. * Not entered XR mode
  107308. */
  107309. NOT_IN_XR = 3
  107310. }
  107311. /**
  107312. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107313. * @see https://doc.babylonjs.com/how_to/webxr
  107314. */
  107315. export class WebXRExperienceHelper implements IDisposable {
  107316. private scene;
  107317. /**
  107318. * 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
  107319. */
  107320. container: AbstractMesh;
  107321. /**
  107322. * Camera used to render xr content
  107323. */
  107324. camera: WebXRCamera;
  107325. /**
  107326. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107327. */
  107328. state: WebXRState;
  107329. private _setState;
  107330. private static _TmpVector;
  107331. /**
  107332. * Fires when the state of the experience helper has changed
  107333. */
  107334. onStateChangedObservable: Observable<WebXRState>;
  107335. /** Session manager used to keep track of xr session */
  107336. sessionManager: WebXRSessionManager;
  107337. private _nonVRCamera;
  107338. private _originalSceneAutoClear;
  107339. private _supported;
  107340. /**
  107341. * Creates the experience helper
  107342. * @param scene the scene to attach the experience helper to
  107343. * @returns a promise for the experience helper
  107344. */
  107345. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107346. /**
  107347. * Creates a WebXRExperienceHelper
  107348. * @param scene The scene the helper should be created in
  107349. */
  107350. private constructor();
  107351. /**
  107352. * Exits XR mode and returns the scene to its original state
  107353. * @returns promise that resolves after xr mode has exited
  107354. */
  107355. exitXRAsync(): Promise<unknown>;
  107356. /**
  107357. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107358. * @param sessionCreationOptions options for the XR session
  107359. * @param referenceSpaceType frame of reference of the XR session
  107360. * @param outputCanvas the output canvas that will be used to enter XR mode
  107361. * @returns promise that resolves after xr mode has entered
  107362. */
  107363. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107364. /**
  107365. * Updates the global position of the camera by moving the camera's container
  107366. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107367. * @param position The desired global position of the camera
  107368. */
  107369. setPositionOfCameraUsingContainer(position: Vector3): void;
  107370. /**
  107371. * Rotates the xr camera by rotating the camera's container around the camera's position
  107372. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107373. * @param rotation the desired quaternion rotation to apply to the camera
  107374. */
  107375. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107376. /**
  107377. * Disposes of the experience helper
  107378. */
  107379. dispose(): void;
  107380. }
  107381. }
  107382. declare module BABYLON {
  107383. /**
  107384. * Button which can be used to enter a different mode of XR
  107385. */
  107386. export class WebXREnterExitUIButton {
  107387. /** button element */
  107388. element: HTMLElement;
  107389. /** XR initialization options for the button */
  107390. sessionMode: XRSessionMode;
  107391. /** Reference space type */
  107392. referenceSpaceType: XRReferenceSpaceType;
  107393. /**
  107394. * Creates a WebXREnterExitUIButton
  107395. * @param element button element
  107396. * @param sessionMode XR initialization session mode
  107397. * @param referenceSpaceType the type of reference space to be used
  107398. */
  107399. constructor(
  107400. /** button element */
  107401. element: HTMLElement,
  107402. /** XR initialization options for the button */
  107403. sessionMode: XRSessionMode,
  107404. /** Reference space type */
  107405. referenceSpaceType: XRReferenceSpaceType);
  107406. /**
  107407. * Overwritable function which can be used to update the button's visuals when the state changes
  107408. * @param activeButton the current active button in the UI
  107409. */
  107410. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107411. }
  107412. /**
  107413. * Options to create the webXR UI
  107414. */
  107415. export class WebXREnterExitUIOptions {
  107416. /**
  107417. * Context to enter xr with
  107418. */
  107419. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107420. /**
  107421. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107422. */
  107423. customButtons?: Array<WebXREnterExitUIButton>;
  107424. }
  107425. /**
  107426. * UI to allow the user to enter/exit XR mode
  107427. */
  107428. export class WebXREnterExitUI implements IDisposable {
  107429. private scene;
  107430. private _overlay;
  107431. private _buttons;
  107432. private _activeButton;
  107433. /**
  107434. * Fired every time the active button is changed.
  107435. *
  107436. * When xr is entered via a button that launches xr that button will be the callback parameter
  107437. *
  107438. * When exiting xr the callback parameter will be null)
  107439. */
  107440. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107441. /**
  107442. * Creates UI to allow the user to enter/exit XR mode
  107443. * @param scene the scene to add the ui to
  107444. * @param helper the xr experience helper to enter/exit xr with
  107445. * @param options options to configure the UI
  107446. * @returns the created ui
  107447. */
  107448. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107449. private constructor();
  107450. private _updateButtons;
  107451. /**
  107452. * Disposes of the object
  107453. */
  107454. dispose(): void;
  107455. }
  107456. }
  107457. declare module BABYLON {
  107458. /**
  107459. * Represents an XR input
  107460. */
  107461. export class WebXRController {
  107462. private scene;
  107463. /** The underlying input source for the controller */
  107464. inputSource: XRInputSource;
  107465. private parentContainer;
  107466. /**
  107467. * 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
  107468. */
  107469. grip?: AbstractMesh;
  107470. /**
  107471. * Pointer which can be used to select objects or attach a visible laser to
  107472. */
  107473. pointer: AbstractMesh;
  107474. /**
  107475. * Event that fires when the controller is removed/disposed
  107476. */
  107477. onDisposeObservable: Observable<{}>;
  107478. private _tmpMatrix;
  107479. private _tmpQuaternion;
  107480. private _tmpVector;
  107481. /**
  107482. * Creates the controller
  107483. * @see https://doc.babylonjs.com/how_to/webxr
  107484. * @param scene the scene which the controller should be associated to
  107485. * @param inputSource the underlying input source for the controller
  107486. * @param parentContainer parent that the controller meshes should be children of
  107487. */
  107488. constructor(scene: Scene,
  107489. /** The underlying input source for the controller */
  107490. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107491. /**
  107492. * Updates the controller pose based on the given XRFrame
  107493. * @param xrFrame xr frame to update the pose with
  107494. * @param referenceSpace reference space to use
  107495. */
  107496. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107497. /**
  107498. * Gets a world space ray coming from the controller
  107499. * @param result the resulting ray
  107500. */
  107501. getWorldPointerRayToRef(result: Ray): void;
  107502. /**
  107503. * Disposes of the object
  107504. */
  107505. dispose(): void;
  107506. }
  107507. }
  107508. declare module BABYLON {
  107509. /**
  107510. * XR input used to track XR inputs such as controllers/rays
  107511. */
  107512. export class WebXRInput implements IDisposable {
  107513. /**
  107514. * Base experience the input listens to
  107515. */
  107516. baseExperience: WebXRExperienceHelper;
  107517. /**
  107518. * XR controllers being tracked
  107519. */
  107520. controllers: Array<WebXRController>;
  107521. private _frameObserver;
  107522. private _stateObserver;
  107523. /**
  107524. * Event when a controller has been connected/added
  107525. */
  107526. onControllerAddedObservable: Observable<WebXRController>;
  107527. /**
  107528. * Event when a controller has been removed/disconnected
  107529. */
  107530. onControllerRemovedObservable: Observable<WebXRController>;
  107531. /**
  107532. * Initializes the WebXRInput
  107533. * @param baseExperience experience helper which the input should be created for
  107534. */
  107535. constructor(
  107536. /**
  107537. * Base experience the input listens to
  107538. */
  107539. baseExperience: WebXRExperienceHelper);
  107540. private _onInputSourcesChange;
  107541. private _addAndRemoveControllers;
  107542. /**
  107543. * Disposes of the object
  107544. */
  107545. dispose(): void;
  107546. }
  107547. }
  107548. declare module BABYLON {
  107549. /**
  107550. * Enables teleportation
  107551. */
  107552. export class WebXRControllerTeleportation {
  107553. private _teleportationFillColor;
  107554. private _teleportationBorderColor;
  107555. private _tmpRay;
  107556. private _tmpVector;
  107557. /**
  107558. * Creates a WebXRControllerTeleportation
  107559. * @param input input manager to add teleportation to
  107560. * @param floorMeshes floormeshes which can be teleported to
  107561. */
  107562. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107563. }
  107564. }
  107565. declare module BABYLON {
  107566. /**
  107567. * Handles pointer input automatically for the pointer of XR controllers
  107568. */
  107569. export class WebXRControllerPointerSelection {
  107570. private static _idCounter;
  107571. private _tmpRay;
  107572. /**
  107573. * Creates a WebXRControllerPointerSelection
  107574. * @param input input manager to setup pointer selection
  107575. */
  107576. constructor(input: WebXRInput);
  107577. private _convertNormalToDirectionOfRay;
  107578. private _updatePointerDistance;
  107579. }
  107580. }
  107581. declare module BABYLON {
  107582. /**
  107583. * Class used to represent data loading progression
  107584. */
  107585. export class SceneLoaderProgressEvent {
  107586. /** defines if data length to load can be evaluated */
  107587. readonly lengthComputable: boolean;
  107588. /** defines the loaded data length */
  107589. readonly loaded: number;
  107590. /** defines the data length to load */
  107591. readonly total: number;
  107592. /**
  107593. * Create a new progress event
  107594. * @param lengthComputable defines if data length to load can be evaluated
  107595. * @param loaded defines the loaded data length
  107596. * @param total defines the data length to load
  107597. */
  107598. constructor(
  107599. /** defines if data length to load can be evaluated */
  107600. lengthComputable: boolean,
  107601. /** defines the loaded data length */
  107602. loaded: number,
  107603. /** defines the data length to load */
  107604. total: number);
  107605. /**
  107606. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107607. * @param event defines the source event
  107608. * @returns a new SceneLoaderProgressEvent
  107609. */
  107610. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107611. }
  107612. /**
  107613. * Interface used by SceneLoader plugins to define supported file extensions
  107614. */
  107615. export interface ISceneLoaderPluginExtensions {
  107616. /**
  107617. * Defines the list of supported extensions
  107618. */
  107619. [extension: string]: {
  107620. isBinary: boolean;
  107621. };
  107622. }
  107623. /**
  107624. * Interface used by SceneLoader plugin factory
  107625. */
  107626. export interface ISceneLoaderPluginFactory {
  107627. /**
  107628. * Defines the name of the factory
  107629. */
  107630. name: string;
  107631. /**
  107632. * Function called to create a new plugin
  107633. * @return the new plugin
  107634. */
  107635. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107636. /**
  107637. * Boolean indicating if the plugin can direct load specific data
  107638. */
  107639. canDirectLoad?: (data: string) => boolean;
  107640. }
  107641. /**
  107642. * Interface used to define a SceneLoader plugin
  107643. */
  107644. export interface ISceneLoaderPlugin {
  107645. /**
  107646. * The friendly name of this plugin.
  107647. */
  107648. name: string;
  107649. /**
  107650. * The file extensions supported by this plugin.
  107651. */
  107652. extensions: string | ISceneLoaderPluginExtensions;
  107653. /**
  107654. * Import meshes into a scene.
  107655. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107656. * @param scene The scene to import into
  107657. * @param data The data to import
  107658. * @param rootUrl The root url for scene and resources
  107659. * @param meshes The meshes array to import into
  107660. * @param particleSystems The particle systems array to import into
  107661. * @param skeletons The skeletons array to import into
  107662. * @param onError The callback when import fails
  107663. * @returns True if successful or false otherwise
  107664. */
  107665. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107666. /**
  107667. * Load into a scene.
  107668. * @param scene The scene to load into
  107669. * @param data The data to import
  107670. * @param rootUrl The root url for scene and resources
  107671. * @param onError The callback when import fails
  107672. * @returns true if successful or false otherwise
  107673. */
  107674. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107675. /**
  107676. * The callback that returns true if the data can be directly loaded.
  107677. */
  107678. canDirectLoad?: (data: string) => boolean;
  107679. /**
  107680. * The callback that allows custom handling of the root url based on the response url.
  107681. */
  107682. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107683. /**
  107684. * Load into an asset container.
  107685. * @param scene The scene to load into
  107686. * @param data The data to import
  107687. * @param rootUrl The root url for scene and resources
  107688. * @param onError The callback when import fails
  107689. * @returns The loaded asset container
  107690. */
  107691. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107692. }
  107693. /**
  107694. * Interface used to define an async SceneLoader plugin
  107695. */
  107696. export interface ISceneLoaderPluginAsync {
  107697. /**
  107698. * The friendly name of this plugin.
  107699. */
  107700. name: string;
  107701. /**
  107702. * The file extensions supported by this plugin.
  107703. */
  107704. extensions: string | ISceneLoaderPluginExtensions;
  107705. /**
  107706. * Import meshes into a scene.
  107707. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107708. * @param scene The scene to import into
  107709. * @param data The data to import
  107710. * @param rootUrl The root url for scene and resources
  107711. * @param onProgress The callback when the load progresses
  107712. * @param fileName Defines the name of the file to load
  107713. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107714. */
  107715. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107716. meshes: AbstractMesh[];
  107717. particleSystems: IParticleSystem[];
  107718. skeletons: Skeleton[];
  107719. animationGroups: AnimationGroup[];
  107720. }>;
  107721. /**
  107722. * Load into a scene.
  107723. * @param scene The scene to load into
  107724. * @param data The data to import
  107725. * @param rootUrl The root url for scene and resources
  107726. * @param onProgress The callback when the load progresses
  107727. * @param fileName Defines the name of the file to load
  107728. * @returns Nothing
  107729. */
  107730. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107731. /**
  107732. * The callback that returns true if the data can be directly loaded.
  107733. */
  107734. canDirectLoad?: (data: string) => boolean;
  107735. /**
  107736. * The callback that allows custom handling of the root url based on the response url.
  107737. */
  107738. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107739. /**
  107740. * Load into an asset container.
  107741. * @param scene The scene to load into
  107742. * @param data The data to import
  107743. * @param rootUrl The root url for scene and resources
  107744. * @param onProgress The callback when the load progresses
  107745. * @param fileName Defines the name of the file to load
  107746. * @returns The loaded asset container
  107747. */
  107748. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107749. }
  107750. /**
  107751. * Class used to load scene from various file formats using registered plugins
  107752. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107753. */
  107754. export class SceneLoader {
  107755. /**
  107756. * No logging while loading
  107757. */
  107758. static readonly NO_LOGGING: number;
  107759. /**
  107760. * Minimal logging while loading
  107761. */
  107762. static readonly MINIMAL_LOGGING: number;
  107763. /**
  107764. * Summary logging while loading
  107765. */
  107766. static readonly SUMMARY_LOGGING: number;
  107767. /**
  107768. * Detailled logging while loading
  107769. */
  107770. static readonly DETAILED_LOGGING: number;
  107771. /**
  107772. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107773. */
  107774. static ForceFullSceneLoadingForIncremental: boolean;
  107775. /**
  107776. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107777. */
  107778. static ShowLoadingScreen: boolean;
  107779. /**
  107780. * Defines the current logging level (while loading the scene)
  107781. * @ignorenaming
  107782. */
  107783. static loggingLevel: number;
  107784. /**
  107785. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107786. */
  107787. static CleanBoneMatrixWeights: boolean;
  107788. /**
  107789. * Event raised when a plugin is used to load a scene
  107790. */
  107791. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107792. private static _registeredPlugins;
  107793. private static _getDefaultPlugin;
  107794. private static _getPluginForExtension;
  107795. private static _getPluginForDirectLoad;
  107796. private static _getPluginForFilename;
  107797. private static _getDirectLoad;
  107798. private static _loadData;
  107799. private static _getFileInfo;
  107800. /**
  107801. * Gets a plugin that can load the given extension
  107802. * @param extension defines the extension to load
  107803. * @returns a plugin or null if none works
  107804. */
  107805. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107806. /**
  107807. * Gets a boolean indicating that the given extension can be loaded
  107808. * @param extension defines the extension to load
  107809. * @returns true if the extension is supported
  107810. */
  107811. static IsPluginForExtensionAvailable(extension: string): boolean;
  107812. /**
  107813. * Adds a new plugin to the list of registered plugins
  107814. * @param plugin defines the plugin to add
  107815. */
  107816. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107817. /**
  107818. * Import meshes into a scene
  107819. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107820. * @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)
  107821. * @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)
  107822. * @param scene the instance of BABYLON.Scene to append to
  107823. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107824. * @param onProgress a callback with a progress event for each file being loaded
  107825. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107826. * @param pluginExtension the extension used to determine the plugin
  107827. * @returns The loaded plugin
  107828. */
  107829. 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>;
  107830. /**
  107831. * Import meshes into a scene
  107832. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107833. * @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)
  107834. * @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)
  107835. * @param scene the instance of BABYLON.Scene to append to
  107836. * @param onProgress a callback with a progress event for each file being loaded
  107837. * @param pluginExtension the extension used to determine the plugin
  107838. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107839. */
  107840. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107841. meshes: AbstractMesh[];
  107842. particleSystems: IParticleSystem[];
  107843. skeletons: Skeleton[];
  107844. animationGroups: AnimationGroup[];
  107845. }>;
  107846. /**
  107847. * Load a scene
  107848. * @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)
  107849. * @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)
  107850. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107851. * @param onSuccess a callback with the scene when import succeeds
  107852. * @param onProgress a callback with a progress event for each file being loaded
  107853. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107854. * @param pluginExtension the extension used to determine the plugin
  107855. * @returns The loaded plugin
  107856. */
  107857. 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>;
  107858. /**
  107859. * Load a scene
  107860. * @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)
  107861. * @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)
  107862. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107863. * @param onProgress a callback with a progress event for each file being loaded
  107864. * @param pluginExtension the extension used to determine the plugin
  107865. * @returns The loaded scene
  107866. */
  107867. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107868. /**
  107869. * Append a scene
  107870. * @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)
  107871. * @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)
  107872. * @param scene is the instance of BABYLON.Scene to append to
  107873. * @param onSuccess a callback with the scene when import succeeds
  107874. * @param onProgress a callback with a progress event for each file being loaded
  107875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107876. * @param pluginExtension the extension used to determine the plugin
  107877. * @returns The loaded plugin
  107878. */
  107879. 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>;
  107880. /**
  107881. * Append a scene
  107882. * @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)
  107883. * @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)
  107884. * @param scene is the instance of BABYLON.Scene to append to
  107885. * @param onProgress a callback with a progress event for each file being loaded
  107886. * @param pluginExtension the extension used to determine the plugin
  107887. * @returns The given scene
  107888. */
  107889. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107890. /**
  107891. * Load a scene into an asset container
  107892. * @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)
  107893. * @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)
  107894. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107895. * @param onSuccess a callback with the scene when import succeeds
  107896. * @param onProgress a callback with a progress event for each file being loaded
  107897. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107898. * @param pluginExtension the extension used to determine the plugin
  107899. * @returns The loaded plugin
  107900. */
  107901. 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>;
  107902. /**
  107903. * Load a scene into an asset container
  107904. * @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)
  107905. * @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)
  107906. * @param scene is the instance of Scene to append to
  107907. * @param onProgress a callback with a progress event for each file being loaded
  107908. * @param pluginExtension the extension used to determine the plugin
  107909. * @returns The loaded asset container
  107910. */
  107911. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107912. }
  107913. }
  107914. declare module BABYLON {
  107915. /**
  107916. * Generic Controller
  107917. */
  107918. export class GenericController extends WebVRController {
  107919. /**
  107920. * Base Url for the controller model.
  107921. */
  107922. static readonly MODEL_BASE_URL: string;
  107923. /**
  107924. * File name for the controller model.
  107925. */
  107926. static readonly MODEL_FILENAME: string;
  107927. /**
  107928. * Creates a new GenericController from a gamepad
  107929. * @param vrGamepad the gamepad that the controller should be created from
  107930. */
  107931. constructor(vrGamepad: any);
  107932. /**
  107933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107934. * @param scene scene in which to add meshes
  107935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107936. */
  107937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107938. /**
  107939. * Called once for each button that changed state since the last frame
  107940. * @param buttonIdx Which button index changed
  107941. * @param state New state of the button
  107942. * @param changes Which properties on the state changed since last frame
  107943. */
  107944. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107945. }
  107946. }
  107947. declare module BABYLON {
  107948. /**
  107949. * Defines the WindowsMotionController object that the state of the windows motion controller
  107950. */
  107951. export class WindowsMotionController extends WebVRController {
  107952. /**
  107953. * The base url used to load the left and right controller models
  107954. */
  107955. static MODEL_BASE_URL: string;
  107956. /**
  107957. * The name of the left controller model file
  107958. */
  107959. static MODEL_LEFT_FILENAME: string;
  107960. /**
  107961. * The name of the right controller model file
  107962. */
  107963. static MODEL_RIGHT_FILENAME: string;
  107964. /**
  107965. * The controller name prefix for this controller type
  107966. */
  107967. static readonly GAMEPAD_ID_PREFIX: string;
  107968. /**
  107969. * The controller id pattern for this controller type
  107970. */
  107971. private static readonly GAMEPAD_ID_PATTERN;
  107972. private _loadedMeshInfo;
  107973. private readonly _mapping;
  107974. /**
  107975. * Fired when the trackpad on this controller is clicked
  107976. */
  107977. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107978. /**
  107979. * Fired when the trackpad on this controller is modified
  107980. */
  107981. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107982. /**
  107983. * The current x and y values of this controller's trackpad
  107984. */
  107985. trackpad: StickValues;
  107986. /**
  107987. * Creates a new WindowsMotionController from a gamepad
  107988. * @param vrGamepad the gamepad that the controller should be created from
  107989. */
  107990. constructor(vrGamepad: any);
  107991. /**
  107992. * Fired when the trigger on this controller is modified
  107993. */
  107994. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107995. /**
  107996. * Fired when the menu button on this controller is modified
  107997. */
  107998. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107999. /**
  108000. * Fired when the grip button on this controller is modified
  108001. */
  108002. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108003. /**
  108004. * Fired when the thumbstick button on this controller is modified
  108005. */
  108006. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108007. /**
  108008. * Fired when the touchpad button on this controller is modified
  108009. */
  108010. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108011. /**
  108012. * Fired when the touchpad values on this controller are modified
  108013. */
  108014. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108015. private _updateTrackpad;
  108016. /**
  108017. * Called once per frame by the engine.
  108018. */
  108019. update(): void;
  108020. /**
  108021. * Called once for each button that changed state since the last frame
  108022. * @param buttonIdx Which button index changed
  108023. * @param state New state of the button
  108024. * @param changes Which properties on the state changed since last frame
  108025. */
  108026. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108027. /**
  108028. * Moves the buttons on the controller mesh based on their current state
  108029. * @param buttonName the name of the button to move
  108030. * @param buttonValue the value of the button which determines the buttons new position
  108031. */
  108032. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108033. /**
  108034. * Moves the axis on the controller mesh based on its current state
  108035. * @param axis the index of the axis
  108036. * @param axisValue the value of the axis which determines the meshes new position
  108037. * @hidden
  108038. */
  108039. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108040. /**
  108041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108042. * @param scene scene in which to add meshes
  108043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108044. */
  108045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108046. /**
  108047. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108048. * can be transformed by button presses and axes values, based on this._mapping.
  108049. *
  108050. * @param scene scene in which the meshes exist
  108051. * @param meshes list of meshes that make up the controller model to process
  108052. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108053. */
  108054. private processModel;
  108055. private createMeshInfo;
  108056. /**
  108057. * Gets the ray of the controller in the direction the controller is pointing
  108058. * @param length the length the resulting ray should be
  108059. * @returns a ray in the direction the controller is pointing
  108060. */
  108061. getForwardRay(length?: number): Ray;
  108062. /**
  108063. * Disposes of the controller
  108064. */
  108065. dispose(): void;
  108066. }
  108067. }
  108068. declare module BABYLON {
  108069. /**
  108070. * Oculus Touch Controller
  108071. */
  108072. export class OculusTouchController extends WebVRController {
  108073. /**
  108074. * Base Url for the controller model.
  108075. */
  108076. static MODEL_BASE_URL: string;
  108077. /**
  108078. * File name for the left controller model.
  108079. */
  108080. static MODEL_LEFT_FILENAME: string;
  108081. /**
  108082. * File name for the right controller model.
  108083. */
  108084. static MODEL_RIGHT_FILENAME: string;
  108085. /**
  108086. * Base Url for the Quest controller model.
  108087. */
  108088. static QUEST_MODEL_BASE_URL: string;
  108089. /**
  108090. * @hidden
  108091. * If the controllers are running on a device that needs the updated Quest controller models
  108092. */
  108093. static _IsQuest: boolean;
  108094. /**
  108095. * Fired when the secondary trigger on this controller is modified
  108096. */
  108097. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108098. /**
  108099. * Fired when the thumb rest on this controller is modified
  108100. */
  108101. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108102. /**
  108103. * Creates a new OculusTouchController from a gamepad
  108104. * @param vrGamepad the gamepad that the controller should be created from
  108105. */
  108106. constructor(vrGamepad: any);
  108107. /**
  108108. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108109. * @param scene scene in which to add meshes
  108110. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108111. */
  108112. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108113. /**
  108114. * Fired when the A button on this controller is modified
  108115. */
  108116. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108117. /**
  108118. * Fired when the B button on this controller is modified
  108119. */
  108120. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108121. /**
  108122. * Fired when the X button on this controller is modified
  108123. */
  108124. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108125. /**
  108126. * Fired when the Y button on this controller is modified
  108127. */
  108128. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108129. /**
  108130. * Called once for each button that changed state since the last frame
  108131. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108132. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108133. * 2) secondary trigger (same)
  108134. * 3) A (right) X (left), touch, pressed = value
  108135. * 4) B / Y
  108136. * 5) thumb rest
  108137. * @param buttonIdx Which button index changed
  108138. * @param state New state of the button
  108139. * @param changes Which properties on the state changed since last frame
  108140. */
  108141. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108142. }
  108143. }
  108144. declare module BABYLON {
  108145. /**
  108146. * Vive Controller
  108147. */
  108148. export class ViveController extends WebVRController {
  108149. /**
  108150. * Base Url for the controller model.
  108151. */
  108152. static MODEL_BASE_URL: string;
  108153. /**
  108154. * File name for the controller model.
  108155. */
  108156. static MODEL_FILENAME: string;
  108157. /**
  108158. * Creates a new ViveController from a gamepad
  108159. * @param vrGamepad the gamepad that the controller should be created from
  108160. */
  108161. constructor(vrGamepad: any);
  108162. /**
  108163. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108164. * @param scene scene in which to add meshes
  108165. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108166. */
  108167. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108168. /**
  108169. * Fired when the left button on this controller is modified
  108170. */
  108171. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108172. /**
  108173. * Fired when the right button on this controller is modified
  108174. */
  108175. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108176. /**
  108177. * Fired when the menu button on this controller is modified
  108178. */
  108179. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108180. /**
  108181. * Called once for each button that changed state since the last frame
  108182. * Vive mapping:
  108183. * 0: touchpad
  108184. * 1: trigger
  108185. * 2: left AND right buttons
  108186. * 3: menu button
  108187. * @param buttonIdx Which button index changed
  108188. * @param state New state of the button
  108189. * @param changes Which properties on the state changed since last frame
  108190. */
  108191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108192. }
  108193. }
  108194. declare module BABYLON {
  108195. /**
  108196. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108197. */
  108198. export class WebXRControllerModelLoader {
  108199. /**
  108200. * Creates the WebXRControllerModelLoader
  108201. * @param input xr input that creates the controllers
  108202. */
  108203. constructor(input: WebXRInput);
  108204. }
  108205. }
  108206. declare module BABYLON {
  108207. /**
  108208. * Contains an array of blocks representing the octree
  108209. */
  108210. export interface IOctreeContainer<T> {
  108211. /**
  108212. * Blocks within the octree
  108213. */
  108214. blocks: Array<OctreeBlock<T>>;
  108215. }
  108216. /**
  108217. * Class used to store a cell in an octree
  108218. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108219. */
  108220. export class OctreeBlock<T> {
  108221. /**
  108222. * Gets the content of the current block
  108223. */
  108224. entries: T[];
  108225. /**
  108226. * Gets the list of block children
  108227. */
  108228. blocks: Array<OctreeBlock<T>>;
  108229. private _depth;
  108230. private _maxDepth;
  108231. private _capacity;
  108232. private _minPoint;
  108233. private _maxPoint;
  108234. private _boundingVectors;
  108235. private _creationFunc;
  108236. /**
  108237. * Creates a new block
  108238. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108239. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108240. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108241. * @param depth defines the current depth of this block in the octree
  108242. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108243. * @param creationFunc defines a callback to call when an element is added to the block
  108244. */
  108245. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108246. /**
  108247. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108248. */
  108249. readonly capacity: number;
  108250. /**
  108251. * Gets the minimum vector (in world space) of the block's bounding box
  108252. */
  108253. readonly minPoint: Vector3;
  108254. /**
  108255. * Gets the maximum vector (in world space) of the block's bounding box
  108256. */
  108257. readonly maxPoint: Vector3;
  108258. /**
  108259. * Add a new element to this block
  108260. * @param entry defines the element to add
  108261. */
  108262. addEntry(entry: T): void;
  108263. /**
  108264. * Remove an element from this block
  108265. * @param entry defines the element to remove
  108266. */
  108267. removeEntry(entry: T): void;
  108268. /**
  108269. * Add an array of elements to this block
  108270. * @param entries defines the array of elements to add
  108271. */
  108272. addEntries(entries: T[]): void;
  108273. /**
  108274. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108275. * @param frustumPlanes defines the frustum planes to test
  108276. * @param selection defines the array to store current content if selection is positive
  108277. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108278. */
  108279. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108280. /**
  108281. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108282. * @param sphereCenter defines the bounding sphere center
  108283. * @param sphereRadius defines the bounding sphere radius
  108284. * @param selection defines the array to store current content if selection is positive
  108285. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108286. */
  108287. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108288. /**
  108289. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108290. * @param ray defines the ray to test with
  108291. * @param selection defines the array to store current content if selection is positive
  108292. */
  108293. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108294. /**
  108295. * Subdivide the content into child blocks (this block will then be empty)
  108296. */
  108297. createInnerBlocks(): void;
  108298. /**
  108299. * @hidden
  108300. */
  108301. 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;
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /**
  108306. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108307. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108308. */
  108309. export class Octree<T> {
  108310. /** 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.) */
  108311. maxDepth: number;
  108312. /**
  108313. * Blocks within the octree containing objects
  108314. */
  108315. blocks: Array<OctreeBlock<T>>;
  108316. /**
  108317. * Content stored in the octree
  108318. */
  108319. dynamicContent: T[];
  108320. private _maxBlockCapacity;
  108321. private _selectionContent;
  108322. private _creationFunc;
  108323. /**
  108324. * Creates a octree
  108325. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108326. * @param creationFunc function to be used to instatiate the octree
  108327. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108328. * @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.)
  108329. */
  108330. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108331. /** 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.) */
  108332. maxDepth?: number);
  108333. /**
  108334. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108335. * @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);
  108336. * @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);
  108337. * @param entries meshes to be added to the octree blocks
  108338. */
  108339. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108340. /**
  108341. * Adds a mesh to the octree
  108342. * @param entry Mesh to add to the octree
  108343. */
  108344. addMesh(entry: T): void;
  108345. /**
  108346. * Remove an element from the octree
  108347. * @param entry defines the element to remove
  108348. */
  108349. removeMesh(entry: T): void;
  108350. /**
  108351. * Selects an array of meshes within the frustum
  108352. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108353. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108354. * @returns array of meshes within the frustum
  108355. */
  108356. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108357. /**
  108358. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108359. * @param sphereCenter defines the bounding sphere center
  108360. * @param sphereRadius defines the bounding sphere radius
  108361. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108362. * @returns an array of objects that intersect the sphere
  108363. */
  108364. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108365. /**
  108366. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108367. * @param ray defines the ray to test with
  108368. * @returns array of intersected objects
  108369. */
  108370. intersectsRay(ray: Ray): SmartArray<T>;
  108371. /**
  108372. * Adds a mesh into the octree block if it intersects the block
  108373. */
  108374. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108375. /**
  108376. * Adds a submesh into the octree block if it intersects the block
  108377. */
  108378. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108379. }
  108380. }
  108381. declare module BABYLON {
  108382. interface Scene {
  108383. /**
  108384. * @hidden
  108385. * Backing Filed
  108386. */
  108387. _selectionOctree: Octree<AbstractMesh>;
  108388. /**
  108389. * Gets the octree used to boost mesh selection (picking)
  108390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108391. */
  108392. selectionOctree: Octree<AbstractMesh>;
  108393. /**
  108394. * Creates or updates the octree used to boost selection (picking)
  108395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108396. * @param maxCapacity defines the maximum capacity per leaf
  108397. * @param maxDepth defines the maximum depth of the octree
  108398. * @returns an octree of AbstractMesh
  108399. */
  108400. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108401. }
  108402. interface AbstractMesh {
  108403. /**
  108404. * @hidden
  108405. * Backing Field
  108406. */
  108407. _submeshesOctree: Octree<SubMesh>;
  108408. /**
  108409. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108410. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108411. * @param maxCapacity defines the maximum size of each block (64 by default)
  108412. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108413. * @returns the new octree
  108414. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108416. */
  108417. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108418. }
  108419. /**
  108420. * Defines the octree scene component responsible to manage any octrees
  108421. * in a given scene.
  108422. */
  108423. export class OctreeSceneComponent {
  108424. /**
  108425. * The component name help to identify the component in the list of scene components.
  108426. */
  108427. readonly name: string;
  108428. /**
  108429. * The scene the component belongs to.
  108430. */
  108431. scene: Scene;
  108432. /**
  108433. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108434. */
  108435. readonly checksIsEnabled: boolean;
  108436. /**
  108437. * Creates a new instance of the component for the given scene
  108438. * @param scene Defines the scene to register the component in
  108439. */
  108440. constructor(scene: Scene);
  108441. /**
  108442. * Registers the component in a given scene
  108443. */
  108444. register(): void;
  108445. /**
  108446. * Return the list of active meshes
  108447. * @returns the list of active meshes
  108448. */
  108449. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108450. /**
  108451. * Return the list of active sub meshes
  108452. * @param mesh The mesh to get the candidates sub meshes from
  108453. * @returns the list of active sub meshes
  108454. */
  108455. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108456. private _tempRay;
  108457. /**
  108458. * Return the list of sub meshes intersecting with a given local ray
  108459. * @param mesh defines the mesh to find the submesh for
  108460. * @param localRay defines the ray in local space
  108461. * @returns the list of intersecting sub meshes
  108462. */
  108463. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108464. /**
  108465. * Return the list of sub meshes colliding with a collider
  108466. * @param mesh defines the mesh to find the submesh for
  108467. * @param collider defines the collider to evaluate the collision against
  108468. * @returns the list of colliding sub meshes
  108469. */
  108470. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108471. /**
  108472. * Rebuilds the elements related to this component in case of
  108473. * context lost for instance.
  108474. */
  108475. rebuild(): void;
  108476. /**
  108477. * Disposes the component and the associated ressources.
  108478. */
  108479. dispose(): void;
  108480. }
  108481. }
  108482. declare module BABYLON {
  108483. /**
  108484. * Renders a layer on top of an existing scene
  108485. */
  108486. export class UtilityLayerRenderer implements IDisposable {
  108487. /** the original scene that will be rendered on top of */
  108488. originalScene: Scene;
  108489. private _pointerCaptures;
  108490. private _lastPointerEvents;
  108491. private static _DefaultUtilityLayer;
  108492. private static _DefaultKeepDepthUtilityLayer;
  108493. private _sharedGizmoLight;
  108494. private _renderCamera;
  108495. /**
  108496. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108497. * @returns the camera that is used when rendering the utility layer
  108498. */
  108499. getRenderCamera(): Nullable<Camera>;
  108500. /**
  108501. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108502. * @param cam the camera that should be used when rendering the utility layer
  108503. */
  108504. setRenderCamera(cam: Nullable<Camera>): void;
  108505. /**
  108506. * @hidden
  108507. * Light which used by gizmos to get light shading
  108508. */
  108509. _getSharedGizmoLight(): HemisphericLight;
  108510. /**
  108511. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108512. */
  108513. pickUtilitySceneFirst: boolean;
  108514. /**
  108515. * 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)
  108516. */
  108517. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108518. /**
  108519. * 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)
  108520. */
  108521. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108522. /**
  108523. * The scene that is rendered on top of the original scene
  108524. */
  108525. utilityLayerScene: Scene;
  108526. /**
  108527. * If the utility layer should automatically be rendered on top of existing scene
  108528. */
  108529. shouldRender: boolean;
  108530. /**
  108531. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108532. */
  108533. onlyCheckPointerDownEvents: boolean;
  108534. /**
  108535. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108536. */
  108537. processAllEvents: boolean;
  108538. /**
  108539. * Observable raised when the pointer move from the utility layer scene to the main scene
  108540. */
  108541. onPointerOutObservable: Observable<number>;
  108542. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108543. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108544. private _afterRenderObserver;
  108545. private _sceneDisposeObserver;
  108546. private _originalPointerObserver;
  108547. /**
  108548. * Instantiates a UtilityLayerRenderer
  108549. * @param originalScene the original scene that will be rendered on top of
  108550. * @param handleEvents boolean indicating if the utility layer should handle events
  108551. */
  108552. constructor(
  108553. /** the original scene that will be rendered on top of */
  108554. originalScene: Scene, handleEvents?: boolean);
  108555. private _notifyObservers;
  108556. /**
  108557. * Renders the utility layers scene on top of the original scene
  108558. */
  108559. render(): void;
  108560. /**
  108561. * Disposes of the renderer
  108562. */
  108563. dispose(): void;
  108564. private _updateCamera;
  108565. }
  108566. }
  108567. declare module BABYLON {
  108568. /**
  108569. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108570. */
  108571. export class Gizmo implements IDisposable {
  108572. /** The utility layer the gizmo will be added to */
  108573. gizmoLayer: UtilityLayerRenderer;
  108574. /**
  108575. * The root mesh of the gizmo
  108576. */
  108577. _rootMesh: Mesh;
  108578. private _attachedMesh;
  108579. /**
  108580. * Ratio for the scale of the gizmo (Default: 1)
  108581. */
  108582. scaleRatio: number;
  108583. /**
  108584. * If a custom mesh has been set (Default: false)
  108585. */
  108586. protected _customMeshSet: boolean;
  108587. /**
  108588. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108589. * * When set, interactions will be enabled
  108590. */
  108591. attachedMesh: Nullable<AbstractMesh>;
  108592. /**
  108593. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108594. * @param mesh The mesh to replace the default mesh of the gizmo
  108595. */
  108596. setCustomMesh(mesh: Mesh): void;
  108597. /**
  108598. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108599. */
  108600. updateGizmoRotationToMatchAttachedMesh: boolean;
  108601. /**
  108602. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108603. */
  108604. updateGizmoPositionToMatchAttachedMesh: boolean;
  108605. /**
  108606. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108607. */
  108608. updateScale: boolean;
  108609. protected _interactionsEnabled: boolean;
  108610. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108611. private _beforeRenderObserver;
  108612. private _tempVector;
  108613. /**
  108614. * Creates a gizmo
  108615. * @param gizmoLayer The utility layer the gizmo will be added to
  108616. */
  108617. constructor(
  108618. /** The utility layer the gizmo will be added to */
  108619. gizmoLayer?: UtilityLayerRenderer);
  108620. /**
  108621. * Updates the gizmo to match the attached mesh's position/rotation
  108622. */
  108623. protected _update(): void;
  108624. /**
  108625. * Disposes of the gizmo
  108626. */
  108627. dispose(): void;
  108628. }
  108629. }
  108630. declare module BABYLON {
  108631. /**
  108632. * Single plane drag gizmo
  108633. */
  108634. export class PlaneDragGizmo extends Gizmo {
  108635. /**
  108636. * Drag behavior responsible for the gizmos dragging interactions
  108637. */
  108638. dragBehavior: PointerDragBehavior;
  108639. private _pointerObserver;
  108640. /**
  108641. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108642. */
  108643. snapDistance: number;
  108644. /**
  108645. * Event that fires each time the gizmo snaps to a new location.
  108646. * * snapDistance is the the change in distance
  108647. */
  108648. onSnapObservable: Observable<{
  108649. snapDistance: number;
  108650. }>;
  108651. private _plane;
  108652. private _coloredMaterial;
  108653. private _hoverMaterial;
  108654. private _isEnabled;
  108655. private _parent;
  108656. /** @hidden */
  108657. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108658. /** @hidden */
  108659. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108660. /**
  108661. * Creates a PlaneDragGizmo
  108662. * @param gizmoLayer The utility layer the gizmo will be added to
  108663. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108664. * @param color The color of the gizmo
  108665. */
  108666. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108667. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108668. /**
  108669. * If the gizmo is enabled
  108670. */
  108671. isEnabled: boolean;
  108672. /**
  108673. * Disposes of the gizmo
  108674. */
  108675. dispose(): void;
  108676. }
  108677. }
  108678. declare module BABYLON {
  108679. /**
  108680. * Gizmo that enables dragging a mesh along 3 axis
  108681. */
  108682. export class PositionGizmo extends Gizmo {
  108683. /**
  108684. * Internal gizmo used for interactions on the x axis
  108685. */
  108686. xGizmo: AxisDragGizmo;
  108687. /**
  108688. * Internal gizmo used for interactions on the y axis
  108689. */
  108690. yGizmo: AxisDragGizmo;
  108691. /**
  108692. * Internal gizmo used for interactions on the z axis
  108693. */
  108694. zGizmo: AxisDragGizmo;
  108695. /**
  108696. * Internal gizmo used for interactions on the yz plane
  108697. */
  108698. xPlaneGizmo: PlaneDragGizmo;
  108699. /**
  108700. * Internal gizmo used for interactions on the xz plane
  108701. */
  108702. yPlaneGizmo: PlaneDragGizmo;
  108703. /**
  108704. * Internal gizmo used for interactions on the xy plane
  108705. */
  108706. zPlaneGizmo: PlaneDragGizmo;
  108707. /**
  108708. * private variables
  108709. */
  108710. private _meshAttached;
  108711. private _updateGizmoRotationToMatchAttachedMesh;
  108712. private _snapDistance;
  108713. private _scaleRatio;
  108714. /** Fires an event when any of it's sub gizmos are dragged */
  108715. onDragStartObservable: Observable<unknown>;
  108716. /** Fires an event when any of it's sub gizmos are released from dragging */
  108717. onDragEndObservable: Observable<unknown>;
  108718. /**
  108719. * If set to true, planar drag is enabled
  108720. */
  108721. private _planarGizmoEnabled;
  108722. attachedMesh: Nullable<AbstractMesh>;
  108723. /**
  108724. * Creates a PositionGizmo
  108725. * @param gizmoLayer The utility layer the gizmo will be added to
  108726. */
  108727. constructor(gizmoLayer?: UtilityLayerRenderer);
  108728. /**
  108729. * If the planar drag gizmo is enabled
  108730. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108731. */
  108732. planarGizmoEnabled: boolean;
  108733. updateGizmoRotationToMatchAttachedMesh: boolean;
  108734. /**
  108735. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108736. */
  108737. snapDistance: number;
  108738. /**
  108739. * Ratio for the scale of the gizmo (Default: 1)
  108740. */
  108741. scaleRatio: number;
  108742. /**
  108743. * Disposes of the gizmo
  108744. */
  108745. dispose(): void;
  108746. /**
  108747. * CustomMeshes are not supported by this gizmo
  108748. * @param mesh The mesh to replace the default mesh of the gizmo
  108749. */
  108750. setCustomMesh(mesh: Mesh): void;
  108751. }
  108752. }
  108753. declare module BABYLON {
  108754. /**
  108755. * Single axis drag gizmo
  108756. */
  108757. export class AxisDragGizmo extends Gizmo {
  108758. /**
  108759. * Drag behavior responsible for the gizmos dragging interactions
  108760. */
  108761. dragBehavior: PointerDragBehavior;
  108762. private _pointerObserver;
  108763. /**
  108764. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108765. */
  108766. snapDistance: number;
  108767. /**
  108768. * Event that fires each time the gizmo snaps to a new location.
  108769. * * snapDistance is the the change in distance
  108770. */
  108771. onSnapObservable: Observable<{
  108772. snapDistance: number;
  108773. }>;
  108774. private _isEnabled;
  108775. private _parent;
  108776. private _arrow;
  108777. private _coloredMaterial;
  108778. private _hoverMaterial;
  108779. /** @hidden */
  108780. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108781. /** @hidden */
  108782. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108783. /**
  108784. * Creates an AxisDragGizmo
  108785. * @param gizmoLayer The utility layer the gizmo will be added to
  108786. * @param dragAxis The axis which the gizmo will be able to drag on
  108787. * @param color The color of the gizmo
  108788. */
  108789. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108790. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108791. /**
  108792. * If the gizmo is enabled
  108793. */
  108794. isEnabled: boolean;
  108795. /**
  108796. * Disposes of the gizmo
  108797. */
  108798. dispose(): void;
  108799. }
  108800. }
  108801. declare module BABYLON.Debug {
  108802. /**
  108803. * The Axes viewer will show 3 axes in a specific point in space
  108804. */
  108805. export class AxesViewer {
  108806. private _xAxis;
  108807. private _yAxis;
  108808. private _zAxis;
  108809. private _scaleLinesFactor;
  108810. private _instanced;
  108811. /**
  108812. * Gets the hosting scene
  108813. */
  108814. scene: Scene;
  108815. /**
  108816. * Gets or sets a number used to scale line length
  108817. */
  108818. scaleLines: number;
  108819. /** Gets the node hierarchy used to render x-axis */
  108820. readonly xAxis: TransformNode;
  108821. /** Gets the node hierarchy used to render y-axis */
  108822. readonly yAxis: TransformNode;
  108823. /** Gets the node hierarchy used to render z-axis */
  108824. readonly zAxis: TransformNode;
  108825. /**
  108826. * Creates a new AxesViewer
  108827. * @param scene defines the hosting scene
  108828. * @param scaleLines defines a number used to scale line length (1 by default)
  108829. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108830. * @param xAxis defines the node hierarchy used to render the x-axis
  108831. * @param yAxis defines the node hierarchy used to render the y-axis
  108832. * @param zAxis defines the node hierarchy used to render the z-axis
  108833. */
  108834. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108835. /**
  108836. * Force the viewer to update
  108837. * @param position defines the position of the viewer
  108838. * @param xaxis defines the x axis of the viewer
  108839. * @param yaxis defines the y axis of the viewer
  108840. * @param zaxis defines the z axis of the viewer
  108841. */
  108842. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108843. /**
  108844. * Creates an instance of this axes viewer.
  108845. * @returns a new axes viewer with instanced meshes
  108846. */
  108847. createInstance(): AxesViewer;
  108848. /** Releases resources */
  108849. dispose(): void;
  108850. private static _SetRenderingGroupId;
  108851. }
  108852. }
  108853. declare module BABYLON.Debug {
  108854. /**
  108855. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108856. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108857. */
  108858. export class BoneAxesViewer extends AxesViewer {
  108859. /**
  108860. * Gets or sets the target mesh where to display the axes viewer
  108861. */
  108862. mesh: Nullable<Mesh>;
  108863. /**
  108864. * Gets or sets the target bone where to display the axes viewer
  108865. */
  108866. bone: Nullable<Bone>;
  108867. /** Gets current position */
  108868. pos: Vector3;
  108869. /** Gets direction of X axis */
  108870. xaxis: Vector3;
  108871. /** Gets direction of Y axis */
  108872. yaxis: Vector3;
  108873. /** Gets direction of Z axis */
  108874. zaxis: Vector3;
  108875. /**
  108876. * Creates a new BoneAxesViewer
  108877. * @param scene defines the hosting scene
  108878. * @param bone defines the target bone
  108879. * @param mesh defines the target mesh
  108880. * @param scaleLines defines a scaling factor for line length (1 by default)
  108881. */
  108882. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108883. /**
  108884. * Force the viewer to update
  108885. */
  108886. update(): void;
  108887. /** Releases resources */
  108888. dispose(): void;
  108889. }
  108890. }
  108891. declare module BABYLON {
  108892. /**
  108893. * Interface used to define scene explorer extensibility option
  108894. */
  108895. export interface IExplorerExtensibilityOption {
  108896. /**
  108897. * Define the option label
  108898. */
  108899. label: string;
  108900. /**
  108901. * Defines the action to execute on click
  108902. */
  108903. action: (entity: any) => void;
  108904. }
  108905. /**
  108906. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108907. */
  108908. export interface IExplorerExtensibilityGroup {
  108909. /**
  108910. * Defines a predicate to test if a given type mut be extended
  108911. */
  108912. predicate: (entity: any) => boolean;
  108913. /**
  108914. * Gets the list of options added to a type
  108915. */
  108916. entries: IExplorerExtensibilityOption[];
  108917. }
  108918. /**
  108919. * Interface used to define the options to use to create the Inspector
  108920. */
  108921. export interface IInspectorOptions {
  108922. /**
  108923. * Display in overlay mode (default: false)
  108924. */
  108925. overlay?: boolean;
  108926. /**
  108927. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108928. */
  108929. globalRoot?: HTMLElement;
  108930. /**
  108931. * Display the Scene explorer
  108932. */
  108933. showExplorer?: boolean;
  108934. /**
  108935. * Display the property inspector
  108936. */
  108937. showInspector?: boolean;
  108938. /**
  108939. * Display in embed mode (both panes on the right)
  108940. */
  108941. embedMode?: boolean;
  108942. /**
  108943. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108944. */
  108945. handleResize?: boolean;
  108946. /**
  108947. * Allow the panes to popup (default: true)
  108948. */
  108949. enablePopup?: boolean;
  108950. /**
  108951. * Allow the panes to be closed by users (default: true)
  108952. */
  108953. enableClose?: boolean;
  108954. /**
  108955. * Optional list of extensibility entries
  108956. */
  108957. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108958. /**
  108959. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108960. */
  108961. inspectorURL?: string;
  108962. }
  108963. interface Scene {
  108964. /**
  108965. * @hidden
  108966. * Backing field
  108967. */
  108968. _debugLayer: DebugLayer;
  108969. /**
  108970. * Gets the debug layer (aka Inspector) associated with the scene
  108971. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108972. */
  108973. debugLayer: DebugLayer;
  108974. }
  108975. /**
  108976. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108977. * what is happening in your scene
  108978. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108979. */
  108980. export class DebugLayer {
  108981. /**
  108982. * Define the url to get the inspector script from.
  108983. * By default it uses the babylonjs CDN.
  108984. * @ignoreNaming
  108985. */
  108986. static InspectorURL: string;
  108987. private _scene;
  108988. private BJSINSPECTOR;
  108989. private _onPropertyChangedObservable?;
  108990. /**
  108991. * Observable triggered when a property is changed through the inspector.
  108992. */
  108993. readonly onPropertyChangedObservable: any;
  108994. /**
  108995. * Instantiates a new debug layer.
  108996. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108997. * what is happening in your scene
  108998. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108999. * @param scene Defines the scene to inspect
  109000. */
  109001. constructor(scene: Scene);
  109002. /** Creates the inspector window. */
  109003. private _createInspector;
  109004. /**
  109005. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109006. * @param entity defines the entity to select
  109007. * @param lineContainerTitle defines the specific block to highlight
  109008. */
  109009. select(entity: any, lineContainerTitle?: string): void;
  109010. /** Get the inspector from bundle or global */
  109011. private _getGlobalInspector;
  109012. /**
  109013. * Get if the inspector is visible or not.
  109014. * @returns true if visible otherwise, false
  109015. */
  109016. isVisible(): boolean;
  109017. /**
  109018. * Hide the inspector and close its window.
  109019. */
  109020. hide(): void;
  109021. /**
  109022. * Launch the debugLayer.
  109023. * @param config Define the configuration of the inspector
  109024. * @return a promise fulfilled when the debug layer is visible
  109025. */
  109026. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109027. }
  109028. }
  109029. declare module BABYLON {
  109030. /**
  109031. * Class containing static functions to help procedurally build meshes
  109032. */
  109033. export class BoxBuilder {
  109034. /**
  109035. * Creates a box mesh
  109036. * * The parameter `size` sets the size (float) of each box side (default 1)
  109037. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109038. * * 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)
  109039. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109043. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109044. * @param name defines the name of the mesh
  109045. * @param options defines the options used to create the mesh
  109046. * @param scene defines the hosting scene
  109047. * @returns the box mesh
  109048. */
  109049. static CreateBox(name: string, options: {
  109050. size?: number;
  109051. width?: number;
  109052. height?: number;
  109053. depth?: number;
  109054. faceUV?: Vector4[];
  109055. faceColors?: Color4[];
  109056. sideOrientation?: number;
  109057. frontUVs?: Vector4;
  109058. backUVs?: Vector4;
  109059. wrap?: boolean;
  109060. topBaseAt?: number;
  109061. bottomBaseAt?: number;
  109062. updatable?: boolean;
  109063. }, scene?: Nullable<Scene>): Mesh;
  109064. }
  109065. }
  109066. declare module BABYLON {
  109067. /**
  109068. * Class containing static functions to help procedurally build meshes
  109069. */
  109070. export class SphereBuilder {
  109071. /**
  109072. * Creates a sphere mesh
  109073. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109074. * * 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`)
  109075. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109076. * * 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
  109077. * * 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)
  109078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109081. * @param name defines the name of the mesh
  109082. * @param options defines the options used to create the mesh
  109083. * @param scene defines the hosting scene
  109084. * @returns the sphere mesh
  109085. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109086. */
  109087. static CreateSphere(name: string, options: {
  109088. segments?: number;
  109089. diameter?: number;
  109090. diameterX?: number;
  109091. diameterY?: number;
  109092. diameterZ?: number;
  109093. arc?: number;
  109094. slice?: number;
  109095. sideOrientation?: number;
  109096. frontUVs?: Vector4;
  109097. backUVs?: Vector4;
  109098. updatable?: boolean;
  109099. }, scene?: Nullable<Scene>): Mesh;
  109100. }
  109101. }
  109102. declare module BABYLON.Debug {
  109103. /**
  109104. * Used to show the physics impostor around the specific mesh
  109105. */
  109106. export class PhysicsViewer {
  109107. /** @hidden */
  109108. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109109. /** @hidden */
  109110. protected _meshes: Array<Nullable<AbstractMesh>>;
  109111. /** @hidden */
  109112. protected _scene: Nullable<Scene>;
  109113. /** @hidden */
  109114. protected _numMeshes: number;
  109115. /** @hidden */
  109116. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109117. private _renderFunction;
  109118. private _utilityLayer;
  109119. private _debugBoxMesh;
  109120. private _debugSphereMesh;
  109121. private _debugCylinderMesh;
  109122. private _debugMaterial;
  109123. private _debugMeshMeshes;
  109124. /**
  109125. * Creates a new PhysicsViewer
  109126. * @param scene defines the hosting scene
  109127. */
  109128. constructor(scene: Scene);
  109129. /** @hidden */
  109130. protected _updateDebugMeshes(): void;
  109131. /**
  109132. * Renders a specified physic impostor
  109133. * @param impostor defines the impostor to render
  109134. * @param targetMesh defines the mesh represented by the impostor
  109135. * @returns the new debug mesh used to render the impostor
  109136. */
  109137. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109138. /**
  109139. * Hides a specified physic impostor
  109140. * @param impostor defines the impostor to hide
  109141. */
  109142. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109143. private _getDebugMaterial;
  109144. private _getDebugBoxMesh;
  109145. private _getDebugSphereMesh;
  109146. private _getDebugCylinderMesh;
  109147. private _getDebugMeshMesh;
  109148. private _getDebugMesh;
  109149. /** Releases all resources */
  109150. dispose(): void;
  109151. }
  109152. }
  109153. declare module BABYLON {
  109154. /**
  109155. * Class containing static functions to help procedurally build meshes
  109156. */
  109157. export class LinesBuilder {
  109158. /**
  109159. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109160. * * 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
  109161. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109162. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109163. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109164. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109165. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109166. * * 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
  109167. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109170. * @param name defines the name of the new line system
  109171. * @param options defines the options used to create the line system
  109172. * @param scene defines the hosting scene
  109173. * @returns a new line system mesh
  109174. */
  109175. static CreateLineSystem(name: string, options: {
  109176. lines: Vector3[][];
  109177. updatable?: boolean;
  109178. instance?: Nullable<LinesMesh>;
  109179. colors?: Nullable<Color4[][]>;
  109180. useVertexAlpha?: boolean;
  109181. }, scene: Nullable<Scene>): LinesMesh;
  109182. /**
  109183. * Creates a line mesh
  109184. * 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
  109185. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109186. * * The parameter `points` is an array successive Vector3
  109187. * * 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
  109188. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109189. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109190. * * When updating an instance, remember that only point positions can change, not the number of points
  109191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109193. * @param name defines the name of the new line system
  109194. * @param options defines the options used to create the line system
  109195. * @param scene defines the hosting scene
  109196. * @returns a new line mesh
  109197. */
  109198. static CreateLines(name: string, options: {
  109199. points: Vector3[];
  109200. updatable?: boolean;
  109201. instance?: Nullable<LinesMesh>;
  109202. colors?: Color4[];
  109203. useVertexAlpha?: boolean;
  109204. }, scene?: Nullable<Scene>): LinesMesh;
  109205. /**
  109206. * Creates a dashed line mesh
  109207. * * 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
  109208. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109209. * * The parameter `points` is an array successive Vector3
  109210. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109211. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109212. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109213. * * 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
  109214. * * When updating an instance, remember that only point positions can change, not the number of points
  109215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109216. * @param name defines the name of the mesh
  109217. * @param options defines the options used to create the mesh
  109218. * @param scene defines the hosting scene
  109219. * @returns the dashed line mesh
  109220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109221. */
  109222. static CreateDashedLines(name: string, options: {
  109223. points: Vector3[];
  109224. dashSize?: number;
  109225. gapSize?: number;
  109226. dashNb?: number;
  109227. updatable?: boolean;
  109228. instance?: LinesMesh;
  109229. }, scene?: Nullable<Scene>): LinesMesh;
  109230. }
  109231. }
  109232. declare module BABYLON {
  109233. /**
  109234. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109235. * in order to better appreciate the issue one might have.
  109236. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109237. */
  109238. export class RayHelper {
  109239. /**
  109240. * Defines the ray we are currently tryin to visualize.
  109241. */
  109242. ray: Nullable<Ray>;
  109243. private _renderPoints;
  109244. private _renderLine;
  109245. private _renderFunction;
  109246. private _scene;
  109247. private _updateToMeshFunction;
  109248. private _attachedToMesh;
  109249. private _meshSpaceDirection;
  109250. private _meshSpaceOrigin;
  109251. /**
  109252. * Helper function to create a colored helper in a scene in one line.
  109253. * @param ray Defines the ray we are currently tryin to visualize
  109254. * @param scene Defines the scene the ray is used in
  109255. * @param color Defines the color we want to see the ray in
  109256. * @returns The newly created ray helper.
  109257. */
  109258. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109259. /**
  109260. * Instantiate a new ray helper.
  109261. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109262. * in order to better appreciate the issue one might have.
  109263. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109264. * @param ray Defines the ray we are currently tryin to visualize
  109265. */
  109266. constructor(ray: Ray);
  109267. /**
  109268. * Shows the ray we are willing to debug.
  109269. * @param scene Defines the scene the ray needs to be rendered in
  109270. * @param color Defines the color the ray needs to be rendered in
  109271. */
  109272. show(scene: Scene, color?: Color3): void;
  109273. /**
  109274. * Hides the ray we are debugging.
  109275. */
  109276. hide(): void;
  109277. private _render;
  109278. /**
  109279. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109280. * @param mesh Defines the mesh we want the helper attached to
  109281. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109282. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109283. * @param length Defines the length of the ray
  109284. */
  109285. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109286. /**
  109287. * Detach the ray helper from the mesh it has previously been attached to.
  109288. */
  109289. detachFromMesh(): void;
  109290. private _updateToMesh;
  109291. /**
  109292. * Dispose the helper and release its associated resources.
  109293. */
  109294. dispose(): void;
  109295. }
  109296. }
  109297. declare module BABYLON.Debug {
  109298. /**
  109299. * Class used to render a debug view of a given skeleton
  109300. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109301. */
  109302. export class SkeletonViewer {
  109303. /** defines the skeleton to render */
  109304. skeleton: Skeleton;
  109305. /** defines the mesh attached to the skeleton */
  109306. mesh: AbstractMesh;
  109307. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109308. autoUpdateBonesMatrices: boolean;
  109309. /** defines the rendering group id to use with the viewer */
  109310. renderingGroupId: number;
  109311. /** Gets or sets the color used to render the skeleton */
  109312. color: Color3;
  109313. private _scene;
  109314. private _debugLines;
  109315. private _debugMesh;
  109316. private _isEnabled;
  109317. private _renderFunction;
  109318. private _utilityLayer;
  109319. /**
  109320. * Returns the mesh used to render the bones
  109321. */
  109322. readonly debugMesh: Nullable<LinesMesh>;
  109323. /**
  109324. * Creates a new SkeletonViewer
  109325. * @param skeleton defines the skeleton to render
  109326. * @param mesh defines the mesh attached to the skeleton
  109327. * @param scene defines the hosting scene
  109328. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109329. * @param renderingGroupId defines the rendering group id to use with the viewer
  109330. */
  109331. constructor(
  109332. /** defines the skeleton to render */
  109333. skeleton: Skeleton,
  109334. /** defines the mesh attached to the skeleton */
  109335. mesh: AbstractMesh, scene: Scene,
  109336. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109337. autoUpdateBonesMatrices?: boolean,
  109338. /** defines the rendering group id to use with the viewer */
  109339. renderingGroupId?: number);
  109340. /** Gets or sets a boolean indicating if the viewer is enabled */
  109341. isEnabled: boolean;
  109342. private _getBonePosition;
  109343. private _getLinesForBonesWithLength;
  109344. private _getLinesForBonesNoLength;
  109345. /** Update the viewer to sync with current skeleton state */
  109346. update(): void;
  109347. /** Release associated resources */
  109348. dispose(): void;
  109349. }
  109350. }
  109351. declare module BABYLON {
  109352. /**
  109353. * Options to create the null engine
  109354. */
  109355. export class NullEngineOptions {
  109356. /**
  109357. * Render width (Default: 512)
  109358. */
  109359. renderWidth: number;
  109360. /**
  109361. * Render height (Default: 256)
  109362. */
  109363. renderHeight: number;
  109364. /**
  109365. * Texture size (Default: 512)
  109366. */
  109367. textureSize: number;
  109368. /**
  109369. * If delta time between frames should be constant
  109370. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109371. */
  109372. deterministicLockstep: boolean;
  109373. /**
  109374. * Maximum about of steps between frames (Default: 4)
  109375. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109376. */
  109377. lockstepMaxSteps: number;
  109378. }
  109379. /**
  109380. * The null engine class provides support for headless version of babylon.js.
  109381. * This can be used in server side scenario or for testing purposes
  109382. */
  109383. export class NullEngine extends Engine {
  109384. private _options;
  109385. /**
  109386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109387. */
  109388. isDeterministicLockStep(): boolean;
  109389. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109390. getLockstepMaxSteps(): number;
  109391. /**
  109392. * Sets hardware scaling, used to save performance if needed
  109393. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109394. */
  109395. getHardwareScalingLevel(): number;
  109396. constructor(options?: NullEngineOptions);
  109397. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109398. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109399. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109400. getRenderWidth(useScreen?: boolean): number;
  109401. getRenderHeight(useScreen?: boolean): number;
  109402. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109403. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109404. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109405. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109406. bindSamplers(effect: Effect): void;
  109407. enableEffect(effect: Effect): void;
  109408. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109409. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109410. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109411. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109412. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109413. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109414. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109415. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109416. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109417. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109418. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109419. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109420. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109421. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109422. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109423. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109424. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109425. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109426. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109427. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109428. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109429. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109430. bindBuffers(vertexBuffers: {
  109431. [key: string]: VertexBuffer;
  109432. }, indexBuffer: DataBuffer, effect: Effect): void;
  109433. wipeCaches(bruteForce?: boolean): void;
  109434. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109435. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109436. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109437. /** @hidden */
  109438. _createTexture(): WebGLTexture;
  109439. /** @hidden */
  109440. _releaseTexture(texture: InternalTexture): void;
  109441. 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;
  109442. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109443. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109444. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109445. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109446. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109447. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109448. areAllEffectsReady(): boolean;
  109449. /**
  109450. * @hidden
  109451. * Get the current error code of the webGL context
  109452. * @returns the error code
  109453. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109454. */
  109455. getError(): number;
  109456. /** @hidden */
  109457. _getUnpackAlignement(): number;
  109458. /** @hidden */
  109459. _unpackFlipY(value: boolean): void;
  109460. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109461. /**
  109462. * Updates a dynamic vertex buffer.
  109463. * @param vertexBuffer the vertex buffer to update
  109464. * @param data the data used to update the vertex buffer
  109465. * @param byteOffset the byte offset of the data (optional)
  109466. * @param byteLength the byte length of the data (optional)
  109467. */
  109468. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109469. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109470. /** @hidden */
  109471. _bindTexture(channel: number, texture: InternalTexture): void;
  109472. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109473. releaseEffects(): void;
  109474. displayLoadingUI(): void;
  109475. hideLoadingUI(): void;
  109476. /** @hidden */
  109477. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109478. /** @hidden */
  109479. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109480. /** @hidden */
  109481. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109482. /** @hidden */
  109483. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109484. }
  109485. }
  109486. declare module BABYLON {
  109487. /** @hidden */
  109488. export class _OcclusionDataStorage {
  109489. /** @hidden */
  109490. occlusionInternalRetryCounter: number;
  109491. /** @hidden */
  109492. isOcclusionQueryInProgress: boolean;
  109493. /** @hidden */
  109494. isOccluded: boolean;
  109495. /** @hidden */
  109496. occlusionRetryCount: number;
  109497. /** @hidden */
  109498. occlusionType: number;
  109499. /** @hidden */
  109500. occlusionQueryAlgorithmType: number;
  109501. }
  109502. interface Engine {
  109503. /**
  109504. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109505. * @return the new query
  109506. */
  109507. createQuery(): WebGLQuery;
  109508. /**
  109509. * Delete and release a webGL query
  109510. * @param query defines the query to delete
  109511. * @return the current engine
  109512. */
  109513. deleteQuery(query: WebGLQuery): Engine;
  109514. /**
  109515. * Check if a given query has resolved and got its value
  109516. * @param query defines the query to check
  109517. * @returns true if the query got its value
  109518. */
  109519. isQueryResultAvailable(query: WebGLQuery): boolean;
  109520. /**
  109521. * Gets the value of a given query
  109522. * @param query defines the query to check
  109523. * @returns the value of the query
  109524. */
  109525. getQueryResult(query: WebGLQuery): number;
  109526. /**
  109527. * Initiates an occlusion query
  109528. * @param algorithmType defines the algorithm to use
  109529. * @param query defines the query to use
  109530. * @returns the current engine
  109531. * @see http://doc.babylonjs.com/features/occlusionquery
  109532. */
  109533. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109534. /**
  109535. * Ends an occlusion query
  109536. * @see http://doc.babylonjs.com/features/occlusionquery
  109537. * @param algorithmType defines the algorithm to use
  109538. * @returns the current engine
  109539. */
  109540. endOcclusionQuery(algorithmType: number): Engine;
  109541. /**
  109542. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109543. * Please note that only one query can be issued at a time
  109544. * @returns a time token used to track the time span
  109545. */
  109546. startTimeQuery(): Nullable<_TimeToken>;
  109547. /**
  109548. * Ends a time query
  109549. * @param token defines the token used to measure the time span
  109550. * @returns the time spent (in ns)
  109551. */
  109552. endTimeQuery(token: _TimeToken): int;
  109553. /** @hidden */
  109554. _currentNonTimestampToken: Nullable<_TimeToken>;
  109555. /** @hidden */
  109556. _createTimeQuery(): WebGLQuery;
  109557. /** @hidden */
  109558. _deleteTimeQuery(query: WebGLQuery): void;
  109559. /** @hidden */
  109560. _getGlAlgorithmType(algorithmType: number): number;
  109561. /** @hidden */
  109562. _getTimeQueryResult(query: WebGLQuery): any;
  109563. /** @hidden */
  109564. _getTimeQueryAvailability(query: WebGLQuery): any;
  109565. }
  109566. interface AbstractMesh {
  109567. /**
  109568. * Backing filed
  109569. * @hidden
  109570. */
  109571. __occlusionDataStorage: _OcclusionDataStorage;
  109572. /**
  109573. * Access property
  109574. * @hidden
  109575. */
  109576. _occlusionDataStorage: _OcclusionDataStorage;
  109577. /**
  109578. * 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.
  109579. * The default value is -1 which means don't break the query and wait till the result
  109580. * @see http://doc.babylonjs.com/features/occlusionquery
  109581. */
  109582. occlusionRetryCount: number;
  109583. /**
  109584. * 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:
  109585. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109586. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109587. * * 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.
  109588. * @see http://doc.babylonjs.com/features/occlusionquery
  109589. */
  109590. occlusionType: number;
  109591. /**
  109592. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109593. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109594. * * 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.
  109595. * @see http://doc.babylonjs.com/features/occlusionquery
  109596. */
  109597. occlusionQueryAlgorithmType: number;
  109598. /**
  109599. * 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
  109600. * @see http://doc.babylonjs.com/features/occlusionquery
  109601. */
  109602. isOccluded: boolean;
  109603. /**
  109604. * Flag to check the progress status of the query
  109605. * @see http://doc.babylonjs.com/features/occlusionquery
  109606. */
  109607. isOcclusionQueryInProgress: boolean;
  109608. }
  109609. }
  109610. declare module BABYLON {
  109611. /** @hidden */
  109612. export var _forceTransformFeedbackToBundle: boolean;
  109613. interface Engine {
  109614. /**
  109615. * Creates a webGL transform feedback object
  109616. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109617. * @returns the webGL transform feedback object
  109618. */
  109619. createTransformFeedback(): WebGLTransformFeedback;
  109620. /**
  109621. * Delete a webGL transform feedback object
  109622. * @param value defines the webGL transform feedback object to delete
  109623. */
  109624. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109625. /**
  109626. * Bind a webGL transform feedback object to the webgl context
  109627. * @param value defines the webGL transform feedback object to bind
  109628. */
  109629. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109630. /**
  109631. * Begins a transform feedback operation
  109632. * @param usePoints defines if points or triangles must be used
  109633. */
  109634. beginTransformFeedback(usePoints: boolean): void;
  109635. /**
  109636. * Ends a transform feedback operation
  109637. */
  109638. endTransformFeedback(): void;
  109639. /**
  109640. * Specify the varyings to use with transform feedback
  109641. * @param program defines the associated webGL program
  109642. * @param value defines the list of strings representing the varying names
  109643. */
  109644. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109645. /**
  109646. * Bind a webGL buffer for a transform feedback operation
  109647. * @param value defines the webGL buffer to bind
  109648. */
  109649. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109650. }
  109651. }
  109652. declare module BABYLON {
  109653. /**
  109654. * Creation options of the multi render target texture.
  109655. */
  109656. export interface IMultiRenderTargetOptions {
  109657. /**
  109658. * Define if the texture needs to create mip maps after render.
  109659. */
  109660. generateMipMaps?: boolean;
  109661. /**
  109662. * Define the types of all the draw buffers we want to create
  109663. */
  109664. types?: number[];
  109665. /**
  109666. * Define the sampling modes of all the draw buffers we want to create
  109667. */
  109668. samplingModes?: number[];
  109669. /**
  109670. * Define if a depth buffer is required
  109671. */
  109672. generateDepthBuffer?: boolean;
  109673. /**
  109674. * Define if a stencil buffer is required
  109675. */
  109676. generateStencilBuffer?: boolean;
  109677. /**
  109678. * Define if a depth texture is required instead of a depth buffer
  109679. */
  109680. generateDepthTexture?: boolean;
  109681. /**
  109682. * Define the number of desired draw buffers
  109683. */
  109684. textureCount?: number;
  109685. /**
  109686. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109687. */
  109688. doNotChangeAspectRatio?: boolean;
  109689. /**
  109690. * Define the default type of the buffers we are creating
  109691. */
  109692. defaultType?: number;
  109693. }
  109694. /**
  109695. * A multi render target, like a render target provides the ability to render to a texture.
  109696. * Unlike the render target, it can render to several draw buffers in one draw.
  109697. * This is specially interesting in deferred rendering or for any effects requiring more than
  109698. * just one color from a single pass.
  109699. */
  109700. export class MultiRenderTarget extends RenderTargetTexture {
  109701. private _internalTextures;
  109702. private _textures;
  109703. private _multiRenderTargetOptions;
  109704. /**
  109705. * Get if draw buffers are currently supported by the used hardware and browser.
  109706. */
  109707. readonly isSupported: boolean;
  109708. /**
  109709. * Get the list of textures generated by the multi render target.
  109710. */
  109711. readonly textures: Texture[];
  109712. /**
  109713. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109714. */
  109715. readonly depthTexture: Texture;
  109716. /**
  109717. * Set the wrapping mode on U of all the textures we are rendering to.
  109718. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109719. */
  109720. wrapU: number;
  109721. /**
  109722. * Set the wrapping mode on V of all the textures we are rendering to.
  109723. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109724. */
  109725. wrapV: number;
  109726. /**
  109727. * Instantiate a new multi render target texture.
  109728. * A multi render target, like a render target provides the ability to render to a texture.
  109729. * Unlike the render target, it can render to several draw buffers in one draw.
  109730. * This is specially interesting in deferred rendering or for any effects requiring more than
  109731. * just one color from a single pass.
  109732. * @param name Define the name of the texture
  109733. * @param size Define the size of the buffers to render to
  109734. * @param count Define the number of target we are rendering into
  109735. * @param scene Define the scene the texture belongs to
  109736. * @param options Define the options used to create the multi render target
  109737. */
  109738. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109739. /** @hidden */
  109740. _rebuild(): void;
  109741. private _createInternalTextures;
  109742. private _createTextures;
  109743. /**
  109744. * Define the number of samples used if MSAA is enabled.
  109745. */
  109746. samples: number;
  109747. /**
  109748. * Resize all the textures in the multi render target.
  109749. * Be carrefull as it will recreate all the data in the new texture.
  109750. * @param size Define the new size
  109751. */
  109752. resize(size: any): void;
  109753. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109754. /**
  109755. * Dispose the render targets and their associated resources
  109756. */
  109757. dispose(): void;
  109758. /**
  109759. * Release all the underlying texture used as draw buffers.
  109760. */
  109761. releaseInternalTextures(): void;
  109762. }
  109763. }
  109764. declare module BABYLON {
  109765. interface Engine {
  109766. /**
  109767. * Unbind a list of render target textures from the webGL context
  109768. * This is used only when drawBuffer extension or webGL2 are active
  109769. * @param textures defines the render target textures to unbind
  109770. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109771. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109772. */
  109773. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109774. /**
  109775. * Create a multi render target texture
  109776. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109777. * @param size defines the size of the texture
  109778. * @param options defines the creation options
  109779. * @returns the cube texture as an InternalTexture
  109780. */
  109781. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109782. /**
  109783. * Update the sample count for a given multiple render target texture
  109784. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109785. * @param textures defines the textures to update
  109786. * @param samples defines the sample count to set
  109787. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109788. */
  109789. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109790. }
  109791. }
  109792. declare module BABYLON {
  109793. /** @hidden */
  109794. export var rgbdEncodePixelShader: {
  109795. name: string;
  109796. shader: string;
  109797. };
  109798. }
  109799. declare module BABYLON {
  109800. /** @hidden */
  109801. export var rgbdDecodePixelShader: {
  109802. name: string;
  109803. shader: string;
  109804. };
  109805. }
  109806. declare module BABYLON {
  109807. /**
  109808. * Raw texture data and descriptor sufficient for WebGL texture upload
  109809. */
  109810. export interface EnvironmentTextureInfo {
  109811. /**
  109812. * Version of the environment map
  109813. */
  109814. version: number;
  109815. /**
  109816. * Width of image
  109817. */
  109818. width: number;
  109819. /**
  109820. * Irradiance information stored in the file.
  109821. */
  109822. irradiance: any;
  109823. /**
  109824. * Specular information stored in the file.
  109825. */
  109826. specular: any;
  109827. }
  109828. /**
  109829. * Defines One Image in the file. It requires only the position in the file
  109830. * as well as the length.
  109831. */
  109832. interface BufferImageData {
  109833. /**
  109834. * Length of the image data.
  109835. */
  109836. length: number;
  109837. /**
  109838. * Position of the data from the null terminator delimiting the end of the JSON.
  109839. */
  109840. position: number;
  109841. }
  109842. /**
  109843. * Defines the specular data enclosed in the file.
  109844. * This corresponds to the version 1 of the data.
  109845. */
  109846. export interface EnvironmentTextureSpecularInfoV1 {
  109847. /**
  109848. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109849. */
  109850. specularDataPosition?: number;
  109851. /**
  109852. * This contains all the images data needed to reconstruct the cubemap.
  109853. */
  109854. mipmaps: Array<BufferImageData>;
  109855. /**
  109856. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109857. */
  109858. lodGenerationScale: number;
  109859. }
  109860. /**
  109861. * Sets of helpers addressing the serialization and deserialization of environment texture
  109862. * stored in a BabylonJS env file.
  109863. * Those files are usually stored as .env files.
  109864. */
  109865. export class EnvironmentTextureTools {
  109866. /**
  109867. * Magic number identifying the env file.
  109868. */
  109869. private static _MagicBytes;
  109870. /**
  109871. * Gets the environment info from an env file.
  109872. * @param data The array buffer containing the .env bytes.
  109873. * @returns the environment file info (the json header) if successfully parsed.
  109874. */
  109875. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109876. /**
  109877. * Creates an environment texture from a loaded cube texture.
  109878. * @param texture defines the cube texture to convert in env file
  109879. * @return a promise containing the environment data if succesfull.
  109880. */
  109881. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109882. /**
  109883. * Creates a JSON representation of the spherical data.
  109884. * @param texture defines the texture containing the polynomials
  109885. * @return the JSON representation of the spherical info
  109886. */
  109887. private static _CreateEnvTextureIrradiance;
  109888. /**
  109889. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109890. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109891. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109892. * @return the views described by info providing access to the underlying buffer
  109893. */
  109894. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109895. /**
  109896. * Uploads the texture info contained in the env file to the GPU.
  109897. * @param texture defines the internal texture to upload to
  109898. * @param arrayBuffer defines the buffer cotaining the data to load
  109899. * @param info defines the texture info retrieved through the GetEnvInfo method
  109900. * @returns a promise
  109901. */
  109902. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109903. /**
  109904. * Uploads the levels of image data to the GPU.
  109905. * @param texture defines the internal texture to upload to
  109906. * @param imageData defines the array buffer views of image data [mipmap][face]
  109907. * @returns a promise
  109908. */
  109909. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109910. /**
  109911. * Uploads spherical polynomials information to the texture.
  109912. * @param texture defines the texture we are trying to upload the information to
  109913. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109914. */
  109915. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109916. /** @hidden */
  109917. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109918. }
  109919. }
  109920. declare module BABYLON {
  109921. /**
  109922. * Contains position and normal vectors for a vertex
  109923. */
  109924. export class PositionNormalVertex {
  109925. /** the position of the vertex (defaut: 0,0,0) */
  109926. position: Vector3;
  109927. /** the normal of the vertex (defaut: 0,1,0) */
  109928. normal: Vector3;
  109929. /**
  109930. * Creates a PositionNormalVertex
  109931. * @param position the position of the vertex (defaut: 0,0,0)
  109932. * @param normal the normal of the vertex (defaut: 0,1,0)
  109933. */
  109934. constructor(
  109935. /** the position of the vertex (defaut: 0,0,0) */
  109936. position?: Vector3,
  109937. /** the normal of the vertex (defaut: 0,1,0) */
  109938. normal?: Vector3);
  109939. /**
  109940. * Clones the PositionNormalVertex
  109941. * @returns the cloned PositionNormalVertex
  109942. */
  109943. clone(): PositionNormalVertex;
  109944. }
  109945. /**
  109946. * Contains position, normal and uv vectors for a vertex
  109947. */
  109948. export class PositionNormalTextureVertex {
  109949. /** the position of the vertex (defaut: 0,0,0) */
  109950. position: Vector3;
  109951. /** the normal of the vertex (defaut: 0,1,0) */
  109952. normal: Vector3;
  109953. /** the uv of the vertex (default: 0,0) */
  109954. uv: Vector2;
  109955. /**
  109956. * Creates a PositionNormalTextureVertex
  109957. * @param position the position of the vertex (defaut: 0,0,0)
  109958. * @param normal the normal of the vertex (defaut: 0,1,0)
  109959. * @param uv the uv of the vertex (default: 0,0)
  109960. */
  109961. constructor(
  109962. /** the position of the vertex (defaut: 0,0,0) */
  109963. position?: Vector3,
  109964. /** the normal of the vertex (defaut: 0,1,0) */
  109965. normal?: Vector3,
  109966. /** the uv of the vertex (default: 0,0) */
  109967. uv?: Vector2);
  109968. /**
  109969. * Clones the PositionNormalTextureVertex
  109970. * @returns the cloned PositionNormalTextureVertex
  109971. */
  109972. clone(): PositionNormalTextureVertex;
  109973. }
  109974. }
  109975. declare module BABYLON {
  109976. /** @hidden */
  109977. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109978. private _genericAttributeLocation;
  109979. private _varyingLocationCount;
  109980. private _varyingLocationMap;
  109981. private _replacements;
  109982. private _textureCount;
  109983. private _uniforms;
  109984. lineProcessor(line: string): string;
  109985. attributeProcessor(attribute: string): string;
  109986. varyingProcessor(varying: string, isFragment: boolean): string;
  109987. uniformProcessor(uniform: string): string;
  109988. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109989. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109990. }
  109991. }
  109992. declare module BABYLON {
  109993. /**
  109994. * Container for accessors for natively-stored mesh data buffers.
  109995. */
  109996. class NativeDataBuffer extends DataBuffer {
  109997. /**
  109998. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109999. */
  110000. nativeIndexBuffer?: any;
  110001. /**
  110002. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  110003. */
  110004. nativeVertexBuffer?: any;
  110005. }
  110006. /** @hidden */
  110007. export class NativeEngine extends Engine {
  110008. private readonly _native;
  110009. getHardwareScalingLevel(): number;
  110010. constructor();
  110011. /**
  110012. * Can be used to override the current requestAnimationFrame requester.
  110013. * @hidden
  110014. */
  110015. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  110016. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110017. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  110018. createVertexBuffer(data: DataArray): NativeDataBuffer;
  110019. recordVertexArrayObject(vertexBuffers: {
  110020. [key: string]: VertexBuffer;
  110021. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  110022. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110023. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  110024. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110025. /**
  110026. * Draw a list of indexed primitives
  110027. * @param fillMode defines the primitive to use
  110028. * @param indexStart defines the starting index
  110029. * @param indexCount defines the number of index to draw
  110030. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110031. */
  110032. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110033. /**
  110034. * Draw a list of unindexed primitives
  110035. * @param fillMode defines the primitive to use
  110036. * @param verticesStart defines the index of first vertex to draw
  110037. * @param verticesCount defines the count of vertices to draw
  110038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110039. */
  110040. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110041. createPipelineContext(): IPipelineContext;
  110042. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  110043. /** @hidden */
  110044. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  110045. /** @hidden */
  110046. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  110047. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110048. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110049. protected _setProgram(program: WebGLProgram): void;
  110050. _releaseEffect(effect: Effect): void;
  110051. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110052. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  110053. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  110054. bindSamplers(effect: Effect): void;
  110055. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  110056. getRenderWidth(useScreen?: boolean): number;
  110057. getRenderHeight(useScreen?: boolean): number;
  110058. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  110059. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110060. /**
  110061. * Set the z offset to apply to current rendering
  110062. * @param value defines the offset to apply
  110063. */
  110064. setZOffset(value: number): void;
  110065. /**
  110066. * Gets the current value of the zOffset
  110067. * @returns the current zOffset state
  110068. */
  110069. getZOffset(): number;
  110070. /**
  110071. * Enable or disable depth buffering
  110072. * @param enable defines the state to set
  110073. */
  110074. setDepthBuffer(enable: boolean): void;
  110075. /**
  110076. * Gets a boolean indicating if depth writing is enabled
  110077. * @returns the current depth writing state
  110078. */
  110079. getDepthWrite(): boolean;
  110080. /**
  110081. * Enable or disable depth writing
  110082. * @param enable defines the state to set
  110083. */
  110084. setDepthWrite(enable: boolean): void;
  110085. /**
  110086. * Enable or disable color writing
  110087. * @param enable defines the state to set
  110088. */
  110089. setColorWrite(enable: boolean): void;
  110090. /**
  110091. * Gets a boolean indicating if color writing is enabled
  110092. * @returns the current color writing state
  110093. */
  110094. getColorWrite(): boolean;
  110095. /**
  110096. * Sets alpha constants used by some alpha blending modes
  110097. * @param r defines the red component
  110098. * @param g defines the green component
  110099. * @param b defines the blue component
  110100. * @param a defines the alpha component
  110101. */
  110102. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  110103. /**
  110104. * Sets the current alpha mode
  110105. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  110106. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110107. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110108. */
  110109. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110110. /**
  110111. * Gets the current alpha mode
  110112. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110113. * @returns the current alpha mode
  110114. */
  110115. getAlphaMode(): number;
  110116. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110117. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110118. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110119. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110120. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110121. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110122. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110123. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110124. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110125. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110126. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110127. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110128. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110129. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110130. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110131. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110132. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110133. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110134. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110135. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110136. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  110137. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  110138. wipeCaches(bruteForce?: boolean): void;
  110139. _createTexture(): WebGLTexture;
  110140. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  110141. /**
  110142. * Usually called from BABYLON.Texture.ts.
  110143. * Passed information to create a WebGLTexture
  110144. * @param urlArg defines a value which contains one of the following:
  110145. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110146. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110147. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110148. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110149. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110150. * @param scene needed for loading to the correct scene
  110151. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110152. * @param onLoad optional callback to be called upon successful completion
  110153. * @param onError optional callback to be called upon failure
  110154. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110155. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110156. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110157. * @param forcedExtension defines the extension to use to pick the right loader
  110158. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110159. */
  110160. 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;
  110161. /**
  110162. * Creates a cube texture
  110163. * @param rootUrl defines the url where the files to load is located
  110164. * @param scene defines the current scene
  110165. * @param files defines the list of files to load (1 per face)
  110166. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110167. * @param onLoad defines an optional callback raised when the texture is loaded
  110168. * @param onError defines an optional callback raised if there is an issue to load the texture
  110169. * @param format defines the format of the data
  110170. * @param forcedExtension defines the extension to use to pick the right loader
  110171. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110172. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110173. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110174. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110175. * @returns the cube texture as an InternalTexture
  110176. */
  110177. 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;
  110178. private _getSamplingFilter;
  110179. private static _GetNativeTextureFormat;
  110180. createRenderTargetTexture(size: number | {
  110181. width: number;
  110182. height: number;
  110183. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110184. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110185. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110186. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110187. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110188. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110189. /**
  110190. * Updates a dynamic vertex buffer.
  110191. * @param vertexBuffer the vertex buffer to update
  110192. * @param data the data used to update the vertex buffer
  110193. * @param byteOffset the byte offset of the data (optional)
  110194. * @param byteLength the byte length of the data (optional)
  110195. */
  110196. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110197. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110198. private _updateAnisotropicLevel;
  110199. private _getAddressMode;
  110200. /** @hidden */
  110201. _bindTexture(channel: number, texture: InternalTexture): void;
  110202. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110203. releaseEffects(): void;
  110204. /** @hidden */
  110205. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110206. /** @hidden */
  110207. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110208. /** @hidden */
  110209. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110210. /** @hidden */
  110211. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110212. }
  110213. }
  110214. declare module BABYLON {
  110215. /**
  110216. * Gather the list of clipboard event types as constants.
  110217. */
  110218. export class ClipboardEventTypes {
  110219. /**
  110220. * The clipboard event is fired when a copy command is active (pressed).
  110221. */
  110222. static readonly COPY: number;
  110223. /**
  110224. * The clipboard event is fired when a cut command is active (pressed).
  110225. */
  110226. static readonly CUT: number;
  110227. /**
  110228. * The clipboard event is fired when a paste command is active (pressed).
  110229. */
  110230. static readonly PASTE: number;
  110231. }
  110232. /**
  110233. * This class is used to store clipboard related info for the onClipboardObservable event.
  110234. */
  110235. export class ClipboardInfo {
  110236. /**
  110237. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110238. */
  110239. type: number;
  110240. /**
  110241. * Defines the related dom event
  110242. */
  110243. event: ClipboardEvent;
  110244. /**
  110245. *Creates an instance of ClipboardInfo.
  110246. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110247. * @param event Defines the related dom event
  110248. */
  110249. constructor(
  110250. /**
  110251. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110252. */
  110253. type: number,
  110254. /**
  110255. * Defines the related dom event
  110256. */
  110257. event: ClipboardEvent);
  110258. /**
  110259. * Get the clipboard event's type from the keycode.
  110260. * @param keyCode Defines the keyCode for the current keyboard event.
  110261. * @return {number}
  110262. */
  110263. static GetTypeFromCharacter(keyCode: number): number;
  110264. }
  110265. }
  110266. declare module BABYLON {
  110267. /**
  110268. * Google Daydream controller
  110269. */
  110270. export class DaydreamController extends WebVRController {
  110271. /**
  110272. * Base Url for the controller model.
  110273. */
  110274. static MODEL_BASE_URL: string;
  110275. /**
  110276. * File name for the controller model.
  110277. */
  110278. static MODEL_FILENAME: string;
  110279. /**
  110280. * Gamepad Id prefix used to identify Daydream Controller.
  110281. */
  110282. static readonly GAMEPAD_ID_PREFIX: string;
  110283. /**
  110284. * Creates a new DaydreamController from a gamepad
  110285. * @param vrGamepad the gamepad that the controller should be created from
  110286. */
  110287. constructor(vrGamepad: any);
  110288. /**
  110289. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110290. * @param scene scene in which to add meshes
  110291. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110292. */
  110293. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110294. /**
  110295. * Called once for each button that changed state since the last frame
  110296. * @param buttonIdx Which button index changed
  110297. * @param state New state of the button
  110298. * @param changes Which properties on the state changed since last frame
  110299. */
  110300. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110301. }
  110302. }
  110303. declare module BABYLON {
  110304. /**
  110305. * Gear VR Controller
  110306. */
  110307. export class GearVRController extends WebVRController {
  110308. /**
  110309. * Base Url for the controller model.
  110310. */
  110311. static MODEL_BASE_URL: string;
  110312. /**
  110313. * File name for the controller model.
  110314. */
  110315. static MODEL_FILENAME: string;
  110316. /**
  110317. * Gamepad Id prefix used to identify this controller.
  110318. */
  110319. static readonly GAMEPAD_ID_PREFIX: string;
  110320. private readonly _buttonIndexToObservableNameMap;
  110321. /**
  110322. * Creates a new GearVRController from a gamepad
  110323. * @param vrGamepad the gamepad that the controller should be created from
  110324. */
  110325. constructor(vrGamepad: any);
  110326. /**
  110327. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110328. * @param scene scene in which to add meshes
  110329. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110330. */
  110331. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110332. /**
  110333. * Called once for each button that changed state since the last frame
  110334. * @param buttonIdx Which button index changed
  110335. * @param state New state of the button
  110336. * @param changes Which properties on the state changed since last frame
  110337. */
  110338. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110339. }
  110340. }
  110341. declare module BABYLON {
  110342. /**
  110343. * Class containing static functions to help procedurally build meshes
  110344. */
  110345. export class PolyhedronBuilder {
  110346. /**
  110347. * Creates a polyhedron mesh
  110348. * * 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
  110349. * * The parameter `size` (positive float, default 1) sets the polygon size
  110350. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110351. * * 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`
  110352. * * 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
  110353. * * 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)`)
  110354. * * 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
  110355. * * 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
  110356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110359. * @param name defines the name of the mesh
  110360. * @param options defines the options used to create the mesh
  110361. * @param scene defines the hosting scene
  110362. * @returns the polyhedron mesh
  110363. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110364. */
  110365. static CreatePolyhedron(name: string, options: {
  110366. type?: number;
  110367. size?: number;
  110368. sizeX?: number;
  110369. sizeY?: number;
  110370. sizeZ?: number;
  110371. custom?: any;
  110372. faceUV?: Vector4[];
  110373. faceColors?: Color4[];
  110374. flat?: boolean;
  110375. updatable?: boolean;
  110376. sideOrientation?: number;
  110377. frontUVs?: Vector4;
  110378. backUVs?: Vector4;
  110379. }, scene?: Nullable<Scene>): Mesh;
  110380. }
  110381. }
  110382. declare module BABYLON {
  110383. /**
  110384. * Gizmo that enables scaling a mesh along 3 axis
  110385. */
  110386. export class ScaleGizmo extends Gizmo {
  110387. /**
  110388. * Internal gizmo used for interactions on the x axis
  110389. */
  110390. xGizmo: AxisScaleGizmo;
  110391. /**
  110392. * Internal gizmo used for interactions on the y axis
  110393. */
  110394. yGizmo: AxisScaleGizmo;
  110395. /**
  110396. * Internal gizmo used for interactions on the z axis
  110397. */
  110398. zGizmo: AxisScaleGizmo;
  110399. /**
  110400. * Internal gizmo used to scale all axis equally
  110401. */
  110402. uniformScaleGizmo: AxisScaleGizmo;
  110403. private _meshAttached;
  110404. private _updateGizmoRotationToMatchAttachedMesh;
  110405. private _snapDistance;
  110406. private _scaleRatio;
  110407. private _uniformScalingMesh;
  110408. private _octahedron;
  110409. /** Fires an event when any of it's sub gizmos are dragged */
  110410. onDragStartObservable: Observable<unknown>;
  110411. /** Fires an event when any of it's sub gizmos are released from dragging */
  110412. onDragEndObservable: Observable<unknown>;
  110413. attachedMesh: Nullable<AbstractMesh>;
  110414. /**
  110415. * Creates a ScaleGizmo
  110416. * @param gizmoLayer The utility layer the gizmo will be added to
  110417. */
  110418. constructor(gizmoLayer?: UtilityLayerRenderer);
  110419. updateGizmoRotationToMatchAttachedMesh: boolean;
  110420. /**
  110421. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110422. */
  110423. snapDistance: number;
  110424. /**
  110425. * Ratio for the scale of the gizmo (Default: 1)
  110426. */
  110427. scaleRatio: number;
  110428. /**
  110429. * Disposes of the gizmo
  110430. */
  110431. dispose(): void;
  110432. }
  110433. }
  110434. declare module BABYLON {
  110435. /**
  110436. * Single axis scale gizmo
  110437. */
  110438. export class AxisScaleGizmo extends Gizmo {
  110439. /**
  110440. * Drag behavior responsible for the gizmos dragging interactions
  110441. */
  110442. dragBehavior: PointerDragBehavior;
  110443. private _pointerObserver;
  110444. /**
  110445. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110446. */
  110447. snapDistance: number;
  110448. /**
  110449. * Event that fires each time the gizmo snaps to a new location.
  110450. * * snapDistance is the the change in distance
  110451. */
  110452. onSnapObservable: Observable<{
  110453. snapDistance: number;
  110454. }>;
  110455. /**
  110456. * If the scaling operation should be done on all axis (default: false)
  110457. */
  110458. uniformScaling: boolean;
  110459. private _isEnabled;
  110460. private _parent;
  110461. private _arrow;
  110462. private _coloredMaterial;
  110463. private _hoverMaterial;
  110464. /**
  110465. * Creates an AxisScaleGizmo
  110466. * @param gizmoLayer The utility layer the gizmo will be added to
  110467. * @param dragAxis The axis which the gizmo will be able to scale on
  110468. * @param color The color of the gizmo
  110469. */
  110470. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110471. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110472. /**
  110473. * If the gizmo is enabled
  110474. */
  110475. isEnabled: boolean;
  110476. /**
  110477. * Disposes of the gizmo
  110478. */
  110479. dispose(): void;
  110480. /**
  110481. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110482. * @param mesh The mesh to replace the default mesh of the gizmo
  110483. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110484. */
  110485. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110486. }
  110487. }
  110488. declare module BABYLON {
  110489. /**
  110490. * Bounding box gizmo
  110491. */
  110492. export class BoundingBoxGizmo extends Gizmo {
  110493. private _lineBoundingBox;
  110494. private _rotateSpheresParent;
  110495. private _scaleBoxesParent;
  110496. private _boundingDimensions;
  110497. private _renderObserver;
  110498. private _pointerObserver;
  110499. private _scaleDragSpeed;
  110500. private _tmpQuaternion;
  110501. private _tmpVector;
  110502. private _tmpRotationMatrix;
  110503. /**
  110504. * 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)
  110505. */
  110506. ignoreChildren: boolean;
  110507. /**
  110508. * 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)
  110509. */
  110510. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110511. /**
  110512. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110513. */
  110514. rotationSphereSize: number;
  110515. /**
  110516. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110517. */
  110518. scaleBoxSize: number;
  110519. /**
  110520. * 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)
  110521. */
  110522. fixedDragMeshScreenSize: boolean;
  110523. /**
  110524. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110525. */
  110526. fixedDragMeshScreenSizeDistanceFactor: number;
  110527. /**
  110528. * Fired when a rotation sphere or scale box is dragged
  110529. */
  110530. onDragStartObservable: Observable<{}>;
  110531. /**
  110532. * Fired when a scale box is dragged
  110533. */
  110534. onScaleBoxDragObservable: Observable<{}>;
  110535. /**
  110536. * Fired when a scale box drag is ended
  110537. */
  110538. onScaleBoxDragEndObservable: Observable<{}>;
  110539. /**
  110540. * Fired when a rotation sphere is dragged
  110541. */
  110542. onRotationSphereDragObservable: Observable<{}>;
  110543. /**
  110544. * Fired when a rotation sphere drag is ended
  110545. */
  110546. onRotationSphereDragEndObservable: Observable<{}>;
  110547. /**
  110548. * 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)
  110549. */
  110550. scalePivot: Nullable<Vector3>;
  110551. /**
  110552. * Mesh used as a pivot to rotate the attached mesh
  110553. */
  110554. private _anchorMesh;
  110555. private _existingMeshScale;
  110556. private _dragMesh;
  110557. private pointerDragBehavior;
  110558. private coloredMaterial;
  110559. private hoverColoredMaterial;
  110560. /**
  110561. * Sets the color of the bounding box gizmo
  110562. * @param color the color to set
  110563. */
  110564. setColor(color: Color3): void;
  110565. /**
  110566. * Creates an BoundingBoxGizmo
  110567. * @param gizmoLayer The utility layer the gizmo will be added to
  110568. * @param color The color of the gizmo
  110569. */
  110570. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110571. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110572. private _selectNode;
  110573. /**
  110574. * Updates the bounding box information for the Gizmo
  110575. */
  110576. updateBoundingBox(): void;
  110577. private _updateRotationSpheres;
  110578. private _updateScaleBoxes;
  110579. /**
  110580. * Enables rotation on the specified axis and disables rotation on the others
  110581. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110582. */
  110583. setEnabledRotationAxis(axis: string): void;
  110584. /**
  110585. * Enables/disables scaling
  110586. * @param enable if scaling should be enabled
  110587. */
  110588. setEnabledScaling(enable: boolean): void;
  110589. private _updateDummy;
  110590. /**
  110591. * Enables a pointer drag behavior on the bounding box of the gizmo
  110592. */
  110593. enableDragBehavior(): void;
  110594. /**
  110595. * Disposes of the gizmo
  110596. */
  110597. dispose(): void;
  110598. /**
  110599. * 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)
  110600. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110601. * @returns the bounding box mesh with the passed in mesh as a child
  110602. */
  110603. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110604. /**
  110605. * CustomMeshes are not supported by this gizmo
  110606. * @param mesh The mesh to replace the default mesh of the gizmo
  110607. */
  110608. setCustomMesh(mesh: Mesh): void;
  110609. }
  110610. }
  110611. declare module BABYLON {
  110612. /**
  110613. * Single plane rotation gizmo
  110614. */
  110615. export class PlaneRotationGizmo extends Gizmo {
  110616. /**
  110617. * Drag behavior responsible for the gizmos dragging interactions
  110618. */
  110619. dragBehavior: PointerDragBehavior;
  110620. private _pointerObserver;
  110621. /**
  110622. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110623. */
  110624. snapDistance: number;
  110625. /**
  110626. * Event that fires each time the gizmo snaps to a new location.
  110627. * * snapDistance is the the change in distance
  110628. */
  110629. onSnapObservable: Observable<{
  110630. snapDistance: number;
  110631. }>;
  110632. private _isEnabled;
  110633. private _parent;
  110634. /**
  110635. * Creates a PlaneRotationGizmo
  110636. * @param gizmoLayer The utility layer the gizmo will be added to
  110637. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110638. * @param color The color of the gizmo
  110639. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110640. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110641. */
  110642. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110643. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110644. /**
  110645. * If the gizmo is enabled
  110646. */
  110647. isEnabled: boolean;
  110648. /**
  110649. * Disposes of the gizmo
  110650. */
  110651. dispose(): void;
  110652. }
  110653. }
  110654. declare module BABYLON {
  110655. /**
  110656. * Gizmo that enables rotating a mesh along 3 axis
  110657. */
  110658. export class RotationGizmo extends Gizmo {
  110659. /**
  110660. * Internal gizmo used for interactions on the x axis
  110661. */
  110662. xGizmo: PlaneRotationGizmo;
  110663. /**
  110664. * Internal gizmo used for interactions on the y axis
  110665. */
  110666. yGizmo: PlaneRotationGizmo;
  110667. /**
  110668. * Internal gizmo used for interactions on the z axis
  110669. */
  110670. zGizmo: PlaneRotationGizmo;
  110671. /** Fires an event when any of it's sub gizmos are dragged */
  110672. onDragStartObservable: Observable<unknown>;
  110673. /** Fires an event when any of it's sub gizmos are released from dragging */
  110674. onDragEndObservable: Observable<unknown>;
  110675. private _meshAttached;
  110676. attachedMesh: Nullable<AbstractMesh>;
  110677. /**
  110678. * Creates a RotationGizmo
  110679. * @param gizmoLayer The utility layer the gizmo will be added to
  110680. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110681. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110682. */
  110683. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110684. updateGizmoRotationToMatchAttachedMesh: boolean;
  110685. /**
  110686. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110687. */
  110688. snapDistance: number;
  110689. /**
  110690. * Ratio for the scale of the gizmo (Default: 1)
  110691. */
  110692. scaleRatio: number;
  110693. /**
  110694. * Disposes of the gizmo
  110695. */
  110696. dispose(): void;
  110697. /**
  110698. * CustomMeshes are not supported by this gizmo
  110699. * @param mesh The mesh to replace the default mesh of the gizmo
  110700. */
  110701. setCustomMesh(mesh: Mesh): void;
  110702. }
  110703. }
  110704. declare module BABYLON {
  110705. /**
  110706. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110707. */
  110708. export class GizmoManager implements IDisposable {
  110709. private scene;
  110710. /**
  110711. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110712. */
  110713. gizmos: {
  110714. positionGizmo: Nullable<PositionGizmo>;
  110715. rotationGizmo: Nullable<RotationGizmo>;
  110716. scaleGizmo: Nullable<ScaleGizmo>;
  110717. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110718. };
  110719. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110720. clearGizmoOnEmptyPointerEvent: boolean;
  110721. /** Fires an event when the manager is attached to a mesh */
  110722. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110723. private _gizmosEnabled;
  110724. private _pointerObserver;
  110725. private _attachedMesh;
  110726. private _boundingBoxColor;
  110727. private _defaultUtilityLayer;
  110728. private _defaultKeepDepthUtilityLayer;
  110729. /**
  110730. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110731. */
  110732. boundingBoxDragBehavior: SixDofDragBehavior;
  110733. /**
  110734. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110735. */
  110736. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110737. /**
  110738. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110739. */
  110740. usePointerToAttachGizmos: boolean;
  110741. /**
  110742. * Utility layer that the bounding box gizmo belongs to
  110743. */
  110744. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110745. /**
  110746. * Utility layer that all gizmos besides bounding box belong to
  110747. */
  110748. readonly utilityLayer: UtilityLayerRenderer;
  110749. /**
  110750. * Instatiates a gizmo manager
  110751. * @param scene the scene to overlay the gizmos on top of
  110752. */
  110753. constructor(scene: Scene);
  110754. /**
  110755. * Attaches a set of gizmos to the specified mesh
  110756. * @param mesh The mesh the gizmo's should be attached to
  110757. */
  110758. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110759. /**
  110760. * If the position gizmo is enabled
  110761. */
  110762. positionGizmoEnabled: boolean;
  110763. /**
  110764. * If the rotation gizmo is enabled
  110765. */
  110766. rotationGizmoEnabled: boolean;
  110767. /**
  110768. * If the scale gizmo is enabled
  110769. */
  110770. scaleGizmoEnabled: boolean;
  110771. /**
  110772. * If the boundingBox gizmo is enabled
  110773. */
  110774. boundingBoxGizmoEnabled: boolean;
  110775. /**
  110776. * Disposes of the gizmo manager
  110777. */
  110778. dispose(): void;
  110779. }
  110780. }
  110781. declare module BABYLON {
  110782. /**
  110783. * A directional light is defined by a direction (what a surprise!).
  110784. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110785. * 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.
  110786. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110787. */
  110788. export class DirectionalLight extends ShadowLight {
  110789. private _shadowFrustumSize;
  110790. /**
  110791. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110792. */
  110793. /**
  110794. * Specifies a fix frustum size for the shadow generation.
  110795. */
  110796. shadowFrustumSize: number;
  110797. private _shadowOrthoScale;
  110798. /**
  110799. * Gets the shadow projection scale against the optimal computed one.
  110800. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110801. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110802. */
  110803. /**
  110804. * Sets the shadow projection scale against the optimal computed one.
  110805. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110806. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110807. */
  110808. shadowOrthoScale: number;
  110809. /**
  110810. * Automatically compute the projection matrix to best fit (including all the casters)
  110811. * on each frame.
  110812. */
  110813. autoUpdateExtends: boolean;
  110814. private _orthoLeft;
  110815. private _orthoRight;
  110816. private _orthoTop;
  110817. private _orthoBottom;
  110818. /**
  110819. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110820. * The directional light is emitted from everywhere in the given direction.
  110821. * It can cast shadows.
  110822. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110823. * @param name The friendly name of the light
  110824. * @param direction The direction of the light
  110825. * @param scene The scene the light belongs to
  110826. */
  110827. constructor(name: string, direction: Vector3, scene: Scene);
  110828. /**
  110829. * Returns the string "DirectionalLight".
  110830. * @return The class name
  110831. */
  110832. getClassName(): string;
  110833. /**
  110834. * Returns the integer 1.
  110835. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110836. */
  110837. getTypeID(): number;
  110838. /**
  110839. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110840. * Returns the DirectionalLight Shadow projection matrix.
  110841. */
  110842. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110843. /**
  110844. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110845. * Returns the DirectionalLight Shadow projection matrix.
  110846. */
  110847. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110848. /**
  110849. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110850. * Returns the DirectionalLight Shadow projection matrix.
  110851. */
  110852. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110853. protected _buildUniformLayout(): void;
  110854. /**
  110855. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110856. * @param effect The effect to update
  110857. * @param lightIndex The index of the light in the effect to update
  110858. * @returns The directional light
  110859. */
  110860. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110861. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110862. /**
  110863. * Gets the minZ used for shadow according to both the scene and the light.
  110864. *
  110865. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110866. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110867. * @param activeCamera The camera we are returning the min for
  110868. * @returns the depth min z
  110869. */
  110870. getDepthMinZ(activeCamera: Camera): number;
  110871. /**
  110872. * Gets the maxZ used for shadow according to both the scene and the light.
  110873. *
  110874. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110875. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110876. * @param activeCamera The camera we are returning the max for
  110877. * @returns the depth max z
  110878. */
  110879. getDepthMaxZ(activeCamera: Camera): number;
  110880. /**
  110881. * Prepares the list of defines specific to the light type.
  110882. * @param defines the list of defines
  110883. * @param lightIndex defines the index of the light for the effect
  110884. */
  110885. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110886. }
  110887. }
  110888. declare module BABYLON {
  110889. /**
  110890. * Class containing static functions to help procedurally build meshes
  110891. */
  110892. export class HemisphereBuilder {
  110893. /**
  110894. * Creates a hemisphere mesh
  110895. * @param name defines the name of the mesh
  110896. * @param options defines the options used to create the mesh
  110897. * @param scene defines the hosting scene
  110898. * @returns the hemisphere mesh
  110899. */
  110900. static CreateHemisphere(name: string, options: {
  110901. segments?: number;
  110902. diameter?: number;
  110903. sideOrientation?: number;
  110904. }, scene: any): Mesh;
  110905. }
  110906. }
  110907. declare module BABYLON {
  110908. /**
  110909. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110910. * These values define a cone of light starting from the position, emitting toward the direction.
  110911. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110912. * and the exponent defines the speed of the decay of the light with distance (reach).
  110913. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110914. */
  110915. export class SpotLight extends ShadowLight {
  110916. private _angle;
  110917. private _innerAngle;
  110918. private _cosHalfAngle;
  110919. private _lightAngleScale;
  110920. private _lightAngleOffset;
  110921. /**
  110922. * Gets the cone angle of the spot light in Radians.
  110923. */
  110924. /**
  110925. * Sets the cone angle of the spot light in Radians.
  110926. */
  110927. angle: number;
  110928. /**
  110929. * Only used in gltf falloff mode, this defines the angle where
  110930. * the directional falloff will start before cutting at angle which could be seen
  110931. * as outer angle.
  110932. */
  110933. /**
  110934. * Only used in gltf falloff mode, this defines the angle where
  110935. * the directional falloff will start before cutting at angle which could be seen
  110936. * as outer angle.
  110937. */
  110938. innerAngle: number;
  110939. private _shadowAngleScale;
  110940. /**
  110941. * Allows scaling the angle of the light for shadow generation only.
  110942. */
  110943. /**
  110944. * Allows scaling the angle of the light for shadow generation only.
  110945. */
  110946. shadowAngleScale: number;
  110947. /**
  110948. * The light decay speed with the distance from the emission spot.
  110949. */
  110950. exponent: number;
  110951. private _projectionTextureMatrix;
  110952. /**
  110953. * Allows reading the projecton texture
  110954. */
  110955. readonly projectionTextureMatrix: Matrix;
  110956. protected _projectionTextureLightNear: number;
  110957. /**
  110958. * Gets the near clip of the Spotlight for texture projection.
  110959. */
  110960. /**
  110961. * Sets the near clip of the Spotlight for texture projection.
  110962. */
  110963. projectionTextureLightNear: number;
  110964. protected _projectionTextureLightFar: number;
  110965. /**
  110966. * Gets the far clip of the Spotlight for texture projection.
  110967. */
  110968. /**
  110969. * Sets the far clip of the Spotlight for texture projection.
  110970. */
  110971. projectionTextureLightFar: number;
  110972. protected _projectionTextureUpDirection: Vector3;
  110973. /**
  110974. * Gets the Up vector of the Spotlight for texture projection.
  110975. */
  110976. /**
  110977. * Sets the Up vector of the Spotlight for texture projection.
  110978. */
  110979. projectionTextureUpDirection: Vector3;
  110980. private _projectionTexture;
  110981. /**
  110982. * Gets the projection texture of the light.
  110983. */
  110984. /**
  110985. * Sets the projection texture of the light.
  110986. */
  110987. projectionTexture: Nullable<BaseTexture>;
  110988. private _projectionTextureViewLightDirty;
  110989. private _projectionTextureProjectionLightDirty;
  110990. private _projectionTextureDirty;
  110991. private _projectionTextureViewTargetVector;
  110992. private _projectionTextureViewLightMatrix;
  110993. private _projectionTextureProjectionLightMatrix;
  110994. private _projectionTextureScalingMatrix;
  110995. /**
  110996. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110997. * It can cast shadows.
  110998. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110999. * @param name The light friendly name
  111000. * @param position The position of the spot light in the scene
  111001. * @param direction The direction of the light in the scene
  111002. * @param angle The cone angle of the light in Radians
  111003. * @param exponent The light decay speed with the distance from the emission spot
  111004. * @param scene The scene the lights belongs to
  111005. */
  111006. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  111007. /**
  111008. * Returns the string "SpotLight".
  111009. * @returns the class name
  111010. */
  111011. getClassName(): string;
  111012. /**
  111013. * Returns the integer 2.
  111014. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111015. */
  111016. getTypeID(): number;
  111017. /**
  111018. * Overrides the direction setter to recompute the projection texture view light Matrix.
  111019. */
  111020. protected _setDirection(value: Vector3): void;
  111021. /**
  111022. * Overrides the position setter to recompute the projection texture view light Matrix.
  111023. */
  111024. protected _setPosition(value: Vector3): void;
  111025. /**
  111026. * 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.
  111027. * Returns the SpotLight.
  111028. */
  111029. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111030. protected _computeProjectionTextureViewLightMatrix(): void;
  111031. protected _computeProjectionTextureProjectionLightMatrix(): void;
  111032. /**
  111033. * Main function for light texture projection matrix computing.
  111034. */
  111035. protected _computeProjectionTextureMatrix(): void;
  111036. protected _buildUniformLayout(): void;
  111037. private _computeAngleValues;
  111038. /**
  111039. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  111040. * @param effect The effect to update
  111041. * @param lightIndex The index of the light in the effect to update
  111042. * @returns The spot light
  111043. */
  111044. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  111045. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111046. /**
  111047. * Disposes the light and the associated resources.
  111048. */
  111049. dispose(): void;
  111050. /**
  111051. * Prepares the list of defines specific to the light type.
  111052. * @param defines the list of defines
  111053. * @param lightIndex defines the index of the light for the effect
  111054. */
  111055. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111056. }
  111057. }
  111058. declare module BABYLON {
  111059. /**
  111060. * Gizmo that enables viewing a light
  111061. */
  111062. export class LightGizmo extends Gizmo {
  111063. private _lightMesh;
  111064. private _material;
  111065. private cachedPosition;
  111066. private cachedForward;
  111067. /**
  111068. * Creates a LightGizmo
  111069. * @param gizmoLayer The utility layer the gizmo will be added to
  111070. */
  111071. constructor(gizmoLayer?: UtilityLayerRenderer);
  111072. private _light;
  111073. /**
  111074. * The light that the gizmo is attached to
  111075. */
  111076. light: Nullable<Light>;
  111077. /**
  111078. * Gets the material used to render the light gizmo
  111079. */
  111080. readonly material: StandardMaterial;
  111081. /**
  111082. * @hidden
  111083. * Updates the gizmo to match the attached mesh's position/rotation
  111084. */
  111085. protected _update(): void;
  111086. private static _Scale;
  111087. /**
  111088. * Creates the lines for a light mesh
  111089. */
  111090. private static _createLightLines;
  111091. /**
  111092. * Disposes of the light gizmo
  111093. */
  111094. dispose(): void;
  111095. private static _CreateHemisphericLightMesh;
  111096. private static _CreatePointLightMesh;
  111097. private static _CreateSpotLightMesh;
  111098. private static _CreateDirectionalLightMesh;
  111099. }
  111100. }
  111101. declare module BABYLON {
  111102. /** @hidden */
  111103. export var backgroundFragmentDeclaration: {
  111104. name: string;
  111105. shader: string;
  111106. };
  111107. }
  111108. declare module BABYLON {
  111109. /** @hidden */
  111110. export var backgroundUboDeclaration: {
  111111. name: string;
  111112. shader: string;
  111113. };
  111114. }
  111115. declare module BABYLON {
  111116. /** @hidden */
  111117. export var backgroundPixelShader: {
  111118. name: string;
  111119. shader: string;
  111120. };
  111121. }
  111122. declare module BABYLON {
  111123. /** @hidden */
  111124. export var backgroundVertexDeclaration: {
  111125. name: string;
  111126. shader: string;
  111127. };
  111128. }
  111129. declare module BABYLON {
  111130. /** @hidden */
  111131. export var backgroundVertexShader: {
  111132. name: string;
  111133. shader: string;
  111134. };
  111135. }
  111136. declare module BABYLON {
  111137. /**
  111138. * Background material used to create an efficient environement around your scene.
  111139. */
  111140. export class BackgroundMaterial extends PushMaterial {
  111141. /**
  111142. * Standard reflectance value at parallel view angle.
  111143. */
  111144. static StandardReflectance0: number;
  111145. /**
  111146. * Standard reflectance value at grazing angle.
  111147. */
  111148. static StandardReflectance90: number;
  111149. protected _primaryColor: Color3;
  111150. /**
  111151. * Key light Color (multiply against the environement texture)
  111152. */
  111153. primaryColor: Color3;
  111154. protected __perceptualColor: Nullable<Color3>;
  111155. /**
  111156. * Experimental Internal Use Only.
  111157. *
  111158. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111159. * This acts as a helper to set the primary color to a more "human friendly" value.
  111160. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111161. * output color as close as possible from the chosen value.
  111162. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111163. * part of lighting setup.)
  111164. */
  111165. _perceptualColor: Nullable<Color3>;
  111166. protected _primaryColorShadowLevel: float;
  111167. /**
  111168. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111169. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111170. */
  111171. primaryColorShadowLevel: float;
  111172. protected _primaryColorHighlightLevel: float;
  111173. /**
  111174. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111175. * The primary color is used at the level chosen to define what the white area would look.
  111176. */
  111177. primaryColorHighlightLevel: float;
  111178. protected _reflectionTexture: Nullable<BaseTexture>;
  111179. /**
  111180. * Reflection Texture used in the material.
  111181. * Should be author in a specific way for the best result (refer to the documentation).
  111182. */
  111183. reflectionTexture: Nullable<BaseTexture>;
  111184. protected _reflectionBlur: float;
  111185. /**
  111186. * Reflection Texture level of blur.
  111187. *
  111188. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111189. * texture twice.
  111190. */
  111191. reflectionBlur: float;
  111192. protected _diffuseTexture: Nullable<BaseTexture>;
  111193. /**
  111194. * Diffuse Texture used in the material.
  111195. * Should be author in a specific way for the best result (refer to the documentation).
  111196. */
  111197. diffuseTexture: Nullable<BaseTexture>;
  111198. protected _shadowLights: Nullable<IShadowLight[]>;
  111199. /**
  111200. * Specify the list of lights casting shadow on the material.
  111201. * All scene shadow lights will be included if null.
  111202. */
  111203. shadowLights: Nullable<IShadowLight[]>;
  111204. protected _shadowLevel: float;
  111205. /**
  111206. * Helps adjusting the shadow to a softer level if required.
  111207. * 0 means black shadows and 1 means no shadows.
  111208. */
  111209. shadowLevel: float;
  111210. protected _sceneCenter: Vector3;
  111211. /**
  111212. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111213. * It is usually zero but might be interesting to modify according to your setup.
  111214. */
  111215. sceneCenter: Vector3;
  111216. protected _opacityFresnel: boolean;
  111217. /**
  111218. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111219. * This helps ensuring a nice transition when the camera goes under the ground.
  111220. */
  111221. opacityFresnel: boolean;
  111222. protected _reflectionFresnel: boolean;
  111223. /**
  111224. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111225. * This helps adding a mirror texture on the ground.
  111226. */
  111227. reflectionFresnel: boolean;
  111228. protected _reflectionFalloffDistance: number;
  111229. /**
  111230. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111231. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111232. */
  111233. reflectionFalloffDistance: number;
  111234. protected _reflectionAmount: number;
  111235. /**
  111236. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111237. */
  111238. reflectionAmount: number;
  111239. protected _reflectionReflectance0: number;
  111240. /**
  111241. * This specifies the weight of the reflection at grazing angle.
  111242. */
  111243. reflectionReflectance0: number;
  111244. protected _reflectionReflectance90: number;
  111245. /**
  111246. * This specifies the weight of the reflection at a perpendicular point of view.
  111247. */
  111248. reflectionReflectance90: number;
  111249. /**
  111250. * Sets the reflection reflectance fresnel values according to the default standard
  111251. * empirically know to work well :-)
  111252. */
  111253. reflectionStandardFresnelWeight: number;
  111254. protected _useRGBColor: boolean;
  111255. /**
  111256. * Helps to directly use the maps channels instead of their level.
  111257. */
  111258. useRGBColor: boolean;
  111259. protected _enableNoise: boolean;
  111260. /**
  111261. * This helps reducing the banding effect that could occur on the background.
  111262. */
  111263. enableNoise: boolean;
  111264. /**
  111265. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111266. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111267. * Recommended to be keep at 1.0 except for special cases.
  111268. */
  111269. fovMultiplier: number;
  111270. private _fovMultiplier;
  111271. /**
  111272. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111273. */
  111274. useEquirectangularFOV: boolean;
  111275. private _maxSimultaneousLights;
  111276. /**
  111277. * Number of Simultaneous lights allowed on the material.
  111278. */
  111279. maxSimultaneousLights: int;
  111280. /**
  111281. * Default configuration related to image processing available in the Background Material.
  111282. */
  111283. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111284. /**
  111285. * Keep track of the image processing observer to allow dispose and replace.
  111286. */
  111287. private _imageProcessingObserver;
  111288. /**
  111289. * Attaches a new image processing configuration to the PBR Material.
  111290. * @param configuration (if null the scene configuration will be use)
  111291. */
  111292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111293. /**
  111294. * Gets the image processing configuration used either in this material.
  111295. */
  111296. /**
  111297. * Sets the Default image processing configuration used either in the this material.
  111298. *
  111299. * If sets to null, the scene one is in use.
  111300. */
  111301. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111302. /**
  111303. * Gets wether the color curves effect is enabled.
  111304. */
  111305. /**
  111306. * Sets wether the color curves effect is enabled.
  111307. */
  111308. cameraColorCurvesEnabled: boolean;
  111309. /**
  111310. * Gets wether the color grading effect is enabled.
  111311. */
  111312. /**
  111313. * Gets wether the color grading effect is enabled.
  111314. */
  111315. cameraColorGradingEnabled: boolean;
  111316. /**
  111317. * Gets wether tonemapping is enabled or not.
  111318. */
  111319. /**
  111320. * Sets wether tonemapping is enabled or not
  111321. */
  111322. cameraToneMappingEnabled: boolean;
  111323. /**
  111324. * The camera exposure used on this material.
  111325. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111326. * This corresponds to a photographic exposure.
  111327. */
  111328. /**
  111329. * The camera exposure used on this material.
  111330. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111331. * This corresponds to a photographic exposure.
  111332. */
  111333. cameraExposure: float;
  111334. /**
  111335. * Gets The camera contrast used on this material.
  111336. */
  111337. /**
  111338. * Sets The camera contrast used on this material.
  111339. */
  111340. cameraContrast: float;
  111341. /**
  111342. * Gets the Color Grading 2D Lookup Texture.
  111343. */
  111344. /**
  111345. * Sets the Color Grading 2D Lookup Texture.
  111346. */
  111347. cameraColorGradingTexture: Nullable<BaseTexture>;
  111348. /**
  111349. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111350. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111351. * 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;
  111352. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111353. */
  111354. /**
  111355. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111356. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111357. * 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;
  111358. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111359. */
  111360. cameraColorCurves: Nullable<ColorCurves>;
  111361. /**
  111362. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111363. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111364. */
  111365. switchToBGR: boolean;
  111366. private _renderTargets;
  111367. private _reflectionControls;
  111368. private _white;
  111369. private _primaryShadowColor;
  111370. private _primaryHighlightColor;
  111371. /**
  111372. * Instantiates a Background Material in the given scene
  111373. * @param name The friendly name of the material
  111374. * @param scene The scene to add the material to
  111375. */
  111376. constructor(name: string, scene: Scene);
  111377. /**
  111378. * Gets a boolean indicating that current material needs to register RTT
  111379. */
  111380. readonly hasRenderTargetTextures: boolean;
  111381. /**
  111382. * The entire material has been created in order to prevent overdraw.
  111383. * @returns false
  111384. */
  111385. needAlphaTesting(): boolean;
  111386. /**
  111387. * The entire material has been created in order to prevent overdraw.
  111388. * @returns true if blending is enable
  111389. */
  111390. needAlphaBlending(): boolean;
  111391. /**
  111392. * Checks wether the material is ready to be rendered for a given mesh.
  111393. * @param mesh The mesh to render
  111394. * @param subMesh The submesh to check against
  111395. * @param useInstances Specify wether or not the material is used with instances
  111396. * @returns true if all the dependencies are ready (Textures, Effects...)
  111397. */
  111398. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111399. /**
  111400. * Compute the primary color according to the chosen perceptual color.
  111401. */
  111402. private _computePrimaryColorFromPerceptualColor;
  111403. /**
  111404. * Compute the highlights and shadow colors according to their chosen levels.
  111405. */
  111406. private _computePrimaryColors;
  111407. /**
  111408. * Build the uniform buffer used in the material.
  111409. */
  111410. buildUniformLayout(): void;
  111411. /**
  111412. * Unbind the material.
  111413. */
  111414. unbind(): void;
  111415. /**
  111416. * Bind only the world matrix to the material.
  111417. * @param world The world matrix to bind.
  111418. */
  111419. bindOnlyWorldMatrix(world: Matrix): void;
  111420. /**
  111421. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111422. * @param world The world matrix to bind.
  111423. * @param subMesh The submesh to bind for.
  111424. */
  111425. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111426. /**
  111427. * Checks to see if a texture is used in the material.
  111428. * @param texture - Base texture to use.
  111429. * @returns - Boolean specifying if a texture is used in the material.
  111430. */
  111431. hasTexture(texture: BaseTexture): boolean;
  111432. /**
  111433. * Dispose the material.
  111434. * @param forceDisposeEffect Force disposal of the associated effect.
  111435. * @param forceDisposeTextures Force disposal of the associated textures.
  111436. */
  111437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111438. /**
  111439. * Clones the material.
  111440. * @param name The cloned name.
  111441. * @returns The cloned material.
  111442. */
  111443. clone(name: string): BackgroundMaterial;
  111444. /**
  111445. * Serializes the current material to its JSON representation.
  111446. * @returns The JSON representation.
  111447. */
  111448. serialize(): any;
  111449. /**
  111450. * Gets the class name of the material
  111451. * @returns "BackgroundMaterial"
  111452. */
  111453. getClassName(): string;
  111454. /**
  111455. * Parse a JSON input to create back a background material.
  111456. * @param source The JSON data to parse
  111457. * @param scene The scene to create the parsed material in
  111458. * @param rootUrl The root url of the assets the material depends upon
  111459. * @returns the instantiated BackgroundMaterial.
  111460. */
  111461. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111462. }
  111463. }
  111464. declare module BABYLON {
  111465. /**
  111466. * Represents the different options available during the creation of
  111467. * a Environment helper.
  111468. *
  111469. * This can control the default ground, skybox and image processing setup of your scene.
  111470. */
  111471. export interface IEnvironmentHelperOptions {
  111472. /**
  111473. * Specifies wether or not to create a ground.
  111474. * True by default.
  111475. */
  111476. createGround: boolean;
  111477. /**
  111478. * Specifies the ground size.
  111479. * 15 by default.
  111480. */
  111481. groundSize: number;
  111482. /**
  111483. * The texture used on the ground for the main color.
  111484. * Comes from the BabylonJS CDN by default.
  111485. *
  111486. * Remarks: Can be either a texture or a url.
  111487. */
  111488. groundTexture: string | BaseTexture;
  111489. /**
  111490. * The color mixed in the ground texture by default.
  111491. * BabylonJS clearColor by default.
  111492. */
  111493. groundColor: Color3;
  111494. /**
  111495. * Specifies the ground opacity.
  111496. * 1 by default.
  111497. */
  111498. groundOpacity: number;
  111499. /**
  111500. * Enables the ground to receive shadows.
  111501. * True by default.
  111502. */
  111503. enableGroundShadow: boolean;
  111504. /**
  111505. * Helps preventing the shadow to be fully black on the ground.
  111506. * 0.5 by default.
  111507. */
  111508. groundShadowLevel: number;
  111509. /**
  111510. * Creates a mirror texture attach to the ground.
  111511. * false by default.
  111512. */
  111513. enableGroundMirror: boolean;
  111514. /**
  111515. * Specifies the ground mirror size ratio.
  111516. * 0.3 by default as the default kernel is 64.
  111517. */
  111518. groundMirrorSizeRatio: number;
  111519. /**
  111520. * Specifies the ground mirror blur kernel size.
  111521. * 64 by default.
  111522. */
  111523. groundMirrorBlurKernel: number;
  111524. /**
  111525. * Specifies the ground mirror visibility amount.
  111526. * 1 by default
  111527. */
  111528. groundMirrorAmount: number;
  111529. /**
  111530. * Specifies the ground mirror reflectance weight.
  111531. * This uses the standard weight of the background material to setup the fresnel effect
  111532. * of the mirror.
  111533. * 1 by default.
  111534. */
  111535. groundMirrorFresnelWeight: number;
  111536. /**
  111537. * Specifies the ground mirror Falloff distance.
  111538. * This can helps reducing the size of the reflection.
  111539. * 0 by Default.
  111540. */
  111541. groundMirrorFallOffDistance: number;
  111542. /**
  111543. * Specifies the ground mirror texture type.
  111544. * Unsigned Int by Default.
  111545. */
  111546. groundMirrorTextureType: number;
  111547. /**
  111548. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111549. * the shown objects.
  111550. */
  111551. groundYBias: number;
  111552. /**
  111553. * Specifies wether or not to create a skybox.
  111554. * True by default.
  111555. */
  111556. createSkybox: boolean;
  111557. /**
  111558. * Specifies the skybox size.
  111559. * 20 by default.
  111560. */
  111561. skyboxSize: number;
  111562. /**
  111563. * The texture used on the skybox for the main color.
  111564. * Comes from the BabylonJS CDN by default.
  111565. *
  111566. * Remarks: Can be either a texture or a url.
  111567. */
  111568. skyboxTexture: string | BaseTexture;
  111569. /**
  111570. * The color mixed in the skybox texture by default.
  111571. * BabylonJS clearColor by default.
  111572. */
  111573. skyboxColor: Color3;
  111574. /**
  111575. * The background rotation around the Y axis of the scene.
  111576. * This helps aligning the key lights of your scene with the background.
  111577. * 0 by default.
  111578. */
  111579. backgroundYRotation: number;
  111580. /**
  111581. * Compute automatically the size of the elements to best fit with the scene.
  111582. */
  111583. sizeAuto: boolean;
  111584. /**
  111585. * Default position of the rootMesh if autoSize is not true.
  111586. */
  111587. rootPosition: Vector3;
  111588. /**
  111589. * Sets up the image processing in the scene.
  111590. * true by default.
  111591. */
  111592. setupImageProcessing: boolean;
  111593. /**
  111594. * The texture used as your environment texture in the scene.
  111595. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111596. *
  111597. * Remarks: Can be either a texture or a url.
  111598. */
  111599. environmentTexture: string | BaseTexture;
  111600. /**
  111601. * The value of the exposure to apply to the scene.
  111602. * 0.6 by default if setupImageProcessing is true.
  111603. */
  111604. cameraExposure: number;
  111605. /**
  111606. * The value of the contrast to apply to the scene.
  111607. * 1.6 by default if setupImageProcessing is true.
  111608. */
  111609. cameraContrast: number;
  111610. /**
  111611. * Specifies wether or not tonemapping should be enabled in the scene.
  111612. * true by default if setupImageProcessing is true.
  111613. */
  111614. toneMappingEnabled: boolean;
  111615. }
  111616. /**
  111617. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111618. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111619. * It also helps with the default setup of your imageProcessing configuration.
  111620. */
  111621. export class EnvironmentHelper {
  111622. /**
  111623. * Default ground texture URL.
  111624. */
  111625. private static _groundTextureCDNUrl;
  111626. /**
  111627. * Default skybox texture URL.
  111628. */
  111629. private static _skyboxTextureCDNUrl;
  111630. /**
  111631. * Default environment texture URL.
  111632. */
  111633. private static _environmentTextureCDNUrl;
  111634. /**
  111635. * Creates the default options for the helper.
  111636. */
  111637. private static _getDefaultOptions;
  111638. private _rootMesh;
  111639. /**
  111640. * Gets the root mesh created by the helper.
  111641. */
  111642. readonly rootMesh: Mesh;
  111643. private _skybox;
  111644. /**
  111645. * Gets the skybox created by the helper.
  111646. */
  111647. readonly skybox: Nullable<Mesh>;
  111648. private _skyboxTexture;
  111649. /**
  111650. * Gets the skybox texture created by the helper.
  111651. */
  111652. readonly skyboxTexture: Nullable<BaseTexture>;
  111653. private _skyboxMaterial;
  111654. /**
  111655. * Gets the skybox material created by the helper.
  111656. */
  111657. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111658. private _ground;
  111659. /**
  111660. * Gets the ground mesh created by the helper.
  111661. */
  111662. readonly ground: Nullable<Mesh>;
  111663. private _groundTexture;
  111664. /**
  111665. * Gets the ground texture created by the helper.
  111666. */
  111667. readonly groundTexture: Nullable<BaseTexture>;
  111668. private _groundMirror;
  111669. /**
  111670. * Gets the ground mirror created by the helper.
  111671. */
  111672. readonly groundMirror: Nullable<MirrorTexture>;
  111673. /**
  111674. * Gets the ground mirror render list to helps pushing the meshes
  111675. * you wish in the ground reflection.
  111676. */
  111677. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111678. private _groundMaterial;
  111679. /**
  111680. * Gets the ground material created by the helper.
  111681. */
  111682. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111683. /**
  111684. * Stores the creation options.
  111685. */
  111686. private readonly _scene;
  111687. private _options;
  111688. /**
  111689. * This observable will be notified with any error during the creation of the environment,
  111690. * mainly texture creation errors.
  111691. */
  111692. onErrorObservable: Observable<{
  111693. message?: string;
  111694. exception?: any;
  111695. }>;
  111696. /**
  111697. * constructor
  111698. * @param options Defines the options we want to customize the helper
  111699. * @param scene The scene to add the material to
  111700. */
  111701. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111702. /**
  111703. * Updates the background according to the new options
  111704. * @param options
  111705. */
  111706. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111707. /**
  111708. * Sets the primary color of all the available elements.
  111709. * @param color the main color to affect to the ground and the background
  111710. */
  111711. setMainColor(color: Color3): void;
  111712. /**
  111713. * Setup the image processing according to the specified options.
  111714. */
  111715. private _setupImageProcessing;
  111716. /**
  111717. * Setup the environment texture according to the specified options.
  111718. */
  111719. private _setupEnvironmentTexture;
  111720. /**
  111721. * Setup the background according to the specified options.
  111722. */
  111723. private _setupBackground;
  111724. /**
  111725. * Get the scene sizes according to the setup.
  111726. */
  111727. private _getSceneSize;
  111728. /**
  111729. * Setup the ground according to the specified options.
  111730. */
  111731. private _setupGround;
  111732. /**
  111733. * Setup the ground material according to the specified options.
  111734. */
  111735. private _setupGroundMaterial;
  111736. /**
  111737. * Setup the ground diffuse texture according to the specified options.
  111738. */
  111739. private _setupGroundDiffuseTexture;
  111740. /**
  111741. * Setup the ground mirror texture according to the specified options.
  111742. */
  111743. private _setupGroundMirrorTexture;
  111744. /**
  111745. * Setup the ground to receive the mirror texture.
  111746. */
  111747. private _setupMirrorInGroundMaterial;
  111748. /**
  111749. * Setup the skybox according to the specified options.
  111750. */
  111751. private _setupSkybox;
  111752. /**
  111753. * Setup the skybox material according to the specified options.
  111754. */
  111755. private _setupSkyboxMaterial;
  111756. /**
  111757. * Setup the skybox reflection texture according to the specified options.
  111758. */
  111759. private _setupSkyboxReflectionTexture;
  111760. private _errorHandler;
  111761. /**
  111762. * Dispose all the elements created by the Helper.
  111763. */
  111764. dispose(): void;
  111765. }
  111766. }
  111767. declare module BABYLON {
  111768. /**
  111769. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111770. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111771. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111773. */
  111774. export class PhotoDome extends TransformNode {
  111775. /**
  111776. * Define the image as a Monoscopic panoramic 360 image.
  111777. */
  111778. static readonly MODE_MONOSCOPIC: number;
  111779. /**
  111780. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111781. */
  111782. static readonly MODE_TOPBOTTOM: number;
  111783. /**
  111784. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111785. */
  111786. static readonly MODE_SIDEBYSIDE: number;
  111787. private _useDirectMapping;
  111788. /**
  111789. * The texture being displayed on the sphere
  111790. */
  111791. protected _photoTexture: Texture;
  111792. /**
  111793. * Gets or sets the texture being displayed on the sphere
  111794. */
  111795. photoTexture: Texture;
  111796. /**
  111797. * Observable raised when an error occured while loading the 360 image
  111798. */
  111799. onLoadErrorObservable: Observable<string>;
  111800. /**
  111801. * The skybox material
  111802. */
  111803. protected _material: BackgroundMaterial;
  111804. /**
  111805. * The surface used for the skybox
  111806. */
  111807. protected _mesh: Mesh;
  111808. /**
  111809. * Gets the mesh used for the skybox.
  111810. */
  111811. readonly mesh: Mesh;
  111812. /**
  111813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111814. * Also see the options.resolution property.
  111815. */
  111816. fovMultiplier: number;
  111817. private _imageMode;
  111818. /**
  111819. * Gets or set the current video mode for the video. It can be:
  111820. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111821. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111822. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111823. */
  111824. imageMode: number;
  111825. /**
  111826. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111827. * @param name Element's name, child elements will append suffixes for their own names.
  111828. * @param urlsOfPhoto defines the url of the photo to display
  111829. * @param options defines an object containing optional or exposed sub element properties
  111830. * @param onError defines a callback called when an error occured while loading the texture
  111831. */
  111832. constructor(name: string, urlOfPhoto: string, options: {
  111833. resolution?: number;
  111834. size?: number;
  111835. useDirectMapping?: boolean;
  111836. faceForward?: boolean;
  111837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111838. private _onBeforeCameraRenderObserver;
  111839. private _changeImageMode;
  111840. /**
  111841. * Releases resources associated with this node.
  111842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111844. */
  111845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111846. }
  111847. }
  111848. declare module BABYLON {
  111849. /**
  111850. * Class used to host RGBD texture specific utilities
  111851. */
  111852. export class RGBDTextureTools {
  111853. /**
  111854. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111855. * @param texture the texture to expand.
  111856. */
  111857. static ExpandRGBDTexture(texture: Texture): void;
  111858. }
  111859. }
  111860. declare module BABYLON {
  111861. /**
  111862. * Class used to host texture specific utilities
  111863. */
  111864. export class BRDFTextureTools {
  111865. /**
  111866. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111867. * @param scene defines the hosting scene
  111868. * @returns the environment BRDF texture
  111869. */
  111870. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111871. private static _environmentBRDFBase64Texture;
  111872. }
  111873. }
  111874. declare module BABYLON {
  111875. /**
  111876. * @hidden
  111877. */
  111878. export interface IMaterialClearCoatDefines {
  111879. CLEARCOAT: boolean;
  111880. CLEARCOAT_DEFAULTIOR: boolean;
  111881. CLEARCOAT_TEXTURE: boolean;
  111882. CLEARCOAT_TEXTUREDIRECTUV: number;
  111883. CLEARCOAT_BUMP: boolean;
  111884. CLEARCOAT_BUMPDIRECTUV: number;
  111885. CLEARCOAT_TINT: boolean;
  111886. CLEARCOAT_TINT_TEXTURE: boolean;
  111887. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111888. /** @hidden */
  111889. _areTexturesDirty: boolean;
  111890. }
  111891. /**
  111892. * Define the code related to the clear coat parameters of the pbr material.
  111893. */
  111894. export class PBRClearCoatConfiguration {
  111895. /**
  111896. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111897. * The default fits with a polyurethane material.
  111898. */
  111899. private static readonly _DefaultIndexOfRefraction;
  111900. private _isEnabled;
  111901. /**
  111902. * Defines if the clear coat is enabled in the material.
  111903. */
  111904. isEnabled: boolean;
  111905. /**
  111906. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111907. */
  111908. intensity: number;
  111909. /**
  111910. * Defines the clear coat layer roughness.
  111911. */
  111912. roughness: number;
  111913. private _indexOfRefraction;
  111914. /**
  111915. * Defines the index of refraction of the clear coat.
  111916. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111917. * The default fits with a polyurethane material.
  111918. * Changing the default value is more performance intensive.
  111919. */
  111920. indexOfRefraction: number;
  111921. private _texture;
  111922. /**
  111923. * Stores the clear coat values in a texture.
  111924. */
  111925. texture: Nullable<BaseTexture>;
  111926. private _bumpTexture;
  111927. /**
  111928. * Define the clear coat specific bump texture.
  111929. */
  111930. bumpTexture: Nullable<BaseTexture>;
  111931. private _isTintEnabled;
  111932. /**
  111933. * Defines if the clear coat tint is enabled in the material.
  111934. */
  111935. isTintEnabled: boolean;
  111936. /**
  111937. * Defines the clear coat tint of the material.
  111938. * This is only use if tint is enabled
  111939. */
  111940. tintColor: Color3;
  111941. /**
  111942. * Defines the distance at which the tint color should be found in the
  111943. * clear coat media.
  111944. * This is only use if tint is enabled
  111945. */
  111946. tintColorAtDistance: number;
  111947. /**
  111948. * Defines the clear coat layer thickness.
  111949. * This is only use if tint is enabled
  111950. */
  111951. tintThickness: number;
  111952. private _tintTexture;
  111953. /**
  111954. * Stores the clear tint values in a texture.
  111955. * rgb is tint
  111956. * a is a thickness factor
  111957. */
  111958. tintTexture: Nullable<BaseTexture>;
  111959. /** @hidden */
  111960. private _internalMarkAllSubMeshesAsTexturesDirty;
  111961. /** @hidden */
  111962. _markAllSubMeshesAsTexturesDirty(): void;
  111963. /**
  111964. * Instantiate a new istance of clear coat configuration.
  111965. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111966. */
  111967. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111968. /**
  111969. * Gets wehter the submesh is ready to be used or not.
  111970. * @param defines the list of "defines" to update.
  111971. * @param scene defines the scene the material belongs to.
  111972. * @param engine defines the engine the material belongs to.
  111973. * @param disableBumpMap defines wether the material disables bump or not.
  111974. * @returns - boolean indicating that the submesh is ready or not.
  111975. */
  111976. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111977. /**
  111978. * Checks to see if a texture is used in the material.
  111979. * @param defines the list of "defines" to update.
  111980. * @param scene defines the scene to the material belongs to.
  111981. */
  111982. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111983. /**
  111984. * Binds the material data.
  111985. * @param uniformBuffer defines the Uniform buffer to fill in.
  111986. * @param scene defines the scene the material belongs to.
  111987. * @param engine defines the engine the material belongs to.
  111988. * @param disableBumpMap defines wether the material disables bump or not.
  111989. * @param isFrozen defines wether the material is frozen or not.
  111990. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111991. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111992. */
  111993. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111994. /**
  111995. * Checks to see if a texture is used in the material.
  111996. * @param texture - Base texture to use.
  111997. * @returns - Boolean specifying if a texture is used in the material.
  111998. */
  111999. hasTexture(texture: BaseTexture): boolean;
  112000. /**
  112001. * Returns an array of the actively used textures.
  112002. * @param activeTextures Array of BaseTextures
  112003. */
  112004. getActiveTextures(activeTextures: BaseTexture[]): void;
  112005. /**
  112006. * Returns the animatable textures.
  112007. * @param animatables Array of animatable textures.
  112008. */
  112009. getAnimatables(animatables: IAnimatable[]): void;
  112010. /**
  112011. * Disposes the resources of the material.
  112012. * @param forceDisposeTextures - Forces the disposal of all textures.
  112013. */
  112014. dispose(forceDisposeTextures?: boolean): void;
  112015. /**
  112016. * Get the current class name of the texture useful for serialization or dynamic coding.
  112017. * @returns "PBRClearCoatConfiguration"
  112018. */
  112019. getClassName(): string;
  112020. /**
  112021. * Add fallbacks to the effect fallbacks list.
  112022. * @param defines defines the Base texture to use.
  112023. * @param fallbacks defines the current fallback list.
  112024. * @param currentRank defines the current fallback rank.
  112025. * @returns the new fallback rank.
  112026. */
  112027. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112028. /**
  112029. * Add the required uniforms to the current list.
  112030. * @param uniforms defines the current uniform list.
  112031. */
  112032. static AddUniforms(uniforms: string[]): void;
  112033. /**
  112034. * Add the required samplers to the current list.
  112035. * @param samplers defines the current sampler list.
  112036. */
  112037. static AddSamplers(samplers: string[]): void;
  112038. /**
  112039. * Add the required uniforms to the current buffer.
  112040. * @param uniformBuffer defines the current uniform buffer.
  112041. */
  112042. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112043. /**
  112044. * Makes a duplicate of the current configuration into another one.
  112045. * @param clearCoatConfiguration define the config where to copy the info
  112046. */
  112047. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  112048. /**
  112049. * Serializes this clear coat configuration.
  112050. * @returns - An object with the serialized config.
  112051. */
  112052. serialize(): any;
  112053. /**
  112054. * Parses a anisotropy Configuration from a serialized object.
  112055. * @param source - Serialized object.
  112056. * @param scene Defines the scene we are parsing for
  112057. * @param rootUrl Defines the rootUrl to load from
  112058. */
  112059. parse(source: any, scene: Scene, rootUrl: string): void;
  112060. }
  112061. }
  112062. declare module BABYLON {
  112063. /**
  112064. * @hidden
  112065. */
  112066. export interface IMaterialAnisotropicDefines {
  112067. ANISOTROPIC: boolean;
  112068. ANISOTROPIC_TEXTURE: boolean;
  112069. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112070. MAINUV1: boolean;
  112071. _areTexturesDirty: boolean;
  112072. _needUVs: boolean;
  112073. }
  112074. /**
  112075. * Define the code related to the anisotropic parameters of the pbr material.
  112076. */
  112077. export class PBRAnisotropicConfiguration {
  112078. private _isEnabled;
  112079. /**
  112080. * Defines if the anisotropy is enabled in the material.
  112081. */
  112082. isEnabled: boolean;
  112083. /**
  112084. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  112085. */
  112086. intensity: number;
  112087. /**
  112088. * Defines if the effect is along the tangents, bitangents or in between.
  112089. * By default, the effect is "strectching" the highlights along the tangents.
  112090. */
  112091. direction: Vector2;
  112092. private _texture;
  112093. /**
  112094. * Stores the anisotropy values in a texture.
  112095. * rg is direction (like normal from -1 to 1)
  112096. * b is a intensity
  112097. */
  112098. texture: Nullable<BaseTexture>;
  112099. /** @hidden */
  112100. private _internalMarkAllSubMeshesAsTexturesDirty;
  112101. /** @hidden */
  112102. _markAllSubMeshesAsTexturesDirty(): void;
  112103. /**
  112104. * Instantiate a new istance of anisotropy configuration.
  112105. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112106. */
  112107. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112108. /**
  112109. * Specifies that the submesh is ready to be used.
  112110. * @param defines the list of "defines" to update.
  112111. * @param scene defines the scene the material belongs to.
  112112. * @returns - boolean indicating that the submesh is ready or not.
  112113. */
  112114. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  112115. /**
  112116. * Checks to see if a texture is used in the material.
  112117. * @param defines the list of "defines" to update.
  112118. * @param mesh the mesh we are preparing the defines for.
  112119. * @param scene defines the scene the material belongs to.
  112120. */
  112121. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  112122. /**
  112123. * Binds the material data.
  112124. * @param uniformBuffer defines the Uniform buffer to fill in.
  112125. * @param scene defines the scene the material belongs to.
  112126. * @param isFrozen defines wether the material is frozen or not.
  112127. */
  112128. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112129. /**
  112130. * Checks to see if a texture is used in the material.
  112131. * @param texture - Base texture to use.
  112132. * @returns - Boolean specifying if a texture is used in the material.
  112133. */
  112134. hasTexture(texture: BaseTexture): boolean;
  112135. /**
  112136. * Returns an array of the actively used textures.
  112137. * @param activeTextures Array of BaseTextures
  112138. */
  112139. getActiveTextures(activeTextures: BaseTexture[]): void;
  112140. /**
  112141. * Returns the animatable textures.
  112142. * @param animatables Array of animatable textures.
  112143. */
  112144. getAnimatables(animatables: IAnimatable[]): void;
  112145. /**
  112146. * Disposes the resources of the material.
  112147. * @param forceDisposeTextures - Forces the disposal of all textures.
  112148. */
  112149. dispose(forceDisposeTextures?: boolean): void;
  112150. /**
  112151. * Get the current class name of the texture useful for serialization or dynamic coding.
  112152. * @returns "PBRAnisotropicConfiguration"
  112153. */
  112154. getClassName(): string;
  112155. /**
  112156. * Add fallbacks to the effect fallbacks list.
  112157. * @param defines defines the Base texture to use.
  112158. * @param fallbacks defines the current fallback list.
  112159. * @param currentRank defines the current fallback rank.
  112160. * @returns the new fallback rank.
  112161. */
  112162. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112163. /**
  112164. * Add the required uniforms to the current list.
  112165. * @param uniforms defines the current uniform list.
  112166. */
  112167. static AddUniforms(uniforms: string[]): void;
  112168. /**
  112169. * Add the required uniforms to the current buffer.
  112170. * @param uniformBuffer defines the current uniform buffer.
  112171. */
  112172. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112173. /**
  112174. * Add the required samplers to the current list.
  112175. * @param samplers defines the current sampler list.
  112176. */
  112177. static AddSamplers(samplers: string[]): void;
  112178. /**
  112179. * Makes a duplicate of the current configuration into another one.
  112180. * @param anisotropicConfiguration define the config where to copy the info
  112181. */
  112182. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112183. /**
  112184. * Serializes this anisotropy configuration.
  112185. * @returns - An object with the serialized config.
  112186. */
  112187. serialize(): any;
  112188. /**
  112189. * Parses a anisotropy Configuration from a serialized object.
  112190. * @param source - Serialized object.
  112191. * @param scene Defines the scene we are parsing for
  112192. * @param rootUrl Defines the rootUrl to load from
  112193. */
  112194. parse(source: any, scene: Scene, rootUrl: string): void;
  112195. }
  112196. }
  112197. declare module BABYLON {
  112198. /**
  112199. * @hidden
  112200. */
  112201. export interface IMaterialBRDFDefines {
  112202. BRDF_V_HEIGHT_CORRELATED: boolean;
  112203. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112204. SPHERICAL_HARMONICS: boolean;
  112205. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112206. /** @hidden */
  112207. _areMiscDirty: boolean;
  112208. }
  112209. /**
  112210. * Define the code related to the BRDF parameters of the pbr material.
  112211. */
  112212. export class PBRBRDFConfiguration {
  112213. /**
  112214. * Default value used for the energy conservation.
  112215. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112216. */
  112217. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112218. /**
  112219. * Default value used for the Smith Visibility Height Correlated mode.
  112220. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112221. */
  112222. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112223. /**
  112224. * Default value used for the IBL diffuse part.
  112225. * This can help switching back to the polynomials mode globally which is a tiny bit
  112226. * less GPU intensive at the drawback of a lower quality.
  112227. */
  112228. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112229. /**
  112230. * Default value used for activating energy conservation for the specular workflow.
  112231. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112232. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112233. */
  112234. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112235. private _useEnergyConservation;
  112236. /**
  112237. * Defines if the material uses energy conservation.
  112238. */
  112239. useEnergyConservation: boolean;
  112240. private _useSmithVisibilityHeightCorrelated;
  112241. /**
  112242. * LEGACY Mode set to false
  112243. * Defines if the material uses height smith correlated visibility term.
  112244. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112245. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112246. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112247. * Not relying on height correlated will also disable energy conservation.
  112248. */
  112249. useSmithVisibilityHeightCorrelated: boolean;
  112250. private _useSphericalHarmonics;
  112251. /**
  112252. * LEGACY Mode set to false
  112253. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112254. * diffuse part of the IBL.
  112255. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112256. * to the ground truth.
  112257. */
  112258. useSphericalHarmonics: boolean;
  112259. private _useSpecularGlossinessInputEnergyConservation;
  112260. /**
  112261. * Defines if the material uses energy conservation, when the specular workflow is active.
  112262. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112263. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112264. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112265. */
  112266. useSpecularGlossinessInputEnergyConservation: boolean;
  112267. /** @hidden */
  112268. private _internalMarkAllSubMeshesAsMiscDirty;
  112269. /** @hidden */
  112270. _markAllSubMeshesAsMiscDirty(): void;
  112271. /**
  112272. * Instantiate a new istance of clear coat configuration.
  112273. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112274. */
  112275. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112276. /**
  112277. * Checks to see if a texture is used in the material.
  112278. * @param defines the list of "defines" to update.
  112279. */
  112280. prepareDefines(defines: IMaterialBRDFDefines): void;
  112281. /**
  112282. * Get the current class name of the texture useful for serialization or dynamic coding.
  112283. * @returns "PBRClearCoatConfiguration"
  112284. */
  112285. getClassName(): string;
  112286. /**
  112287. * Makes a duplicate of the current configuration into another one.
  112288. * @param brdfConfiguration define the config where to copy the info
  112289. */
  112290. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112291. /**
  112292. * Serializes this BRDF configuration.
  112293. * @returns - An object with the serialized config.
  112294. */
  112295. serialize(): any;
  112296. /**
  112297. * Parses a anisotropy Configuration from a serialized object.
  112298. * @param source - Serialized object.
  112299. * @param scene Defines the scene we are parsing for
  112300. * @param rootUrl Defines the rootUrl to load from
  112301. */
  112302. parse(source: any, scene: Scene, rootUrl: string): void;
  112303. }
  112304. }
  112305. declare module BABYLON {
  112306. /**
  112307. * @hidden
  112308. */
  112309. export interface IMaterialSheenDefines {
  112310. SHEEN: boolean;
  112311. SHEEN_TEXTURE: boolean;
  112312. SHEEN_TEXTUREDIRECTUV: number;
  112313. SHEEN_LINKWITHALBEDO: boolean;
  112314. /** @hidden */
  112315. _areTexturesDirty: boolean;
  112316. }
  112317. /**
  112318. * Define the code related to the Sheen parameters of the pbr material.
  112319. */
  112320. export class PBRSheenConfiguration {
  112321. private _isEnabled;
  112322. /**
  112323. * Defines if the material uses sheen.
  112324. */
  112325. isEnabled: boolean;
  112326. private _linkSheenWithAlbedo;
  112327. /**
  112328. * Defines if the sheen is linked to the sheen color.
  112329. */
  112330. linkSheenWithAlbedo: boolean;
  112331. /**
  112332. * Defines the sheen intensity.
  112333. */
  112334. intensity: number;
  112335. /**
  112336. * Defines the sheen color.
  112337. */
  112338. color: Color3;
  112339. private _texture;
  112340. /**
  112341. * Stores the sheen tint values in a texture.
  112342. * rgb is tint
  112343. * a is a intensity
  112344. */
  112345. texture: Nullable<BaseTexture>;
  112346. /** @hidden */
  112347. private _internalMarkAllSubMeshesAsTexturesDirty;
  112348. /** @hidden */
  112349. _markAllSubMeshesAsTexturesDirty(): void;
  112350. /**
  112351. * Instantiate a new istance of clear coat configuration.
  112352. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112353. */
  112354. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112355. /**
  112356. * Specifies that the submesh is ready to be used.
  112357. * @param defines the list of "defines" to update.
  112358. * @param scene defines the scene the material belongs to.
  112359. * @returns - boolean indicating that the submesh is ready or not.
  112360. */
  112361. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112362. /**
  112363. * Checks to see if a texture is used in the material.
  112364. * @param defines the list of "defines" to update.
  112365. * @param scene defines the scene the material belongs to.
  112366. */
  112367. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112368. /**
  112369. * Binds the material data.
  112370. * @param uniformBuffer defines the Uniform buffer to fill in.
  112371. * @param scene defines the scene the material belongs to.
  112372. * @param isFrozen defines wether the material is frozen or not.
  112373. */
  112374. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112375. /**
  112376. * Checks to see if a texture is used in the material.
  112377. * @param texture - Base texture to use.
  112378. * @returns - Boolean specifying if a texture is used in the material.
  112379. */
  112380. hasTexture(texture: BaseTexture): boolean;
  112381. /**
  112382. * Returns an array of the actively used textures.
  112383. * @param activeTextures Array of BaseTextures
  112384. */
  112385. getActiveTextures(activeTextures: BaseTexture[]): void;
  112386. /**
  112387. * Returns the animatable textures.
  112388. * @param animatables Array of animatable textures.
  112389. */
  112390. getAnimatables(animatables: IAnimatable[]): void;
  112391. /**
  112392. * Disposes the resources of the material.
  112393. * @param forceDisposeTextures - Forces the disposal of all textures.
  112394. */
  112395. dispose(forceDisposeTextures?: boolean): void;
  112396. /**
  112397. * Get the current class name of the texture useful for serialization or dynamic coding.
  112398. * @returns "PBRSheenConfiguration"
  112399. */
  112400. getClassName(): string;
  112401. /**
  112402. * Add fallbacks to the effect fallbacks list.
  112403. * @param defines defines the Base texture to use.
  112404. * @param fallbacks defines the current fallback list.
  112405. * @param currentRank defines the current fallback rank.
  112406. * @returns the new fallback rank.
  112407. */
  112408. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112409. /**
  112410. * Add the required uniforms to the current list.
  112411. * @param uniforms defines the current uniform list.
  112412. */
  112413. static AddUniforms(uniforms: string[]): void;
  112414. /**
  112415. * Add the required uniforms to the current buffer.
  112416. * @param uniformBuffer defines the current uniform buffer.
  112417. */
  112418. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112419. /**
  112420. * Add the required samplers to the current list.
  112421. * @param samplers defines the current sampler list.
  112422. */
  112423. static AddSamplers(samplers: string[]): void;
  112424. /**
  112425. * Makes a duplicate of the current configuration into another one.
  112426. * @param sheenConfiguration define the config where to copy the info
  112427. */
  112428. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112429. /**
  112430. * Serializes this BRDF configuration.
  112431. * @returns - An object with the serialized config.
  112432. */
  112433. serialize(): any;
  112434. /**
  112435. * Parses a anisotropy Configuration from a serialized object.
  112436. * @param source - Serialized object.
  112437. * @param scene Defines the scene we are parsing for
  112438. * @param rootUrl Defines the rootUrl to load from
  112439. */
  112440. parse(source: any, scene: Scene, rootUrl: string): void;
  112441. }
  112442. }
  112443. declare module BABYLON {
  112444. /**
  112445. * @hidden
  112446. */
  112447. export interface IMaterialSubSurfaceDefines {
  112448. SUBSURFACE: boolean;
  112449. SS_REFRACTION: boolean;
  112450. SS_TRANSLUCENCY: boolean;
  112451. SS_SCATERRING: boolean;
  112452. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112453. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112454. SS_REFRACTIONMAP_3D: boolean;
  112455. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112456. SS_LODINREFRACTIONALPHA: boolean;
  112457. SS_GAMMAREFRACTION: boolean;
  112458. SS_RGBDREFRACTION: boolean;
  112459. SS_LINEARSPECULARREFRACTION: boolean;
  112460. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112461. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112462. /** @hidden */
  112463. _areTexturesDirty: boolean;
  112464. }
  112465. /**
  112466. * Define the code related to the sub surface parameters of the pbr material.
  112467. */
  112468. export class PBRSubSurfaceConfiguration {
  112469. private _isRefractionEnabled;
  112470. /**
  112471. * Defines if the refraction is enabled in the material.
  112472. */
  112473. isRefractionEnabled: boolean;
  112474. private _isTranslucencyEnabled;
  112475. /**
  112476. * Defines if the translucency is enabled in the material.
  112477. */
  112478. isTranslucencyEnabled: boolean;
  112479. private _isScatteringEnabled;
  112480. /**
  112481. * Defines the refraction intensity of the material.
  112482. * The refraction when enabled replaces the Diffuse part of the material.
  112483. * The intensity helps transitionning between diffuse and refraction.
  112484. */
  112485. refractionIntensity: number;
  112486. /**
  112487. * Defines the translucency intensity of the material.
  112488. * When translucency has been enabled, this defines how much of the "translucency"
  112489. * is addded to the diffuse part of the material.
  112490. */
  112491. translucencyIntensity: number;
  112492. /**
  112493. * Defines the scattering intensity of the material.
  112494. * When scattering has been enabled, this defines how much of the "scattered light"
  112495. * is addded to the diffuse part of the material.
  112496. */
  112497. scatteringIntensity: number;
  112498. private _thicknessTexture;
  112499. /**
  112500. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112501. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112502. * 0 would mean minimumThickness
  112503. * 1 would mean maximumThickness
  112504. * The other channels might be use as a mask to vary the different effects intensity.
  112505. */
  112506. thicknessTexture: Nullable<BaseTexture>;
  112507. private _refractionTexture;
  112508. /**
  112509. * Defines the texture to use for refraction.
  112510. */
  112511. refractionTexture: Nullable<BaseTexture>;
  112512. private _indexOfRefraction;
  112513. /**
  112514. * Defines the index of refraction used in the material.
  112515. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112516. */
  112517. indexOfRefraction: number;
  112518. private _invertRefractionY;
  112519. /**
  112520. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112521. */
  112522. invertRefractionY: boolean;
  112523. private _linkRefractionWithTransparency;
  112524. /**
  112525. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112526. * Materials half opaque for instance using refraction could benefit from this control.
  112527. */
  112528. linkRefractionWithTransparency: boolean;
  112529. /**
  112530. * Defines the minimum thickness stored in the thickness map.
  112531. * If no thickness map is defined, this value will be used to simulate thickness.
  112532. */
  112533. minimumThickness: number;
  112534. /**
  112535. * Defines the maximum thickness stored in the thickness map.
  112536. */
  112537. maximumThickness: number;
  112538. /**
  112539. * Defines the volume tint of the material.
  112540. * This is used for both translucency and scattering.
  112541. */
  112542. tintColor: Color3;
  112543. /**
  112544. * Defines the distance at which the tint color should be found in the media.
  112545. * This is used for refraction only.
  112546. */
  112547. tintColorAtDistance: number;
  112548. /**
  112549. * Defines how far each channel transmit through the media.
  112550. * It is defined as a color to simplify it selection.
  112551. */
  112552. diffusionDistance: Color3;
  112553. private _useMaskFromThicknessTexture;
  112554. /**
  112555. * Stores the intensity of the different subsurface effects in the thickness texture.
  112556. * * the green channel is the translucency intensity.
  112557. * * the blue channel is the scattering intensity.
  112558. * * the alpha channel is the refraction intensity.
  112559. */
  112560. useMaskFromThicknessTexture: boolean;
  112561. /** @hidden */
  112562. private _internalMarkAllSubMeshesAsTexturesDirty;
  112563. /** @hidden */
  112564. _markAllSubMeshesAsTexturesDirty(): void;
  112565. /**
  112566. * Instantiate a new istance of sub surface configuration.
  112567. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112568. */
  112569. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112570. /**
  112571. * Gets wehter the submesh is ready to be used or not.
  112572. * @param defines the list of "defines" to update.
  112573. * @param scene defines the scene the material belongs to.
  112574. * @returns - boolean indicating that the submesh is ready or not.
  112575. */
  112576. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112577. /**
  112578. * Checks to see if a texture is used in the material.
  112579. * @param defines the list of "defines" to update.
  112580. * @param scene defines the scene to the material belongs to.
  112581. */
  112582. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112583. /**
  112584. * Binds the material data.
  112585. * @param uniformBuffer defines the Uniform buffer to fill in.
  112586. * @param scene defines the scene the material belongs to.
  112587. * @param engine defines the engine the material belongs to.
  112588. * @param isFrozen defines wether the material is frozen or not.
  112589. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112590. */
  112591. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112592. /**
  112593. * Unbinds the material from the mesh.
  112594. * @param activeEffect defines the effect that should be unbound from.
  112595. * @returns true if unbound, otherwise false
  112596. */
  112597. unbind(activeEffect: Effect): boolean;
  112598. /**
  112599. * Returns the texture used for refraction or null if none is used.
  112600. * @param scene defines the scene the material belongs to.
  112601. * @returns - Refraction texture if present. If no refraction texture and refraction
  112602. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112603. */
  112604. private _getRefractionTexture;
  112605. /**
  112606. * Returns true if alpha blending should be disabled.
  112607. */
  112608. readonly disableAlphaBlending: boolean;
  112609. /**
  112610. * Fills the list of render target textures.
  112611. * @param renderTargets the list of render targets to update
  112612. */
  112613. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112614. /**
  112615. * Checks to see if a texture is used in the material.
  112616. * @param texture - Base texture to use.
  112617. * @returns - Boolean specifying if a texture is used in the material.
  112618. */
  112619. hasTexture(texture: BaseTexture): boolean;
  112620. /**
  112621. * Gets a boolean indicating that current material needs to register RTT
  112622. * @returns true if this uses a render target otherwise false.
  112623. */
  112624. hasRenderTargetTextures(): boolean;
  112625. /**
  112626. * Returns an array of the actively used textures.
  112627. * @param activeTextures Array of BaseTextures
  112628. */
  112629. getActiveTextures(activeTextures: BaseTexture[]): void;
  112630. /**
  112631. * Returns the animatable textures.
  112632. * @param animatables Array of animatable textures.
  112633. */
  112634. getAnimatables(animatables: IAnimatable[]): void;
  112635. /**
  112636. * Disposes the resources of the material.
  112637. * @param forceDisposeTextures - Forces the disposal of all textures.
  112638. */
  112639. dispose(forceDisposeTextures?: boolean): void;
  112640. /**
  112641. * Get the current class name of the texture useful for serialization or dynamic coding.
  112642. * @returns "PBRSubSurfaceConfiguration"
  112643. */
  112644. getClassName(): string;
  112645. /**
  112646. * Add fallbacks to the effect fallbacks list.
  112647. * @param defines defines the Base texture to use.
  112648. * @param fallbacks defines the current fallback list.
  112649. * @param currentRank defines the current fallback rank.
  112650. * @returns the new fallback rank.
  112651. */
  112652. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112653. /**
  112654. * Add the required uniforms to the current list.
  112655. * @param uniforms defines the current uniform list.
  112656. */
  112657. static AddUniforms(uniforms: string[]): void;
  112658. /**
  112659. * Add the required samplers to the current list.
  112660. * @param samplers defines the current sampler list.
  112661. */
  112662. static AddSamplers(samplers: string[]): void;
  112663. /**
  112664. * Add the required uniforms to the current buffer.
  112665. * @param uniformBuffer defines the current uniform buffer.
  112666. */
  112667. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112668. /**
  112669. * Makes a duplicate of the current configuration into another one.
  112670. * @param configuration define the config where to copy the info
  112671. */
  112672. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112673. /**
  112674. * Serializes this Sub Surface configuration.
  112675. * @returns - An object with the serialized config.
  112676. */
  112677. serialize(): any;
  112678. /**
  112679. * Parses a anisotropy Configuration from a serialized object.
  112680. * @param source - Serialized object.
  112681. * @param scene Defines the scene we are parsing for
  112682. * @param rootUrl Defines the rootUrl to load from
  112683. */
  112684. parse(source: any, scene: Scene, rootUrl: string): void;
  112685. }
  112686. }
  112687. declare module BABYLON {
  112688. /** @hidden */
  112689. export var pbrFragmentDeclaration: {
  112690. name: string;
  112691. shader: string;
  112692. };
  112693. }
  112694. declare module BABYLON {
  112695. /** @hidden */
  112696. export var pbrUboDeclaration: {
  112697. name: string;
  112698. shader: string;
  112699. };
  112700. }
  112701. declare module BABYLON {
  112702. /** @hidden */
  112703. export var pbrFragmentExtraDeclaration: {
  112704. name: string;
  112705. shader: string;
  112706. };
  112707. }
  112708. declare module BABYLON {
  112709. /** @hidden */
  112710. export var pbrFragmentSamplersDeclaration: {
  112711. name: string;
  112712. shader: string;
  112713. };
  112714. }
  112715. declare module BABYLON {
  112716. /** @hidden */
  112717. export var pbrHelperFunctions: {
  112718. name: string;
  112719. shader: string;
  112720. };
  112721. }
  112722. declare module BABYLON {
  112723. /** @hidden */
  112724. export var harmonicsFunctions: {
  112725. name: string;
  112726. shader: string;
  112727. };
  112728. }
  112729. declare module BABYLON {
  112730. /** @hidden */
  112731. export var pbrDirectLightingSetupFunctions: {
  112732. name: string;
  112733. shader: string;
  112734. };
  112735. }
  112736. declare module BABYLON {
  112737. /** @hidden */
  112738. export var pbrDirectLightingFalloffFunctions: {
  112739. name: string;
  112740. shader: string;
  112741. };
  112742. }
  112743. declare module BABYLON {
  112744. /** @hidden */
  112745. export var pbrBRDFFunctions: {
  112746. name: string;
  112747. shader: string;
  112748. };
  112749. }
  112750. declare module BABYLON {
  112751. /** @hidden */
  112752. export var pbrDirectLightingFunctions: {
  112753. name: string;
  112754. shader: string;
  112755. };
  112756. }
  112757. declare module BABYLON {
  112758. /** @hidden */
  112759. export var pbrIBLFunctions: {
  112760. name: string;
  112761. shader: string;
  112762. };
  112763. }
  112764. declare module BABYLON {
  112765. /** @hidden */
  112766. export var pbrDebug: {
  112767. name: string;
  112768. shader: string;
  112769. };
  112770. }
  112771. declare module BABYLON {
  112772. /** @hidden */
  112773. export var pbrPixelShader: {
  112774. name: string;
  112775. shader: string;
  112776. };
  112777. }
  112778. declare module BABYLON {
  112779. /** @hidden */
  112780. export var pbrVertexDeclaration: {
  112781. name: string;
  112782. shader: string;
  112783. };
  112784. }
  112785. declare module BABYLON {
  112786. /** @hidden */
  112787. export var pbrVertexShader: {
  112788. name: string;
  112789. shader: string;
  112790. };
  112791. }
  112792. declare module BABYLON {
  112793. /**
  112794. * Manages the defines for the PBR Material.
  112795. * @hidden
  112796. */
  112797. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112798. PBR: boolean;
  112799. MAINUV1: boolean;
  112800. MAINUV2: boolean;
  112801. UV1: boolean;
  112802. UV2: boolean;
  112803. ALBEDO: boolean;
  112804. ALBEDODIRECTUV: number;
  112805. VERTEXCOLOR: boolean;
  112806. AMBIENT: boolean;
  112807. AMBIENTDIRECTUV: number;
  112808. AMBIENTINGRAYSCALE: boolean;
  112809. OPACITY: boolean;
  112810. VERTEXALPHA: boolean;
  112811. OPACITYDIRECTUV: number;
  112812. OPACITYRGB: boolean;
  112813. ALPHATEST: boolean;
  112814. DEPTHPREPASS: boolean;
  112815. ALPHABLEND: boolean;
  112816. ALPHAFROMALBEDO: boolean;
  112817. ALPHATESTVALUE: string;
  112818. SPECULAROVERALPHA: boolean;
  112819. RADIANCEOVERALPHA: boolean;
  112820. ALPHAFRESNEL: boolean;
  112821. LINEARALPHAFRESNEL: boolean;
  112822. PREMULTIPLYALPHA: boolean;
  112823. EMISSIVE: boolean;
  112824. EMISSIVEDIRECTUV: number;
  112825. REFLECTIVITY: boolean;
  112826. REFLECTIVITYDIRECTUV: number;
  112827. SPECULARTERM: boolean;
  112828. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112829. MICROSURFACEAUTOMATIC: boolean;
  112830. LODBASEDMICROSFURACE: boolean;
  112831. MICROSURFACEMAP: boolean;
  112832. MICROSURFACEMAPDIRECTUV: number;
  112833. METALLICWORKFLOW: boolean;
  112834. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112835. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112836. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112837. AOSTOREINMETALMAPRED: boolean;
  112838. ENVIRONMENTBRDF: boolean;
  112839. ENVIRONMENTBRDF_RGBD: boolean;
  112840. NORMAL: boolean;
  112841. TANGENT: boolean;
  112842. BUMP: boolean;
  112843. BUMPDIRECTUV: number;
  112844. OBJECTSPACE_NORMALMAP: boolean;
  112845. PARALLAX: boolean;
  112846. PARALLAXOCCLUSION: boolean;
  112847. NORMALXYSCALE: boolean;
  112848. LIGHTMAP: boolean;
  112849. LIGHTMAPDIRECTUV: number;
  112850. USELIGHTMAPASSHADOWMAP: boolean;
  112851. GAMMALIGHTMAP: boolean;
  112852. RGBDLIGHTMAP: boolean;
  112853. REFLECTION: boolean;
  112854. REFLECTIONMAP_3D: boolean;
  112855. REFLECTIONMAP_SPHERICAL: boolean;
  112856. REFLECTIONMAP_PLANAR: boolean;
  112857. REFLECTIONMAP_CUBIC: boolean;
  112858. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112859. REFLECTIONMAP_PROJECTION: boolean;
  112860. REFLECTIONMAP_SKYBOX: boolean;
  112861. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112862. REFLECTIONMAP_EXPLICIT: boolean;
  112863. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112864. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112865. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112866. INVERTCUBICMAP: boolean;
  112867. USESPHERICALFROMREFLECTIONMAP: boolean;
  112868. USEIRRADIANCEMAP: boolean;
  112869. SPHERICAL_HARMONICS: boolean;
  112870. USESPHERICALINVERTEX: boolean;
  112871. REFLECTIONMAP_OPPOSITEZ: boolean;
  112872. LODINREFLECTIONALPHA: boolean;
  112873. GAMMAREFLECTION: boolean;
  112874. RGBDREFLECTION: boolean;
  112875. LINEARSPECULARREFLECTION: boolean;
  112876. RADIANCEOCCLUSION: boolean;
  112877. HORIZONOCCLUSION: boolean;
  112878. INSTANCES: boolean;
  112879. NUM_BONE_INFLUENCERS: number;
  112880. BonesPerMesh: number;
  112881. BONETEXTURE: boolean;
  112882. NONUNIFORMSCALING: boolean;
  112883. MORPHTARGETS: boolean;
  112884. MORPHTARGETS_NORMAL: boolean;
  112885. MORPHTARGETS_TANGENT: boolean;
  112886. MORPHTARGETS_UV: boolean;
  112887. NUM_MORPH_INFLUENCERS: number;
  112888. IMAGEPROCESSING: boolean;
  112889. VIGNETTE: boolean;
  112890. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112891. VIGNETTEBLENDMODEOPAQUE: boolean;
  112892. TONEMAPPING: boolean;
  112893. TONEMAPPING_ACES: boolean;
  112894. CONTRAST: boolean;
  112895. COLORCURVES: boolean;
  112896. COLORGRADING: boolean;
  112897. COLORGRADING3D: boolean;
  112898. SAMPLER3DGREENDEPTH: boolean;
  112899. SAMPLER3DBGRMAP: boolean;
  112900. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112901. EXPOSURE: boolean;
  112902. MULTIVIEW: boolean;
  112903. USEPHYSICALLIGHTFALLOFF: boolean;
  112904. USEGLTFLIGHTFALLOFF: boolean;
  112905. TWOSIDEDLIGHTING: boolean;
  112906. SHADOWFLOAT: boolean;
  112907. CLIPPLANE: boolean;
  112908. CLIPPLANE2: boolean;
  112909. CLIPPLANE3: boolean;
  112910. CLIPPLANE4: boolean;
  112911. POINTSIZE: boolean;
  112912. FOG: boolean;
  112913. LOGARITHMICDEPTH: boolean;
  112914. FORCENORMALFORWARD: boolean;
  112915. SPECULARAA: boolean;
  112916. CLEARCOAT: boolean;
  112917. CLEARCOAT_DEFAULTIOR: boolean;
  112918. CLEARCOAT_TEXTURE: boolean;
  112919. CLEARCOAT_TEXTUREDIRECTUV: number;
  112920. CLEARCOAT_BUMP: boolean;
  112921. CLEARCOAT_BUMPDIRECTUV: number;
  112922. CLEARCOAT_TINT: boolean;
  112923. CLEARCOAT_TINT_TEXTURE: boolean;
  112924. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112925. ANISOTROPIC: boolean;
  112926. ANISOTROPIC_TEXTURE: boolean;
  112927. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112928. BRDF_V_HEIGHT_CORRELATED: boolean;
  112929. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112930. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112931. SHEEN: boolean;
  112932. SHEEN_TEXTURE: boolean;
  112933. SHEEN_TEXTUREDIRECTUV: number;
  112934. SHEEN_LINKWITHALBEDO: boolean;
  112935. SUBSURFACE: boolean;
  112936. SS_REFRACTION: boolean;
  112937. SS_TRANSLUCENCY: boolean;
  112938. SS_SCATERRING: boolean;
  112939. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112940. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112941. SS_REFRACTIONMAP_3D: boolean;
  112942. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112943. SS_LODINREFRACTIONALPHA: boolean;
  112944. SS_GAMMAREFRACTION: boolean;
  112945. SS_RGBDREFRACTION: boolean;
  112946. SS_LINEARSPECULARREFRACTION: boolean;
  112947. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112948. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112949. UNLIT: boolean;
  112950. DEBUGMODE: number;
  112951. /**
  112952. * Initializes the PBR Material defines.
  112953. */
  112954. constructor();
  112955. /**
  112956. * Resets the PBR Material defines.
  112957. */
  112958. reset(): void;
  112959. }
  112960. /**
  112961. * The Physically based material base class of BJS.
  112962. *
  112963. * This offers the main features of a standard PBR material.
  112964. * For more information, please refer to the documentation :
  112965. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112966. */
  112967. export abstract class PBRBaseMaterial extends PushMaterial {
  112968. /**
  112969. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112970. */
  112971. static readonly PBRMATERIAL_OPAQUE: number;
  112972. /**
  112973. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112974. */
  112975. static readonly PBRMATERIAL_ALPHATEST: number;
  112976. /**
  112977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112978. */
  112979. static readonly PBRMATERIAL_ALPHABLEND: number;
  112980. /**
  112981. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112982. * They are also discarded below the alpha cutoff threshold to improve performances.
  112983. */
  112984. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112985. /**
  112986. * Defines the default value of how much AO map is occluding the analytical lights
  112987. * (point spot...).
  112988. */
  112989. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112990. /**
  112991. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112992. */
  112993. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112994. /**
  112995. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112996. * to enhance interoperability with other engines.
  112997. */
  112998. static readonly LIGHTFALLOFF_GLTF: number;
  112999. /**
  113000. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  113001. * to enhance interoperability with other materials.
  113002. */
  113003. static readonly LIGHTFALLOFF_STANDARD: number;
  113004. /**
  113005. * Intensity of the direct lights e.g. the four lights available in your scene.
  113006. * This impacts both the direct diffuse and specular highlights.
  113007. */
  113008. protected _directIntensity: number;
  113009. /**
  113010. * Intensity of the emissive part of the material.
  113011. * This helps controlling the emissive effect without modifying the emissive color.
  113012. */
  113013. protected _emissiveIntensity: number;
  113014. /**
  113015. * Intensity of the environment e.g. how much the environment will light the object
  113016. * either through harmonics for rough material or through the refelction for shiny ones.
  113017. */
  113018. protected _environmentIntensity: number;
  113019. /**
  113020. * This is a special control allowing the reduction of the specular highlights coming from the
  113021. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113022. */
  113023. protected _specularIntensity: number;
  113024. /**
  113025. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  113026. */
  113027. private _lightingInfos;
  113028. /**
  113029. * Debug Control allowing disabling the bump map on this material.
  113030. */
  113031. protected _disableBumpMap: boolean;
  113032. /**
  113033. * AKA Diffuse Texture in standard nomenclature.
  113034. */
  113035. protected _albedoTexture: Nullable<BaseTexture>;
  113036. /**
  113037. * AKA Occlusion Texture in other nomenclature.
  113038. */
  113039. protected _ambientTexture: Nullable<BaseTexture>;
  113040. /**
  113041. * AKA Occlusion Texture Intensity in other nomenclature.
  113042. */
  113043. protected _ambientTextureStrength: number;
  113044. /**
  113045. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113046. * 1 means it completely occludes it
  113047. * 0 mean it has no impact
  113048. */
  113049. protected _ambientTextureImpactOnAnalyticalLights: number;
  113050. /**
  113051. * Stores the alpha values in a texture.
  113052. */
  113053. protected _opacityTexture: Nullable<BaseTexture>;
  113054. /**
  113055. * Stores the reflection values in a texture.
  113056. */
  113057. protected _reflectionTexture: Nullable<BaseTexture>;
  113058. /**
  113059. * Stores the emissive values in a texture.
  113060. */
  113061. protected _emissiveTexture: Nullable<BaseTexture>;
  113062. /**
  113063. * AKA Specular texture in other nomenclature.
  113064. */
  113065. protected _reflectivityTexture: Nullable<BaseTexture>;
  113066. /**
  113067. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113068. */
  113069. protected _metallicTexture: Nullable<BaseTexture>;
  113070. /**
  113071. * Specifies the metallic scalar of the metallic/roughness workflow.
  113072. * Can also be used to scale the metalness values of the metallic texture.
  113073. */
  113074. protected _metallic: Nullable<number>;
  113075. /**
  113076. * Specifies the roughness scalar of the metallic/roughness workflow.
  113077. * Can also be used to scale the roughness values of the metallic texture.
  113078. */
  113079. protected _roughness: Nullable<number>;
  113080. /**
  113081. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113082. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113083. */
  113084. protected _microSurfaceTexture: Nullable<BaseTexture>;
  113085. /**
  113086. * Stores surface normal data used to displace a mesh in a texture.
  113087. */
  113088. protected _bumpTexture: Nullable<BaseTexture>;
  113089. /**
  113090. * Stores the pre-calculated light information of a mesh in a texture.
  113091. */
  113092. protected _lightmapTexture: Nullable<BaseTexture>;
  113093. /**
  113094. * The color of a material in ambient lighting.
  113095. */
  113096. protected _ambientColor: Color3;
  113097. /**
  113098. * AKA Diffuse Color in other nomenclature.
  113099. */
  113100. protected _albedoColor: Color3;
  113101. /**
  113102. * AKA Specular Color in other nomenclature.
  113103. */
  113104. protected _reflectivityColor: Color3;
  113105. /**
  113106. * The color applied when light is reflected from a material.
  113107. */
  113108. protected _reflectionColor: Color3;
  113109. /**
  113110. * The color applied when light is emitted from a material.
  113111. */
  113112. protected _emissiveColor: Color3;
  113113. /**
  113114. * AKA Glossiness in other nomenclature.
  113115. */
  113116. protected _microSurface: number;
  113117. /**
  113118. * Specifies that the material will use the light map as a show map.
  113119. */
  113120. protected _useLightmapAsShadowmap: boolean;
  113121. /**
  113122. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113123. * makes the reflect vector face the model (under horizon).
  113124. */
  113125. protected _useHorizonOcclusion: boolean;
  113126. /**
  113127. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113128. * too much the area relying on ambient texture to define their ambient occlusion.
  113129. */
  113130. protected _useRadianceOcclusion: boolean;
  113131. /**
  113132. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113133. */
  113134. protected _useAlphaFromAlbedoTexture: boolean;
  113135. /**
  113136. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  113137. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113138. */
  113139. protected _useSpecularOverAlpha: boolean;
  113140. /**
  113141. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113142. */
  113143. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113144. /**
  113145. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113146. */
  113147. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  113148. /**
  113149. * Specifies if the metallic texture contains the roughness information in its green channel.
  113150. */
  113151. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113152. /**
  113153. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113154. */
  113155. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113156. /**
  113157. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113158. */
  113159. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113160. /**
  113161. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113162. */
  113163. protected _useAmbientInGrayScale: boolean;
  113164. /**
  113165. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113166. * The material will try to infer what glossiness each pixel should be.
  113167. */
  113168. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113169. /**
  113170. * Defines the falloff type used in this material.
  113171. * It by default is Physical.
  113172. */
  113173. protected _lightFalloff: number;
  113174. /**
  113175. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113176. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113177. */
  113178. protected _useRadianceOverAlpha: boolean;
  113179. /**
  113180. * Allows using an object space normal map (instead of tangent space).
  113181. */
  113182. protected _useObjectSpaceNormalMap: boolean;
  113183. /**
  113184. * Allows using the bump map in parallax mode.
  113185. */
  113186. protected _useParallax: boolean;
  113187. /**
  113188. * Allows using the bump map in parallax occlusion mode.
  113189. */
  113190. protected _useParallaxOcclusion: boolean;
  113191. /**
  113192. * Controls the scale bias of the parallax mode.
  113193. */
  113194. protected _parallaxScaleBias: number;
  113195. /**
  113196. * If sets to true, disables all the lights affecting the material.
  113197. */
  113198. protected _disableLighting: boolean;
  113199. /**
  113200. * Number of Simultaneous lights allowed on the material.
  113201. */
  113202. protected _maxSimultaneousLights: number;
  113203. /**
  113204. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113205. */
  113206. protected _invertNormalMapX: boolean;
  113207. /**
  113208. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113209. */
  113210. protected _invertNormalMapY: boolean;
  113211. /**
  113212. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113213. */
  113214. protected _twoSidedLighting: boolean;
  113215. /**
  113216. * Defines the alpha limits in alpha test mode.
  113217. */
  113218. protected _alphaCutOff: number;
  113219. /**
  113220. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113221. */
  113222. protected _forceAlphaTest: boolean;
  113223. /**
  113224. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113225. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113226. */
  113227. protected _useAlphaFresnel: boolean;
  113228. /**
  113229. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113230. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113231. */
  113232. protected _useLinearAlphaFresnel: boolean;
  113233. /**
  113234. * The transparency mode of the material.
  113235. */
  113236. protected _transparencyMode: Nullable<number>;
  113237. /**
  113238. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113239. * from cos thetav and roughness:
  113240. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113241. */
  113242. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113243. /**
  113244. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113245. */
  113246. protected _forceIrradianceInFragment: boolean;
  113247. /**
  113248. * Force normal to face away from face.
  113249. */
  113250. protected _forceNormalForward: boolean;
  113251. /**
  113252. * Enables specular anti aliasing in the PBR shader.
  113253. * It will both interacts on the Geometry for analytical and IBL lighting.
  113254. * It also prefilter the roughness map based on the bump values.
  113255. */
  113256. protected _enableSpecularAntiAliasing: boolean;
  113257. /**
  113258. * Default configuration related to image processing available in the PBR Material.
  113259. */
  113260. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113261. /**
  113262. * Keep track of the image processing observer to allow dispose and replace.
  113263. */
  113264. private _imageProcessingObserver;
  113265. /**
  113266. * Attaches a new image processing configuration to the PBR Material.
  113267. * @param configuration
  113268. */
  113269. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113270. /**
  113271. * Stores the available render targets.
  113272. */
  113273. private _renderTargets;
  113274. /**
  113275. * Sets the global ambient color for the material used in lighting calculations.
  113276. */
  113277. private _globalAmbientColor;
  113278. /**
  113279. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113280. */
  113281. private _useLogarithmicDepth;
  113282. /**
  113283. * If set to true, no lighting calculations will be applied.
  113284. */
  113285. private _unlit;
  113286. private _debugMode;
  113287. /**
  113288. * @hidden
  113289. * This is reserved for the inspector.
  113290. * Defines the material debug mode.
  113291. * It helps seeing only some components of the material while troubleshooting.
  113292. */
  113293. debugMode: number;
  113294. /**
  113295. * @hidden
  113296. * This is reserved for the inspector.
  113297. * Specify from where on screen the debug mode should start.
  113298. * The value goes from -1 (full screen) to 1 (not visible)
  113299. * It helps with side by side comparison against the final render
  113300. * This defaults to -1
  113301. */
  113302. private debugLimit;
  113303. /**
  113304. * @hidden
  113305. * This is reserved for the inspector.
  113306. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113307. * You can use the factor to better multiply the final value.
  113308. */
  113309. private debugFactor;
  113310. /**
  113311. * Defines the clear coat layer parameters for the material.
  113312. */
  113313. readonly clearCoat: PBRClearCoatConfiguration;
  113314. /**
  113315. * Defines the anisotropic parameters for the material.
  113316. */
  113317. readonly anisotropy: PBRAnisotropicConfiguration;
  113318. /**
  113319. * Defines the BRDF parameters for the material.
  113320. */
  113321. readonly brdf: PBRBRDFConfiguration;
  113322. /**
  113323. * Defines the Sheen parameters for the material.
  113324. */
  113325. readonly sheen: PBRSheenConfiguration;
  113326. /**
  113327. * Defines the SubSurface parameters for the material.
  113328. */
  113329. readonly subSurface: PBRSubSurfaceConfiguration;
  113330. /**
  113331. * Custom callback helping to override the default shader used in the material.
  113332. */
  113333. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113334. protected _rebuildInParallel: boolean;
  113335. /**
  113336. * Instantiates a new PBRMaterial instance.
  113337. *
  113338. * @param name The material name
  113339. * @param scene The scene the material will be use in.
  113340. */
  113341. constructor(name: string, scene: Scene);
  113342. /**
  113343. * Gets a boolean indicating that current material needs to register RTT
  113344. */
  113345. readonly hasRenderTargetTextures: boolean;
  113346. /**
  113347. * Gets the name of the material class.
  113348. */
  113349. getClassName(): string;
  113350. /**
  113351. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113352. */
  113353. /**
  113354. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113355. */
  113356. useLogarithmicDepth: boolean;
  113357. /**
  113358. * Gets the current transparency mode.
  113359. */
  113360. /**
  113361. * Sets the transparency mode of the material.
  113362. *
  113363. * | Value | Type | Description |
  113364. * | ----- | ----------------------------------- | ----------- |
  113365. * | 0 | OPAQUE | |
  113366. * | 1 | ALPHATEST | |
  113367. * | 2 | ALPHABLEND | |
  113368. * | 3 | ALPHATESTANDBLEND | |
  113369. *
  113370. */
  113371. transparencyMode: Nullable<number>;
  113372. /**
  113373. * Returns true if alpha blending should be disabled.
  113374. */
  113375. private readonly _disableAlphaBlending;
  113376. /**
  113377. * Specifies whether or not this material should be rendered in alpha blend mode.
  113378. */
  113379. needAlphaBlending(): boolean;
  113380. /**
  113381. * Specifies if the mesh will require alpha blending.
  113382. * @param mesh - BJS mesh.
  113383. */
  113384. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113385. /**
  113386. * Specifies whether or not this material should be rendered in alpha test mode.
  113387. */
  113388. needAlphaTesting(): boolean;
  113389. /**
  113390. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113391. */
  113392. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113393. /**
  113394. * Gets the texture used for the alpha test.
  113395. */
  113396. getAlphaTestTexture(): Nullable<BaseTexture>;
  113397. /**
  113398. * Specifies that the submesh is ready to be used.
  113399. * @param mesh - BJS mesh.
  113400. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113401. * @param useInstances - Specifies that instances should be used.
  113402. * @returns - boolean indicating that the submesh is ready or not.
  113403. */
  113404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113405. /**
  113406. * Specifies if the material uses metallic roughness workflow.
  113407. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113408. */
  113409. isMetallicWorkflow(): boolean;
  113410. private _prepareEffect;
  113411. private _prepareDefines;
  113412. /**
  113413. * Force shader compilation
  113414. */
  113415. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113416. clipPlane: boolean;
  113417. }>): void;
  113418. /**
  113419. * Initializes the uniform buffer layout for the shader.
  113420. */
  113421. buildUniformLayout(): void;
  113422. /**
  113423. * Unbinds the material from the mesh
  113424. */
  113425. unbind(): void;
  113426. /**
  113427. * Binds the submesh data.
  113428. * @param world - The world matrix.
  113429. * @param mesh - The BJS mesh.
  113430. * @param subMesh - A submesh of the BJS mesh.
  113431. */
  113432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113433. /**
  113434. * Returns the animatable textures.
  113435. * @returns - Array of animatable textures.
  113436. */
  113437. getAnimatables(): IAnimatable[];
  113438. /**
  113439. * Returns the texture used for reflections.
  113440. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113441. */
  113442. private _getReflectionTexture;
  113443. /**
  113444. * Returns an array of the actively used textures.
  113445. * @returns - Array of BaseTextures
  113446. */
  113447. getActiveTextures(): BaseTexture[];
  113448. /**
  113449. * Checks to see if a texture is used in the material.
  113450. * @param texture - Base texture to use.
  113451. * @returns - Boolean specifying if a texture is used in the material.
  113452. */
  113453. hasTexture(texture: BaseTexture): boolean;
  113454. /**
  113455. * Disposes the resources of the material.
  113456. * @param forceDisposeEffect - Forces the disposal of effects.
  113457. * @param forceDisposeTextures - Forces the disposal of all textures.
  113458. */
  113459. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113460. }
  113461. }
  113462. declare module BABYLON {
  113463. /**
  113464. * The Physically based material of BJS.
  113465. *
  113466. * This offers the main features of a standard PBR material.
  113467. * For more information, please refer to the documentation :
  113468. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113469. */
  113470. export class PBRMaterial extends PBRBaseMaterial {
  113471. /**
  113472. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113473. */
  113474. static readonly PBRMATERIAL_OPAQUE: number;
  113475. /**
  113476. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113477. */
  113478. static readonly PBRMATERIAL_ALPHATEST: number;
  113479. /**
  113480. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113481. */
  113482. static readonly PBRMATERIAL_ALPHABLEND: number;
  113483. /**
  113484. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113485. * They are also discarded below the alpha cutoff threshold to improve performances.
  113486. */
  113487. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113488. /**
  113489. * Defines the default value of how much AO map is occluding the analytical lights
  113490. * (point spot...).
  113491. */
  113492. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113493. /**
  113494. * Intensity of the direct lights e.g. the four lights available in your scene.
  113495. * This impacts both the direct diffuse and specular highlights.
  113496. */
  113497. directIntensity: number;
  113498. /**
  113499. * Intensity of the emissive part of the material.
  113500. * This helps controlling the emissive effect without modifying the emissive color.
  113501. */
  113502. emissiveIntensity: number;
  113503. /**
  113504. * Intensity of the environment e.g. how much the environment will light the object
  113505. * either through harmonics for rough material or through the refelction for shiny ones.
  113506. */
  113507. environmentIntensity: number;
  113508. /**
  113509. * This is a special control allowing the reduction of the specular highlights coming from the
  113510. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113511. */
  113512. specularIntensity: number;
  113513. /**
  113514. * Debug Control allowing disabling the bump map on this material.
  113515. */
  113516. disableBumpMap: boolean;
  113517. /**
  113518. * AKA Diffuse Texture in standard nomenclature.
  113519. */
  113520. albedoTexture: BaseTexture;
  113521. /**
  113522. * AKA Occlusion Texture in other nomenclature.
  113523. */
  113524. ambientTexture: BaseTexture;
  113525. /**
  113526. * AKA Occlusion Texture Intensity in other nomenclature.
  113527. */
  113528. ambientTextureStrength: number;
  113529. /**
  113530. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113531. * 1 means it completely occludes it
  113532. * 0 mean it has no impact
  113533. */
  113534. ambientTextureImpactOnAnalyticalLights: number;
  113535. /**
  113536. * Stores the alpha values in a texture.
  113537. */
  113538. opacityTexture: BaseTexture;
  113539. /**
  113540. * Stores the reflection values in a texture.
  113541. */
  113542. reflectionTexture: Nullable<BaseTexture>;
  113543. /**
  113544. * Stores the emissive values in a texture.
  113545. */
  113546. emissiveTexture: BaseTexture;
  113547. /**
  113548. * AKA Specular texture in other nomenclature.
  113549. */
  113550. reflectivityTexture: BaseTexture;
  113551. /**
  113552. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113553. */
  113554. metallicTexture: BaseTexture;
  113555. /**
  113556. * Specifies the metallic scalar of the metallic/roughness workflow.
  113557. * Can also be used to scale the metalness values of the metallic texture.
  113558. */
  113559. metallic: Nullable<number>;
  113560. /**
  113561. * Specifies the roughness scalar of the metallic/roughness workflow.
  113562. * Can also be used to scale the roughness values of the metallic texture.
  113563. */
  113564. roughness: Nullable<number>;
  113565. /**
  113566. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113567. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113568. */
  113569. microSurfaceTexture: BaseTexture;
  113570. /**
  113571. * Stores surface normal data used to displace a mesh in a texture.
  113572. */
  113573. bumpTexture: BaseTexture;
  113574. /**
  113575. * Stores the pre-calculated light information of a mesh in a texture.
  113576. */
  113577. lightmapTexture: BaseTexture;
  113578. /**
  113579. * Stores the refracted light information in a texture.
  113580. */
  113581. refractionTexture: Nullable<BaseTexture>;
  113582. /**
  113583. * The color of a material in ambient lighting.
  113584. */
  113585. ambientColor: Color3;
  113586. /**
  113587. * AKA Diffuse Color in other nomenclature.
  113588. */
  113589. albedoColor: Color3;
  113590. /**
  113591. * AKA Specular Color in other nomenclature.
  113592. */
  113593. reflectivityColor: Color3;
  113594. /**
  113595. * The color reflected from the material.
  113596. */
  113597. reflectionColor: Color3;
  113598. /**
  113599. * The color emitted from the material.
  113600. */
  113601. emissiveColor: Color3;
  113602. /**
  113603. * AKA Glossiness in other nomenclature.
  113604. */
  113605. microSurface: number;
  113606. /**
  113607. * source material index of refraction (IOR)' / 'destination material IOR.
  113608. */
  113609. indexOfRefraction: number;
  113610. /**
  113611. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113612. */
  113613. invertRefractionY: boolean;
  113614. /**
  113615. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113616. * Materials half opaque for instance using refraction could benefit from this control.
  113617. */
  113618. linkRefractionWithTransparency: boolean;
  113619. /**
  113620. * If true, the light map contains occlusion information instead of lighting info.
  113621. */
  113622. useLightmapAsShadowmap: boolean;
  113623. /**
  113624. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113625. */
  113626. useAlphaFromAlbedoTexture: boolean;
  113627. /**
  113628. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113629. */
  113630. forceAlphaTest: boolean;
  113631. /**
  113632. * Defines the alpha limits in alpha test mode.
  113633. */
  113634. alphaCutOff: number;
  113635. /**
  113636. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113637. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113638. */
  113639. useSpecularOverAlpha: boolean;
  113640. /**
  113641. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113642. */
  113643. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113644. /**
  113645. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113646. */
  113647. useRoughnessFromMetallicTextureAlpha: boolean;
  113648. /**
  113649. * Specifies if the metallic texture contains the roughness information in its green channel.
  113650. */
  113651. useRoughnessFromMetallicTextureGreen: boolean;
  113652. /**
  113653. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113654. */
  113655. useMetallnessFromMetallicTextureBlue: boolean;
  113656. /**
  113657. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113658. */
  113659. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113660. /**
  113661. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113662. */
  113663. useAmbientInGrayScale: boolean;
  113664. /**
  113665. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113666. * The material will try to infer what glossiness each pixel should be.
  113667. */
  113668. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113669. /**
  113670. * BJS is using an harcoded light falloff based on a manually sets up range.
  113671. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113672. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113673. */
  113674. /**
  113675. * BJS is using an harcoded light falloff based on a manually sets up range.
  113676. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113677. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113678. */
  113679. usePhysicalLightFalloff: boolean;
  113680. /**
  113681. * In order to support the falloff compatibility with gltf, a special mode has been added
  113682. * to reproduce the gltf light falloff.
  113683. */
  113684. /**
  113685. * In order to support the falloff compatibility with gltf, a special mode has been added
  113686. * to reproduce the gltf light falloff.
  113687. */
  113688. useGLTFLightFalloff: boolean;
  113689. /**
  113690. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113691. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113692. */
  113693. useRadianceOverAlpha: boolean;
  113694. /**
  113695. * Allows using an object space normal map (instead of tangent space).
  113696. */
  113697. useObjectSpaceNormalMap: boolean;
  113698. /**
  113699. * Allows using the bump map in parallax mode.
  113700. */
  113701. useParallax: boolean;
  113702. /**
  113703. * Allows using the bump map in parallax occlusion mode.
  113704. */
  113705. useParallaxOcclusion: boolean;
  113706. /**
  113707. * Controls the scale bias of the parallax mode.
  113708. */
  113709. parallaxScaleBias: number;
  113710. /**
  113711. * If sets to true, disables all the lights affecting the material.
  113712. */
  113713. disableLighting: boolean;
  113714. /**
  113715. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113716. */
  113717. forceIrradianceInFragment: boolean;
  113718. /**
  113719. * Number of Simultaneous lights allowed on the material.
  113720. */
  113721. maxSimultaneousLights: number;
  113722. /**
  113723. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113724. */
  113725. invertNormalMapX: boolean;
  113726. /**
  113727. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113728. */
  113729. invertNormalMapY: boolean;
  113730. /**
  113731. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113732. */
  113733. twoSidedLighting: boolean;
  113734. /**
  113735. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113736. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113737. */
  113738. useAlphaFresnel: boolean;
  113739. /**
  113740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113741. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113742. */
  113743. useLinearAlphaFresnel: boolean;
  113744. /**
  113745. * Let user defines the brdf lookup texture used for IBL.
  113746. * A default 8bit version is embedded but you could point at :
  113747. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113748. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113749. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113750. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113751. */
  113752. environmentBRDFTexture: Nullable<BaseTexture>;
  113753. /**
  113754. * Force normal to face away from face.
  113755. */
  113756. forceNormalForward: boolean;
  113757. /**
  113758. * Enables specular anti aliasing in the PBR shader.
  113759. * It will both interacts on the Geometry for analytical and IBL lighting.
  113760. * It also prefilter the roughness map based on the bump values.
  113761. */
  113762. enableSpecularAntiAliasing: boolean;
  113763. /**
  113764. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113765. * makes the reflect vector face the model (under horizon).
  113766. */
  113767. useHorizonOcclusion: boolean;
  113768. /**
  113769. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113770. * too much the area relying on ambient texture to define their ambient occlusion.
  113771. */
  113772. useRadianceOcclusion: boolean;
  113773. /**
  113774. * If set to true, no lighting calculations will be applied.
  113775. */
  113776. unlit: boolean;
  113777. /**
  113778. * Gets the image processing configuration used either in this material.
  113779. */
  113780. /**
  113781. * Sets the Default image processing configuration used either in the this material.
  113782. *
  113783. * If sets to null, the scene one is in use.
  113784. */
  113785. imageProcessingConfiguration: ImageProcessingConfiguration;
  113786. /**
  113787. * Gets wether the color curves effect is enabled.
  113788. */
  113789. /**
  113790. * Sets wether the color curves effect is enabled.
  113791. */
  113792. cameraColorCurvesEnabled: boolean;
  113793. /**
  113794. * Gets wether the color grading effect is enabled.
  113795. */
  113796. /**
  113797. * Gets wether the color grading effect is enabled.
  113798. */
  113799. cameraColorGradingEnabled: boolean;
  113800. /**
  113801. * Gets wether tonemapping is enabled or not.
  113802. */
  113803. /**
  113804. * Sets wether tonemapping is enabled or not
  113805. */
  113806. cameraToneMappingEnabled: boolean;
  113807. /**
  113808. * The camera exposure used on this material.
  113809. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113810. * This corresponds to a photographic exposure.
  113811. */
  113812. /**
  113813. * The camera exposure used on this material.
  113814. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113815. * This corresponds to a photographic exposure.
  113816. */
  113817. cameraExposure: number;
  113818. /**
  113819. * Gets The camera contrast used on this material.
  113820. */
  113821. /**
  113822. * Sets The camera contrast used on this material.
  113823. */
  113824. cameraContrast: number;
  113825. /**
  113826. * Gets the Color Grading 2D Lookup Texture.
  113827. */
  113828. /**
  113829. * Sets the Color Grading 2D Lookup Texture.
  113830. */
  113831. cameraColorGradingTexture: Nullable<BaseTexture>;
  113832. /**
  113833. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113834. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113835. * 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;
  113836. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113837. */
  113838. /**
  113839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113841. * 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;
  113842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113843. */
  113844. cameraColorCurves: Nullable<ColorCurves>;
  113845. /**
  113846. * Instantiates a new PBRMaterial instance.
  113847. *
  113848. * @param name The material name
  113849. * @param scene The scene the material will be use in.
  113850. */
  113851. constructor(name: string, scene: Scene);
  113852. /**
  113853. * Returns the name of this material class.
  113854. */
  113855. getClassName(): string;
  113856. /**
  113857. * Makes a duplicate of the current material.
  113858. * @param name - name to use for the new material.
  113859. */
  113860. clone(name: string): PBRMaterial;
  113861. /**
  113862. * Serializes this PBR Material.
  113863. * @returns - An object with the serialized material.
  113864. */
  113865. serialize(): any;
  113866. /**
  113867. * Parses a PBR Material from a serialized object.
  113868. * @param source - Serialized object.
  113869. * @param scene - BJS scene instance.
  113870. * @param rootUrl - url for the scene object
  113871. * @returns - PBRMaterial
  113872. */
  113873. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113874. }
  113875. }
  113876. declare module BABYLON {
  113877. /**
  113878. * Direct draw surface info
  113879. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113880. */
  113881. export interface DDSInfo {
  113882. /**
  113883. * Width of the texture
  113884. */
  113885. width: number;
  113886. /**
  113887. * Width of the texture
  113888. */
  113889. height: number;
  113890. /**
  113891. * Number of Mipmaps for the texture
  113892. * @see https://en.wikipedia.org/wiki/Mipmap
  113893. */
  113894. mipmapCount: number;
  113895. /**
  113896. * If the textures format is a known fourCC format
  113897. * @see https://www.fourcc.org/
  113898. */
  113899. isFourCC: boolean;
  113900. /**
  113901. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113902. */
  113903. isRGB: boolean;
  113904. /**
  113905. * If the texture is a lumincance format
  113906. */
  113907. isLuminance: boolean;
  113908. /**
  113909. * If this is a cube texture
  113910. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113911. */
  113912. isCube: boolean;
  113913. /**
  113914. * If the texture is a compressed format eg. FOURCC_DXT1
  113915. */
  113916. isCompressed: boolean;
  113917. /**
  113918. * The dxgiFormat of the texture
  113919. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113920. */
  113921. dxgiFormat: number;
  113922. /**
  113923. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113924. */
  113925. textureType: number;
  113926. /**
  113927. * Sphericle polynomial created for the dds texture
  113928. */
  113929. sphericalPolynomial?: SphericalPolynomial;
  113930. }
  113931. /**
  113932. * Class used to provide DDS decompression tools
  113933. */
  113934. export class DDSTools {
  113935. /**
  113936. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113937. */
  113938. static StoreLODInAlphaChannel: boolean;
  113939. /**
  113940. * Gets DDS information from an array buffer
  113941. * @param arrayBuffer defines the array buffer to read data from
  113942. * @returns the DDS information
  113943. */
  113944. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113945. private static _FloatView;
  113946. private static _Int32View;
  113947. private static _ToHalfFloat;
  113948. private static _FromHalfFloat;
  113949. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113950. private static _GetHalfFloatRGBAArrayBuffer;
  113951. private static _GetFloatRGBAArrayBuffer;
  113952. private static _GetFloatAsUIntRGBAArrayBuffer;
  113953. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113954. private static _GetRGBAArrayBuffer;
  113955. private static _ExtractLongWordOrder;
  113956. private static _GetRGBArrayBuffer;
  113957. private static _GetLuminanceArrayBuffer;
  113958. /**
  113959. * Uploads DDS Levels to a Babylon Texture
  113960. * @hidden
  113961. */
  113962. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113963. }
  113964. interface Engine {
  113965. /**
  113966. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113967. * @param rootUrl defines the url where the file to load is located
  113968. * @param scene defines the current scene
  113969. * @param lodScale defines scale to apply to the mip map selection
  113970. * @param lodOffset defines offset to apply to the mip map selection
  113971. * @param onLoad defines an optional callback raised when the texture is loaded
  113972. * @param onError defines an optional callback raised if there is an issue to load the texture
  113973. * @param format defines the format of the data
  113974. * @param forcedExtension defines the extension to use to pick the right loader
  113975. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113976. * @returns the cube texture as an InternalTexture
  113977. */
  113978. 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;
  113979. }
  113980. }
  113981. declare module BABYLON {
  113982. /**
  113983. * Implementation of the DDS Texture Loader.
  113984. * @hidden
  113985. */
  113986. export class _DDSTextureLoader implements IInternalTextureLoader {
  113987. /**
  113988. * Defines wether the loader supports cascade loading the different faces.
  113989. */
  113990. readonly supportCascades: boolean;
  113991. /**
  113992. * This returns if the loader support the current file information.
  113993. * @param extension defines the file extension of the file being loaded
  113994. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113995. * @param fallback defines the fallback internal texture if any
  113996. * @param isBase64 defines whether the texture is encoded as a base64
  113997. * @param isBuffer defines whether the texture data are stored as a buffer
  113998. * @returns true if the loader can load the specified file
  113999. */
  114000. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114001. /**
  114002. * Transform the url before loading if required.
  114003. * @param rootUrl the url of the texture
  114004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114005. * @returns the transformed texture
  114006. */
  114007. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114008. /**
  114009. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114010. * @param rootUrl the url of the texture
  114011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114012. * @returns the fallback texture
  114013. */
  114014. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114015. /**
  114016. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114017. * @param data contains the texture data
  114018. * @param texture defines the BabylonJS internal texture
  114019. * @param createPolynomials will be true if polynomials have been requested
  114020. * @param onLoad defines the callback to trigger once the texture is ready
  114021. * @param onError defines the callback to trigger in case of error
  114022. */
  114023. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114024. /**
  114025. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114026. * @param data contains the texture data
  114027. * @param texture defines the BabylonJS internal texture
  114028. * @param callback defines the method to call once ready to upload
  114029. */
  114030. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114031. }
  114032. }
  114033. declare module BABYLON {
  114034. /**
  114035. * Implementation of the ENV Texture Loader.
  114036. * @hidden
  114037. */
  114038. export class _ENVTextureLoader implements IInternalTextureLoader {
  114039. /**
  114040. * Defines wether the loader supports cascade loading the different faces.
  114041. */
  114042. readonly supportCascades: boolean;
  114043. /**
  114044. * This returns if the loader support the current file information.
  114045. * @param extension defines the file extension of the file being loaded
  114046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114047. * @param fallback defines the fallback internal texture if any
  114048. * @param isBase64 defines whether the texture is encoded as a base64
  114049. * @param isBuffer defines whether the texture data are stored as a buffer
  114050. * @returns true if the loader can load the specified file
  114051. */
  114052. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114053. /**
  114054. * Transform the url before loading if required.
  114055. * @param rootUrl the url of the texture
  114056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114057. * @returns the transformed texture
  114058. */
  114059. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114060. /**
  114061. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114062. * @param rootUrl the url of the texture
  114063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114064. * @returns the fallback texture
  114065. */
  114066. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114067. /**
  114068. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114069. * @param data contains the texture data
  114070. * @param texture defines the BabylonJS internal texture
  114071. * @param createPolynomials will be true if polynomials have been requested
  114072. * @param onLoad defines the callback to trigger once the texture is ready
  114073. * @param onError defines the callback to trigger in case of error
  114074. */
  114075. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114076. /**
  114077. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114078. * @param data contains the texture data
  114079. * @param texture defines the BabylonJS internal texture
  114080. * @param callback defines the method to call once ready to upload
  114081. */
  114082. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114083. }
  114084. }
  114085. declare module BABYLON {
  114086. /**
  114087. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  114088. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  114089. */
  114090. export class KhronosTextureContainer {
  114091. /** contents of the KTX container file */
  114092. arrayBuffer: any;
  114093. private static HEADER_LEN;
  114094. private static COMPRESSED_2D;
  114095. private static COMPRESSED_3D;
  114096. private static TEX_2D;
  114097. private static TEX_3D;
  114098. /**
  114099. * Gets the openGL type
  114100. */
  114101. glType: number;
  114102. /**
  114103. * Gets the openGL type size
  114104. */
  114105. glTypeSize: number;
  114106. /**
  114107. * Gets the openGL format
  114108. */
  114109. glFormat: number;
  114110. /**
  114111. * Gets the openGL internal format
  114112. */
  114113. glInternalFormat: number;
  114114. /**
  114115. * Gets the base internal format
  114116. */
  114117. glBaseInternalFormat: number;
  114118. /**
  114119. * Gets image width in pixel
  114120. */
  114121. pixelWidth: number;
  114122. /**
  114123. * Gets image height in pixel
  114124. */
  114125. pixelHeight: number;
  114126. /**
  114127. * Gets image depth in pixels
  114128. */
  114129. pixelDepth: number;
  114130. /**
  114131. * Gets the number of array elements
  114132. */
  114133. numberOfArrayElements: number;
  114134. /**
  114135. * Gets the number of faces
  114136. */
  114137. numberOfFaces: number;
  114138. /**
  114139. * Gets the number of mipmap levels
  114140. */
  114141. numberOfMipmapLevels: number;
  114142. /**
  114143. * Gets the bytes of key value data
  114144. */
  114145. bytesOfKeyValueData: number;
  114146. /**
  114147. * Gets the load type
  114148. */
  114149. loadType: number;
  114150. /**
  114151. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114152. */
  114153. isInvalid: boolean;
  114154. /**
  114155. * Creates a new KhronosTextureContainer
  114156. * @param arrayBuffer contents of the KTX container file
  114157. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114158. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114159. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114160. */
  114161. constructor(
  114162. /** contents of the KTX container file */
  114163. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114164. /**
  114165. * Uploads KTX content to a Babylon Texture.
  114166. * It is assumed that the texture has already been created & is currently bound
  114167. * @hidden
  114168. */
  114169. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114170. private _upload2DCompressedLevels;
  114171. }
  114172. }
  114173. declare module BABYLON {
  114174. /**
  114175. * Implementation of the KTX Texture Loader.
  114176. * @hidden
  114177. */
  114178. export class _KTXTextureLoader implements IInternalTextureLoader {
  114179. /**
  114180. * Defines wether the loader supports cascade loading the different faces.
  114181. */
  114182. readonly supportCascades: boolean;
  114183. /**
  114184. * This returns if the loader support the current file information.
  114185. * @param extension defines the file extension of the file being loaded
  114186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114187. * @param fallback defines the fallback internal texture if any
  114188. * @param isBase64 defines whether the texture is encoded as a base64
  114189. * @param isBuffer defines whether the texture data are stored as a buffer
  114190. * @returns true if the loader can load the specified file
  114191. */
  114192. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114193. /**
  114194. * Transform the url before loading if required.
  114195. * @param rootUrl the url of the texture
  114196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114197. * @returns the transformed texture
  114198. */
  114199. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114200. /**
  114201. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114202. * @param rootUrl the url of the texture
  114203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114204. * @returns the fallback texture
  114205. */
  114206. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114207. /**
  114208. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114209. * @param data contains the texture data
  114210. * @param texture defines the BabylonJS internal texture
  114211. * @param createPolynomials will be true if polynomials have been requested
  114212. * @param onLoad defines the callback to trigger once the texture is ready
  114213. * @param onError defines the callback to trigger in case of error
  114214. */
  114215. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114216. /**
  114217. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114218. * @param data contains the texture data
  114219. * @param texture defines the BabylonJS internal texture
  114220. * @param callback defines the method to call once ready to upload
  114221. */
  114222. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114223. }
  114224. }
  114225. declare module BABYLON {
  114226. /**
  114227. * Options for the default xr helper
  114228. */
  114229. export class WebXRDefaultExperienceOptions {
  114230. /**
  114231. * Floor meshes that should be used for teleporting
  114232. */
  114233. floorMeshes: Array<AbstractMesh>;
  114234. }
  114235. /**
  114236. * Default experience which provides a similar setup to the previous webVRExperience
  114237. */
  114238. export class WebXRDefaultExperience {
  114239. /**
  114240. * Base experience
  114241. */
  114242. baseExperience: WebXRExperienceHelper;
  114243. /**
  114244. * Input experience extension
  114245. */
  114246. input: WebXRInput;
  114247. /**
  114248. * Loads the controller models
  114249. */
  114250. controllerModelLoader: WebXRControllerModelLoader;
  114251. /**
  114252. * Enables laser pointer and selection
  114253. */
  114254. pointerSelection: WebXRControllerPointerSelection;
  114255. /**
  114256. * Enables teleportation
  114257. */
  114258. teleportation: WebXRControllerTeleportation;
  114259. /**
  114260. * Enables ui for enetering/exiting xr
  114261. */
  114262. enterExitUI: WebXREnterExitUI;
  114263. /**
  114264. * Default output canvas xr should render to
  114265. */
  114266. outputCanvas: WebXRManagedOutputCanvas;
  114267. /**
  114268. * Creates the default xr experience
  114269. * @param scene scene
  114270. * @param options options for basic configuration
  114271. * @returns resulting WebXRDefaultExperience
  114272. */
  114273. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114274. private constructor();
  114275. /**
  114276. * DIsposes of the experience helper
  114277. */
  114278. dispose(): void;
  114279. }
  114280. }
  114281. declare module BABYLON {
  114282. /** @hidden */
  114283. export var _forceSceneHelpersToBundle: boolean;
  114284. interface Scene {
  114285. /**
  114286. * Creates a default light for the scene.
  114287. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114288. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114289. */
  114290. createDefaultLight(replace?: boolean): void;
  114291. /**
  114292. * Creates a default camera for the scene.
  114293. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114294. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114295. * @param replace has default false, when true replaces the active camera in the scene
  114296. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114297. */
  114298. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114299. /**
  114300. * Creates a default camera and a default light.
  114301. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114302. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114303. * @param replace has the default false, when true replaces the active camera/light in the scene
  114304. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114305. */
  114306. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114307. /**
  114308. * Creates a new sky box
  114309. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114310. * @param environmentTexture defines the texture to use as environment texture
  114311. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114312. * @param scale defines the overall scale of the skybox
  114313. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114314. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114315. * @returns a new mesh holding the sky box
  114316. */
  114317. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114318. /**
  114319. * Creates a new environment
  114320. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114321. * @param options defines the options you can use to configure the environment
  114322. * @returns the new EnvironmentHelper
  114323. */
  114324. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114325. /**
  114326. * Creates a new VREXperienceHelper
  114327. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114328. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114329. * @returns a new VREXperienceHelper
  114330. */
  114331. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114332. /**
  114333. * Creates a new WebXRDefaultExperience
  114334. * @see http://doc.babylonjs.com/how_to/webxr
  114335. * @param options experience options
  114336. * @returns a promise for a new WebXRDefaultExperience
  114337. */
  114338. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114339. }
  114340. }
  114341. declare module BABYLON {
  114342. /**
  114343. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114344. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114345. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114346. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114347. */
  114348. export class VideoDome extends TransformNode {
  114349. /**
  114350. * Define the video source as a Monoscopic panoramic 360 video.
  114351. */
  114352. static readonly MODE_MONOSCOPIC: number;
  114353. /**
  114354. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114355. */
  114356. static readonly MODE_TOPBOTTOM: number;
  114357. /**
  114358. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114359. */
  114360. static readonly MODE_SIDEBYSIDE: number;
  114361. private _halfDome;
  114362. private _useDirectMapping;
  114363. /**
  114364. * The video texture being displayed on the sphere
  114365. */
  114366. protected _videoTexture: VideoTexture;
  114367. /**
  114368. * Gets the video texture being displayed on the sphere
  114369. */
  114370. readonly videoTexture: VideoTexture;
  114371. /**
  114372. * The skybox material
  114373. */
  114374. protected _material: BackgroundMaterial;
  114375. /**
  114376. * The surface used for the skybox
  114377. */
  114378. protected _mesh: Mesh;
  114379. /**
  114380. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114381. */
  114382. private _halfDomeMask;
  114383. /**
  114384. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114385. * Also see the options.resolution property.
  114386. */
  114387. fovMultiplier: number;
  114388. private _videoMode;
  114389. /**
  114390. * Gets or set the current video mode for the video. It can be:
  114391. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114392. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114393. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114394. */
  114395. videoMode: number;
  114396. /**
  114397. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114398. *
  114399. */
  114400. /**
  114401. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114402. */
  114403. halfDome: boolean;
  114404. /**
  114405. * Oberserver used in Stereoscopic VR Mode.
  114406. */
  114407. private _onBeforeCameraRenderObserver;
  114408. /**
  114409. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114410. * @param name Element's name, child elements will append suffixes for their own names.
  114411. * @param urlsOrVideo defines the url(s) or the video element to use
  114412. * @param options An object containing optional or exposed sub element properties
  114413. */
  114414. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114415. resolution?: number;
  114416. clickToPlay?: boolean;
  114417. autoPlay?: boolean;
  114418. loop?: boolean;
  114419. size?: number;
  114420. poster?: string;
  114421. faceForward?: boolean;
  114422. useDirectMapping?: boolean;
  114423. halfDomeMode?: boolean;
  114424. }, scene: Scene);
  114425. private _changeVideoMode;
  114426. /**
  114427. * Releases resources associated with this node.
  114428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114430. */
  114431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114432. }
  114433. }
  114434. declare module BABYLON {
  114435. /**
  114436. * This class can be used to get instrumentation data from a Babylon engine
  114437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114438. */
  114439. export class EngineInstrumentation implements IDisposable {
  114440. /**
  114441. * Define the instrumented engine.
  114442. */
  114443. engine: Engine;
  114444. private _captureGPUFrameTime;
  114445. private _gpuFrameTimeToken;
  114446. private _gpuFrameTime;
  114447. private _captureShaderCompilationTime;
  114448. private _shaderCompilationTime;
  114449. private _onBeginFrameObserver;
  114450. private _onEndFrameObserver;
  114451. private _onBeforeShaderCompilationObserver;
  114452. private _onAfterShaderCompilationObserver;
  114453. /**
  114454. * Gets the perf counter used for GPU frame time
  114455. */
  114456. readonly gpuFrameTimeCounter: PerfCounter;
  114457. /**
  114458. * Gets the GPU frame time capture status
  114459. */
  114460. /**
  114461. * Enable or disable the GPU frame time capture
  114462. */
  114463. captureGPUFrameTime: boolean;
  114464. /**
  114465. * Gets the perf counter used for shader compilation time
  114466. */
  114467. readonly shaderCompilationTimeCounter: PerfCounter;
  114468. /**
  114469. * Gets the shader compilation time capture status
  114470. */
  114471. /**
  114472. * Enable or disable the shader compilation time capture
  114473. */
  114474. captureShaderCompilationTime: boolean;
  114475. /**
  114476. * Instantiates a new engine instrumentation.
  114477. * This class can be used to get instrumentation data from a Babylon engine
  114478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114479. * @param engine Defines the engine to instrument
  114480. */
  114481. constructor(
  114482. /**
  114483. * Define the instrumented engine.
  114484. */
  114485. engine: Engine);
  114486. /**
  114487. * Dispose and release associated resources.
  114488. */
  114489. dispose(): void;
  114490. }
  114491. }
  114492. declare module BABYLON {
  114493. /**
  114494. * This class can be used to get instrumentation data from a Babylon engine
  114495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114496. */
  114497. export class SceneInstrumentation implements IDisposable {
  114498. /**
  114499. * Defines the scene to instrument
  114500. */
  114501. scene: Scene;
  114502. private _captureActiveMeshesEvaluationTime;
  114503. private _activeMeshesEvaluationTime;
  114504. private _captureRenderTargetsRenderTime;
  114505. private _renderTargetsRenderTime;
  114506. private _captureFrameTime;
  114507. private _frameTime;
  114508. private _captureRenderTime;
  114509. private _renderTime;
  114510. private _captureInterFrameTime;
  114511. private _interFrameTime;
  114512. private _captureParticlesRenderTime;
  114513. private _particlesRenderTime;
  114514. private _captureSpritesRenderTime;
  114515. private _spritesRenderTime;
  114516. private _capturePhysicsTime;
  114517. private _physicsTime;
  114518. private _captureAnimationsTime;
  114519. private _animationsTime;
  114520. private _captureCameraRenderTime;
  114521. private _cameraRenderTime;
  114522. private _onBeforeActiveMeshesEvaluationObserver;
  114523. private _onAfterActiveMeshesEvaluationObserver;
  114524. private _onBeforeRenderTargetsRenderObserver;
  114525. private _onAfterRenderTargetsRenderObserver;
  114526. private _onAfterRenderObserver;
  114527. private _onBeforeDrawPhaseObserver;
  114528. private _onAfterDrawPhaseObserver;
  114529. private _onBeforeAnimationsObserver;
  114530. private _onBeforeParticlesRenderingObserver;
  114531. private _onAfterParticlesRenderingObserver;
  114532. private _onBeforeSpritesRenderingObserver;
  114533. private _onAfterSpritesRenderingObserver;
  114534. private _onBeforePhysicsObserver;
  114535. private _onAfterPhysicsObserver;
  114536. private _onAfterAnimationsObserver;
  114537. private _onBeforeCameraRenderObserver;
  114538. private _onAfterCameraRenderObserver;
  114539. /**
  114540. * Gets the perf counter used for active meshes evaluation time
  114541. */
  114542. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114543. /**
  114544. * Gets the active meshes evaluation time capture status
  114545. */
  114546. /**
  114547. * Enable or disable the active meshes evaluation time capture
  114548. */
  114549. captureActiveMeshesEvaluationTime: boolean;
  114550. /**
  114551. * Gets the perf counter used for render targets render time
  114552. */
  114553. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114554. /**
  114555. * Gets the render targets render time capture status
  114556. */
  114557. /**
  114558. * Enable or disable the render targets render time capture
  114559. */
  114560. captureRenderTargetsRenderTime: boolean;
  114561. /**
  114562. * Gets the perf counter used for particles render time
  114563. */
  114564. readonly particlesRenderTimeCounter: PerfCounter;
  114565. /**
  114566. * Gets the particles render time capture status
  114567. */
  114568. /**
  114569. * Enable or disable the particles render time capture
  114570. */
  114571. captureParticlesRenderTime: boolean;
  114572. /**
  114573. * Gets the perf counter used for sprites render time
  114574. */
  114575. readonly spritesRenderTimeCounter: PerfCounter;
  114576. /**
  114577. * Gets the sprites render time capture status
  114578. */
  114579. /**
  114580. * Enable or disable the sprites render time capture
  114581. */
  114582. captureSpritesRenderTime: boolean;
  114583. /**
  114584. * Gets the perf counter used for physics time
  114585. */
  114586. readonly physicsTimeCounter: PerfCounter;
  114587. /**
  114588. * Gets the physics time capture status
  114589. */
  114590. /**
  114591. * Enable or disable the physics time capture
  114592. */
  114593. capturePhysicsTime: boolean;
  114594. /**
  114595. * Gets the perf counter used for animations time
  114596. */
  114597. readonly animationsTimeCounter: PerfCounter;
  114598. /**
  114599. * Gets the animations time capture status
  114600. */
  114601. /**
  114602. * Enable or disable the animations time capture
  114603. */
  114604. captureAnimationsTime: boolean;
  114605. /**
  114606. * Gets the perf counter used for frame time capture
  114607. */
  114608. readonly frameTimeCounter: PerfCounter;
  114609. /**
  114610. * Gets the frame time capture status
  114611. */
  114612. /**
  114613. * Enable or disable the frame time capture
  114614. */
  114615. captureFrameTime: boolean;
  114616. /**
  114617. * Gets the perf counter used for inter-frames time capture
  114618. */
  114619. readonly interFrameTimeCounter: PerfCounter;
  114620. /**
  114621. * Gets the inter-frames time capture status
  114622. */
  114623. /**
  114624. * Enable or disable the inter-frames time capture
  114625. */
  114626. captureInterFrameTime: boolean;
  114627. /**
  114628. * Gets the perf counter used for render time capture
  114629. */
  114630. readonly renderTimeCounter: PerfCounter;
  114631. /**
  114632. * Gets the render time capture status
  114633. */
  114634. /**
  114635. * Enable or disable the render time capture
  114636. */
  114637. captureRenderTime: boolean;
  114638. /**
  114639. * Gets the perf counter used for camera render time capture
  114640. */
  114641. readonly cameraRenderTimeCounter: PerfCounter;
  114642. /**
  114643. * Gets the camera render time capture status
  114644. */
  114645. /**
  114646. * Enable or disable the camera render time capture
  114647. */
  114648. captureCameraRenderTime: boolean;
  114649. /**
  114650. * Gets the perf counter used for draw calls
  114651. */
  114652. readonly drawCallsCounter: PerfCounter;
  114653. /**
  114654. * Instantiates a new scene instrumentation.
  114655. * This class can be used to get instrumentation data from a Babylon engine
  114656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114657. * @param scene Defines the scene to instrument
  114658. */
  114659. constructor(
  114660. /**
  114661. * Defines the scene to instrument
  114662. */
  114663. scene: Scene);
  114664. /**
  114665. * Dispose and release associated resources.
  114666. */
  114667. dispose(): void;
  114668. }
  114669. }
  114670. declare module BABYLON {
  114671. /** @hidden */
  114672. export var glowMapGenerationPixelShader: {
  114673. name: string;
  114674. shader: string;
  114675. };
  114676. }
  114677. declare module BABYLON {
  114678. /** @hidden */
  114679. export var glowMapGenerationVertexShader: {
  114680. name: string;
  114681. shader: string;
  114682. };
  114683. }
  114684. declare module BABYLON {
  114685. /**
  114686. * Effect layer options. This helps customizing the behaviour
  114687. * of the effect layer.
  114688. */
  114689. export interface IEffectLayerOptions {
  114690. /**
  114691. * Multiplication factor apply to the canvas size to compute the render target size
  114692. * used to generated the objects (the smaller the faster).
  114693. */
  114694. mainTextureRatio: number;
  114695. /**
  114696. * Enforces a fixed size texture to ensure effect stability across devices.
  114697. */
  114698. mainTextureFixedSize?: number;
  114699. /**
  114700. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114701. */
  114702. alphaBlendingMode: number;
  114703. /**
  114704. * The camera attached to the layer.
  114705. */
  114706. camera: Nullable<Camera>;
  114707. /**
  114708. * The rendering group to draw the layer in.
  114709. */
  114710. renderingGroupId: number;
  114711. }
  114712. /**
  114713. * The effect layer Helps adding post process effect blended with the main pass.
  114714. *
  114715. * This can be for instance use to generate glow or higlight effects on the scene.
  114716. *
  114717. * The effect layer class can not be used directly and is intented to inherited from to be
  114718. * customized per effects.
  114719. */
  114720. export abstract class EffectLayer {
  114721. private _vertexBuffers;
  114722. private _indexBuffer;
  114723. private _cachedDefines;
  114724. private _effectLayerMapGenerationEffect;
  114725. private _effectLayerOptions;
  114726. private _mergeEffect;
  114727. protected _scene: Scene;
  114728. protected _engine: Engine;
  114729. protected _maxSize: number;
  114730. protected _mainTextureDesiredSize: ISize;
  114731. protected _mainTexture: RenderTargetTexture;
  114732. protected _shouldRender: boolean;
  114733. protected _postProcesses: PostProcess[];
  114734. protected _textures: BaseTexture[];
  114735. protected _emissiveTextureAndColor: {
  114736. texture: Nullable<BaseTexture>;
  114737. color: Color4;
  114738. };
  114739. /**
  114740. * The name of the layer
  114741. */
  114742. name: string;
  114743. /**
  114744. * The clear color of the texture used to generate the glow map.
  114745. */
  114746. neutralColor: Color4;
  114747. /**
  114748. * Specifies wether the highlight layer is enabled or not.
  114749. */
  114750. isEnabled: boolean;
  114751. /**
  114752. * Gets the camera attached to the layer.
  114753. */
  114754. readonly camera: Nullable<Camera>;
  114755. /**
  114756. * Gets the rendering group id the layer should render in.
  114757. */
  114758. renderingGroupId: number;
  114759. /**
  114760. * An event triggered when the effect layer has been disposed.
  114761. */
  114762. onDisposeObservable: Observable<EffectLayer>;
  114763. /**
  114764. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114765. */
  114766. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114767. /**
  114768. * An event triggered when the generated texture is being merged in the scene.
  114769. */
  114770. onBeforeComposeObservable: Observable<EffectLayer>;
  114771. /**
  114772. * An event triggered when the generated texture has been merged in the scene.
  114773. */
  114774. onAfterComposeObservable: Observable<EffectLayer>;
  114775. /**
  114776. * An event triggered when the efffect layer changes its size.
  114777. */
  114778. onSizeChangedObservable: Observable<EffectLayer>;
  114779. /** @hidden */
  114780. static _SceneComponentInitialization: (scene: Scene) => void;
  114781. /**
  114782. * Instantiates a new effect Layer and references it in the scene.
  114783. * @param name The name of the layer
  114784. * @param scene The scene to use the layer in
  114785. */
  114786. constructor(
  114787. /** The Friendly of the effect in the scene */
  114788. name: string, scene: Scene);
  114789. /**
  114790. * Get the effect name of the layer.
  114791. * @return The effect name
  114792. */
  114793. abstract getEffectName(): string;
  114794. /**
  114795. * Checks for the readiness of the element composing the layer.
  114796. * @param subMesh the mesh to check for
  114797. * @param useInstances specify wether or not to use instances to render the mesh
  114798. * @return true if ready otherwise, false
  114799. */
  114800. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114801. /**
  114802. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114803. * @returns true if the effect requires stencil during the main canvas render pass.
  114804. */
  114805. abstract needStencil(): boolean;
  114806. /**
  114807. * Create the merge effect. This is the shader use to blit the information back
  114808. * to the main canvas at the end of the scene rendering.
  114809. * @returns The effect containing the shader used to merge the effect on the main canvas
  114810. */
  114811. protected abstract _createMergeEffect(): Effect;
  114812. /**
  114813. * Creates the render target textures and post processes used in the effect layer.
  114814. */
  114815. protected abstract _createTextureAndPostProcesses(): void;
  114816. /**
  114817. * Implementation specific of rendering the generating effect on the main canvas.
  114818. * @param effect The effect used to render through
  114819. */
  114820. protected abstract _internalRender(effect: Effect): void;
  114821. /**
  114822. * Sets the required values for both the emissive texture and and the main color.
  114823. */
  114824. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114825. /**
  114826. * Free any resources and references associated to a mesh.
  114827. * Internal use
  114828. * @param mesh The mesh to free.
  114829. */
  114830. abstract _disposeMesh(mesh: Mesh): void;
  114831. /**
  114832. * Serializes this layer (Glow or Highlight for example)
  114833. * @returns a serialized layer object
  114834. */
  114835. abstract serialize?(): any;
  114836. /**
  114837. * Initializes the effect layer with the required options.
  114838. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114839. */
  114840. protected _init(options: Partial<IEffectLayerOptions>): void;
  114841. /**
  114842. * Generates the index buffer of the full screen quad blending to the main canvas.
  114843. */
  114844. private _generateIndexBuffer;
  114845. /**
  114846. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114847. */
  114848. private _generateVertexBuffer;
  114849. /**
  114850. * Sets the main texture desired size which is the closest power of two
  114851. * of the engine canvas size.
  114852. */
  114853. private _setMainTextureSize;
  114854. /**
  114855. * Creates the main texture for the effect layer.
  114856. */
  114857. protected _createMainTexture(): void;
  114858. /**
  114859. * Adds specific effects defines.
  114860. * @param defines The defines to add specifics to.
  114861. */
  114862. protected _addCustomEffectDefines(defines: string[]): void;
  114863. /**
  114864. * Checks for the readiness of the element composing the layer.
  114865. * @param subMesh the mesh to check for
  114866. * @param useInstances specify wether or not to use instances to render the mesh
  114867. * @param emissiveTexture the associated emissive texture used to generate the glow
  114868. * @return true if ready otherwise, false
  114869. */
  114870. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114871. /**
  114872. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114873. */
  114874. render(): void;
  114875. /**
  114876. * Determine if a given mesh will be used in the current effect.
  114877. * @param mesh mesh to test
  114878. * @returns true if the mesh will be used
  114879. */
  114880. hasMesh(mesh: AbstractMesh): boolean;
  114881. /**
  114882. * Returns true if the layer contains information to display, otherwise false.
  114883. * @returns true if the glow layer should be rendered
  114884. */
  114885. shouldRender(): boolean;
  114886. /**
  114887. * Returns true if the mesh should render, otherwise false.
  114888. * @param mesh The mesh to render
  114889. * @returns true if it should render otherwise false
  114890. */
  114891. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114892. /**
  114893. * Returns true if the mesh can be rendered, otherwise false.
  114894. * @param mesh The mesh to render
  114895. * @param material The material used on the mesh
  114896. * @returns true if it can be rendered otherwise false
  114897. */
  114898. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114899. /**
  114900. * Returns true if the mesh should render, otherwise false.
  114901. * @param mesh The mesh to render
  114902. * @returns true if it should render otherwise false
  114903. */
  114904. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114905. /**
  114906. * Renders the submesh passed in parameter to the generation map.
  114907. */
  114908. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114909. /**
  114910. * Rebuild the required buffers.
  114911. * @hidden Internal use only.
  114912. */
  114913. _rebuild(): void;
  114914. /**
  114915. * Dispose only the render target textures and post process.
  114916. */
  114917. private _disposeTextureAndPostProcesses;
  114918. /**
  114919. * Dispose the highlight layer and free resources.
  114920. */
  114921. dispose(): void;
  114922. /**
  114923. * Gets the class name of the effect layer
  114924. * @returns the string with the class name of the effect layer
  114925. */
  114926. getClassName(): string;
  114927. /**
  114928. * Creates an effect layer from parsed effect layer data
  114929. * @param parsedEffectLayer defines effect layer data
  114930. * @param scene defines the current scene
  114931. * @param rootUrl defines the root URL containing the effect layer information
  114932. * @returns a parsed effect Layer
  114933. */
  114934. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114935. }
  114936. }
  114937. declare module BABYLON {
  114938. interface AbstractScene {
  114939. /**
  114940. * The list of effect layers (highlights/glow) added to the scene
  114941. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114942. * @see http://doc.babylonjs.com/how_to/glow_layer
  114943. */
  114944. effectLayers: Array<EffectLayer>;
  114945. /**
  114946. * Removes the given effect layer from this scene.
  114947. * @param toRemove defines the effect layer to remove
  114948. * @returns the index of the removed effect layer
  114949. */
  114950. removeEffectLayer(toRemove: EffectLayer): number;
  114951. /**
  114952. * Adds the given effect layer to this scene
  114953. * @param newEffectLayer defines the effect layer to add
  114954. */
  114955. addEffectLayer(newEffectLayer: EffectLayer): void;
  114956. }
  114957. /**
  114958. * Defines the layer scene component responsible to manage any effect layers
  114959. * in a given scene.
  114960. */
  114961. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114962. /**
  114963. * The component name helpfull to identify the component in the list of scene components.
  114964. */
  114965. readonly name: string;
  114966. /**
  114967. * The scene the component belongs to.
  114968. */
  114969. scene: Scene;
  114970. private _engine;
  114971. private _renderEffects;
  114972. private _needStencil;
  114973. private _previousStencilState;
  114974. /**
  114975. * Creates a new instance of the component for the given scene
  114976. * @param scene Defines the scene to register the component in
  114977. */
  114978. constructor(scene: Scene);
  114979. /**
  114980. * Registers the component in a given scene
  114981. */
  114982. register(): void;
  114983. /**
  114984. * Rebuilds the elements related to this component in case of
  114985. * context lost for instance.
  114986. */
  114987. rebuild(): void;
  114988. /**
  114989. * Serializes the component data to the specified json object
  114990. * @param serializationObject The object to serialize to
  114991. */
  114992. serialize(serializationObject: any): void;
  114993. /**
  114994. * Adds all the elements from the container to the scene
  114995. * @param container the container holding the elements
  114996. */
  114997. addFromContainer(container: AbstractScene): void;
  114998. /**
  114999. * Removes all the elements in the container from the scene
  115000. * @param container contains the elements to remove
  115001. * @param dispose if the removed element should be disposed (default: false)
  115002. */
  115003. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115004. /**
  115005. * Disposes the component and the associated ressources.
  115006. */
  115007. dispose(): void;
  115008. private _isReadyForMesh;
  115009. private _renderMainTexture;
  115010. private _setStencil;
  115011. private _setStencilBack;
  115012. private _draw;
  115013. private _drawCamera;
  115014. private _drawRenderingGroup;
  115015. }
  115016. }
  115017. declare module BABYLON {
  115018. /** @hidden */
  115019. export var glowMapMergePixelShader: {
  115020. name: string;
  115021. shader: string;
  115022. };
  115023. }
  115024. declare module BABYLON {
  115025. /** @hidden */
  115026. export var glowMapMergeVertexShader: {
  115027. name: string;
  115028. shader: string;
  115029. };
  115030. }
  115031. declare module BABYLON {
  115032. interface AbstractScene {
  115033. /**
  115034. * Return a the first highlight layer of the scene with a given name.
  115035. * @param name The name of the highlight layer to look for.
  115036. * @return The highlight layer if found otherwise null.
  115037. */
  115038. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  115039. }
  115040. /**
  115041. * Glow layer options. This helps customizing the behaviour
  115042. * of the glow layer.
  115043. */
  115044. export interface IGlowLayerOptions {
  115045. /**
  115046. * Multiplication factor apply to the canvas size to compute the render target size
  115047. * used to generated the glowing objects (the smaller the faster).
  115048. */
  115049. mainTextureRatio: number;
  115050. /**
  115051. * Enforces a fixed size texture to ensure resize independant blur.
  115052. */
  115053. mainTextureFixedSize?: number;
  115054. /**
  115055. * How big is the kernel of the blur texture.
  115056. */
  115057. blurKernelSize: number;
  115058. /**
  115059. * The camera attached to the layer.
  115060. */
  115061. camera: Nullable<Camera>;
  115062. /**
  115063. * Enable MSAA by chosing the number of samples.
  115064. */
  115065. mainTextureSamples?: number;
  115066. /**
  115067. * The rendering group to draw the layer in.
  115068. */
  115069. renderingGroupId: number;
  115070. }
  115071. /**
  115072. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  115073. *
  115074. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115075. * glowy meshes to your scene.
  115076. *
  115077. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  115078. */
  115079. export class GlowLayer extends EffectLayer {
  115080. /**
  115081. * Effect Name of the layer.
  115082. */
  115083. static readonly EffectName: string;
  115084. /**
  115085. * The default blur kernel size used for the glow.
  115086. */
  115087. static DefaultBlurKernelSize: number;
  115088. /**
  115089. * The default texture size ratio used for the glow.
  115090. */
  115091. static DefaultTextureRatio: number;
  115092. /**
  115093. * Sets the kernel size of the blur.
  115094. */
  115095. /**
  115096. * Gets the kernel size of the blur.
  115097. */
  115098. blurKernelSize: number;
  115099. /**
  115100. * Sets the glow intensity.
  115101. */
  115102. /**
  115103. * Gets the glow intensity.
  115104. */
  115105. intensity: number;
  115106. private _options;
  115107. private _intensity;
  115108. private _horizontalBlurPostprocess1;
  115109. private _verticalBlurPostprocess1;
  115110. private _horizontalBlurPostprocess2;
  115111. private _verticalBlurPostprocess2;
  115112. private _blurTexture1;
  115113. private _blurTexture2;
  115114. private _postProcesses1;
  115115. private _postProcesses2;
  115116. private _includedOnlyMeshes;
  115117. private _excludedMeshes;
  115118. /**
  115119. * Callback used to let the user override the color selection on a per mesh basis
  115120. */
  115121. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  115122. /**
  115123. * Callback used to let the user override the texture selection on a per mesh basis
  115124. */
  115125. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  115126. /**
  115127. * Instantiates a new glow Layer and references it to the scene.
  115128. * @param name The name of the layer
  115129. * @param scene The scene to use the layer in
  115130. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  115131. */
  115132. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  115133. /**
  115134. * Get the effect name of the layer.
  115135. * @return The effect name
  115136. */
  115137. getEffectName(): string;
  115138. /**
  115139. * Create the merge effect. This is the shader use to blit the information back
  115140. * to the main canvas at the end of the scene rendering.
  115141. */
  115142. protected _createMergeEffect(): Effect;
  115143. /**
  115144. * Creates the render target textures and post processes used in the glow layer.
  115145. */
  115146. protected _createTextureAndPostProcesses(): void;
  115147. /**
  115148. * Checks for the readiness of the element composing the layer.
  115149. * @param subMesh the mesh to check for
  115150. * @param useInstances specify wether or not to use instances to render the mesh
  115151. * @param emissiveTexture the associated emissive texture used to generate the glow
  115152. * @return true if ready otherwise, false
  115153. */
  115154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115155. /**
  115156. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115157. */
  115158. needStencil(): boolean;
  115159. /**
  115160. * Returns true if the mesh can be rendered, otherwise false.
  115161. * @param mesh The mesh to render
  115162. * @param material The material used on the mesh
  115163. * @returns true if it can be rendered otherwise false
  115164. */
  115165. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115166. /**
  115167. * Implementation specific of rendering the generating effect on the main canvas.
  115168. * @param effect The effect used to render through
  115169. */
  115170. protected _internalRender(effect: Effect): void;
  115171. /**
  115172. * Sets the required values for both the emissive texture and and the main color.
  115173. */
  115174. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115175. /**
  115176. * Returns true if the mesh should render, otherwise false.
  115177. * @param mesh The mesh to render
  115178. * @returns true if it should render otherwise false
  115179. */
  115180. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115181. /**
  115182. * Adds specific effects defines.
  115183. * @param defines The defines to add specifics to.
  115184. */
  115185. protected _addCustomEffectDefines(defines: string[]): void;
  115186. /**
  115187. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115188. * @param mesh The mesh to exclude from the glow layer
  115189. */
  115190. addExcludedMesh(mesh: Mesh): void;
  115191. /**
  115192. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115193. * @param mesh The mesh to remove
  115194. */
  115195. removeExcludedMesh(mesh: Mesh): void;
  115196. /**
  115197. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115198. * @param mesh The mesh to include in the glow layer
  115199. */
  115200. addIncludedOnlyMesh(mesh: Mesh): void;
  115201. /**
  115202. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115203. * @param mesh The mesh to remove
  115204. */
  115205. removeIncludedOnlyMesh(mesh: Mesh): void;
  115206. /**
  115207. * Determine if a given mesh will be used in the glow layer
  115208. * @param mesh The mesh to test
  115209. * @returns true if the mesh will be highlighted by the current glow layer
  115210. */
  115211. hasMesh(mesh: AbstractMesh): boolean;
  115212. /**
  115213. * Free any resources and references associated to a mesh.
  115214. * Internal use
  115215. * @param mesh The mesh to free.
  115216. * @hidden
  115217. */
  115218. _disposeMesh(mesh: Mesh): void;
  115219. /**
  115220. * Gets the class name of the effect layer
  115221. * @returns the string with the class name of the effect layer
  115222. */
  115223. getClassName(): string;
  115224. /**
  115225. * Serializes this glow layer
  115226. * @returns a serialized glow layer object
  115227. */
  115228. serialize(): any;
  115229. /**
  115230. * Creates a Glow Layer from parsed glow layer data
  115231. * @param parsedGlowLayer defines glow layer data
  115232. * @param scene defines the current scene
  115233. * @param rootUrl defines the root URL containing the glow layer information
  115234. * @returns a parsed Glow Layer
  115235. */
  115236. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115237. }
  115238. }
  115239. declare module BABYLON {
  115240. /** @hidden */
  115241. export var glowBlurPostProcessPixelShader: {
  115242. name: string;
  115243. shader: string;
  115244. };
  115245. }
  115246. declare module BABYLON {
  115247. interface AbstractScene {
  115248. /**
  115249. * Return a the first highlight layer of the scene with a given name.
  115250. * @param name The name of the highlight layer to look for.
  115251. * @return The highlight layer if found otherwise null.
  115252. */
  115253. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115254. }
  115255. /**
  115256. * Highlight layer options. This helps customizing the behaviour
  115257. * of the highlight layer.
  115258. */
  115259. export interface IHighlightLayerOptions {
  115260. /**
  115261. * Multiplication factor apply to the canvas size to compute the render target size
  115262. * used to generated the glowing objects (the smaller the faster).
  115263. */
  115264. mainTextureRatio: number;
  115265. /**
  115266. * Enforces a fixed size texture to ensure resize independant blur.
  115267. */
  115268. mainTextureFixedSize?: number;
  115269. /**
  115270. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115271. * of the picture to blur (the smaller the faster).
  115272. */
  115273. blurTextureSizeRatio: number;
  115274. /**
  115275. * How big in texel of the blur texture is the vertical blur.
  115276. */
  115277. blurVerticalSize: number;
  115278. /**
  115279. * How big in texel of the blur texture is the horizontal blur.
  115280. */
  115281. blurHorizontalSize: number;
  115282. /**
  115283. * Alpha blending mode used to apply the blur. Default is combine.
  115284. */
  115285. alphaBlendingMode: number;
  115286. /**
  115287. * The camera attached to the layer.
  115288. */
  115289. camera: Nullable<Camera>;
  115290. /**
  115291. * Should we display highlight as a solid stroke?
  115292. */
  115293. isStroke?: boolean;
  115294. /**
  115295. * The rendering group to draw the layer in.
  115296. */
  115297. renderingGroupId: number;
  115298. }
  115299. /**
  115300. * The highlight layer Helps adding a glow effect around a mesh.
  115301. *
  115302. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115303. * glowy meshes to your scene.
  115304. *
  115305. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115306. */
  115307. export class HighlightLayer extends EffectLayer {
  115308. name: string;
  115309. /**
  115310. * Effect Name of the highlight layer.
  115311. */
  115312. static readonly EffectName: string;
  115313. /**
  115314. * The neutral color used during the preparation of the glow effect.
  115315. * This is black by default as the blend operation is a blend operation.
  115316. */
  115317. static NeutralColor: Color4;
  115318. /**
  115319. * Stencil value used for glowing meshes.
  115320. */
  115321. static GlowingMeshStencilReference: number;
  115322. /**
  115323. * Stencil value used for the other meshes in the scene.
  115324. */
  115325. static NormalMeshStencilReference: number;
  115326. /**
  115327. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115328. */
  115329. innerGlow: boolean;
  115330. /**
  115331. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115332. */
  115333. outerGlow: boolean;
  115334. /**
  115335. * Specifies the horizontal size of the blur.
  115336. */
  115337. /**
  115338. * Gets the horizontal size of the blur.
  115339. */
  115340. blurHorizontalSize: number;
  115341. /**
  115342. * Specifies the vertical size of the blur.
  115343. */
  115344. /**
  115345. * Gets the vertical size of the blur.
  115346. */
  115347. blurVerticalSize: number;
  115348. /**
  115349. * An event triggered when the highlight layer is being blurred.
  115350. */
  115351. onBeforeBlurObservable: Observable<HighlightLayer>;
  115352. /**
  115353. * An event triggered when the highlight layer has been blurred.
  115354. */
  115355. onAfterBlurObservable: Observable<HighlightLayer>;
  115356. private _instanceGlowingMeshStencilReference;
  115357. private _options;
  115358. private _downSamplePostprocess;
  115359. private _horizontalBlurPostprocess;
  115360. private _verticalBlurPostprocess;
  115361. private _blurTexture;
  115362. private _meshes;
  115363. private _excludedMeshes;
  115364. /**
  115365. * Instantiates a new highlight Layer and references it to the scene..
  115366. * @param name The name of the layer
  115367. * @param scene The scene to use the layer in
  115368. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115369. */
  115370. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115371. /**
  115372. * Get the effect name of the layer.
  115373. * @return The effect name
  115374. */
  115375. getEffectName(): string;
  115376. /**
  115377. * Create the merge effect. This is the shader use to blit the information back
  115378. * to the main canvas at the end of the scene rendering.
  115379. */
  115380. protected _createMergeEffect(): Effect;
  115381. /**
  115382. * Creates the render target textures and post processes used in the highlight layer.
  115383. */
  115384. protected _createTextureAndPostProcesses(): void;
  115385. /**
  115386. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115387. */
  115388. needStencil(): boolean;
  115389. /**
  115390. * Checks for the readiness of the element composing the layer.
  115391. * @param subMesh the mesh to check for
  115392. * @param useInstances specify wether or not to use instances to render the mesh
  115393. * @param emissiveTexture the associated emissive texture used to generate the glow
  115394. * @return true if ready otherwise, false
  115395. */
  115396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115397. /**
  115398. * Implementation specific of rendering the generating effect on the main canvas.
  115399. * @param effect The effect used to render through
  115400. */
  115401. protected _internalRender(effect: Effect): void;
  115402. /**
  115403. * Returns true if the layer contains information to display, otherwise false.
  115404. */
  115405. shouldRender(): boolean;
  115406. /**
  115407. * Returns true if the mesh should render, otherwise false.
  115408. * @param mesh The mesh to render
  115409. * @returns true if it should render otherwise false
  115410. */
  115411. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115412. /**
  115413. * Sets the required values for both the emissive texture and and the main color.
  115414. */
  115415. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115416. /**
  115417. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115418. * @param mesh The mesh to exclude from the highlight layer
  115419. */
  115420. addExcludedMesh(mesh: Mesh): void;
  115421. /**
  115422. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115423. * @param mesh The mesh to highlight
  115424. */
  115425. removeExcludedMesh(mesh: Mesh): void;
  115426. /**
  115427. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115428. * @param mesh mesh to test
  115429. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115430. */
  115431. hasMesh(mesh: AbstractMesh): boolean;
  115432. /**
  115433. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115434. * @param mesh The mesh to highlight
  115435. * @param color The color of the highlight
  115436. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115437. */
  115438. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115439. /**
  115440. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115441. * @param mesh The mesh to highlight
  115442. */
  115443. removeMesh(mesh: Mesh): void;
  115444. /**
  115445. * Force the stencil to the normal expected value for none glowing parts
  115446. */
  115447. private _defaultStencilReference;
  115448. /**
  115449. * Free any resources and references associated to a mesh.
  115450. * Internal use
  115451. * @param mesh The mesh to free.
  115452. * @hidden
  115453. */
  115454. _disposeMesh(mesh: Mesh): void;
  115455. /**
  115456. * Dispose the highlight layer and free resources.
  115457. */
  115458. dispose(): void;
  115459. /**
  115460. * Gets the class name of the effect layer
  115461. * @returns the string with the class name of the effect layer
  115462. */
  115463. getClassName(): string;
  115464. /**
  115465. * Serializes this Highlight layer
  115466. * @returns a serialized Highlight layer object
  115467. */
  115468. serialize(): any;
  115469. /**
  115470. * Creates a Highlight layer from parsed Highlight layer data
  115471. * @param parsedHightlightLayer defines the Highlight layer data
  115472. * @param scene defines the current scene
  115473. * @param rootUrl defines the root URL containing the Highlight layer information
  115474. * @returns a parsed Highlight layer
  115475. */
  115476. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115477. }
  115478. }
  115479. declare module BABYLON {
  115480. interface AbstractScene {
  115481. /**
  115482. * The list of layers (background and foreground) of the scene
  115483. */
  115484. layers: Array<Layer>;
  115485. }
  115486. /**
  115487. * Defines the layer scene component responsible to manage any layers
  115488. * in a given scene.
  115489. */
  115490. export class LayerSceneComponent implements ISceneComponent {
  115491. /**
  115492. * The component name helpfull to identify the component in the list of scene components.
  115493. */
  115494. readonly name: string;
  115495. /**
  115496. * The scene the component belongs to.
  115497. */
  115498. scene: Scene;
  115499. private _engine;
  115500. /**
  115501. * Creates a new instance of the component for the given scene
  115502. * @param scene Defines the scene to register the component in
  115503. */
  115504. constructor(scene: Scene);
  115505. /**
  115506. * Registers the component in a given scene
  115507. */
  115508. register(): void;
  115509. /**
  115510. * Rebuilds the elements related to this component in case of
  115511. * context lost for instance.
  115512. */
  115513. rebuild(): void;
  115514. /**
  115515. * Disposes the component and the associated ressources.
  115516. */
  115517. dispose(): void;
  115518. private _draw;
  115519. private _drawCameraPredicate;
  115520. private _drawCameraBackground;
  115521. private _drawCameraForeground;
  115522. private _drawRenderTargetPredicate;
  115523. private _drawRenderTargetBackground;
  115524. private _drawRenderTargetForeground;
  115525. /**
  115526. * Adds all the elements from the container to the scene
  115527. * @param container the container holding the elements
  115528. */
  115529. addFromContainer(container: AbstractScene): void;
  115530. /**
  115531. * Removes all the elements in the container from the scene
  115532. * @param container contains the elements to remove
  115533. * @param dispose if the removed element should be disposed (default: false)
  115534. */
  115535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115536. }
  115537. }
  115538. declare module BABYLON {
  115539. /** @hidden */
  115540. export var layerPixelShader: {
  115541. name: string;
  115542. shader: string;
  115543. };
  115544. }
  115545. declare module BABYLON {
  115546. /** @hidden */
  115547. export var layerVertexShader: {
  115548. name: string;
  115549. shader: string;
  115550. };
  115551. }
  115552. declare module BABYLON {
  115553. /**
  115554. * This represents a full screen 2d layer.
  115555. * This can be useful to display a picture in the background of your scene for instance.
  115556. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115557. */
  115558. export class Layer {
  115559. /**
  115560. * Define the name of the layer.
  115561. */
  115562. name: string;
  115563. /**
  115564. * Define the texture the layer should display.
  115565. */
  115566. texture: Nullable<Texture>;
  115567. /**
  115568. * Is the layer in background or foreground.
  115569. */
  115570. isBackground: boolean;
  115571. /**
  115572. * Define the color of the layer (instead of texture).
  115573. */
  115574. color: Color4;
  115575. /**
  115576. * Define the scale of the layer in order to zoom in out of the texture.
  115577. */
  115578. scale: Vector2;
  115579. /**
  115580. * Define an offset for the layer in order to shift the texture.
  115581. */
  115582. offset: Vector2;
  115583. /**
  115584. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115585. */
  115586. alphaBlendingMode: number;
  115587. /**
  115588. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115589. * Alpha test will not mix with the background color in case of transparency.
  115590. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115591. */
  115592. alphaTest: boolean;
  115593. /**
  115594. * Define a mask to restrict the layer to only some of the scene cameras.
  115595. */
  115596. layerMask: number;
  115597. /**
  115598. * Define the list of render target the layer is visible into.
  115599. */
  115600. renderTargetTextures: RenderTargetTexture[];
  115601. /**
  115602. * Define if the layer is only used in renderTarget or if it also
  115603. * renders in the main frame buffer of the canvas.
  115604. */
  115605. renderOnlyInRenderTargetTextures: boolean;
  115606. private _scene;
  115607. private _vertexBuffers;
  115608. private _indexBuffer;
  115609. private _effect;
  115610. private _alphaTestEffect;
  115611. /**
  115612. * An event triggered when the layer is disposed.
  115613. */
  115614. onDisposeObservable: Observable<Layer>;
  115615. private _onDisposeObserver;
  115616. /**
  115617. * Back compatibility with callback before the onDisposeObservable existed.
  115618. * The set callback will be triggered when the layer has been disposed.
  115619. */
  115620. onDispose: () => void;
  115621. /**
  115622. * An event triggered before rendering the scene
  115623. */
  115624. onBeforeRenderObservable: Observable<Layer>;
  115625. private _onBeforeRenderObserver;
  115626. /**
  115627. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115628. * The set callback will be triggered just before rendering the layer.
  115629. */
  115630. onBeforeRender: () => void;
  115631. /**
  115632. * An event triggered after rendering the scene
  115633. */
  115634. onAfterRenderObservable: Observable<Layer>;
  115635. private _onAfterRenderObserver;
  115636. /**
  115637. * Back compatibility with callback before the onAfterRenderObservable existed.
  115638. * The set callback will be triggered just after rendering the layer.
  115639. */
  115640. onAfterRender: () => void;
  115641. /**
  115642. * Instantiates a new layer.
  115643. * This represents a full screen 2d layer.
  115644. * This can be useful to display a picture in the background of your scene for instance.
  115645. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115646. * @param name Define the name of the layer in the scene
  115647. * @param imgUrl Define the url of the texture to display in the layer
  115648. * @param scene Define the scene the layer belongs to
  115649. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115650. * @param color Defines a color for the layer
  115651. */
  115652. constructor(
  115653. /**
  115654. * Define the name of the layer.
  115655. */
  115656. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115657. private _createIndexBuffer;
  115658. /** @hidden */
  115659. _rebuild(): void;
  115660. /**
  115661. * Renders the layer in the scene.
  115662. */
  115663. render(): void;
  115664. /**
  115665. * Disposes and releases the associated ressources.
  115666. */
  115667. dispose(): void;
  115668. }
  115669. }
  115670. declare module BABYLON {
  115671. /** @hidden */
  115672. export var lensFlarePixelShader: {
  115673. name: string;
  115674. shader: string;
  115675. };
  115676. }
  115677. declare module BABYLON {
  115678. /** @hidden */
  115679. export var lensFlareVertexShader: {
  115680. name: string;
  115681. shader: string;
  115682. };
  115683. }
  115684. declare module BABYLON {
  115685. /**
  115686. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115687. * It is usually composed of several `lensFlare`.
  115688. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115689. */
  115690. export class LensFlareSystem {
  115691. /**
  115692. * Define the name of the lens flare system
  115693. */
  115694. name: string;
  115695. /**
  115696. * List of lens flares used in this system.
  115697. */
  115698. lensFlares: LensFlare[];
  115699. /**
  115700. * Define a limit from the border the lens flare can be visible.
  115701. */
  115702. borderLimit: number;
  115703. /**
  115704. * Define a viewport border we do not want to see the lens flare in.
  115705. */
  115706. viewportBorder: number;
  115707. /**
  115708. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115709. */
  115710. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115711. /**
  115712. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115713. */
  115714. layerMask: number;
  115715. /**
  115716. * Define the id of the lens flare system in the scene.
  115717. * (equal to name by default)
  115718. */
  115719. id: string;
  115720. private _scene;
  115721. private _emitter;
  115722. private _vertexBuffers;
  115723. private _indexBuffer;
  115724. private _effect;
  115725. private _positionX;
  115726. private _positionY;
  115727. private _isEnabled;
  115728. /** @hidden */
  115729. static _SceneComponentInitialization: (scene: Scene) => void;
  115730. /**
  115731. * Instantiates a lens flare system.
  115732. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115733. * It is usually composed of several `lensFlare`.
  115734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115735. * @param name Define the name of the lens flare system in the scene
  115736. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115737. * @param scene Define the scene the lens flare system belongs to
  115738. */
  115739. constructor(
  115740. /**
  115741. * Define the name of the lens flare system
  115742. */
  115743. name: string, emitter: any, scene: Scene);
  115744. /**
  115745. * Define if the lens flare system is enabled.
  115746. */
  115747. isEnabled: boolean;
  115748. /**
  115749. * Get the scene the effects belongs to.
  115750. * @returns the scene holding the lens flare system
  115751. */
  115752. getScene(): Scene;
  115753. /**
  115754. * Get the emitter of the lens flare system.
  115755. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115756. * @returns the emitter of the lens flare system
  115757. */
  115758. getEmitter(): any;
  115759. /**
  115760. * Set the emitter of the lens flare system.
  115761. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115762. * @param newEmitter Define the new emitter of the system
  115763. */
  115764. setEmitter(newEmitter: any): void;
  115765. /**
  115766. * Get the lens flare system emitter position.
  115767. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115768. * @returns the position
  115769. */
  115770. getEmitterPosition(): Vector3;
  115771. /**
  115772. * @hidden
  115773. */
  115774. computeEffectivePosition(globalViewport: Viewport): boolean;
  115775. /** @hidden */
  115776. _isVisible(): boolean;
  115777. /**
  115778. * @hidden
  115779. */
  115780. render(): boolean;
  115781. /**
  115782. * Dispose and release the lens flare with its associated resources.
  115783. */
  115784. dispose(): void;
  115785. /**
  115786. * Parse a lens flare system from a JSON repressentation
  115787. * @param parsedLensFlareSystem Define the JSON to parse
  115788. * @param scene Define the scene the parsed system should be instantiated in
  115789. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115790. * @returns the parsed system
  115791. */
  115792. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115793. /**
  115794. * Serialize the current Lens Flare System into a JSON representation.
  115795. * @returns the serialized JSON
  115796. */
  115797. serialize(): any;
  115798. }
  115799. }
  115800. declare module BABYLON {
  115801. /**
  115802. * This represents one of the lens effect in a `lensFlareSystem`.
  115803. * It controls one of the indiviual texture used in the effect.
  115804. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115805. */
  115806. export class LensFlare {
  115807. /**
  115808. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115809. */
  115810. size: number;
  115811. /**
  115812. * 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.
  115813. */
  115814. position: number;
  115815. /**
  115816. * Define the lens color.
  115817. */
  115818. color: Color3;
  115819. /**
  115820. * Define the lens texture.
  115821. */
  115822. texture: Nullable<Texture>;
  115823. /**
  115824. * Define the alpha mode to render this particular lens.
  115825. */
  115826. alphaMode: number;
  115827. private _system;
  115828. /**
  115829. * Creates a new Lens Flare.
  115830. * This represents one of the lens effect in a `lensFlareSystem`.
  115831. * It controls one of the indiviual texture used in the effect.
  115832. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115833. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115834. * @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.
  115835. * @param color Define the lens color
  115836. * @param imgUrl Define the lens texture url
  115837. * @param system Define the `lensFlareSystem` this flare is part of
  115838. * @returns The newly created Lens Flare
  115839. */
  115840. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115841. /**
  115842. * Instantiates a new Lens Flare.
  115843. * This represents one of the lens effect in a `lensFlareSystem`.
  115844. * It controls one of the indiviual texture used in the effect.
  115845. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115846. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115847. * @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.
  115848. * @param color Define the lens color
  115849. * @param imgUrl Define the lens texture url
  115850. * @param system Define the `lensFlareSystem` this flare is part of
  115851. */
  115852. constructor(
  115853. /**
  115854. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115855. */
  115856. size: number,
  115857. /**
  115858. * 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.
  115859. */
  115860. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115861. /**
  115862. * Dispose and release the lens flare with its associated resources.
  115863. */
  115864. dispose(): void;
  115865. }
  115866. }
  115867. declare module BABYLON {
  115868. interface AbstractScene {
  115869. /**
  115870. * The list of lens flare system added to the scene
  115871. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115872. */
  115873. lensFlareSystems: Array<LensFlareSystem>;
  115874. /**
  115875. * Removes the given lens flare system from this scene.
  115876. * @param toRemove The lens flare system to remove
  115877. * @returns The index of the removed lens flare system
  115878. */
  115879. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115880. /**
  115881. * Adds the given lens flare system to this scene
  115882. * @param newLensFlareSystem The lens flare system to add
  115883. */
  115884. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115885. /**
  115886. * Gets a lens flare system using its name
  115887. * @param name defines the name to look for
  115888. * @returns the lens flare system or null if not found
  115889. */
  115890. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115891. /**
  115892. * Gets a lens flare system using its id
  115893. * @param id defines the id to look for
  115894. * @returns the lens flare system or null if not found
  115895. */
  115896. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115897. }
  115898. /**
  115899. * Defines the lens flare scene component responsible to manage any lens flares
  115900. * in a given scene.
  115901. */
  115902. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115903. /**
  115904. * The component name helpfull to identify the component in the list of scene components.
  115905. */
  115906. readonly name: string;
  115907. /**
  115908. * The scene the component belongs to.
  115909. */
  115910. scene: Scene;
  115911. /**
  115912. * Creates a new instance of the component for the given scene
  115913. * @param scene Defines the scene to register the component in
  115914. */
  115915. constructor(scene: Scene);
  115916. /**
  115917. * Registers the component in a given scene
  115918. */
  115919. register(): void;
  115920. /**
  115921. * Rebuilds the elements related to this component in case of
  115922. * context lost for instance.
  115923. */
  115924. rebuild(): void;
  115925. /**
  115926. * Adds all the elements from the container to the scene
  115927. * @param container the container holding the elements
  115928. */
  115929. addFromContainer(container: AbstractScene): void;
  115930. /**
  115931. * Removes all the elements in the container from the scene
  115932. * @param container contains the elements to remove
  115933. * @param dispose if the removed element should be disposed (default: false)
  115934. */
  115935. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115936. /**
  115937. * Serializes the component data to the specified json object
  115938. * @param serializationObject The object to serialize to
  115939. */
  115940. serialize(serializationObject: any): void;
  115941. /**
  115942. * Disposes the component and the associated ressources.
  115943. */
  115944. dispose(): void;
  115945. private _draw;
  115946. }
  115947. }
  115948. declare module BABYLON {
  115949. /**
  115950. * Defines the shadow generator component responsible to manage any shadow generators
  115951. * in a given scene.
  115952. */
  115953. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115954. /**
  115955. * The component name helpfull to identify the component in the list of scene components.
  115956. */
  115957. readonly name: string;
  115958. /**
  115959. * The scene the component belongs to.
  115960. */
  115961. scene: Scene;
  115962. /**
  115963. * Creates a new instance of the component for the given scene
  115964. * @param scene Defines the scene to register the component in
  115965. */
  115966. constructor(scene: Scene);
  115967. /**
  115968. * Registers the component in a given scene
  115969. */
  115970. register(): void;
  115971. /**
  115972. * Rebuilds the elements related to this component in case of
  115973. * context lost for instance.
  115974. */
  115975. rebuild(): void;
  115976. /**
  115977. * Serializes the component data to the specified json object
  115978. * @param serializationObject The object to serialize to
  115979. */
  115980. serialize(serializationObject: any): void;
  115981. /**
  115982. * Adds all the elements from the container to the scene
  115983. * @param container the container holding the elements
  115984. */
  115985. addFromContainer(container: AbstractScene): void;
  115986. /**
  115987. * Removes all the elements in the container from the scene
  115988. * @param container contains the elements to remove
  115989. * @param dispose if the removed element should be disposed (default: false)
  115990. */
  115991. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115992. /**
  115993. * Rebuilds the elements related to this component in case of
  115994. * context lost for instance.
  115995. */
  115996. dispose(): void;
  115997. private _gatherRenderTargets;
  115998. }
  115999. }
  116000. declare module BABYLON {
  116001. /**
  116002. * A point light is a light defined by an unique point in world space.
  116003. * The light is emitted in every direction from this point.
  116004. * A good example of a point light is a standard light bulb.
  116005. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116006. */
  116007. export class PointLight extends ShadowLight {
  116008. private _shadowAngle;
  116009. /**
  116010. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116011. * This specifies what angle the shadow will use to be created.
  116012. *
  116013. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116014. */
  116015. /**
  116016. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116017. * This specifies what angle the shadow will use to be created.
  116018. *
  116019. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  116020. */
  116021. shadowAngle: number;
  116022. /**
  116023. * Gets the direction if it has been set.
  116024. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116025. */
  116026. /**
  116027. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  116028. */
  116029. direction: Vector3;
  116030. /**
  116031. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  116032. * A PointLight emits the light in every direction.
  116033. * It can cast shadows.
  116034. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  116035. * ```javascript
  116036. * var pointLight = new PointLight("pl", camera.position, scene);
  116037. * ```
  116038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116039. * @param name The light friendly name
  116040. * @param position The position of the point light in the scene
  116041. * @param scene The scene the lights belongs to
  116042. */
  116043. constructor(name: string, position: Vector3, scene: Scene);
  116044. /**
  116045. * Returns the string "PointLight"
  116046. * @returns the class name
  116047. */
  116048. getClassName(): string;
  116049. /**
  116050. * Returns the integer 0.
  116051. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116052. */
  116053. getTypeID(): number;
  116054. /**
  116055. * Specifies wether or not the shadowmap should be a cube texture.
  116056. * @returns true if the shadowmap needs to be a cube texture.
  116057. */
  116058. needCube(): boolean;
  116059. /**
  116060. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  116061. * @param faceIndex The index of the face we are computed the direction to generate shadow
  116062. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  116063. */
  116064. getShadowDirection(faceIndex?: number): Vector3;
  116065. /**
  116066. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  116067. * - fov = PI / 2
  116068. * - aspect ratio : 1.0
  116069. * - z-near and far equal to the active camera minZ and maxZ.
  116070. * Returns the PointLight.
  116071. */
  116072. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116073. protected _buildUniformLayout(): void;
  116074. /**
  116075. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  116076. * @param effect The effect to update
  116077. * @param lightIndex The index of the light in the effect to update
  116078. * @returns The point light
  116079. */
  116080. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  116081. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116082. /**
  116083. * Prepares the list of defines specific to the light type.
  116084. * @param defines the list of defines
  116085. * @param lightIndex defines the index of the light for the effect
  116086. */
  116087. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116088. }
  116089. }
  116090. declare module BABYLON {
  116091. /**
  116092. * Header information of HDR texture files.
  116093. */
  116094. export interface HDRInfo {
  116095. /**
  116096. * The height of the texture in pixels.
  116097. */
  116098. height: number;
  116099. /**
  116100. * The width of the texture in pixels.
  116101. */
  116102. width: number;
  116103. /**
  116104. * The index of the beginning of the data in the binary file.
  116105. */
  116106. dataPosition: number;
  116107. }
  116108. /**
  116109. * This groups tools to convert HDR texture to native colors array.
  116110. */
  116111. export class HDRTools {
  116112. private static Ldexp;
  116113. private static Rgbe2float;
  116114. private static readStringLine;
  116115. /**
  116116. * Reads header information from an RGBE texture stored in a native array.
  116117. * More information on this format are available here:
  116118. * https://en.wikipedia.org/wiki/RGBE_image_format
  116119. *
  116120. * @param uint8array The binary file stored in native array.
  116121. * @return The header information.
  116122. */
  116123. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  116124. /**
  116125. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  116126. * This RGBE texture needs to store the information as a panorama.
  116127. *
  116128. * More information on this format are available here:
  116129. * https://en.wikipedia.org/wiki/RGBE_image_format
  116130. *
  116131. * @param buffer The binary file stored in an array buffer.
  116132. * @param size The expected size of the extracted cubemap.
  116133. * @return The Cube Map information.
  116134. */
  116135. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  116136. /**
  116137. * Returns the pixels data extracted from an RGBE texture.
  116138. * This pixels will be stored left to right up to down in the R G B order in one array.
  116139. *
  116140. * More information on this format are available here:
  116141. * https://en.wikipedia.org/wiki/RGBE_image_format
  116142. *
  116143. * @param uint8array The binary file stored in an array buffer.
  116144. * @param hdrInfo The header information of the file.
  116145. * @return The pixels data in RGB right to left up to down order.
  116146. */
  116147. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  116148. private static RGBE_ReadPixels_RLE;
  116149. }
  116150. }
  116151. declare module BABYLON {
  116152. /**
  116153. * This represents a texture coming from an HDR input.
  116154. *
  116155. * The only supported format is currently panorama picture stored in RGBE format.
  116156. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116157. */
  116158. export class HDRCubeTexture extends BaseTexture {
  116159. private static _facesMapping;
  116160. private _generateHarmonics;
  116161. private _noMipmap;
  116162. private _textureMatrix;
  116163. private _size;
  116164. private _onLoad;
  116165. private _onError;
  116166. /**
  116167. * The texture URL.
  116168. */
  116169. url: string;
  116170. /**
  116171. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116172. */
  116173. coordinatesMode: number;
  116174. protected _isBlocking: boolean;
  116175. /**
  116176. * Sets wether or not the texture is blocking during loading.
  116177. */
  116178. /**
  116179. * Gets wether or not the texture is blocking during loading.
  116180. */
  116181. isBlocking: boolean;
  116182. protected _rotationY: number;
  116183. /**
  116184. * Sets texture matrix rotation angle around Y axis in radians.
  116185. */
  116186. /**
  116187. * Gets texture matrix rotation angle around Y axis radians.
  116188. */
  116189. rotationY: number;
  116190. /**
  116191. * Gets or sets the center of the bounding box associated with the cube texture
  116192. * It must define where the camera used to render the texture was set
  116193. */
  116194. boundingBoxPosition: Vector3;
  116195. private _boundingBoxSize;
  116196. /**
  116197. * Gets or sets the size of the bounding box associated with the cube texture
  116198. * When defined, the cubemap will switch to local mode
  116199. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116200. * @example https://www.babylonjs-playground.com/#RNASML
  116201. */
  116202. boundingBoxSize: Vector3;
  116203. /**
  116204. * Instantiates an HDRTexture from the following parameters.
  116205. *
  116206. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116207. * @param scene The scene the texture will be used in
  116208. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116209. * @param noMipmap Forces to not generate the mipmap if true
  116210. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116211. * @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)
  116212. * @param reserved Reserved flag for internal use.
  116213. */
  116214. 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>);
  116215. /**
  116216. * Get the current class name of the texture useful for serialization or dynamic coding.
  116217. * @returns "HDRCubeTexture"
  116218. */
  116219. getClassName(): string;
  116220. /**
  116221. * Occurs when the file is raw .hdr file.
  116222. */
  116223. private loadTexture;
  116224. clone(): HDRCubeTexture;
  116225. delayLoad(): void;
  116226. /**
  116227. * Get the texture reflection matrix used to rotate/transform the reflection.
  116228. * @returns the reflection matrix
  116229. */
  116230. getReflectionTextureMatrix(): Matrix;
  116231. /**
  116232. * Set the texture reflection matrix used to rotate/transform the reflection.
  116233. * @param value Define the reflection matrix to set
  116234. */
  116235. setReflectionTextureMatrix(value: Matrix): void;
  116236. /**
  116237. * Parses a JSON representation of an HDR Texture in order to create the texture
  116238. * @param parsedTexture Define the JSON representation
  116239. * @param scene Define the scene the texture should be created in
  116240. * @param rootUrl Define the root url in case we need to load relative dependencies
  116241. * @returns the newly created texture after parsing
  116242. */
  116243. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116244. serialize(): any;
  116245. }
  116246. }
  116247. declare module BABYLON {
  116248. /**
  116249. * Class used to control physics engine
  116250. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116251. */
  116252. export class PhysicsEngine implements IPhysicsEngine {
  116253. private _physicsPlugin;
  116254. /**
  116255. * Global value used to control the smallest number supported by the simulation
  116256. */
  116257. static Epsilon: number;
  116258. private _impostors;
  116259. private _joints;
  116260. /**
  116261. * Gets the gravity vector used by the simulation
  116262. */
  116263. gravity: Vector3;
  116264. /**
  116265. * Factory used to create the default physics plugin.
  116266. * @returns The default physics plugin
  116267. */
  116268. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116269. /**
  116270. * Creates a new Physics Engine
  116271. * @param gravity defines the gravity vector used by the simulation
  116272. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116273. */
  116274. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116275. /**
  116276. * Sets the gravity vector used by the simulation
  116277. * @param gravity defines the gravity vector to use
  116278. */
  116279. setGravity(gravity: Vector3): void;
  116280. /**
  116281. * Set the time step of the physics engine.
  116282. * Default is 1/60.
  116283. * To slow it down, enter 1/600 for example.
  116284. * To speed it up, 1/30
  116285. * @param newTimeStep defines the new timestep to apply to this world.
  116286. */
  116287. setTimeStep(newTimeStep?: number): void;
  116288. /**
  116289. * Get the time step of the physics engine.
  116290. * @returns the current time step
  116291. */
  116292. getTimeStep(): number;
  116293. /**
  116294. * Release all resources
  116295. */
  116296. dispose(): void;
  116297. /**
  116298. * Gets the name of the current physics plugin
  116299. * @returns the name of the plugin
  116300. */
  116301. getPhysicsPluginName(): string;
  116302. /**
  116303. * Adding a new impostor for the impostor tracking.
  116304. * This will be done by the impostor itself.
  116305. * @param impostor the impostor to add
  116306. */
  116307. addImpostor(impostor: PhysicsImpostor): void;
  116308. /**
  116309. * Remove an impostor from the engine.
  116310. * This impostor and its mesh will not longer be updated by the physics engine.
  116311. * @param impostor the impostor to remove
  116312. */
  116313. removeImpostor(impostor: PhysicsImpostor): void;
  116314. /**
  116315. * Add a joint to the physics engine
  116316. * @param mainImpostor defines the main impostor to which the joint is added.
  116317. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116318. * @param joint defines the joint that will connect both impostors.
  116319. */
  116320. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116321. /**
  116322. * Removes a joint from the simulation
  116323. * @param mainImpostor defines the impostor used with the joint
  116324. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116325. * @param joint defines the joint to remove
  116326. */
  116327. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116328. /**
  116329. * Called by the scene. No need to call it.
  116330. * @param delta defines the timespam between frames
  116331. */
  116332. _step(delta: number): void;
  116333. /**
  116334. * Gets the current plugin used to run the simulation
  116335. * @returns current plugin
  116336. */
  116337. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116338. /**
  116339. * Gets the list of physic impostors
  116340. * @returns an array of PhysicsImpostor
  116341. */
  116342. getImpostors(): Array<PhysicsImpostor>;
  116343. /**
  116344. * Gets the impostor for a physics enabled object
  116345. * @param object defines the object impersonated by the impostor
  116346. * @returns the PhysicsImpostor or null if not found
  116347. */
  116348. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116349. /**
  116350. * Gets the impostor for a physics body object
  116351. * @param body defines physics body used by the impostor
  116352. * @returns the PhysicsImpostor or null if not found
  116353. */
  116354. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116355. /**
  116356. * Does a raycast in the physics world
  116357. * @param from when should the ray start?
  116358. * @param to when should the ray end?
  116359. * @returns PhysicsRaycastResult
  116360. */
  116361. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116362. }
  116363. }
  116364. declare module BABYLON {
  116365. /** @hidden */
  116366. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116367. private _useDeltaForWorldStep;
  116368. world: any;
  116369. name: string;
  116370. private _physicsMaterials;
  116371. private _fixedTimeStep;
  116372. private _cannonRaycastResult;
  116373. private _raycastResult;
  116374. private _physicsBodysToRemoveAfterStep;
  116375. BJSCANNON: any;
  116376. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116377. setGravity(gravity: Vector3): void;
  116378. setTimeStep(timeStep: number): void;
  116379. getTimeStep(): number;
  116380. executeStep(delta: number): void;
  116381. private _removeMarkedPhysicsBodiesFromWorld;
  116382. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116383. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116384. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116385. private _processChildMeshes;
  116386. removePhysicsBody(impostor: PhysicsImpostor): void;
  116387. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116388. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116389. private _addMaterial;
  116390. private _checkWithEpsilon;
  116391. private _createShape;
  116392. private _createHeightmap;
  116393. private _minus90X;
  116394. private _plus90X;
  116395. private _tmpPosition;
  116396. private _tmpDeltaPosition;
  116397. private _tmpUnityRotation;
  116398. private _updatePhysicsBodyTransformation;
  116399. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116400. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116401. isSupported(): boolean;
  116402. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116403. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116404. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116405. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116406. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116407. getBodyMass(impostor: PhysicsImpostor): number;
  116408. getBodyFriction(impostor: PhysicsImpostor): number;
  116409. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116410. getBodyRestitution(impostor: PhysicsImpostor): number;
  116411. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116412. sleepBody(impostor: PhysicsImpostor): void;
  116413. wakeUpBody(impostor: PhysicsImpostor): void;
  116414. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116415. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116416. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116417. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116418. getRadius(impostor: PhysicsImpostor): number;
  116419. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116420. dispose(): void;
  116421. private _extendNamespace;
  116422. /**
  116423. * Does a raycast in the physics world
  116424. * @param from when should the ray start?
  116425. * @param to when should the ray end?
  116426. * @returns PhysicsRaycastResult
  116427. */
  116428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116429. }
  116430. }
  116431. declare module BABYLON {
  116432. /** @hidden */
  116433. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116434. world: any;
  116435. name: string;
  116436. BJSOIMO: any;
  116437. private _raycastResult;
  116438. constructor(iterations?: number, oimoInjection?: any);
  116439. setGravity(gravity: Vector3): void;
  116440. setTimeStep(timeStep: number): void;
  116441. getTimeStep(): number;
  116442. private _tmpImpostorsArray;
  116443. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116444. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116445. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116446. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116447. private _tmpPositionVector;
  116448. removePhysicsBody(impostor: PhysicsImpostor): void;
  116449. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116450. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116451. isSupported(): boolean;
  116452. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116454. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116455. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116456. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116457. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116458. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116459. getBodyMass(impostor: PhysicsImpostor): number;
  116460. getBodyFriction(impostor: PhysicsImpostor): number;
  116461. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116462. getBodyRestitution(impostor: PhysicsImpostor): number;
  116463. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116464. sleepBody(impostor: PhysicsImpostor): void;
  116465. wakeUpBody(impostor: PhysicsImpostor): void;
  116466. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116467. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116468. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116469. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116470. getRadius(impostor: PhysicsImpostor): number;
  116471. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116472. dispose(): void;
  116473. /**
  116474. * Does a raycast in the physics world
  116475. * @param from when should the ray start?
  116476. * @param to when should the ray end?
  116477. * @returns PhysicsRaycastResult
  116478. */
  116479. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116480. }
  116481. }
  116482. declare module BABYLON {
  116483. /**
  116484. * Class containing static functions to help procedurally build meshes
  116485. */
  116486. export class RibbonBuilder {
  116487. /**
  116488. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116489. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116490. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116491. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116492. * * 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
  116493. * * 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
  116494. * * 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
  116495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116497. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116498. * * 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
  116499. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116500. * * 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
  116501. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116503. * @param name defines the name of the mesh
  116504. * @param options defines the options used to create the mesh
  116505. * @param scene defines the hosting scene
  116506. * @returns the ribbon mesh
  116507. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116508. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116509. */
  116510. static CreateRibbon(name: string, options: {
  116511. pathArray: Vector3[][];
  116512. closeArray?: boolean;
  116513. closePath?: boolean;
  116514. offset?: number;
  116515. updatable?: boolean;
  116516. sideOrientation?: number;
  116517. frontUVs?: Vector4;
  116518. backUVs?: Vector4;
  116519. instance?: Mesh;
  116520. invertUV?: boolean;
  116521. uvs?: Vector2[];
  116522. colors?: Color4[];
  116523. }, scene?: Nullable<Scene>): Mesh;
  116524. }
  116525. }
  116526. declare module BABYLON {
  116527. /**
  116528. * Class containing static functions to help procedurally build meshes
  116529. */
  116530. export class ShapeBuilder {
  116531. /**
  116532. * 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.
  116533. * * 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.
  116534. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116535. * * 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.
  116536. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116537. * * 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
  116538. * * 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
  116539. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116544. * @param name defines the name of the mesh
  116545. * @param options defines the options used to create the mesh
  116546. * @param scene defines the hosting scene
  116547. * @returns the extruded shape mesh
  116548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116550. */
  116551. static ExtrudeShape(name: string, options: {
  116552. shape: Vector3[];
  116553. path: Vector3[];
  116554. scale?: number;
  116555. rotation?: number;
  116556. cap?: number;
  116557. updatable?: boolean;
  116558. sideOrientation?: number;
  116559. frontUVs?: Vector4;
  116560. backUVs?: Vector4;
  116561. instance?: Mesh;
  116562. invertUV?: boolean;
  116563. }, scene?: Nullable<Scene>): Mesh;
  116564. /**
  116565. * Creates an custom extruded shape mesh.
  116566. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116567. * * 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.
  116568. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116569. * * 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
  116570. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116571. * * 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
  116572. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116573. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116574. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116575. * * 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
  116576. * * 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
  116577. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116582. * @param name defines the name of the mesh
  116583. * @param options defines the options used to create the mesh
  116584. * @param scene defines the hosting scene
  116585. * @returns the custom extruded shape mesh
  116586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116589. */
  116590. static ExtrudeShapeCustom(name: string, options: {
  116591. shape: Vector3[];
  116592. path: Vector3[];
  116593. scaleFunction?: any;
  116594. rotationFunction?: any;
  116595. ribbonCloseArray?: boolean;
  116596. ribbonClosePath?: boolean;
  116597. cap?: number;
  116598. updatable?: boolean;
  116599. sideOrientation?: number;
  116600. frontUVs?: Vector4;
  116601. backUVs?: Vector4;
  116602. instance?: Mesh;
  116603. invertUV?: boolean;
  116604. }, scene?: Nullable<Scene>): Mesh;
  116605. private static _ExtrudeShapeGeneric;
  116606. }
  116607. }
  116608. declare module BABYLON {
  116609. /**
  116610. * AmmoJS Physics plugin
  116611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116612. * @see https://github.com/kripken/ammo.js/
  116613. */
  116614. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116615. private _useDeltaForWorldStep;
  116616. /**
  116617. * Reference to the Ammo library
  116618. */
  116619. bjsAMMO: any;
  116620. /**
  116621. * Created ammoJS world which physics bodies are added to
  116622. */
  116623. world: any;
  116624. /**
  116625. * Name of the plugin
  116626. */
  116627. name: string;
  116628. private _timeStep;
  116629. private _fixedTimeStep;
  116630. private _maxSteps;
  116631. private _tmpQuaternion;
  116632. private _tmpAmmoTransform;
  116633. private _tmpAmmoQuaternion;
  116634. private _tmpAmmoConcreteContactResultCallback;
  116635. private _collisionConfiguration;
  116636. private _dispatcher;
  116637. private _overlappingPairCache;
  116638. private _solver;
  116639. private _softBodySolver;
  116640. private _tmpAmmoVectorA;
  116641. private _tmpAmmoVectorB;
  116642. private _tmpAmmoVectorC;
  116643. private _tmpAmmoVectorD;
  116644. private _tmpContactCallbackResult;
  116645. private _tmpAmmoVectorRCA;
  116646. private _tmpAmmoVectorRCB;
  116647. private _raycastResult;
  116648. private static readonly DISABLE_COLLISION_FLAG;
  116649. private static readonly KINEMATIC_FLAG;
  116650. private static readonly DISABLE_DEACTIVATION_FLAG;
  116651. /**
  116652. * Initializes the ammoJS plugin
  116653. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116654. * @param ammoInjection can be used to inject your own ammo reference
  116655. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116656. */
  116657. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116658. /**
  116659. * Sets the gravity of the physics world (m/(s^2))
  116660. * @param gravity Gravity to set
  116661. */
  116662. setGravity(gravity: Vector3): void;
  116663. /**
  116664. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116665. * @param timeStep timestep to use in seconds
  116666. */
  116667. setTimeStep(timeStep: number): void;
  116668. /**
  116669. * 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)
  116670. * @param fixedTimeStep fixedTimeStep to use in seconds
  116671. */
  116672. setFixedTimeStep(fixedTimeStep: number): void;
  116673. /**
  116674. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116675. * @param maxSteps the maximum number of steps by the physics engine per frame
  116676. */
  116677. setMaxSteps(maxSteps: number): void;
  116678. /**
  116679. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116680. * @returns the current timestep in seconds
  116681. */
  116682. getTimeStep(): number;
  116683. private _isImpostorInContact;
  116684. private _isImpostorPairInContact;
  116685. private _stepSimulation;
  116686. /**
  116687. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116688. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116689. * After the step the babylon meshes are set to the position of the physics imposters
  116690. * @param delta amount of time to step forward
  116691. * @param impostors array of imposters to update before/after the step
  116692. */
  116693. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116694. /**
  116695. * Update babylon mesh to match physics world object
  116696. * @param impostor imposter to match
  116697. */
  116698. private _afterSoftStep;
  116699. /**
  116700. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116701. * @param impostor imposter to match
  116702. */
  116703. private _ropeStep;
  116704. /**
  116705. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116706. * @param impostor imposter to match
  116707. */
  116708. private _softbodyOrClothStep;
  116709. private _tmpVector;
  116710. private _tmpMatrix;
  116711. /**
  116712. * Applies an impulse on the imposter
  116713. * @param impostor imposter to apply impulse to
  116714. * @param force amount of force to be applied to the imposter
  116715. * @param contactPoint the location to apply the impulse on the imposter
  116716. */
  116717. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116718. /**
  116719. * Applies a force on the imposter
  116720. * @param impostor imposter to apply force
  116721. * @param force amount of force to be applied to the imposter
  116722. * @param contactPoint the location to apply the force on the imposter
  116723. */
  116724. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116725. /**
  116726. * Creates a physics body using the plugin
  116727. * @param impostor the imposter to create the physics body on
  116728. */
  116729. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116730. /**
  116731. * Removes the physics body from the imposter and disposes of the body's memory
  116732. * @param impostor imposter to remove the physics body from
  116733. */
  116734. removePhysicsBody(impostor: PhysicsImpostor): void;
  116735. /**
  116736. * Generates a joint
  116737. * @param impostorJoint the imposter joint to create the joint with
  116738. */
  116739. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116740. /**
  116741. * Removes a joint
  116742. * @param impostorJoint the imposter joint to remove the joint from
  116743. */
  116744. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116745. private _addMeshVerts;
  116746. /**
  116747. * Initialise the soft body vertices to match its object's (mesh) vertices
  116748. * Softbody vertices (nodes) are in world space and to match this
  116749. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116750. * @param impostor to create the softbody for
  116751. */
  116752. private _softVertexData;
  116753. /**
  116754. * Create an impostor's soft body
  116755. * @param impostor to create the softbody for
  116756. */
  116757. private _createSoftbody;
  116758. /**
  116759. * Create cloth for an impostor
  116760. * @param impostor to create the softbody for
  116761. */
  116762. private _createCloth;
  116763. /**
  116764. * Create rope for an impostor
  116765. * @param impostor to create the softbody for
  116766. */
  116767. private _createRope;
  116768. private _addHullVerts;
  116769. private _createShape;
  116770. /**
  116771. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116772. * @param impostor imposter containing the physics body and babylon object
  116773. */
  116774. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116775. /**
  116776. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116777. * @param impostor imposter containing the physics body and babylon object
  116778. * @param newPosition new position
  116779. * @param newRotation new rotation
  116780. */
  116781. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116782. /**
  116783. * If this plugin is supported
  116784. * @returns true if its supported
  116785. */
  116786. isSupported(): boolean;
  116787. /**
  116788. * Sets the linear velocity of the physics body
  116789. * @param impostor imposter to set the velocity on
  116790. * @param velocity velocity to set
  116791. */
  116792. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116793. /**
  116794. * Sets the angular velocity of the physics body
  116795. * @param impostor imposter to set the velocity on
  116796. * @param velocity velocity to set
  116797. */
  116798. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116799. /**
  116800. * gets the linear velocity
  116801. * @param impostor imposter to get linear velocity from
  116802. * @returns linear velocity
  116803. */
  116804. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116805. /**
  116806. * gets the angular velocity
  116807. * @param impostor imposter to get angular velocity from
  116808. * @returns angular velocity
  116809. */
  116810. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116811. /**
  116812. * Sets the mass of physics body
  116813. * @param impostor imposter to set the mass on
  116814. * @param mass mass to set
  116815. */
  116816. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116817. /**
  116818. * Gets the mass of the physics body
  116819. * @param impostor imposter to get the mass from
  116820. * @returns mass
  116821. */
  116822. getBodyMass(impostor: PhysicsImpostor): number;
  116823. /**
  116824. * Gets friction of the impostor
  116825. * @param impostor impostor to get friction from
  116826. * @returns friction value
  116827. */
  116828. getBodyFriction(impostor: PhysicsImpostor): number;
  116829. /**
  116830. * Sets friction of the impostor
  116831. * @param impostor impostor to set friction on
  116832. * @param friction friction value
  116833. */
  116834. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116835. /**
  116836. * Gets restitution of the impostor
  116837. * @param impostor impostor to get restitution from
  116838. * @returns restitution value
  116839. */
  116840. getBodyRestitution(impostor: PhysicsImpostor): number;
  116841. /**
  116842. * Sets resitution of the impostor
  116843. * @param impostor impostor to set resitution on
  116844. * @param restitution resitution value
  116845. */
  116846. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116847. /**
  116848. * Gets pressure inside the impostor
  116849. * @param impostor impostor to get pressure from
  116850. * @returns pressure value
  116851. */
  116852. getBodyPressure(impostor: PhysicsImpostor): number;
  116853. /**
  116854. * Sets pressure inside a soft body impostor
  116855. * Cloth and rope must remain 0 pressure
  116856. * @param impostor impostor to set pressure on
  116857. * @param pressure pressure value
  116858. */
  116859. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116860. /**
  116861. * Gets stiffness of the impostor
  116862. * @param impostor impostor to get stiffness from
  116863. * @returns pressure value
  116864. */
  116865. getBodyStiffness(impostor: PhysicsImpostor): number;
  116866. /**
  116867. * Sets stiffness of the impostor
  116868. * @param impostor impostor to set stiffness on
  116869. * @param stiffness stiffness value from 0 to 1
  116870. */
  116871. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116872. /**
  116873. * Gets velocityIterations of the impostor
  116874. * @param impostor impostor to get velocity iterations from
  116875. * @returns velocityIterations value
  116876. */
  116877. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116878. /**
  116879. * Sets velocityIterations of the impostor
  116880. * @param impostor impostor to set velocity iterations on
  116881. * @param velocityIterations velocityIterations value
  116882. */
  116883. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116884. /**
  116885. * Gets positionIterations of the impostor
  116886. * @param impostor impostor to get position iterations from
  116887. * @returns positionIterations value
  116888. */
  116889. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116890. /**
  116891. * Sets positionIterations of the impostor
  116892. * @param impostor impostor to set position on
  116893. * @param positionIterations positionIterations value
  116894. */
  116895. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116896. /**
  116897. * Append an anchor to a cloth object
  116898. * @param impostor is the cloth impostor to add anchor to
  116899. * @param otherImpostor is the rigid impostor to anchor to
  116900. * @param width ratio across width from 0 to 1
  116901. * @param height ratio up height from 0 to 1
  116902. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116903. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116904. */
  116905. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116906. /**
  116907. * Append an hook to a rope object
  116908. * @param impostor is the rope impostor to add hook to
  116909. * @param otherImpostor is the rigid impostor to hook to
  116910. * @param length ratio along the rope from 0 to 1
  116911. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116912. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116913. */
  116914. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116915. /**
  116916. * Sleeps the physics body and stops it from being active
  116917. * @param impostor impostor to sleep
  116918. */
  116919. sleepBody(impostor: PhysicsImpostor): void;
  116920. /**
  116921. * Activates the physics body
  116922. * @param impostor impostor to activate
  116923. */
  116924. wakeUpBody(impostor: PhysicsImpostor): void;
  116925. /**
  116926. * Updates the distance parameters of the joint
  116927. * @param joint joint to update
  116928. * @param maxDistance maximum distance of the joint
  116929. * @param minDistance minimum distance of the joint
  116930. */
  116931. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116932. /**
  116933. * Sets a motor on the joint
  116934. * @param joint joint to set motor on
  116935. * @param speed speed of the motor
  116936. * @param maxForce maximum force of the motor
  116937. * @param motorIndex index of the motor
  116938. */
  116939. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116940. /**
  116941. * Sets the motors limit
  116942. * @param joint joint to set limit on
  116943. * @param upperLimit upper limit
  116944. * @param lowerLimit lower limit
  116945. */
  116946. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116947. /**
  116948. * Syncs the position and rotation of a mesh with the impostor
  116949. * @param mesh mesh to sync
  116950. * @param impostor impostor to update the mesh with
  116951. */
  116952. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116953. /**
  116954. * Gets the radius of the impostor
  116955. * @param impostor impostor to get radius from
  116956. * @returns the radius
  116957. */
  116958. getRadius(impostor: PhysicsImpostor): number;
  116959. /**
  116960. * Gets the box size of the impostor
  116961. * @param impostor impostor to get box size from
  116962. * @param result the resulting box size
  116963. */
  116964. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116965. /**
  116966. * Disposes of the impostor
  116967. */
  116968. dispose(): void;
  116969. /**
  116970. * Does a raycast in the physics world
  116971. * @param from when should the ray start?
  116972. * @param to when should the ray end?
  116973. * @returns PhysicsRaycastResult
  116974. */
  116975. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116976. }
  116977. }
  116978. declare module BABYLON {
  116979. interface AbstractScene {
  116980. /**
  116981. * The list of reflection probes added to the scene
  116982. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116983. */
  116984. reflectionProbes: Array<ReflectionProbe>;
  116985. /**
  116986. * Removes the given reflection probe from this scene.
  116987. * @param toRemove The reflection probe to remove
  116988. * @returns The index of the removed reflection probe
  116989. */
  116990. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116991. /**
  116992. * Adds the given reflection probe to this scene.
  116993. * @param newReflectionProbe The reflection probe to add
  116994. */
  116995. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116996. }
  116997. /**
  116998. * Class used to generate realtime reflection / refraction cube textures
  116999. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  117000. */
  117001. export class ReflectionProbe {
  117002. /** defines the name of the probe */
  117003. name: string;
  117004. private _scene;
  117005. private _renderTargetTexture;
  117006. private _projectionMatrix;
  117007. private _viewMatrix;
  117008. private _target;
  117009. private _add;
  117010. private _attachedMesh;
  117011. private _invertYAxis;
  117012. /** Gets or sets probe position (center of the cube map) */
  117013. position: Vector3;
  117014. /**
  117015. * Creates a new reflection probe
  117016. * @param name defines the name of the probe
  117017. * @param size defines the texture resolution (for each face)
  117018. * @param scene defines the hosting scene
  117019. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  117020. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  117021. */
  117022. constructor(
  117023. /** defines the name of the probe */
  117024. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  117025. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  117026. samples: number;
  117027. /** Gets or sets the refresh rate to use (on every frame by default) */
  117028. refreshRate: number;
  117029. /**
  117030. * Gets the hosting scene
  117031. * @returns a Scene
  117032. */
  117033. getScene(): Scene;
  117034. /** Gets the internal CubeTexture used to render to */
  117035. readonly cubeTexture: RenderTargetTexture;
  117036. /** Gets the list of meshes to render */
  117037. readonly renderList: Nullable<AbstractMesh[]>;
  117038. /**
  117039. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  117040. * @param mesh defines the mesh to attach to
  117041. */
  117042. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  117043. /**
  117044. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  117045. * @param renderingGroupId The rendering group id corresponding to its index
  117046. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117047. */
  117048. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  117049. /**
  117050. * Clean all associated resources
  117051. */
  117052. dispose(): void;
  117053. /**
  117054. * Converts the reflection probe information to a readable string for debug purpose.
  117055. * @param fullDetails Supports for multiple levels of logging within scene loading
  117056. * @returns the human readable reflection probe info
  117057. */
  117058. toString(fullDetails?: boolean): string;
  117059. /**
  117060. * Get the class name of the relfection probe.
  117061. * @returns "ReflectionProbe"
  117062. */
  117063. getClassName(): string;
  117064. /**
  117065. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  117066. * @returns The JSON representation of the texture
  117067. */
  117068. serialize(): any;
  117069. /**
  117070. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  117071. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  117072. * @param scene Define the scene the parsed reflection probe should be instantiated in
  117073. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  117074. * @returns The parsed reflection probe if successful
  117075. */
  117076. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  117077. }
  117078. }
  117079. declare module BABYLON {
  117080. /** @hidden */
  117081. export var _BabylonLoaderRegistered: boolean;
  117082. }
  117083. declare module BABYLON {
  117084. /**
  117085. * The Physically based simple base material of BJS.
  117086. *
  117087. * This enables better naming and convention enforcements on top of the pbrMaterial.
  117088. * It is used as the base class for both the specGloss and metalRough conventions.
  117089. */
  117090. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  117091. /**
  117092. * Number of Simultaneous lights allowed on the material.
  117093. */
  117094. maxSimultaneousLights: number;
  117095. /**
  117096. * If sets to true, disables all the lights affecting the material.
  117097. */
  117098. disableLighting: boolean;
  117099. /**
  117100. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  117101. */
  117102. environmentTexture: BaseTexture;
  117103. /**
  117104. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117105. */
  117106. invertNormalMapX: boolean;
  117107. /**
  117108. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117109. */
  117110. invertNormalMapY: boolean;
  117111. /**
  117112. * Normal map used in the model.
  117113. */
  117114. normalTexture: BaseTexture;
  117115. /**
  117116. * Emissivie color used to self-illuminate the model.
  117117. */
  117118. emissiveColor: Color3;
  117119. /**
  117120. * Emissivie texture used to self-illuminate the model.
  117121. */
  117122. emissiveTexture: BaseTexture;
  117123. /**
  117124. * Occlusion Channel Strenght.
  117125. */
  117126. occlusionStrength: number;
  117127. /**
  117128. * Occlusion Texture of the material (adding extra occlusion effects).
  117129. */
  117130. occlusionTexture: BaseTexture;
  117131. /**
  117132. * Defines the alpha limits in alpha test mode.
  117133. */
  117134. alphaCutOff: number;
  117135. /**
  117136. * Gets the current double sided mode.
  117137. */
  117138. /**
  117139. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117140. */
  117141. doubleSided: boolean;
  117142. /**
  117143. * Stores the pre-calculated light information of a mesh in a texture.
  117144. */
  117145. lightmapTexture: BaseTexture;
  117146. /**
  117147. * If true, the light map contains occlusion information instead of lighting info.
  117148. */
  117149. useLightmapAsShadowmap: boolean;
  117150. /**
  117151. * Instantiates a new PBRMaterial instance.
  117152. *
  117153. * @param name The material name
  117154. * @param scene The scene the material will be use in.
  117155. */
  117156. constructor(name: string, scene: Scene);
  117157. getClassName(): string;
  117158. }
  117159. }
  117160. declare module BABYLON {
  117161. /**
  117162. * The PBR material of BJS following the metal roughness convention.
  117163. *
  117164. * This fits to the PBR convention in the GLTF definition:
  117165. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117166. */
  117167. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117168. /**
  117169. * The base color has two different interpretations depending on the value of metalness.
  117170. * When the material is a metal, the base color is the specific measured reflectance value
  117171. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117172. * of the material.
  117173. */
  117174. baseColor: Color3;
  117175. /**
  117176. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117177. * well as opacity information in the alpha channel.
  117178. */
  117179. baseTexture: BaseTexture;
  117180. /**
  117181. * Specifies the metallic scalar value of the material.
  117182. * Can also be used to scale the metalness values of the metallic texture.
  117183. */
  117184. metallic: number;
  117185. /**
  117186. * Specifies the roughness scalar value of the material.
  117187. * Can also be used to scale the roughness values of the metallic texture.
  117188. */
  117189. roughness: number;
  117190. /**
  117191. * Texture containing both the metallic value in the B channel and the
  117192. * roughness value in the G channel to keep better precision.
  117193. */
  117194. metallicRoughnessTexture: BaseTexture;
  117195. /**
  117196. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117197. *
  117198. * @param name The material name
  117199. * @param scene The scene the material will be use in.
  117200. */
  117201. constructor(name: string, scene: Scene);
  117202. /**
  117203. * Return the currrent class name of the material.
  117204. */
  117205. getClassName(): string;
  117206. /**
  117207. * Makes a duplicate of the current material.
  117208. * @param name - name to use for the new material.
  117209. */
  117210. clone(name: string): PBRMetallicRoughnessMaterial;
  117211. /**
  117212. * Serialize the material to a parsable JSON object.
  117213. */
  117214. serialize(): any;
  117215. /**
  117216. * Parses a JSON object correponding to the serialize function.
  117217. */
  117218. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117219. }
  117220. }
  117221. declare module BABYLON {
  117222. /**
  117223. * The PBR material of BJS following the specular glossiness convention.
  117224. *
  117225. * This fits to the PBR convention in the GLTF definition:
  117226. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117227. */
  117228. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117229. /**
  117230. * Specifies the diffuse color of the material.
  117231. */
  117232. diffuseColor: Color3;
  117233. /**
  117234. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117235. * channel.
  117236. */
  117237. diffuseTexture: BaseTexture;
  117238. /**
  117239. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117240. */
  117241. specularColor: Color3;
  117242. /**
  117243. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117244. */
  117245. glossiness: number;
  117246. /**
  117247. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117248. */
  117249. specularGlossinessTexture: BaseTexture;
  117250. /**
  117251. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117252. *
  117253. * @param name The material name
  117254. * @param scene The scene the material will be use in.
  117255. */
  117256. constructor(name: string, scene: Scene);
  117257. /**
  117258. * Return the currrent class name of the material.
  117259. */
  117260. getClassName(): string;
  117261. /**
  117262. * Makes a duplicate of the current material.
  117263. * @param name - name to use for the new material.
  117264. */
  117265. clone(name: string): PBRSpecularGlossinessMaterial;
  117266. /**
  117267. * Serialize the material to a parsable JSON object.
  117268. */
  117269. serialize(): any;
  117270. /**
  117271. * Parses a JSON object correponding to the serialize function.
  117272. */
  117273. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117274. }
  117275. }
  117276. declare module BABYLON {
  117277. /**
  117278. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117279. * It can help converting any input color in a desired output one. This can then be used to create effects
  117280. * from sepia, black and white to sixties or futuristic rendering...
  117281. *
  117282. * The only supported format is currently 3dl.
  117283. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117284. */
  117285. export class ColorGradingTexture extends BaseTexture {
  117286. /**
  117287. * The current texture matrix. (will always be identity in color grading texture)
  117288. */
  117289. private _textureMatrix;
  117290. /**
  117291. * The texture URL.
  117292. */
  117293. url: string;
  117294. /**
  117295. * Empty line regex stored for GC.
  117296. */
  117297. private static _noneEmptyLineRegex;
  117298. private _engine;
  117299. /**
  117300. * Instantiates a ColorGradingTexture from the following parameters.
  117301. *
  117302. * @param url The location of the color gradind data (currently only supporting 3dl)
  117303. * @param scene The scene the texture will be used in
  117304. */
  117305. constructor(url: string, scene: Scene);
  117306. /**
  117307. * Returns the texture matrix used in most of the material.
  117308. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117309. */
  117310. getTextureMatrix(): Matrix;
  117311. /**
  117312. * Occurs when the file being loaded is a .3dl LUT file.
  117313. */
  117314. private load3dlTexture;
  117315. /**
  117316. * Starts the loading process of the texture.
  117317. */
  117318. private loadTexture;
  117319. /**
  117320. * Clones the color gradind texture.
  117321. */
  117322. clone(): ColorGradingTexture;
  117323. /**
  117324. * Called during delayed load for textures.
  117325. */
  117326. delayLoad(): void;
  117327. /**
  117328. * Parses a color grading texture serialized by Babylon.
  117329. * @param parsedTexture The texture information being parsedTexture
  117330. * @param scene The scene to load the texture in
  117331. * @param rootUrl The root url of the data assets to load
  117332. * @return A color gradind texture
  117333. */
  117334. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117335. /**
  117336. * Serializes the LUT texture to json format.
  117337. */
  117338. serialize(): any;
  117339. }
  117340. }
  117341. declare module BABYLON {
  117342. /**
  117343. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117344. */
  117345. export class EquiRectangularCubeTexture extends BaseTexture {
  117346. /** The six faces of the cube. */
  117347. private static _FacesMapping;
  117348. private _noMipmap;
  117349. private _onLoad;
  117350. private _onError;
  117351. /** The size of the cubemap. */
  117352. private _size;
  117353. /** The buffer of the image. */
  117354. private _buffer;
  117355. /** The width of the input image. */
  117356. private _width;
  117357. /** The height of the input image. */
  117358. private _height;
  117359. /** The URL to the image. */
  117360. url: string;
  117361. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117362. coordinatesMode: number;
  117363. /**
  117364. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117365. * @param url The location of the image
  117366. * @param scene The scene the texture will be used in
  117367. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117368. * @param noMipmap Forces to not generate the mipmap if true
  117369. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117370. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117371. * @param onLoad — defines a callback called when texture is loaded
  117372. * @param onError — defines a callback called if there is an error
  117373. */
  117374. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117375. /**
  117376. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117377. */
  117378. private loadImage;
  117379. /**
  117380. * Convert the image buffer into a cubemap and create a CubeTexture.
  117381. */
  117382. private loadTexture;
  117383. /**
  117384. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117385. * @param buffer The ArrayBuffer that should be converted.
  117386. * @returns The buffer as Float32Array.
  117387. */
  117388. private getFloat32ArrayFromArrayBuffer;
  117389. /**
  117390. * Get the current class name of the texture useful for serialization or dynamic coding.
  117391. * @returns "EquiRectangularCubeTexture"
  117392. */
  117393. getClassName(): string;
  117394. /**
  117395. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117396. * @returns A clone of the current EquiRectangularCubeTexture.
  117397. */
  117398. clone(): EquiRectangularCubeTexture;
  117399. }
  117400. }
  117401. declare module BABYLON {
  117402. /**
  117403. * Based on jsTGALoader - Javascript loader for TGA file
  117404. * By Vincent Thibault
  117405. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117406. */
  117407. export class TGATools {
  117408. private static _TYPE_INDEXED;
  117409. private static _TYPE_RGB;
  117410. private static _TYPE_GREY;
  117411. private static _TYPE_RLE_INDEXED;
  117412. private static _TYPE_RLE_RGB;
  117413. private static _TYPE_RLE_GREY;
  117414. private static _ORIGIN_MASK;
  117415. private static _ORIGIN_SHIFT;
  117416. private static _ORIGIN_BL;
  117417. private static _ORIGIN_BR;
  117418. private static _ORIGIN_UL;
  117419. private static _ORIGIN_UR;
  117420. /**
  117421. * Gets the header of a TGA file
  117422. * @param data defines the TGA data
  117423. * @returns the header
  117424. */
  117425. static GetTGAHeader(data: Uint8Array): any;
  117426. /**
  117427. * Uploads TGA content to a Babylon Texture
  117428. * @hidden
  117429. */
  117430. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117431. /** @hidden */
  117432. 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;
  117433. /** @hidden */
  117434. 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;
  117435. /** @hidden */
  117436. 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;
  117437. /** @hidden */
  117438. 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;
  117439. /** @hidden */
  117440. 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;
  117441. /** @hidden */
  117442. 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;
  117443. }
  117444. }
  117445. declare module BABYLON {
  117446. /**
  117447. * Implementation of the TGA Texture Loader.
  117448. * @hidden
  117449. */
  117450. export class _TGATextureLoader implements IInternalTextureLoader {
  117451. /**
  117452. * Defines wether the loader supports cascade loading the different faces.
  117453. */
  117454. readonly supportCascades: boolean;
  117455. /**
  117456. * This returns if the loader support the current file information.
  117457. * @param extension defines the file extension of the file being loaded
  117458. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117459. * @param fallback defines the fallback internal texture if any
  117460. * @param isBase64 defines whether the texture is encoded as a base64
  117461. * @param isBuffer defines whether the texture data are stored as a buffer
  117462. * @returns true if the loader can load the specified file
  117463. */
  117464. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117465. /**
  117466. * Transform the url before loading if required.
  117467. * @param rootUrl the url of the texture
  117468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117469. * @returns the transformed texture
  117470. */
  117471. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117472. /**
  117473. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117474. * @param rootUrl the url of the texture
  117475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117476. * @returns the fallback texture
  117477. */
  117478. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117479. /**
  117480. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117481. * @param data contains the texture data
  117482. * @param texture defines the BabylonJS internal texture
  117483. * @param createPolynomials will be true if polynomials have been requested
  117484. * @param onLoad defines the callback to trigger once the texture is ready
  117485. * @param onError defines the callback to trigger in case of error
  117486. */
  117487. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117488. /**
  117489. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117490. * @param data contains the texture data
  117491. * @param texture defines the BabylonJS internal texture
  117492. * @param callback defines the method to call once ready to upload
  117493. */
  117494. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117495. }
  117496. }
  117497. declare module BABYLON {
  117498. /**
  117499. * Info about the .basis files
  117500. */
  117501. class BasisFileInfo {
  117502. /**
  117503. * If the file has alpha
  117504. */
  117505. hasAlpha: boolean;
  117506. /**
  117507. * Info about each image of the basis file
  117508. */
  117509. images: Array<{
  117510. levels: Array<{
  117511. width: number;
  117512. height: number;
  117513. transcodedPixels: ArrayBufferView;
  117514. }>;
  117515. }>;
  117516. }
  117517. /**
  117518. * Result of transcoding a basis file
  117519. */
  117520. class TranscodeResult {
  117521. /**
  117522. * Info about the .basis file
  117523. */
  117524. fileInfo: BasisFileInfo;
  117525. /**
  117526. * Format to use when loading the file
  117527. */
  117528. format: number;
  117529. }
  117530. /**
  117531. * Configuration options for the Basis transcoder
  117532. */
  117533. export class BasisTranscodeConfiguration {
  117534. /**
  117535. * Supported compression formats used to determine the supported output format of the transcoder
  117536. */
  117537. supportedCompressionFormats?: {
  117538. /**
  117539. * etc1 compression format
  117540. */
  117541. etc1?: boolean;
  117542. /**
  117543. * s3tc compression format
  117544. */
  117545. s3tc?: boolean;
  117546. /**
  117547. * pvrtc compression format
  117548. */
  117549. pvrtc?: boolean;
  117550. /**
  117551. * etc2 compression format
  117552. */
  117553. etc2?: boolean;
  117554. };
  117555. /**
  117556. * If mipmap levels should be loaded for transcoded images (Default: true)
  117557. */
  117558. loadMipmapLevels?: boolean;
  117559. /**
  117560. * Index of a single image to load (Default: all images)
  117561. */
  117562. loadSingleImage?: number;
  117563. }
  117564. /**
  117565. * Used to load .Basis files
  117566. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117567. */
  117568. export class BasisTools {
  117569. private static _IgnoreSupportedFormats;
  117570. /**
  117571. * URL to use when loading the basis transcoder
  117572. */
  117573. static JSModuleURL: string;
  117574. /**
  117575. * URL to use when loading the wasm module for the transcoder
  117576. */
  117577. static WasmModuleURL: string;
  117578. /**
  117579. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117580. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117581. * @returns internal format corresponding to the Basis format
  117582. */
  117583. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117584. private static _WorkerPromise;
  117585. private static _Worker;
  117586. private static _actionId;
  117587. private static _CreateWorkerAsync;
  117588. /**
  117589. * Transcodes a loaded image file to compressed pixel data
  117590. * @param imageData image data to transcode
  117591. * @param config configuration options for the transcoding
  117592. * @returns a promise resulting in the transcoded image
  117593. */
  117594. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117595. /**
  117596. * Loads a texture from the transcode result
  117597. * @param texture texture load to
  117598. * @param transcodeResult the result of transcoding the basis file to load from
  117599. */
  117600. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117601. }
  117602. }
  117603. declare module BABYLON {
  117604. /**
  117605. * Loader for .basis file format
  117606. */
  117607. export class _BasisTextureLoader implements IInternalTextureLoader {
  117608. /**
  117609. * Defines whether the loader supports cascade loading the different faces.
  117610. */
  117611. readonly supportCascades: boolean;
  117612. /**
  117613. * This returns if the loader support the current file information.
  117614. * @param extension defines the file extension of the file being loaded
  117615. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117616. * @param fallback defines the fallback internal texture if any
  117617. * @param isBase64 defines whether the texture is encoded as a base64
  117618. * @param isBuffer defines whether the texture data are stored as a buffer
  117619. * @returns true if the loader can load the specified file
  117620. */
  117621. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117622. /**
  117623. * Transform the url before loading if required.
  117624. * @param rootUrl the url of the texture
  117625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117626. * @returns the transformed texture
  117627. */
  117628. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117629. /**
  117630. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117631. * @param rootUrl the url of the texture
  117632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117633. * @returns the fallback texture
  117634. */
  117635. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117636. /**
  117637. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117638. * @param data contains the texture data
  117639. * @param texture defines the BabylonJS internal texture
  117640. * @param createPolynomials will be true if polynomials have been requested
  117641. * @param onLoad defines the callback to trigger once the texture is ready
  117642. * @param onError defines the callback to trigger in case of error
  117643. */
  117644. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117645. /**
  117646. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117647. * @param data contains the texture data
  117648. * @param texture defines the BabylonJS internal texture
  117649. * @param callback defines the method to call once ready to upload
  117650. */
  117651. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117652. }
  117653. }
  117654. declare module BABYLON {
  117655. /**
  117656. * 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.
  117657. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117658. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117659. */
  117660. export class CustomProceduralTexture extends ProceduralTexture {
  117661. private _animate;
  117662. private _time;
  117663. private _config;
  117664. private _texturePath;
  117665. /**
  117666. * Instantiates a new Custom Procedural Texture.
  117667. * 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.
  117668. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117669. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117670. * @param name Define the name of the texture
  117671. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117672. * @param size Define the size of the texture to create
  117673. * @param scene Define the scene the texture belongs to
  117674. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117675. * @param generateMipMaps Define if the texture should creates mip maps or not
  117676. */
  117677. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117678. private _loadJson;
  117679. /**
  117680. * Is the texture ready to be used ? (rendered at least once)
  117681. * @returns true if ready, otherwise, false.
  117682. */
  117683. isReady(): boolean;
  117684. /**
  117685. * Render the texture to its associated render target.
  117686. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117687. */
  117688. render(useCameraPostProcess?: boolean): void;
  117689. /**
  117690. * Update the list of dependant textures samplers in the shader.
  117691. */
  117692. updateTextures(): void;
  117693. /**
  117694. * Update the uniform values of the procedural texture in the shader.
  117695. */
  117696. updateShaderUniforms(): void;
  117697. /**
  117698. * Define if the texture animates or not.
  117699. */
  117700. animate: boolean;
  117701. }
  117702. }
  117703. declare module BABYLON {
  117704. /** @hidden */
  117705. export var noisePixelShader: {
  117706. name: string;
  117707. shader: string;
  117708. };
  117709. }
  117710. declare module BABYLON {
  117711. /**
  117712. * Class used to generate noise procedural textures
  117713. */
  117714. export class NoiseProceduralTexture extends ProceduralTexture {
  117715. private _time;
  117716. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117717. brightness: number;
  117718. /** Defines the number of octaves to process */
  117719. octaves: number;
  117720. /** Defines the level of persistence (0.8 by default) */
  117721. persistence: number;
  117722. /** Gets or sets animation speed factor (default is 1) */
  117723. animationSpeedFactor: number;
  117724. /**
  117725. * Creates a new NoiseProceduralTexture
  117726. * @param name defines the name fo the texture
  117727. * @param size defines the size of the texture (default is 256)
  117728. * @param scene defines the hosting scene
  117729. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117730. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117731. */
  117732. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117733. private _updateShaderUniforms;
  117734. protected _getDefines(): string;
  117735. /** Generate the current state of the procedural texture */
  117736. render(useCameraPostProcess?: boolean): void;
  117737. /**
  117738. * Serializes this noise procedural texture
  117739. * @returns a serialized noise procedural texture object
  117740. */
  117741. serialize(): any;
  117742. /**
  117743. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117744. * @param parsedTexture defines parsed texture data
  117745. * @param scene defines the current scene
  117746. * @param rootUrl defines the root URL containing noise procedural texture information
  117747. * @returns a parsed NoiseProceduralTexture
  117748. */
  117749. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117750. }
  117751. }
  117752. declare module BABYLON {
  117753. /**
  117754. * Raw cube texture where the raw buffers are passed in
  117755. */
  117756. export class RawCubeTexture extends CubeTexture {
  117757. /**
  117758. * Creates a cube texture where the raw buffers are passed in.
  117759. * @param scene defines the scene the texture is attached to
  117760. * @param data defines the array of data to use to create each face
  117761. * @param size defines the size of the textures
  117762. * @param format defines the format of the data
  117763. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117764. * @param generateMipMaps defines if the engine should generate the mip levels
  117765. * @param invertY defines if data must be stored with Y axis inverted
  117766. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117767. * @param compression defines the compression used (null by default)
  117768. */
  117769. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117770. /**
  117771. * Updates the raw cube texture.
  117772. * @param data defines the data to store
  117773. * @param format defines the data format
  117774. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117775. * @param invertY defines if data must be stored with Y axis inverted
  117776. * @param compression defines the compression used (null by default)
  117777. * @param level defines which level of the texture to update
  117778. */
  117779. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117780. /**
  117781. * Updates a raw cube texture with RGBD encoded data.
  117782. * @param data defines the array of data [mipmap][face] to use to create each face
  117783. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117784. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117785. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117786. * @returns a promsie that resolves when the operation is complete
  117787. */
  117788. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117789. /**
  117790. * Clones the raw cube texture.
  117791. * @return a new cube texture
  117792. */
  117793. clone(): CubeTexture;
  117794. /** @hidden */
  117795. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117796. }
  117797. }
  117798. declare module BABYLON {
  117799. /**
  117800. * Class used to store 3D textures containing user data
  117801. */
  117802. export class RawTexture3D extends Texture {
  117803. /** Gets or sets the texture format to use */
  117804. format: number;
  117805. private _engine;
  117806. /**
  117807. * Create a new RawTexture3D
  117808. * @param data defines the data of the texture
  117809. * @param width defines the width of the texture
  117810. * @param height defines the height of the texture
  117811. * @param depth defines the depth of the texture
  117812. * @param format defines the texture format to use
  117813. * @param scene defines the hosting scene
  117814. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117815. * @param invertY defines if texture must be stored with Y axis inverted
  117816. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117817. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117818. */
  117819. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117820. /** Gets or sets the texture format to use */
  117821. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117822. /**
  117823. * Update the texture with new data
  117824. * @param data defines the data to store in the texture
  117825. */
  117826. update(data: ArrayBufferView): void;
  117827. }
  117828. }
  117829. declare module BABYLON {
  117830. /**
  117831. * Creates a refraction texture used by refraction channel of the standard material.
  117832. * It is like a mirror but to see through a material.
  117833. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117834. */
  117835. export class RefractionTexture extends RenderTargetTexture {
  117836. /**
  117837. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117838. * 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.
  117839. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117840. */
  117841. refractionPlane: Plane;
  117842. /**
  117843. * Define how deep under the surface we should see.
  117844. */
  117845. depth: number;
  117846. /**
  117847. * Creates a refraction texture used by refraction channel of the standard material.
  117848. * It is like a mirror but to see through a material.
  117849. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117850. * @param name Define the texture name
  117851. * @param size Define the size of the underlying texture
  117852. * @param scene Define the scene the refraction belongs to
  117853. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117854. */
  117855. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117856. /**
  117857. * Clone the refraction texture.
  117858. * @returns the cloned texture
  117859. */
  117860. clone(): RefractionTexture;
  117861. /**
  117862. * Serialize the texture to a JSON representation you could use in Parse later on
  117863. * @returns the serialized JSON representation
  117864. */
  117865. serialize(): any;
  117866. }
  117867. }
  117868. declare module BABYLON {
  117869. /**
  117870. * Defines the options related to the creation of an HtmlElementTexture
  117871. */
  117872. export interface IHtmlElementTextureOptions {
  117873. /**
  117874. * Defines wether mip maps should be created or not.
  117875. */
  117876. generateMipMaps?: boolean;
  117877. /**
  117878. * Defines the sampling mode of the texture.
  117879. */
  117880. samplingMode?: number;
  117881. /**
  117882. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117883. */
  117884. engine: Nullable<Engine>;
  117885. /**
  117886. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117887. */
  117888. scene: Nullable<Scene>;
  117889. }
  117890. /**
  117891. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117892. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117893. * is automatically managed.
  117894. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117895. * in your application.
  117896. *
  117897. * As the update is not automatic, you need to call them manually.
  117898. */
  117899. export class HtmlElementTexture extends BaseTexture {
  117900. /**
  117901. * The texture URL.
  117902. */
  117903. element: HTMLVideoElement | HTMLCanvasElement;
  117904. private static readonly DefaultOptions;
  117905. private _textureMatrix;
  117906. private _engine;
  117907. private _isVideo;
  117908. private _generateMipMaps;
  117909. private _samplingMode;
  117910. /**
  117911. * Instantiates a HtmlElementTexture from the following parameters.
  117912. *
  117913. * @param name Defines the name of the texture
  117914. * @param element Defines the video or canvas the texture is filled with
  117915. * @param options Defines the other none mandatory texture creation options
  117916. */
  117917. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117918. private _createInternalTexture;
  117919. /**
  117920. * Returns the texture matrix used in most of the material.
  117921. */
  117922. getTextureMatrix(): Matrix;
  117923. /**
  117924. * Updates the content of the texture.
  117925. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117926. */
  117927. update(invertY?: Nullable<boolean>): void;
  117928. }
  117929. }
  117930. declare module BABYLON {
  117931. /**
  117932. * Enum used to define the target of a block
  117933. */
  117934. export enum NodeMaterialBlockTargets {
  117935. /** Vertex shader */
  117936. Vertex = 1,
  117937. /** Fragment shader */
  117938. Fragment = 2,
  117939. /** Neutral */
  117940. Neutral = 4,
  117941. /** Vertex and Fragment */
  117942. VertexAndFragment = 3
  117943. }
  117944. }
  117945. declare module BABYLON {
  117946. /**
  117947. * Defines the kind of connection point for node based material
  117948. */
  117949. export enum NodeMaterialBlockConnectionPointTypes {
  117950. /** Float */
  117951. Float = 1,
  117952. /** Int */
  117953. Int = 2,
  117954. /** Vector2 */
  117955. Vector2 = 4,
  117956. /** Vector3 */
  117957. Vector3 = 8,
  117958. /** Vector4 */
  117959. Vector4 = 16,
  117960. /** Color3 */
  117961. Color3 = 32,
  117962. /** Color4 */
  117963. Color4 = 64,
  117964. /** Matrix */
  117965. Matrix = 128,
  117966. /** Detect type based on connection */
  117967. AutoDetect = 1024,
  117968. /** Output type that will be defined by input type */
  117969. BasedOnInput = 2048
  117970. }
  117971. }
  117972. declare module BABYLON {
  117973. /**
  117974. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117975. */
  117976. export enum NodeMaterialBlockConnectionPointMode {
  117977. /** Value is an uniform */
  117978. Uniform = 0,
  117979. /** Value is a mesh attribute */
  117980. Attribute = 1,
  117981. /** Value is a varying between vertex and fragment shaders */
  117982. Varying = 2,
  117983. /** Mode is undefined */
  117984. Undefined = 3
  117985. }
  117986. }
  117987. declare module BABYLON {
  117988. /**
  117989. * Enum used to define system values e.g. values automatically provided by the system
  117990. */
  117991. export enum NodeMaterialSystemValues {
  117992. /** World */
  117993. World = 1,
  117994. /** View */
  117995. View = 2,
  117996. /** Projection */
  117997. Projection = 3,
  117998. /** ViewProjection */
  117999. ViewProjection = 4,
  118000. /** WorldView */
  118001. WorldView = 5,
  118002. /** WorldViewProjection */
  118003. WorldViewProjection = 6,
  118004. /** CameraPosition */
  118005. CameraPosition = 7,
  118006. /** Fog Color */
  118007. FogColor = 8
  118008. }
  118009. }
  118010. declare module BABYLON {
  118011. /**
  118012. * Root class for all node material optimizers
  118013. */
  118014. export class NodeMaterialOptimizer {
  118015. /**
  118016. * Function used to optimize a NodeMaterial graph
  118017. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  118018. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  118019. */
  118020. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  118021. }
  118022. }
  118023. declare module BABYLON {
  118024. /**
  118025. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  118026. */
  118027. export class TransformBlock extends NodeMaterialBlock {
  118028. /**
  118029. * Defines the value to use to complement W value to transform it to a Vector4
  118030. */
  118031. complementW: number;
  118032. /**
  118033. * Defines the value to use to complement z value to transform it to a Vector4
  118034. */
  118035. complementZ: number;
  118036. /**
  118037. * Creates a new TransformBlock
  118038. * @param name defines the block name
  118039. */
  118040. constructor(name: string);
  118041. /**
  118042. * Gets the current class name
  118043. * @returns the class name
  118044. */
  118045. getClassName(): string;
  118046. /**
  118047. * Gets the vector input
  118048. */
  118049. readonly vector: NodeMaterialConnectionPoint;
  118050. /**
  118051. * Gets the output component
  118052. */
  118053. readonly output: NodeMaterialConnectionPoint;
  118054. /**
  118055. * Gets the matrix transform input
  118056. */
  118057. readonly transform: NodeMaterialConnectionPoint;
  118058. protected _buildBlock(state: NodeMaterialBuildState): this;
  118059. serialize(): any;
  118060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118061. protected _dumpPropertiesCode(): string;
  118062. }
  118063. }
  118064. declare module BABYLON {
  118065. /**
  118066. * Block used to output the vertex position
  118067. */
  118068. export class VertexOutputBlock extends NodeMaterialBlock {
  118069. /**
  118070. * Creates a new VertexOutputBlock
  118071. * @param name defines the block name
  118072. */
  118073. constructor(name: string);
  118074. /**
  118075. * Gets the current class name
  118076. * @returns the class name
  118077. */
  118078. getClassName(): string;
  118079. /**
  118080. * Gets the vector input component
  118081. */
  118082. readonly vector: NodeMaterialConnectionPoint;
  118083. protected _buildBlock(state: NodeMaterialBuildState): this;
  118084. }
  118085. }
  118086. declare module BABYLON {
  118087. /**
  118088. * Block used to output the final color
  118089. */
  118090. export class FragmentOutputBlock extends NodeMaterialBlock {
  118091. /**
  118092. * Create a new FragmentOutputBlock
  118093. * @param name defines the block name
  118094. */
  118095. constructor(name: string);
  118096. /**
  118097. * Gets the current class name
  118098. * @returns the class name
  118099. */
  118100. getClassName(): string;
  118101. /**
  118102. * Gets the rgba input component
  118103. */
  118104. readonly rgba: NodeMaterialConnectionPoint;
  118105. /**
  118106. * Gets the rgb input component
  118107. */
  118108. readonly rgb: NodeMaterialConnectionPoint;
  118109. /**
  118110. * Gets the a input component
  118111. */
  118112. readonly a: NodeMaterialConnectionPoint;
  118113. protected _buildBlock(state: NodeMaterialBuildState): this;
  118114. }
  118115. }
  118116. declare module BABYLON {
  118117. /**
  118118. * Block used to read a reflection texture from a sampler
  118119. */
  118120. export class ReflectionTextureBlock extends NodeMaterialBlock {
  118121. private _define3DName;
  118122. private _defineCubicName;
  118123. private _defineExplicitName;
  118124. private _defineProjectionName;
  118125. private _defineLocalCubicName;
  118126. private _defineSphericalName;
  118127. private _definePlanarName;
  118128. private _defineEquirectangularName;
  118129. private _defineMirroredEquirectangularFixedName;
  118130. private _defineEquirectangularFixedName;
  118131. private _defineSkyboxName;
  118132. private _cubeSamplerName;
  118133. private _2DSamplerName;
  118134. private _positionUVWName;
  118135. private _directionWName;
  118136. private _reflectionCoordsName;
  118137. private _reflection2DCoordsName;
  118138. private _reflectionColorName;
  118139. private _reflectionMatrixName;
  118140. /**
  118141. * Gets or sets the texture associated with the node
  118142. */
  118143. texture: Nullable<BaseTexture>;
  118144. /**
  118145. * Create a new TextureBlock
  118146. * @param name defines the block name
  118147. */
  118148. constructor(name: string);
  118149. /**
  118150. * Gets the current class name
  118151. * @returns the class name
  118152. */
  118153. getClassName(): string;
  118154. /**
  118155. * Gets the world position input component
  118156. */
  118157. readonly position: NodeMaterialConnectionPoint;
  118158. /**
  118159. * Gets the world position input component
  118160. */
  118161. readonly worldPosition: NodeMaterialConnectionPoint;
  118162. /**
  118163. * Gets the world normal input component
  118164. */
  118165. readonly worldNormal: NodeMaterialConnectionPoint;
  118166. /**
  118167. * Gets the world input component
  118168. */
  118169. readonly world: NodeMaterialConnectionPoint;
  118170. /**
  118171. * Gets the camera (or eye) position component
  118172. */
  118173. readonly cameraPosition: NodeMaterialConnectionPoint;
  118174. /**
  118175. * Gets the view input component
  118176. */
  118177. readonly view: NodeMaterialConnectionPoint;
  118178. /**
  118179. * Gets the rgb output component
  118180. */
  118181. readonly rgb: NodeMaterialConnectionPoint;
  118182. /**
  118183. * Gets the r output component
  118184. */
  118185. readonly r: NodeMaterialConnectionPoint;
  118186. /**
  118187. * Gets the g output component
  118188. */
  118189. readonly g: NodeMaterialConnectionPoint;
  118190. /**
  118191. * Gets the b output component
  118192. */
  118193. readonly b: NodeMaterialConnectionPoint;
  118194. autoConfigure(material: NodeMaterial): void;
  118195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118196. isReady(): boolean;
  118197. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118198. private _injectVertexCode;
  118199. private _writeOutput;
  118200. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118201. serialize(): any;
  118202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118203. }
  118204. }
  118205. declare module BABYLON {
  118206. /**
  118207. * Interface used to configure the node material editor
  118208. */
  118209. export interface INodeMaterialEditorOptions {
  118210. /** Define the URl to load node editor script */
  118211. editorURL?: string;
  118212. }
  118213. /** @hidden */
  118214. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118215. /** BONES */
  118216. NUM_BONE_INFLUENCERS: number;
  118217. BonesPerMesh: number;
  118218. BONETEXTURE: boolean;
  118219. /** MORPH TARGETS */
  118220. MORPHTARGETS: boolean;
  118221. MORPHTARGETS_NORMAL: boolean;
  118222. MORPHTARGETS_TANGENT: boolean;
  118223. MORPHTARGETS_UV: boolean;
  118224. NUM_MORPH_INFLUENCERS: number;
  118225. /** IMAGE PROCESSING */
  118226. IMAGEPROCESSING: boolean;
  118227. VIGNETTE: boolean;
  118228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118229. VIGNETTEBLENDMODEOPAQUE: boolean;
  118230. TONEMAPPING: boolean;
  118231. TONEMAPPING_ACES: boolean;
  118232. CONTRAST: boolean;
  118233. EXPOSURE: boolean;
  118234. COLORCURVES: boolean;
  118235. COLORGRADING: boolean;
  118236. COLORGRADING3D: boolean;
  118237. SAMPLER3DGREENDEPTH: boolean;
  118238. SAMPLER3DBGRMAP: boolean;
  118239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118240. /** MISC. */
  118241. BUMPDIRECTUV: number;
  118242. constructor();
  118243. setValue(name: string, value: boolean): void;
  118244. }
  118245. /**
  118246. * Class used to configure NodeMaterial
  118247. */
  118248. export interface INodeMaterialOptions {
  118249. /**
  118250. * Defines if blocks should emit comments
  118251. */
  118252. emitComments: boolean;
  118253. }
  118254. /**
  118255. * Class used to create a node based material built by assembling shader blocks
  118256. */
  118257. export class NodeMaterial extends PushMaterial {
  118258. private static _BuildIdGenerator;
  118259. private _options;
  118260. private _vertexCompilationState;
  118261. private _fragmentCompilationState;
  118262. private _sharedData;
  118263. private _buildId;
  118264. private _buildWasSuccessful;
  118265. private _cachedWorldViewMatrix;
  118266. private _cachedWorldViewProjectionMatrix;
  118267. private _optimizers;
  118268. private _animationFrame;
  118269. /** Define the URl to load node editor script */
  118270. static EditorURL: string;
  118271. private BJSNODEMATERIALEDITOR;
  118272. /** Get the inspector from bundle or global */
  118273. private _getGlobalNodeMaterialEditor;
  118274. /**
  118275. * 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)
  118276. */
  118277. ignoreAlpha: boolean;
  118278. /**
  118279. * Defines the maximum number of lights that can be used in the material
  118280. */
  118281. maxSimultaneousLights: number;
  118282. /**
  118283. * Observable raised when the material is built
  118284. */
  118285. onBuildObservable: Observable<NodeMaterial>;
  118286. /**
  118287. * Gets or sets the root nodes of the material vertex shader
  118288. */
  118289. _vertexOutputNodes: NodeMaterialBlock[];
  118290. /**
  118291. * Gets or sets the root nodes of the material fragment (pixel) shader
  118292. */
  118293. _fragmentOutputNodes: NodeMaterialBlock[];
  118294. /** Gets or sets options to control the node material overall behavior */
  118295. options: INodeMaterialOptions;
  118296. /**
  118297. * Default configuration related to image processing available in the standard Material.
  118298. */
  118299. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118300. /**
  118301. * Gets the image processing configuration used either in this material.
  118302. */
  118303. /**
  118304. * Sets the Default image processing configuration used either in the this material.
  118305. *
  118306. * If sets to null, the scene one is in use.
  118307. */
  118308. imageProcessingConfiguration: ImageProcessingConfiguration;
  118309. /**
  118310. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118311. */
  118312. attachedBlocks: NodeMaterialBlock[];
  118313. /**
  118314. * Create a new node based material
  118315. * @param name defines the material name
  118316. * @param scene defines the hosting scene
  118317. * @param options defines creation option
  118318. */
  118319. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118320. /**
  118321. * Gets the current class name of the material e.g. "NodeMaterial"
  118322. * @returns the class name
  118323. */
  118324. getClassName(): string;
  118325. /**
  118326. * Keep track of the image processing observer to allow dispose and replace.
  118327. */
  118328. private _imageProcessingObserver;
  118329. /**
  118330. * Attaches a new image processing configuration to the Standard Material.
  118331. * @param configuration
  118332. */
  118333. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118334. /**
  118335. * Get a block by its name
  118336. * @param name defines the name of the block to retrieve
  118337. * @returns the required block or null if not found
  118338. */
  118339. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118340. /**
  118341. * Get a block by its name
  118342. * @param predicate defines the predicate used to find the good candidate
  118343. * @returns the required block or null if not found
  118344. */
  118345. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118346. /**
  118347. * Get an input block by its name
  118348. * @param predicate defines the predicate used to find the good candidate
  118349. * @returns the required input block or null if not found
  118350. */
  118351. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118352. /**
  118353. * Gets the list of input blocks attached to this material
  118354. * @returns an array of InputBlocks
  118355. */
  118356. getInputBlocks(): InputBlock[];
  118357. /**
  118358. * Adds a new optimizer to the list of optimizers
  118359. * @param optimizer defines the optimizers to add
  118360. * @returns the current material
  118361. */
  118362. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118363. /**
  118364. * Remove an optimizer from the list of optimizers
  118365. * @param optimizer defines the optimizers to remove
  118366. * @returns the current material
  118367. */
  118368. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118369. /**
  118370. * Add a new block to the list of output nodes
  118371. * @param node defines the node to add
  118372. * @returns the current material
  118373. */
  118374. addOutputNode(node: NodeMaterialBlock): this;
  118375. /**
  118376. * Remove a block from the list of root nodes
  118377. * @param node defines the node to remove
  118378. * @returns the current material
  118379. */
  118380. removeOutputNode(node: NodeMaterialBlock): this;
  118381. private _addVertexOutputNode;
  118382. private _removeVertexOutputNode;
  118383. private _addFragmentOutputNode;
  118384. private _removeFragmentOutputNode;
  118385. /**
  118386. * Specifies if the material will require alpha blending
  118387. * @returns a boolean specifying if alpha blending is needed
  118388. */
  118389. needAlphaBlending(): boolean;
  118390. /**
  118391. * Specifies if this material should be rendered in alpha test mode
  118392. * @returns a boolean specifying if an alpha test is needed.
  118393. */
  118394. needAlphaTesting(): boolean;
  118395. private _initializeBlock;
  118396. private _resetDualBlocks;
  118397. /**
  118398. * Build the material and generates the inner effect
  118399. * @param verbose defines if the build should log activity
  118400. */
  118401. build(verbose?: boolean): void;
  118402. /**
  118403. * Runs an otpimization phase to try to improve the shader code
  118404. */
  118405. optimize(): void;
  118406. private _prepareDefinesForAttributes;
  118407. /**
  118408. * Get if the submesh is ready to be used and all its information available.
  118409. * Child classes can use it to update shaders
  118410. * @param mesh defines the mesh to check
  118411. * @param subMesh defines which submesh to check
  118412. * @param useInstances specifies that instances should be used
  118413. * @returns a boolean indicating that the submesh is ready or not
  118414. */
  118415. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118416. /**
  118417. * Get a string representing the shaders built by the current node graph
  118418. */
  118419. readonly compiledShaders: string;
  118420. /**
  118421. * Binds the world matrix to the material
  118422. * @param world defines the world transformation matrix
  118423. */
  118424. bindOnlyWorldMatrix(world: Matrix): void;
  118425. /**
  118426. * Binds the submesh to this material by preparing the effect and shader to draw
  118427. * @param world defines the world transformation matrix
  118428. * @param mesh defines the mesh containing the submesh
  118429. * @param subMesh defines the submesh to bind the material to
  118430. */
  118431. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118432. /**
  118433. * Gets the active textures from the material
  118434. * @returns an array of textures
  118435. */
  118436. getActiveTextures(): BaseTexture[];
  118437. /**
  118438. * Gets the list of texture blocks
  118439. * @returns an array of texture blocks
  118440. */
  118441. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118442. /**
  118443. * Specifies if the material uses a texture
  118444. * @param texture defines the texture to check against the material
  118445. * @returns a boolean specifying if the material uses the texture
  118446. */
  118447. hasTexture(texture: BaseTexture): boolean;
  118448. /**
  118449. * Disposes the material
  118450. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118451. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118452. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118453. */
  118454. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118455. /** Creates the node editor window. */
  118456. private _createNodeEditor;
  118457. /**
  118458. * Launch the node material editor
  118459. * @param config Define the configuration of the editor
  118460. * @return a promise fulfilled when the node editor is visible
  118461. */
  118462. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118463. /**
  118464. * Clear the current material
  118465. */
  118466. clear(): void;
  118467. /**
  118468. * Clear the current material and set it to a default state
  118469. */
  118470. setToDefault(): void;
  118471. /**
  118472. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118473. * @param url defines the url to load from
  118474. * @returns a promise that will fullfil when the material is fully loaded
  118475. */
  118476. loadAsync(url: string): Promise<unknown>;
  118477. private _gatherBlocks;
  118478. /**
  118479. * Generate a string containing the code declaration required to create an equivalent of this material
  118480. * @returns a string
  118481. */
  118482. generateCode(): string;
  118483. /**
  118484. * Serializes this material in a JSON representation
  118485. * @returns the serialized material object
  118486. */
  118487. serialize(): any;
  118488. private _restoreConnections;
  118489. /**
  118490. * Clear the current graph and load a new one from a serialization object
  118491. * @param source defines the JSON representation of the material
  118492. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118493. */
  118494. loadFromSerialization(source: any, rootUrl?: string): void;
  118495. /**
  118496. * Creates a node material from parsed material data
  118497. * @param source defines the JSON representation of the material
  118498. * @param scene defines the hosting scene
  118499. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118500. * @returns a new node material
  118501. */
  118502. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118503. /**
  118504. * Creates a new node material set to default basic configuration
  118505. * @param name defines the name of the material
  118506. * @param scene defines the hosting scene
  118507. * @returns a new NodeMaterial
  118508. */
  118509. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118510. }
  118511. }
  118512. declare module BABYLON {
  118513. /**
  118514. * Block used to read a texture from a sampler
  118515. */
  118516. export class TextureBlock extends NodeMaterialBlock {
  118517. private _defineName;
  118518. private _samplerName;
  118519. private _transformedUVName;
  118520. private _textureTransformName;
  118521. private _textureInfoName;
  118522. private _mainUVName;
  118523. private _mainUVDefineName;
  118524. /**
  118525. * Gets or sets the texture associated with the node
  118526. */
  118527. texture: Nullable<Texture>;
  118528. /**
  118529. * Create a new TextureBlock
  118530. * @param name defines the block name
  118531. */
  118532. constructor(name: string);
  118533. /**
  118534. * Gets the current class name
  118535. * @returns the class name
  118536. */
  118537. getClassName(): string;
  118538. /**
  118539. * Gets the uv input component
  118540. */
  118541. readonly uv: NodeMaterialConnectionPoint;
  118542. /**
  118543. * Gets the rgba output component
  118544. */
  118545. readonly rgba: NodeMaterialConnectionPoint;
  118546. /**
  118547. * Gets the rgb output component
  118548. */
  118549. readonly rgb: NodeMaterialConnectionPoint;
  118550. /**
  118551. * Gets the r output component
  118552. */
  118553. readonly r: NodeMaterialConnectionPoint;
  118554. /**
  118555. * Gets the g output component
  118556. */
  118557. readonly g: NodeMaterialConnectionPoint;
  118558. /**
  118559. * Gets the b output component
  118560. */
  118561. readonly b: NodeMaterialConnectionPoint;
  118562. /**
  118563. * Gets the a output component
  118564. */
  118565. readonly a: NodeMaterialConnectionPoint;
  118566. readonly target: NodeMaterialBlockTargets;
  118567. autoConfigure(material: NodeMaterial): void;
  118568. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118569. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118570. isReady(): boolean;
  118571. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118572. private readonly _isMixed;
  118573. private _injectVertexCode;
  118574. private _writeOutput;
  118575. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118576. protected _dumpPropertiesCode(): string;
  118577. serialize(): any;
  118578. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118579. }
  118580. }
  118581. declare module BABYLON {
  118582. /**
  118583. * Class used to store shared data between 2 NodeMaterialBuildState
  118584. */
  118585. export class NodeMaterialBuildStateSharedData {
  118586. /**
  118587. * Gets the list of emitted varyings
  118588. */
  118589. temps: string[];
  118590. /**
  118591. * Gets the list of emitted varyings
  118592. */
  118593. varyings: string[];
  118594. /**
  118595. * Gets the varying declaration string
  118596. */
  118597. varyingDeclaration: string;
  118598. /**
  118599. * Input blocks
  118600. */
  118601. inputBlocks: InputBlock[];
  118602. /**
  118603. * Input blocks
  118604. */
  118605. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118606. /**
  118607. * Bindable blocks (Blocks that need to set data to the effect)
  118608. */
  118609. bindableBlocks: NodeMaterialBlock[];
  118610. /**
  118611. * List of blocks that can provide a compilation fallback
  118612. */
  118613. blocksWithFallbacks: NodeMaterialBlock[];
  118614. /**
  118615. * List of blocks that can provide a define update
  118616. */
  118617. blocksWithDefines: NodeMaterialBlock[];
  118618. /**
  118619. * List of blocks that can provide a repeatable content
  118620. */
  118621. repeatableContentBlocks: NodeMaterialBlock[];
  118622. /**
  118623. * List of blocks that can provide a dynamic list of uniforms
  118624. */
  118625. dynamicUniformBlocks: NodeMaterialBlock[];
  118626. /**
  118627. * List of blocks that can block the isReady function for the material
  118628. */
  118629. blockingBlocks: NodeMaterialBlock[];
  118630. /**
  118631. * Gets the list of animated inputs
  118632. */
  118633. animatedInputs: InputBlock[];
  118634. /**
  118635. * Build Id used to avoid multiple recompilations
  118636. */
  118637. buildId: number;
  118638. /** List of emitted variables */
  118639. variableNames: {
  118640. [key: string]: number;
  118641. };
  118642. /** List of emitted defines */
  118643. defineNames: {
  118644. [key: string]: number;
  118645. };
  118646. /** Should emit comments? */
  118647. emitComments: boolean;
  118648. /** Emit build activity */
  118649. verbose: boolean;
  118650. /** Gets or sets the hosting scene */
  118651. scene: Scene;
  118652. /**
  118653. * Gets the compilation hints emitted at compilation time
  118654. */
  118655. hints: {
  118656. needWorldViewMatrix: boolean;
  118657. needWorldViewProjectionMatrix: boolean;
  118658. needAlphaBlending: boolean;
  118659. needAlphaTesting: boolean;
  118660. };
  118661. /**
  118662. * List of compilation checks
  118663. */
  118664. checks: {
  118665. emitVertex: boolean;
  118666. emitFragment: boolean;
  118667. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118668. };
  118669. /** Creates a new shared data */
  118670. constructor();
  118671. /**
  118672. * Emits console errors and exceptions if there is a failing check
  118673. */
  118674. emitErrors(): void;
  118675. }
  118676. }
  118677. declare module BABYLON {
  118678. /**
  118679. * Class used to store node based material build state
  118680. */
  118681. export class NodeMaterialBuildState {
  118682. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118683. supportUniformBuffers: boolean;
  118684. /**
  118685. * Gets the list of emitted attributes
  118686. */
  118687. attributes: string[];
  118688. /**
  118689. * Gets the list of emitted uniforms
  118690. */
  118691. uniforms: string[];
  118692. /**
  118693. * Gets the list of emitted constants
  118694. */
  118695. constants: string[];
  118696. /**
  118697. * Gets the list of emitted uniform buffers
  118698. */
  118699. uniformBuffers: string[];
  118700. /**
  118701. * Gets the list of emitted samplers
  118702. */
  118703. samplers: string[];
  118704. /**
  118705. * Gets the list of emitted functions
  118706. */
  118707. functions: {
  118708. [key: string]: string;
  118709. };
  118710. /**
  118711. * Gets the list of emitted extensions
  118712. */
  118713. extensions: {
  118714. [key: string]: string;
  118715. };
  118716. /**
  118717. * Gets the target of the compilation state
  118718. */
  118719. target: NodeMaterialBlockTargets;
  118720. /**
  118721. * Gets the list of emitted counters
  118722. */
  118723. counters: {
  118724. [key: string]: number;
  118725. };
  118726. /**
  118727. * Shared data between multiple NodeMaterialBuildState instances
  118728. */
  118729. sharedData: NodeMaterialBuildStateSharedData;
  118730. /** @hidden */
  118731. _vertexState: NodeMaterialBuildState;
  118732. /** @hidden */
  118733. _attributeDeclaration: string;
  118734. /** @hidden */
  118735. _uniformDeclaration: string;
  118736. /** @hidden */
  118737. _constantDeclaration: string;
  118738. /** @hidden */
  118739. _samplerDeclaration: string;
  118740. /** @hidden */
  118741. _varyingTransfer: string;
  118742. private _repeatableContentAnchorIndex;
  118743. /** @hidden */
  118744. _builtCompilationString: string;
  118745. /**
  118746. * Gets the emitted compilation strings
  118747. */
  118748. compilationString: string;
  118749. /**
  118750. * Finalize the compilation strings
  118751. * @param state defines the current compilation state
  118752. */
  118753. finalize(state: NodeMaterialBuildState): void;
  118754. /** @hidden */
  118755. readonly _repeatableContentAnchor: string;
  118756. /** @hidden */
  118757. _getFreeVariableName(prefix: string): string;
  118758. /** @hidden */
  118759. _getFreeDefineName(prefix: string): string;
  118760. /** @hidden */
  118761. _excludeVariableName(name: string): void;
  118762. /** @hidden */
  118763. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118764. /** @hidden */
  118765. _emitExtension(name: string, extension: string): void;
  118766. /** @hidden */
  118767. _emitFunction(name: string, code: string, comments: string): void;
  118768. /** @hidden */
  118769. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118770. replaceStrings?: {
  118771. search: RegExp;
  118772. replace: string;
  118773. }[];
  118774. repeatKey?: string;
  118775. }): string;
  118776. /** @hidden */
  118777. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118778. repeatKey?: string;
  118779. removeAttributes?: boolean;
  118780. removeUniforms?: boolean;
  118781. removeVaryings?: boolean;
  118782. removeIfDef?: boolean;
  118783. replaceStrings?: {
  118784. search: RegExp;
  118785. replace: string;
  118786. }[];
  118787. }, storeKey?: string): void;
  118788. /** @hidden */
  118789. _registerTempVariable(name: string): boolean;
  118790. /** @hidden */
  118791. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118792. /** @hidden */
  118793. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118794. }
  118795. }
  118796. declare module BABYLON {
  118797. /**
  118798. * Defines a block that can be used inside a node based material
  118799. */
  118800. export class NodeMaterialBlock {
  118801. private _buildId;
  118802. private _buildTarget;
  118803. private _target;
  118804. private _isFinalMerger;
  118805. private _isInput;
  118806. /** @hidden */
  118807. _codeVariableName: string;
  118808. /** @hidden */
  118809. _inputs: NodeMaterialConnectionPoint[];
  118810. /** @hidden */
  118811. _outputs: NodeMaterialConnectionPoint[];
  118812. /** @hidden */
  118813. _preparationId: number;
  118814. /**
  118815. * Gets or sets the name of the block
  118816. */
  118817. name: string;
  118818. /**
  118819. * Gets or sets the unique id of the node
  118820. */
  118821. uniqueId: number;
  118822. /**
  118823. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118824. */
  118825. readonly isFinalMerger: boolean;
  118826. /**
  118827. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118828. */
  118829. readonly isInput: boolean;
  118830. /**
  118831. * Gets or sets the build Id
  118832. */
  118833. buildId: number;
  118834. /**
  118835. * Gets or sets the target of the block
  118836. */
  118837. target: NodeMaterialBlockTargets;
  118838. /**
  118839. * Gets the list of input points
  118840. */
  118841. readonly inputs: NodeMaterialConnectionPoint[];
  118842. /** Gets the list of output points */
  118843. readonly outputs: NodeMaterialConnectionPoint[];
  118844. /**
  118845. * Find an input by its name
  118846. * @param name defines the name of the input to look for
  118847. * @returns the input or null if not found
  118848. */
  118849. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118850. /**
  118851. * Find an output by its name
  118852. * @param name defines the name of the outputto look for
  118853. * @returns the output or null if not found
  118854. */
  118855. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118856. /**
  118857. * Creates a new NodeMaterialBlock
  118858. * @param name defines the block name
  118859. * @param target defines the target of that block (Vertex by default)
  118860. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118861. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118862. */
  118863. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118864. /**
  118865. * Initialize the block and prepare the context for build
  118866. * @param state defines the state that will be used for the build
  118867. */
  118868. initialize(state: NodeMaterialBuildState): void;
  118869. /**
  118870. * Bind data to effect. Will only be called for blocks with isBindable === true
  118871. * @param effect defines the effect to bind data to
  118872. * @param nodeMaterial defines the hosting NodeMaterial
  118873. * @param mesh defines the mesh that will be rendered
  118874. */
  118875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118876. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118877. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118878. protected _writeFloat(value: number): string;
  118879. /**
  118880. * Gets the current class name e.g. "NodeMaterialBlock"
  118881. * @returns the class name
  118882. */
  118883. getClassName(): string;
  118884. /**
  118885. * Register a new input. Must be called inside a block constructor
  118886. * @param name defines the connection point name
  118887. * @param type defines the connection point type
  118888. * @param isOptional defines a boolean indicating that this input can be omitted
  118889. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118890. * @returns the current block
  118891. */
  118892. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118893. /**
  118894. * Register a new output. Must be called inside a block constructor
  118895. * @param name defines the connection point name
  118896. * @param type defines the connection point type
  118897. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118898. * @returns the current block
  118899. */
  118900. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118901. /**
  118902. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118903. * @param forOutput defines an optional connection point to check compatibility with
  118904. * @returns the first available input or null
  118905. */
  118906. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118907. /**
  118908. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118909. * @param forBlock defines an optional block to check compatibility with
  118910. * @returns the first available input or null
  118911. */
  118912. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118913. /**
  118914. * Gets the sibling of the given output
  118915. * @param current defines the current output
  118916. * @returns the next output in the list or null
  118917. */
  118918. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118919. /**
  118920. * Connect current block with another block
  118921. * @param other defines the block to connect with
  118922. * @param options define the various options to help pick the right connections
  118923. * @returns the current block
  118924. */
  118925. connectTo(other: NodeMaterialBlock, options?: {
  118926. input?: string;
  118927. output?: string;
  118928. outputSwizzle?: string;
  118929. }): this | undefined;
  118930. protected _buildBlock(state: NodeMaterialBuildState): void;
  118931. /**
  118932. * Add uniforms, samplers and uniform buffers at compilation time
  118933. * @param state defines the state to update
  118934. * @param nodeMaterial defines the node material requesting the update
  118935. * @param defines defines the material defines to update
  118936. */
  118937. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118938. /**
  118939. * Add potential fallbacks if shader compilation fails
  118940. * @param mesh defines the mesh to be rendered
  118941. * @param fallbacks defines the current prioritized list of fallbacks
  118942. */
  118943. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118944. /**
  118945. * Initialize defines for shader compilation
  118946. * @param mesh defines the mesh to be rendered
  118947. * @param nodeMaterial defines the node material requesting the update
  118948. * @param defines defines the material defines to update
  118949. * @param useInstances specifies that instances should be used
  118950. */
  118951. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118952. /**
  118953. * Update defines for shader compilation
  118954. * @param mesh defines the mesh to be rendered
  118955. * @param nodeMaterial defines the node material requesting the update
  118956. * @param defines defines the material defines to update
  118957. * @param useInstances specifies that instances should be used
  118958. */
  118959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118960. /**
  118961. * Lets the block try to connect some inputs automatically
  118962. * @param material defines the hosting NodeMaterial
  118963. */
  118964. autoConfigure(material: NodeMaterial): void;
  118965. /**
  118966. * Function called when a block is declared as repeatable content generator
  118967. * @param vertexShaderState defines the current compilation state for the vertex shader
  118968. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118969. * @param mesh defines the mesh to be rendered
  118970. * @param defines defines the material defines to update
  118971. */
  118972. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118973. /**
  118974. * Checks if the block is ready
  118975. * @param mesh defines the mesh to be rendered
  118976. * @param nodeMaterial defines the node material requesting the update
  118977. * @param defines defines the material defines to update
  118978. * @param useInstances specifies that instances should be used
  118979. * @returns true if the block is ready
  118980. */
  118981. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118982. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118983. private _processBuild;
  118984. /**
  118985. * Compile the current node and generate the shader code
  118986. * @param state defines the current compilation state (uniforms, samplers, current string)
  118987. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118988. * @returns true if already built
  118989. */
  118990. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118991. protected _inputRename(name: string): string;
  118992. protected _outputRename(name: string): string;
  118993. protected _dumpPropertiesCode(): string;
  118994. /** @hidden */
  118995. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118996. /**
  118997. * Clone the current block to a new identical block
  118998. * @param scene defines the hosting scene
  118999. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119000. * @returns a copy of the current block
  119001. */
  119002. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  119003. /**
  119004. * Serializes this block in a JSON representation
  119005. * @returns the serialized block object
  119006. */
  119007. serialize(): any;
  119008. /** @hidden */
  119009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119010. }
  119011. }
  119012. declare module BABYLON {
  119013. /**
  119014. * Enum defining the type of animations supported by InputBlock
  119015. */
  119016. export enum AnimatedInputBlockTypes {
  119017. /** No animation */
  119018. None = 0,
  119019. /** Time based animation. Will only work for floats */
  119020. Time = 1
  119021. }
  119022. }
  119023. declare module BABYLON {
  119024. /**
  119025. * Block used to expose an input value
  119026. */
  119027. export class InputBlock extends NodeMaterialBlock {
  119028. private _mode;
  119029. private _associatedVariableName;
  119030. private _storedValue;
  119031. private _valueCallback;
  119032. private _type;
  119033. private _animationType;
  119034. /** Gets or set a value used to limit the range of float values */
  119035. min: number;
  119036. /** Gets or set a value used to limit the range of float values */
  119037. max: number;
  119038. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  119039. matrixMode: number;
  119040. /** @hidden */
  119041. _systemValue: Nullable<NodeMaterialSystemValues>;
  119042. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  119043. visibleInInspector: boolean;
  119044. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  119045. isConstant: boolean;
  119046. /**
  119047. * Gets or sets the connection point type (default is float)
  119048. */
  119049. readonly type: NodeMaterialBlockConnectionPointTypes;
  119050. /**
  119051. * Creates a new InputBlock
  119052. * @param name defines the block name
  119053. * @param target defines the target of that block (Vertex by default)
  119054. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  119055. */
  119056. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  119057. /**
  119058. * Gets the output component
  119059. */
  119060. readonly output: NodeMaterialConnectionPoint;
  119061. /**
  119062. * Set the source of this connection point to a vertex attribute
  119063. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  119064. * @returns the current connection point
  119065. */
  119066. setAsAttribute(attributeName?: string): InputBlock;
  119067. /**
  119068. * Set the source of this connection point to a system value
  119069. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  119070. * @returns the current connection point
  119071. */
  119072. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  119073. /**
  119074. * Gets or sets the value of that point.
  119075. * Please note that this value will be ignored if valueCallback is defined
  119076. */
  119077. value: any;
  119078. /**
  119079. * Gets or sets a callback used to get the value of that point.
  119080. * Please note that setting this value will force the connection point to ignore the value property
  119081. */
  119082. valueCallback: () => any;
  119083. /**
  119084. * Gets or sets the associated variable name in the shader
  119085. */
  119086. associatedVariableName: string;
  119087. /** Gets or sets the type of animation applied to the input */
  119088. animationType: AnimatedInputBlockTypes;
  119089. /**
  119090. * Gets a boolean indicating that this connection point not defined yet
  119091. */
  119092. readonly isUndefined: boolean;
  119093. /**
  119094. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  119095. * In this case the connection point name must be the name of the uniform to use.
  119096. * Can only be set on inputs
  119097. */
  119098. isUniform: boolean;
  119099. /**
  119100. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  119101. * In this case the connection point name must be the name of the attribute to use
  119102. * Can only be set on inputs
  119103. */
  119104. isAttribute: boolean;
  119105. /**
  119106. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  119107. * Can only be set on exit points
  119108. */
  119109. isVarying: boolean;
  119110. /**
  119111. * Gets a boolean indicating that the current connection point is a system value
  119112. */
  119113. readonly isSystemValue: boolean;
  119114. /**
  119115. * Gets or sets the current well known value or null if not defined as a system value
  119116. */
  119117. systemValue: Nullable<NodeMaterialSystemValues>;
  119118. /**
  119119. * Gets the current class name
  119120. * @returns the class name
  119121. */
  119122. getClassName(): string;
  119123. /**
  119124. * Animate the input if animationType !== None
  119125. * @param scene defines the rendering scene
  119126. */
  119127. animate(scene: Scene): void;
  119128. private _emitDefine;
  119129. initialize(state: NodeMaterialBuildState): void;
  119130. /**
  119131. * Set the input block to its default value (based on its type)
  119132. */
  119133. setDefaultValue(): void;
  119134. private _emitConstant;
  119135. private _emit;
  119136. /** @hidden */
  119137. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  119138. /** @hidden */
  119139. _transmit(effect: Effect, scene: Scene): void;
  119140. protected _buildBlock(state: NodeMaterialBuildState): void;
  119141. protected _dumpPropertiesCode(): string;
  119142. serialize(): any;
  119143. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119144. }
  119145. }
  119146. declare module BABYLON {
  119147. /**
  119148. * Defines a connection point for a block
  119149. */
  119150. export class NodeMaterialConnectionPoint {
  119151. /** @hidden */
  119152. _ownerBlock: NodeMaterialBlock;
  119153. /** @hidden */
  119154. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119155. private _endpoints;
  119156. private _associatedVariableName;
  119157. /** @hidden */
  119158. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119159. /** @hidden */
  119160. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119161. private _type;
  119162. /** @hidden */
  119163. _enforceAssociatedVariableName: boolean;
  119164. /**
  119165. * Gets or sets the additional types supported by this connection point
  119166. */
  119167. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119168. /**
  119169. * Gets or sets the additional types excluded by this connection point
  119170. */
  119171. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119172. /**
  119173. * Gets or sets the associated variable name in the shader
  119174. */
  119175. associatedVariableName: string;
  119176. /**
  119177. * Gets or sets the connection point type (default is float)
  119178. */
  119179. type: NodeMaterialBlockConnectionPointTypes;
  119180. /**
  119181. * Gets or sets the connection point name
  119182. */
  119183. name: string;
  119184. /**
  119185. * Gets or sets a boolean indicating that this connection point can be omitted
  119186. */
  119187. isOptional: boolean;
  119188. /**
  119189. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119190. */
  119191. define: string;
  119192. /** Gets or sets the target of that connection point */
  119193. target: NodeMaterialBlockTargets;
  119194. /**
  119195. * Gets a boolean indicating that the current point is connected
  119196. */
  119197. readonly isConnected: boolean;
  119198. /**
  119199. * Gets a boolean indicating that the current point is connected to an input block
  119200. */
  119201. readonly isConnectedToInputBlock: boolean;
  119202. /**
  119203. * Gets a the connected input block (if any)
  119204. */
  119205. readonly connectInputBlock: Nullable<InputBlock>;
  119206. /** Get the other side of the connection (if any) */
  119207. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119208. /** Get the block that owns this connection point */
  119209. readonly ownerBlock: NodeMaterialBlock;
  119210. /** Get the block connected on the other side of this connection (if any) */
  119211. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119212. /** Get the block connected on the endpoints of this connection (if any) */
  119213. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119214. /** Gets the list of connected endpoints */
  119215. readonly endpoints: NodeMaterialConnectionPoint[];
  119216. /** Gets a boolean indicating if that output point is connected to at least one input */
  119217. readonly hasEndpoints: boolean;
  119218. /**
  119219. * Creates a new connection point
  119220. * @param name defines the connection point name
  119221. * @param ownerBlock defines the block hosting this connection point
  119222. */
  119223. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119224. /**
  119225. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119226. * @returns the class name
  119227. */
  119228. getClassName(): string;
  119229. /**
  119230. * Gets an boolean indicating if the current point can be connected to another point
  119231. * @param connectionPoint defines the other connection point
  119232. * @returns true if the connection is possible
  119233. */
  119234. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119235. /**
  119236. * Connect this point to another connection point
  119237. * @param connectionPoint defines the other connection point
  119238. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119239. * @returns the current connection point
  119240. */
  119241. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119242. /**
  119243. * Disconnect this point from one of his endpoint
  119244. * @param endpoint defines the other connection point
  119245. * @returns the current connection point
  119246. */
  119247. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119248. /**
  119249. * Serializes this point in a JSON representation
  119250. * @returns the serialized point object
  119251. */
  119252. serialize(): any;
  119253. }
  119254. }
  119255. declare module BABYLON {
  119256. /**
  119257. * Block used to add support for vertex skinning (bones)
  119258. */
  119259. export class BonesBlock extends NodeMaterialBlock {
  119260. /**
  119261. * Creates a new BonesBlock
  119262. * @param name defines the block name
  119263. */
  119264. constructor(name: string);
  119265. /**
  119266. * Initialize the block and prepare the context for build
  119267. * @param state defines the state that will be used for the build
  119268. */
  119269. initialize(state: NodeMaterialBuildState): void;
  119270. /**
  119271. * Gets the current class name
  119272. * @returns the class name
  119273. */
  119274. getClassName(): string;
  119275. /**
  119276. * Gets the matrix indices input component
  119277. */
  119278. readonly matricesIndices: NodeMaterialConnectionPoint;
  119279. /**
  119280. * Gets the matrix weights input component
  119281. */
  119282. readonly matricesWeights: NodeMaterialConnectionPoint;
  119283. /**
  119284. * Gets the extra matrix indices input component
  119285. */
  119286. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119287. /**
  119288. * Gets the extra matrix weights input component
  119289. */
  119290. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119291. /**
  119292. * Gets the world input component
  119293. */
  119294. readonly world: NodeMaterialConnectionPoint;
  119295. /**
  119296. * Gets the output component
  119297. */
  119298. readonly output: NodeMaterialConnectionPoint;
  119299. autoConfigure(material: NodeMaterial): void;
  119300. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119302. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119303. protected _buildBlock(state: NodeMaterialBuildState): this;
  119304. }
  119305. }
  119306. declare module BABYLON {
  119307. /**
  119308. * Block used to add support for instances
  119309. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119310. */
  119311. export class InstancesBlock extends NodeMaterialBlock {
  119312. /**
  119313. * Creates a new InstancesBlock
  119314. * @param name defines the block name
  119315. */
  119316. constructor(name: string);
  119317. /**
  119318. * Gets the current class name
  119319. * @returns the class name
  119320. */
  119321. getClassName(): string;
  119322. /**
  119323. * Gets the first world row input component
  119324. */
  119325. readonly world0: NodeMaterialConnectionPoint;
  119326. /**
  119327. * Gets the second world row input component
  119328. */
  119329. readonly world1: NodeMaterialConnectionPoint;
  119330. /**
  119331. * Gets the third world row input component
  119332. */
  119333. readonly world2: NodeMaterialConnectionPoint;
  119334. /**
  119335. * Gets the forth world row input component
  119336. */
  119337. readonly world3: NodeMaterialConnectionPoint;
  119338. /**
  119339. * Gets the world input component
  119340. */
  119341. readonly world: NodeMaterialConnectionPoint;
  119342. /**
  119343. * Gets the output component
  119344. */
  119345. readonly output: NodeMaterialConnectionPoint;
  119346. autoConfigure(material: NodeMaterial): void;
  119347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119348. protected _buildBlock(state: NodeMaterialBuildState): this;
  119349. }
  119350. }
  119351. declare module BABYLON {
  119352. /**
  119353. * Block used to add morph targets support to vertex shader
  119354. */
  119355. export class MorphTargetsBlock extends NodeMaterialBlock {
  119356. private _repeatableContentAnchor;
  119357. private _repeatebleContentGenerated;
  119358. /**
  119359. * Create a new MorphTargetsBlock
  119360. * @param name defines the block name
  119361. */
  119362. constructor(name: string);
  119363. /**
  119364. * Gets the current class name
  119365. * @returns the class name
  119366. */
  119367. getClassName(): string;
  119368. /**
  119369. * Gets the position input component
  119370. */
  119371. readonly position: NodeMaterialConnectionPoint;
  119372. /**
  119373. * Gets the normal input component
  119374. */
  119375. readonly normal: NodeMaterialConnectionPoint;
  119376. /**
  119377. * Gets the tangent input component
  119378. */
  119379. readonly tangent: NodeMaterialConnectionPoint;
  119380. /**
  119381. * Gets the tangent input component
  119382. */
  119383. readonly uv: NodeMaterialConnectionPoint;
  119384. /**
  119385. * Gets the position output component
  119386. */
  119387. readonly positionOutput: NodeMaterialConnectionPoint;
  119388. /**
  119389. * Gets the normal output component
  119390. */
  119391. readonly normalOutput: NodeMaterialConnectionPoint;
  119392. /**
  119393. * Gets the tangent output component
  119394. */
  119395. readonly tangentOutput: NodeMaterialConnectionPoint;
  119396. /**
  119397. * Gets the tangent output component
  119398. */
  119399. readonly uvOutput: NodeMaterialConnectionPoint;
  119400. initialize(state: NodeMaterialBuildState): void;
  119401. autoConfigure(material: NodeMaterial): void;
  119402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119403. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119404. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119405. protected _buildBlock(state: NodeMaterialBuildState): this;
  119406. }
  119407. }
  119408. declare module BABYLON {
  119409. /**
  119410. * Block used to get data information from a light
  119411. */
  119412. export class LightInformationBlock extends NodeMaterialBlock {
  119413. private _lightDataUniformName;
  119414. private _lightColorUniformName;
  119415. private _lightTypeDefineName;
  119416. /**
  119417. * Gets or sets the light associated with this block
  119418. */
  119419. light: Nullable<Light>;
  119420. /**
  119421. * Creates a new LightInformationBlock
  119422. * @param name defines the block name
  119423. */
  119424. constructor(name: string);
  119425. /**
  119426. * Gets the current class name
  119427. * @returns the class name
  119428. */
  119429. getClassName(): string;
  119430. /**
  119431. * Gets the world position input component
  119432. */
  119433. readonly worldPosition: NodeMaterialConnectionPoint;
  119434. /**
  119435. * Gets the direction output component
  119436. */
  119437. readonly direction: NodeMaterialConnectionPoint;
  119438. /**
  119439. * Gets the direction output component
  119440. */
  119441. readonly color: NodeMaterialConnectionPoint;
  119442. /**
  119443. * Gets the direction output component
  119444. */
  119445. readonly intensity: NodeMaterialConnectionPoint;
  119446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119448. protected _buildBlock(state: NodeMaterialBuildState): this;
  119449. serialize(): any;
  119450. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119451. }
  119452. }
  119453. declare module BABYLON {
  119454. /**
  119455. * Block used to add image processing support to fragment shader
  119456. */
  119457. export class ImageProcessingBlock extends NodeMaterialBlock {
  119458. /**
  119459. * Create a new ImageProcessingBlock
  119460. * @param name defines the block name
  119461. */
  119462. constructor(name: string);
  119463. /**
  119464. * Gets the current class name
  119465. * @returns the class name
  119466. */
  119467. getClassName(): string;
  119468. /**
  119469. * Gets the color input component
  119470. */
  119471. readonly color: NodeMaterialConnectionPoint;
  119472. /**
  119473. * Gets the output component
  119474. */
  119475. readonly output: NodeMaterialConnectionPoint;
  119476. /**
  119477. * Initialize the block and prepare the context for build
  119478. * @param state defines the state that will be used for the build
  119479. */
  119480. initialize(state: NodeMaterialBuildState): void;
  119481. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119482. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119483. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119484. protected _buildBlock(state: NodeMaterialBuildState): this;
  119485. }
  119486. }
  119487. declare module BABYLON {
  119488. /**
  119489. * Block used to pertub normals based on a normal map
  119490. */
  119491. export class PerturbNormalBlock extends NodeMaterialBlock {
  119492. private _tangentSpaceParameterName;
  119493. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119494. invertX: boolean;
  119495. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119496. invertY: boolean;
  119497. /**
  119498. * Create a new PerturbNormalBlock
  119499. * @param name defines the block name
  119500. */
  119501. constructor(name: string);
  119502. /**
  119503. * Gets the current class name
  119504. * @returns the class name
  119505. */
  119506. getClassName(): string;
  119507. /**
  119508. * Gets the world position input component
  119509. */
  119510. readonly worldPosition: NodeMaterialConnectionPoint;
  119511. /**
  119512. * Gets the world normal input component
  119513. */
  119514. readonly worldNormal: NodeMaterialConnectionPoint;
  119515. /**
  119516. * Gets the uv input component
  119517. */
  119518. readonly uv: NodeMaterialConnectionPoint;
  119519. /**
  119520. * Gets the normal map color input component
  119521. */
  119522. readonly normalMapColor: NodeMaterialConnectionPoint;
  119523. /**
  119524. * Gets the strength input component
  119525. */
  119526. readonly strength: NodeMaterialConnectionPoint;
  119527. /**
  119528. * Gets the output component
  119529. */
  119530. readonly output: NodeMaterialConnectionPoint;
  119531. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119533. autoConfigure(material: NodeMaterial): void;
  119534. protected _buildBlock(state: NodeMaterialBuildState): this;
  119535. protected _dumpPropertiesCode(): string;
  119536. serialize(): any;
  119537. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119538. }
  119539. }
  119540. declare module BABYLON {
  119541. /**
  119542. * Block used to discard a pixel if a value is smaller than a cutoff
  119543. */
  119544. export class DiscardBlock extends NodeMaterialBlock {
  119545. /**
  119546. * Create a new DiscardBlock
  119547. * @param name defines the block name
  119548. */
  119549. constructor(name: string);
  119550. /**
  119551. * Gets the current class name
  119552. * @returns the class name
  119553. */
  119554. getClassName(): string;
  119555. /**
  119556. * Gets the color input component
  119557. */
  119558. readonly value: NodeMaterialConnectionPoint;
  119559. /**
  119560. * Gets the cutoff input component
  119561. */
  119562. readonly cutoff: NodeMaterialConnectionPoint;
  119563. protected _buildBlock(state: NodeMaterialBuildState): this;
  119564. }
  119565. }
  119566. declare module BABYLON {
  119567. /**
  119568. * Block used to add support for scene fog
  119569. */
  119570. export class FogBlock extends NodeMaterialBlock {
  119571. private _fogDistanceName;
  119572. private _fogParameters;
  119573. /**
  119574. * Create a new FogBlock
  119575. * @param name defines the block name
  119576. */
  119577. constructor(name: string);
  119578. /**
  119579. * Gets the current class name
  119580. * @returns the class name
  119581. */
  119582. getClassName(): string;
  119583. /**
  119584. * Gets the world position input component
  119585. */
  119586. readonly worldPosition: NodeMaterialConnectionPoint;
  119587. /**
  119588. * Gets the view input component
  119589. */
  119590. readonly view: NodeMaterialConnectionPoint;
  119591. /**
  119592. * Gets the color input component
  119593. */
  119594. readonly input: NodeMaterialConnectionPoint;
  119595. /**
  119596. * Gets the fog color input component
  119597. */
  119598. readonly fogColor: NodeMaterialConnectionPoint;
  119599. /**
  119600. * Gets the output component
  119601. */
  119602. readonly output: NodeMaterialConnectionPoint;
  119603. autoConfigure(material: NodeMaterial): void;
  119604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119606. protected _buildBlock(state: NodeMaterialBuildState): this;
  119607. }
  119608. }
  119609. declare module BABYLON {
  119610. /**
  119611. * Block used to add light in the fragment shader
  119612. */
  119613. export class LightBlock extends NodeMaterialBlock {
  119614. private _lightId;
  119615. /**
  119616. * Gets or sets the light associated with this block
  119617. */
  119618. light: Nullable<Light>;
  119619. /**
  119620. * Create a new LightBlock
  119621. * @param name defines the block name
  119622. */
  119623. constructor(name: string);
  119624. /**
  119625. * Gets the current class name
  119626. * @returns the class name
  119627. */
  119628. getClassName(): string;
  119629. /**
  119630. * Gets the world position input component
  119631. */
  119632. readonly worldPosition: NodeMaterialConnectionPoint;
  119633. /**
  119634. * Gets the world normal input component
  119635. */
  119636. readonly worldNormal: NodeMaterialConnectionPoint;
  119637. /**
  119638. * Gets the camera (or eye) position component
  119639. */
  119640. readonly cameraPosition: NodeMaterialConnectionPoint;
  119641. /**
  119642. * Gets the diffuse output component
  119643. */
  119644. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119645. /**
  119646. * Gets the specular output component
  119647. */
  119648. readonly specularOutput: NodeMaterialConnectionPoint;
  119649. autoConfigure(material: NodeMaterial): void;
  119650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119651. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119653. private _injectVertexCode;
  119654. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119655. serialize(): any;
  119656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119657. }
  119658. }
  119659. declare module BABYLON {
  119660. /**
  119661. * Block used to multiply 2 values
  119662. */
  119663. export class MultiplyBlock extends NodeMaterialBlock {
  119664. /**
  119665. * Creates a new MultiplyBlock
  119666. * @param name defines the block name
  119667. */
  119668. constructor(name: string);
  119669. /**
  119670. * Gets the current class name
  119671. * @returns the class name
  119672. */
  119673. getClassName(): string;
  119674. /**
  119675. * Gets the left operand input component
  119676. */
  119677. readonly left: NodeMaterialConnectionPoint;
  119678. /**
  119679. * Gets the right operand input component
  119680. */
  119681. readonly right: NodeMaterialConnectionPoint;
  119682. /**
  119683. * Gets the output component
  119684. */
  119685. readonly output: NodeMaterialConnectionPoint;
  119686. protected _buildBlock(state: NodeMaterialBuildState): this;
  119687. }
  119688. }
  119689. declare module BABYLON {
  119690. /**
  119691. * Block used to add 2 vectors
  119692. */
  119693. export class AddBlock extends NodeMaterialBlock {
  119694. /**
  119695. * Creates a new AddBlock
  119696. * @param name defines the block name
  119697. */
  119698. constructor(name: string);
  119699. /**
  119700. * Gets the current class name
  119701. * @returns the class name
  119702. */
  119703. getClassName(): string;
  119704. /**
  119705. * Gets the left operand input component
  119706. */
  119707. readonly left: NodeMaterialConnectionPoint;
  119708. /**
  119709. * Gets the right operand input component
  119710. */
  119711. readonly right: NodeMaterialConnectionPoint;
  119712. /**
  119713. * Gets the output component
  119714. */
  119715. readonly output: NodeMaterialConnectionPoint;
  119716. protected _buildBlock(state: NodeMaterialBuildState): this;
  119717. }
  119718. }
  119719. declare module BABYLON {
  119720. /**
  119721. * Block used to scale a vector by a float
  119722. */
  119723. export class ScaleBlock extends NodeMaterialBlock {
  119724. /**
  119725. * Creates a new ScaleBlock
  119726. * @param name defines the block name
  119727. */
  119728. constructor(name: string);
  119729. /**
  119730. * Gets the current class name
  119731. * @returns the class name
  119732. */
  119733. getClassName(): string;
  119734. /**
  119735. * Gets the input component
  119736. */
  119737. readonly input: NodeMaterialConnectionPoint;
  119738. /**
  119739. * Gets the factor input component
  119740. */
  119741. readonly factor: NodeMaterialConnectionPoint;
  119742. /**
  119743. * Gets the output component
  119744. */
  119745. readonly output: NodeMaterialConnectionPoint;
  119746. protected _buildBlock(state: NodeMaterialBuildState): this;
  119747. }
  119748. }
  119749. declare module BABYLON {
  119750. /**
  119751. * Block used to clamp a float
  119752. */
  119753. export class ClampBlock extends NodeMaterialBlock {
  119754. /** Gets or sets the minimum range */
  119755. minimum: number;
  119756. /** Gets or sets the maximum range */
  119757. maximum: number;
  119758. /**
  119759. * Creates a new ClampBlock
  119760. * @param name defines the block name
  119761. */
  119762. constructor(name: string);
  119763. /**
  119764. * Gets the current class name
  119765. * @returns the class name
  119766. */
  119767. getClassName(): string;
  119768. /**
  119769. * Gets the value input component
  119770. */
  119771. readonly value: NodeMaterialConnectionPoint;
  119772. /**
  119773. * Gets the output component
  119774. */
  119775. readonly output: NodeMaterialConnectionPoint;
  119776. protected _buildBlock(state: NodeMaterialBuildState): this;
  119777. protected _dumpPropertiesCode(): string;
  119778. serialize(): any;
  119779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119780. }
  119781. }
  119782. declare module BABYLON {
  119783. /**
  119784. * Block used to apply a cross product between 2 vectors
  119785. */
  119786. export class CrossBlock extends NodeMaterialBlock {
  119787. /**
  119788. * Creates a new CrossBlock
  119789. * @param name defines the block name
  119790. */
  119791. constructor(name: string);
  119792. /**
  119793. * Gets the current class name
  119794. * @returns the class name
  119795. */
  119796. getClassName(): string;
  119797. /**
  119798. * Gets the left operand input component
  119799. */
  119800. readonly left: NodeMaterialConnectionPoint;
  119801. /**
  119802. * Gets the right operand input component
  119803. */
  119804. readonly right: NodeMaterialConnectionPoint;
  119805. /**
  119806. * Gets the output component
  119807. */
  119808. readonly output: NodeMaterialConnectionPoint;
  119809. protected _buildBlock(state: NodeMaterialBuildState): this;
  119810. }
  119811. }
  119812. declare module BABYLON {
  119813. /**
  119814. * Block used to apply a dot product between 2 vectors
  119815. */
  119816. export class DotBlock extends NodeMaterialBlock {
  119817. /**
  119818. * Creates a new DotBlock
  119819. * @param name defines the block name
  119820. */
  119821. constructor(name: string);
  119822. /**
  119823. * Gets the current class name
  119824. * @returns the class name
  119825. */
  119826. getClassName(): string;
  119827. /**
  119828. * Gets the left operand input component
  119829. */
  119830. readonly left: NodeMaterialConnectionPoint;
  119831. /**
  119832. * Gets the right operand input component
  119833. */
  119834. readonly right: NodeMaterialConnectionPoint;
  119835. /**
  119836. * Gets the output component
  119837. */
  119838. readonly output: NodeMaterialConnectionPoint;
  119839. protected _buildBlock(state: NodeMaterialBuildState): this;
  119840. }
  119841. }
  119842. declare module BABYLON {
  119843. /**
  119844. * Block used to remap a float from a range to a new one
  119845. */
  119846. export class RemapBlock extends NodeMaterialBlock {
  119847. /**
  119848. * Gets or sets the source range
  119849. */
  119850. sourceRange: Vector2;
  119851. /**
  119852. * Gets or sets the target range
  119853. */
  119854. targetRange: Vector2;
  119855. /**
  119856. * Creates a new RemapBlock
  119857. * @param name defines the block name
  119858. */
  119859. constructor(name: string);
  119860. /**
  119861. * Gets the current class name
  119862. * @returns the class name
  119863. */
  119864. getClassName(): string;
  119865. /**
  119866. * Gets the input component
  119867. */
  119868. readonly input: NodeMaterialConnectionPoint;
  119869. /**
  119870. * Gets the source min input component
  119871. */
  119872. readonly sourceMin: NodeMaterialConnectionPoint;
  119873. /**
  119874. * Gets the source max input component
  119875. */
  119876. readonly sourceMax: NodeMaterialConnectionPoint;
  119877. /**
  119878. * Gets the target min input component
  119879. */
  119880. readonly targetMin: NodeMaterialConnectionPoint;
  119881. /**
  119882. * Gets the target max input component
  119883. */
  119884. readonly targetMax: NodeMaterialConnectionPoint;
  119885. /**
  119886. * Gets the output component
  119887. */
  119888. readonly output: NodeMaterialConnectionPoint;
  119889. protected _buildBlock(state: NodeMaterialBuildState): this;
  119890. protected _dumpPropertiesCode(): string;
  119891. serialize(): any;
  119892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119893. }
  119894. }
  119895. declare module BABYLON {
  119896. /**
  119897. * Block used to normalize a vector
  119898. */
  119899. export class NormalizeBlock extends NodeMaterialBlock {
  119900. /**
  119901. * Creates a new NormalizeBlock
  119902. * @param name defines the block name
  119903. */
  119904. constructor(name: string);
  119905. /**
  119906. * Gets the current class name
  119907. * @returns the class name
  119908. */
  119909. getClassName(): string;
  119910. /**
  119911. * Gets the input component
  119912. */
  119913. readonly input: NodeMaterialConnectionPoint;
  119914. /**
  119915. * Gets the output component
  119916. */
  119917. readonly output: NodeMaterialConnectionPoint;
  119918. protected _buildBlock(state: NodeMaterialBuildState): this;
  119919. }
  119920. }
  119921. declare module BABYLON {
  119922. /**
  119923. * Operations supported by the Trigonometry block
  119924. */
  119925. export enum TrigonometryBlockOperations {
  119926. /** Cos */
  119927. Cos = 0,
  119928. /** Sin */
  119929. Sin = 1,
  119930. /** Abs */
  119931. Abs = 2,
  119932. /** Exp */
  119933. Exp = 3,
  119934. /** Exp2 */
  119935. Exp2 = 4,
  119936. /** Round */
  119937. Round = 5,
  119938. /** Floor */
  119939. Floor = 6,
  119940. /** Ceiling */
  119941. Ceiling = 7,
  119942. /** Square root */
  119943. Sqrt = 8
  119944. }
  119945. /**
  119946. * Block used to apply trigonometry operation to floats
  119947. */
  119948. export class TrigonometryBlock extends NodeMaterialBlock {
  119949. /**
  119950. * Gets or sets the operation applied by the block
  119951. */
  119952. operation: TrigonometryBlockOperations;
  119953. /**
  119954. * Creates a new TrigonometryBlock
  119955. * @param name defines the block name
  119956. */
  119957. constructor(name: string);
  119958. /**
  119959. * Gets the current class name
  119960. * @returns the class name
  119961. */
  119962. getClassName(): string;
  119963. /**
  119964. * Gets the input component
  119965. */
  119966. readonly input: NodeMaterialConnectionPoint;
  119967. /**
  119968. * Gets the output component
  119969. */
  119970. readonly output: NodeMaterialConnectionPoint;
  119971. protected _buildBlock(state: NodeMaterialBuildState): this;
  119972. serialize(): any;
  119973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119974. }
  119975. }
  119976. declare module BABYLON {
  119977. /**
  119978. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119979. */
  119980. export class ColorMergerBlock extends NodeMaterialBlock {
  119981. /**
  119982. * Create a new ColorMergerBlock
  119983. * @param name defines the block name
  119984. */
  119985. constructor(name: string);
  119986. /**
  119987. * Gets the current class name
  119988. * @returns the class name
  119989. */
  119990. getClassName(): string;
  119991. /**
  119992. * Gets the r component (input)
  119993. */
  119994. readonly r: NodeMaterialConnectionPoint;
  119995. /**
  119996. * Gets the g component (input)
  119997. */
  119998. readonly g: NodeMaterialConnectionPoint;
  119999. /**
  120000. * Gets the b component (input)
  120001. */
  120002. readonly b: NodeMaterialConnectionPoint;
  120003. /**
  120004. * Gets the a component (input)
  120005. */
  120006. readonly a: NodeMaterialConnectionPoint;
  120007. /**
  120008. * Gets the rgba component (output)
  120009. */
  120010. readonly rgba: NodeMaterialConnectionPoint;
  120011. /**
  120012. * Gets the rgb component (output)
  120013. */
  120014. readonly rgb: NodeMaterialConnectionPoint;
  120015. protected _buildBlock(state: NodeMaterialBuildState): this;
  120016. }
  120017. }
  120018. declare module BABYLON {
  120019. /**
  120020. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  120021. */
  120022. export class VectorMergerBlock extends NodeMaterialBlock {
  120023. /**
  120024. * Create a new VectorMergerBlock
  120025. * @param name defines the block name
  120026. */
  120027. constructor(name: string);
  120028. /**
  120029. * Gets the current class name
  120030. * @returns the class name
  120031. */
  120032. getClassName(): string;
  120033. /**
  120034. * Gets the x component (input)
  120035. */
  120036. readonly x: NodeMaterialConnectionPoint;
  120037. /**
  120038. * Gets the y component (input)
  120039. */
  120040. readonly y: NodeMaterialConnectionPoint;
  120041. /**
  120042. * Gets the z component (input)
  120043. */
  120044. readonly z: NodeMaterialConnectionPoint;
  120045. /**
  120046. * Gets the w component (input)
  120047. */
  120048. readonly w: NodeMaterialConnectionPoint;
  120049. /**
  120050. * Gets the xyzw component (output)
  120051. */
  120052. readonly xyzw: NodeMaterialConnectionPoint;
  120053. /**
  120054. * Gets the xyz component (output)
  120055. */
  120056. readonly xyz: NodeMaterialConnectionPoint;
  120057. /**
  120058. * Gets the xy component (output)
  120059. */
  120060. readonly xy: NodeMaterialConnectionPoint;
  120061. protected _buildBlock(state: NodeMaterialBuildState): this;
  120062. }
  120063. }
  120064. declare module BABYLON {
  120065. /**
  120066. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  120067. */
  120068. export class ColorSplitterBlock extends NodeMaterialBlock {
  120069. /**
  120070. * Create a new ColorSplitterBlock
  120071. * @param name defines the block name
  120072. */
  120073. constructor(name: string);
  120074. /**
  120075. * Gets the current class name
  120076. * @returns the class name
  120077. */
  120078. getClassName(): string;
  120079. /**
  120080. * Gets the rgba component (input)
  120081. */
  120082. readonly rgba: NodeMaterialConnectionPoint;
  120083. /**
  120084. * Gets the rgb component (input)
  120085. */
  120086. readonly rgbIn: NodeMaterialConnectionPoint;
  120087. /**
  120088. * Gets the rgb component (output)
  120089. */
  120090. readonly rgbOut: NodeMaterialConnectionPoint;
  120091. /**
  120092. * Gets the r component (output)
  120093. */
  120094. readonly r: NodeMaterialConnectionPoint;
  120095. /**
  120096. * Gets the g component (output)
  120097. */
  120098. readonly g: NodeMaterialConnectionPoint;
  120099. /**
  120100. * Gets the b component (output)
  120101. */
  120102. readonly b: NodeMaterialConnectionPoint;
  120103. /**
  120104. * Gets the a component (output)
  120105. */
  120106. readonly a: NodeMaterialConnectionPoint;
  120107. protected _inputRename(name: string): string;
  120108. protected _outputRename(name: string): string;
  120109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120110. }
  120111. }
  120112. declare module BABYLON {
  120113. /**
  120114. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  120115. */
  120116. export class VectorSplitterBlock extends NodeMaterialBlock {
  120117. /**
  120118. * Create a new VectorSplitterBlock
  120119. * @param name defines the block name
  120120. */
  120121. constructor(name: string);
  120122. /**
  120123. * Gets the current class name
  120124. * @returns the class name
  120125. */
  120126. getClassName(): string;
  120127. /**
  120128. * Gets the xyzw component (input)
  120129. */
  120130. readonly xyzw: NodeMaterialConnectionPoint;
  120131. /**
  120132. * Gets the xyz component (input)
  120133. */
  120134. readonly xyzIn: NodeMaterialConnectionPoint;
  120135. /**
  120136. * Gets the xy component (input)
  120137. */
  120138. readonly xyIn: NodeMaterialConnectionPoint;
  120139. /**
  120140. * Gets the xyz component (output)
  120141. */
  120142. readonly xyzOut: NodeMaterialConnectionPoint;
  120143. /**
  120144. * Gets the xy component (output)
  120145. */
  120146. readonly xyOut: NodeMaterialConnectionPoint;
  120147. /**
  120148. * Gets the x component (output)
  120149. */
  120150. readonly x: NodeMaterialConnectionPoint;
  120151. /**
  120152. * Gets the y component (output)
  120153. */
  120154. readonly y: NodeMaterialConnectionPoint;
  120155. /**
  120156. * Gets the z component (output)
  120157. */
  120158. readonly z: NodeMaterialConnectionPoint;
  120159. /**
  120160. * Gets the w component (output)
  120161. */
  120162. readonly w: NodeMaterialConnectionPoint;
  120163. protected _inputRename(name: string): string;
  120164. protected _outputRename(name: string): string;
  120165. protected _buildBlock(state: NodeMaterialBuildState): this;
  120166. }
  120167. }
  120168. declare module BABYLON {
  120169. /**
  120170. * Block used to lerp 2 values
  120171. */
  120172. export class LerpBlock extends NodeMaterialBlock {
  120173. /**
  120174. * Creates a new LerpBlock
  120175. * @param name defines the block name
  120176. */
  120177. constructor(name: string);
  120178. /**
  120179. * Gets the current class name
  120180. * @returns the class name
  120181. */
  120182. getClassName(): string;
  120183. /**
  120184. * Gets the left operand input component
  120185. */
  120186. readonly left: NodeMaterialConnectionPoint;
  120187. /**
  120188. * Gets the right operand input component
  120189. */
  120190. readonly right: NodeMaterialConnectionPoint;
  120191. /**
  120192. * Gets the gradient operand input component
  120193. */
  120194. readonly gradient: NodeMaterialConnectionPoint;
  120195. /**
  120196. * Gets the output component
  120197. */
  120198. readonly output: NodeMaterialConnectionPoint;
  120199. protected _buildBlock(state: NodeMaterialBuildState): this;
  120200. }
  120201. }
  120202. declare module BABYLON {
  120203. /**
  120204. * Block used to divide 2 vectors
  120205. */
  120206. export class DivideBlock extends NodeMaterialBlock {
  120207. /**
  120208. * Creates a new DivideBlock
  120209. * @param name defines the block name
  120210. */
  120211. constructor(name: string);
  120212. /**
  120213. * Gets the current class name
  120214. * @returns the class name
  120215. */
  120216. getClassName(): string;
  120217. /**
  120218. * Gets the left operand input component
  120219. */
  120220. readonly left: NodeMaterialConnectionPoint;
  120221. /**
  120222. * Gets the right operand input component
  120223. */
  120224. readonly right: NodeMaterialConnectionPoint;
  120225. /**
  120226. * Gets the output component
  120227. */
  120228. readonly output: NodeMaterialConnectionPoint;
  120229. protected _buildBlock(state: NodeMaterialBuildState): this;
  120230. }
  120231. }
  120232. declare module BABYLON {
  120233. /**
  120234. * Block used to subtract 2 vectors
  120235. */
  120236. export class SubtractBlock extends NodeMaterialBlock {
  120237. /**
  120238. * Creates a new SubtractBlock
  120239. * @param name defines the block name
  120240. */
  120241. constructor(name: string);
  120242. /**
  120243. * Gets the current class name
  120244. * @returns the class name
  120245. */
  120246. getClassName(): string;
  120247. /**
  120248. * Gets the left operand input component
  120249. */
  120250. readonly left: NodeMaterialConnectionPoint;
  120251. /**
  120252. * Gets the right operand input component
  120253. */
  120254. readonly right: NodeMaterialConnectionPoint;
  120255. /**
  120256. * Gets the output component
  120257. */
  120258. readonly output: NodeMaterialConnectionPoint;
  120259. protected _buildBlock(state: NodeMaterialBuildState): this;
  120260. }
  120261. }
  120262. declare module BABYLON {
  120263. /**
  120264. * Block used to step a value
  120265. */
  120266. export class StepBlock extends NodeMaterialBlock {
  120267. /**
  120268. * Creates a new AddBlock
  120269. * @param name defines the block name
  120270. */
  120271. constructor(name: string);
  120272. /**
  120273. * Gets the current class name
  120274. * @returns the class name
  120275. */
  120276. getClassName(): string;
  120277. /**
  120278. * Gets the value operand input component
  120279. */
  120280. readonly value: NodeMaterialConnectionPoint;
  120281. /**
  120282. * Gets the edge operand input component
  120283. */
  120284. readonly edge: NodeMaterialConnectionPoint;
  120285. /**
  120286. * Gets the output component
  120287. */
  120288. readonly output: NodeMaterialConnectionPoint;
  120289. protected _buildBlock(state: NodeMaterialBuildState): this;
  120290. }
  120291. }
  120292. declare module BABYLON {
  120293. /**
  120294. * Block used to get the opposite (1 - x) of a value
  120295. */
  120296. export class OneMinusBlock extends NodeMaterialBlock {
  120297. /**
  120298. * Creates a new OneMinusBlock
  120299. * @param name defines the block name
  120300. */
  120301. constructor(name: string);
  120302. /**
  120303. * Gets the current class name
  120304. * @returns the class name
  120305. */
  120306. getClassName(): string;
  120307. /**
  120308. * Gets the input component
  120309. */
  120310. readonly input: NodeMaterialConnectionPoint;
  120311. /**
  120312. * Gets the output component
  120313. */
  120314. readonly output: NodeMaterialConnectionPoint;
  120315. protected _buildBlock(state: NodeMaterialBuildState): this;
  120316. }
  120317. }
  120318. declare module BABYLON {
  120319. /**
  120320. * Block used to get the view direction
  120321. */
  120322. export class ViewDirectionBlock extends NodeMaterialBlock {
  120323. /**
  120324. * Creates a new ViewDirectionBlock
  120325. * @param name defines the block name
  120326. */
  120327. constructor(name: string);
  120328. /**
  120329. * Gets the current class name
  120330. * @returns the class name
  120331. */
  120332. getClassName(): string;
  120333. /**
  120334. * Gets the world position component
  120335. */
  120336. readonly worldPosition: NodeMaterialConnectionPoint;
  120337. /**
  120338. * Gets the camera position component
  120339. */
  120340. readonly cameraPosition: NodeMaterialConnectionPoint;
  120341. /**
  120342. * Gets the output component
  120343. */
  120344. readonly output: NodeMaterialConnectionPoint;
  120345. autoConfigure(material: NodeMaterial): void;
  120346. protected _buildBlock(state: NodeMaterialBuildState): this;
  120347. }
  120348. }
  120349. declare module BABYLON {
  120350. /**
  120351. * Block used to compute fresnel value
  120352. */
  120353. export class FresnelBlock extends NodeMaterialBlock {
  120354. /**
  120355. * Create a new FresnelBlock
  120356. * @param name defines the block name
  120357. */
  120358. constructor(name: string);
  120359. /**
  120360. * Gets the current class name
  120361. * @returns the class name
  120362. */
  120363. getClassName(): string;
  120364. /**
  120365. * Gets the world normal input component
  120366. */
  120367. readonly worldNormal: NodeMaterialConnectionPoint;
  120368. /**
  120369. * Gets the view direction input component
  120370. */
  120371. readonly viewDirection: NodeMaterialConnectionPoint;
  120372. /**
  120373. * Gets the bias input component
  120374. */
  120375. readonly bias: NodeMaterialConnectionPoint;
  120376. /**
  120377. * Gets the camera (or eye) position component
  120378. */
  120379. readonly power: NodeMaterialConnectionPoint;
  120380. /**
  120381. * Gets the fresnel output component
  120382. */
  120383. readonly fresnel: NodeMaterialConnectionPoint;
  120384. autoConfigure(material: NodeMaterial): void;
  120385. protected _buildBlock(state: NodeMaterialBuildState): this;
  120386. }
  120387. }
  120388. declare module BABYLON {
  120389. /**
  120390. * Block used to get the max of 2 values
  120391. */
  120392. export class MaxBlock extends NodeMaterialBlock {
  120393. /**
  120394. * Creates a new MaxBlock
  120395. * @param name defines the block name
  120396. */
  120397. constructor(name: string);
  120398. /**
  120399. * Gets the current class name
  120400. * @returns the class name
  120401. */
  120402. getClassName(): string;
  120403. /**
  120404. * Gets the left operand input component
  120405. */
  120406. readonly left: NodeMaterialConnectionPoint;
  120407. /**
  120408. * Gets the right operand input component
  120409. */
  120410. readonly right: NodeMaterialConnectionPoint;
  120411. /**
  120412. * Gets the output component
  120413. */
  120414. readonly output: NodeMaterialConnectionPoint;
  120415. protected _buildBlock(state: NodeMaterialBuildState): this;
  120416. }
  120417. }
  120418. declare module BABYLON {
  120419. /**
  120420. * Block used to get the min of 2 values
  120421. */
  120422. export class MinBlock extends NodeMaterialBlock {
  120423. /**
  120424. * Creates a new MinBlock
  120425. * @param name defines the block name
  120426. */
  120427. constructor(name: string);
  120428. /**
  120429. * Gets the current class name
  120430. * @returns the class name
  120431. */
  120432. getClassName(): string;
  120433. /**
  120434. * Gets the left operand input component
  120435. */
  120436. readonly left: NodeMaterialConnectionPoint;
  120437. /**
  120438. * Gets the right operand input component
  120439. */
  120440. readonly right: NodeMaterialConnectionPoint;
  120441. /**
  120442. * Gets the output component
  120443. */
  120444. readonly output: NodeMaterialConnectionPoint;
  120445. protected _buildBlock(state: NodeMaterialBuildState): this;
  120446. }
  120447. }
  120448. declare module BABYLON {
  120449. /**
  120450. * Block used to get the distance between 2 values
  120451. */
  120452. export class DistanceBlock extends NodeMaterialBlock {
  120453. /**
  120454. * Creates a new DistanceBlock
  120455. * @param name defines the block name
  120456. */
  120457. constructor(name: string);
  120458. /**
  120459. * Gets the current class name
  120460. * @returns the class name
  120461. */
  120462. getClassName(): string;
  120463. /**
  120464. * Gets the left operand input component
  120465. */
  120466. readonly left: NodeMaterialConnectionPoint;
  120467. /**
  120468. * Gets the right operand input component
  120469. */
  120470. readonly right: NodeMaterialConnectionPoint;
  120471. /**
  120472. * Gets the output component
  120473. */
  120474. readonly output: NodeMaterialConnectionPoint;
  120475. protected _buildBlock(state: NodeMaterialBuildState): this;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. /**
  120480. * Block used to get the length of a vector
  120481. */
  120482. export class LengthBlock extends NodeMaterialBlock {
  120483. /**
  120484. * Creates a new LengthBlock
  120485. * @param name defines the block name
  120486. */
  120487. constructor(name: string);
  120488. /**
  120489. * Gets the current class name
  120490. * @returns the class name
  120491. */
  120492. getClassName(): string;
  120493. /**
  120494. * Gets the value input component
  120495. */
  120496. readonly value: NodeMaterialConnectionPoint;
  120497. /**
  120498. * Gets the output component
  120499. */
  120500. readonly output: NodeMaterialConnectionPoint;
  120501. protected _buildBlock(state: NodeMaterialBuildState): this;
  120502. }
  120503. }
  120504. declare module BABYLON {
  120505. /**
  120506. * Block used to get negative version of a value (i.e. x * -1)
  120507. */
  120508. export class NegateBlock extends NodeMaterialBlock {
  120509. /**
  120510. * Creates a new NegateBlock
  120511. * @param name defines the block name
  120512. */
  120513. constructor(name: string);
  120514. /**
  120515. * Gets the current class name
  120516. * @returns the class name
  120517. */
  120518. getClassName(): string;
  120519. /**
  120520. * Gets the value input component
  120521. */
  120522. readonly value: NodeMaterialConnectionPoint;
  120523. /**
  120524. * Gets the output component
  120525. */
  120526. readonly output: NodeMaterialConnectionPoint;
  120527. protected _buildBlock(state: NodeMaterialBuildState): this;
  120528. }
  120529. }
  120530. declare module BABYLON {
  120531. /**
  120532. * Block used to get the value of the first parameter raised to the power of the second
  120533. */
  120534. export class PowBlock extends NodeMaterialBlock {
  120535. /**
  120536. * Creates a new PowBlock
  120537. * @param name defines the block name
  120538. */
  120539. constructor(name: string);
  120540. /**
  120541. * Gets the current class name
  120542. * @returns the class name
  120543. */
  120544. getClassName(): string;
  120545. /**
  120546. * Gets the value operand input component
  120547. */
  120548. readonly value: NodeMaterialConnectionPoint;
  120549. /**
  120550. * Gets the power operand input component
  120551. */
  120552. readonly power: NodeMaterialConnectionPoint;
  120553. /**
  120554. * Gets the output component
  120555. */
  120556. readonly output: NodeMaterialConnectionPoint;
  120557. protected _buildBlock(state: NodeMaterialBuildState): this;
  120558. }
  120559. }
  120560. declare module BABYLON {
  120561. /**
  120562. * Block used to get a random number
  120563. */
  120564. export class RandomNumberBlock extends NodeMaterialBlock {
  120565. /**
  120566. * Creates a new RandomNumberBlock
  120567. * @param name defines the block name
  120568. */
  120569. constructor(name: string);
  120570. /**
  120571. * Gets the current class name
  120572. * @returns the class name
  120573. */
  120574. getClassName(): string;
  120575. /**
  120576. * Gets the seed input component
  120577. */
  120578. readonly seed: NodeMaterialConnectionPoint;
  120579. /**
  120580. * Gets the output component
  120581. */
  120582. readonly output: NodeMaterialConnectionPoint;
  120583. protected _buildBlock(state: NodeMaterialBuildState): this;
  120584. }
  120585. }
  120586. declare module BABYLON {
  120587. /**
  120588. * Effect Render Options
  120589. */
  120590. export interface IEffectRendererOptions {
  120591. /**
  120592. * Defines the vertices positions.
  120593. */
  120594. positions?: number[];
  120595. /**
  120596. * Defines the indices.
  120597. */
  120598. indices?: number[];
  120599. }
  120600. /**
  120601. * Helper class to render one or more effects
  120602. */
  120603. export class EffectRenderer {
  120604. private engine;
  120605. private static _DefaultOptions;
  120606. private _vertexBuffers;
  120607. private _indexBuffer;
  120608. private _ringBufferIndex;
  120609. private _ringScreenBuffer;
  120610. private _fullscreenViewport;
  120611. private _getNextFrameBuffer;
  120612. /**
  120613. * Creates an effect renderer
  120614. * @param engine the engine to use for rendering
  120615. * @param options defines the options of the effect renderer
  120616. */
  120617. constructor(engine: Engine, options?: IEffectRendererOptions);
  120618. /**
  120619. * Sets the current viewport in normalized coordinates 0-1
  120620. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120621. */
  120622. setViewport(viewport?: Viewport): void;
  120623. /**
  120624. * Binds the embedded attributes buffer to the effect.
  120625. * @param effect Defines the effect to bind the attributes for
  120626. */
  120627. bindBuffers(effect: Effect): void;
  120628. /**
  120629. * Sets the current effect wrapper to use during draw.
  120630. * The effect needs to be ready before calling this api.
  120631. * This also sets the default full screen position attribute.
  120632. * @param effectWrapper Defines the effect to draw with
  120633. */
  120634. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120635. /**
  120636. * Draws a full screen quad.
  120637. */
  120638. draw(): void;
  120639. /**
  120640. * renders one or more effects to a specified texture
  120641. * @param effectWrappers list of effects to renderer
  120642. * @param outputTexture texture to draw to, if null it will render to the screen
  120643. */
  120644. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120645. /**
  120646. * Disposes of the effect renderer
  120647. */
  120648. dispose(): void;
  120649. }
  120650. /**
  120651. * Options to create an EffectWrapper
  120652. */
  120653. interface EffectWrapperCreationOptions {
  120654. /**
  120655. * Engine to use to create the effect
  120656. */
  120657. engine: Engine;
  120658. /**
  120659. * Fragment shader for the effect
  120660. */
  120661. fragmentShader: string;
  120662. /**
  120663. * Vertex shader for the effect
  120664. */
  120665. vertexShader?: string;
  120666. /**
  120667. * Attributes to use in the shader
  120668. */
  120669. attributeNames?: Array<string>;
  120670. /**
  120671. * Uniforms to use in the shader
  120672. */
  120673. uniformNames?: Array<string>;
  120674. /**
  120675. * Texture sampler names to use in the shader
  120676. */
  120677. samplerNames?: Array<string>;
  120678. /**
  120679. * The friendly name of the effect displayed in Spector.
  120680. */
  120681. name?: string;
  120682. }
  120683. /**
  120684. * Wraps an effect to be used for rendering
  120685. */
  120686. export class EffectWrapper {
  120687. /**
  120688. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120689. */
  120690. onApplyObservable: Observable<{}>;
  120691. /**
  120692. * The underlying effect
  120693. */
  120694. effect: Effect;
  120695. /**
  120696. * Creates an effect to be renderer
  120697. * @param creationOptions options to create the effect
  120698. */
  120699. constructor(creationOptions: EffectWrapperCreationOptions);
  120700. /**
  120701. * Disposes of the effect wrapper
  120702. */
  120703. dispose(): void;
  120704. }
  120705. }
  120706. declare module BABYLON {
  120707. /**
  120708. * Helper class to push actions to a pool of workers.
  120709. */
  120710. export class WorkerPool implements IDisposable {
  120711. private _workerInfos;
  120712. private _pendingActions;
  120713. /**
  120714. * Constructor
  120715. * @param workers Array of workers to use for actions
  120716. */
  120717. constructor(workers: Array<Worker>);
  120718. /**
  120719. * Terminates all workers and clears any pending actions.
  120720. */
  120721. dispose(): void;
  120722. /**
  120723. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120724. * pended until a worker has completed its action.
  120725. * @param action The action to perform. Call onComplete when the action is complete.
  120726. */
  120727. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120728. private _execute;
  120729. }
  120730. }
  120731. declare module BABYLON {
  120732. /**
  120733. * Configuration for Draco compression
  120734. */
  120735. export interface IDracoCompressionConfiguration {
  120736. /**
  120737. * Configuration for the decoder.
  120738. */
  120739. decoder: {
  120740. /**
  120741. * The url to the WebAssembly module.
  120742. */
  120743. wasmUrl?: string;
  120744. /**
  120745. * The url to the WebAssembly binary.
  120746. */
  120747. wasmBinaryUrl?: string;
  120748. /**
  120749. * The url to the fallback JavaScript module.
  120750. */
  120751. fallbackUrl?: string;
  120752. };
  120753. }
  120754. /**
  120755. * Draco compression (https://google.github.io/draco/)
  120756. *
  120757. * This class wraps the Draco module.
  120758. *
  120759. * **Encoder**
  120760. *
  120761. * The encoder is not currently implemented.
  120762. *
  120763. * **Decoder**
  120764. *
  120765. * 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.
  120766. *
  120767. * To update the configuration, use the following code:
  120768. * ```javascript
  120769. * DracoCompression.Configuration = {
  120770. * decoder: {
  120771. * wasmUrl: "<url to the WebAssembly library>",
  120772. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120773. * fallbackUrl: "<url to the fallback JavaScript library>",
  120774. * }
  120775. * };
  120776. * ```
  120777. *
  120778. * 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.
  120779. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120780. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120781. *
  120782. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120783. * ```javascript
  120784. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120785. * ```
  120786. *
  120787. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120788. */
  120789. export class DracoCompression implements IDisposable {
  120790. private _workerPoolPromise?;
  120791. private _decoderModulePromise?;
  120792. /**
  120793. * The configuration. Defaults to the following urls:
  120794. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120795. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120796. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120797. */
  120798. static Configuration: IDracoCompressionConfiguration;
  120799. /**
  120800. * Returns true if the decoder configuration is available.
  120801. */
  120802. static readonly DecoderAvailable: boolean;
  120803. /**
  120804. * Default number of workers to create when creating the draco compression object.
  120805. */
  120806. static DefaultNumWorkers: number;
  120807. private static GetDefaultNumWorkers;
  120808. private static _Default;
  120809. /**
  120810. * Default instance for the draco compression object.
  120811. */
  120812. static readonly Default: DracoCompression;
  120813. /**
  120814. * Constructor
  120815. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120816. */
  120817. constructor(numWorkers?: number);
  120818. /**
  120819. * Stop all async operations and release resources.
  120820. */
  120821. dispose(): void;
  120822. /**
  120823. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120824. * @returns a promise that resolves when ready
  120825. */
  120826. whenReadyAsync(): Promise<void>;
  120827. /**
  120828. * Decode Draco compressed mesh data to vertex data.
  120829. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120830. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120831. * @returns A promise that resolves with the decoded vertex data
  120832. */
  120833. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120834. [kind: string]: number;
  120835. }): Promise<VertexData>;
  120836. }
  120837. }
  120838. declare module BABYLON {
  120839. /**
  120840. * Class for building Constructive Solid Geometry
  120841. */
  120842. export class CSG {
  120843. private polygons;
  120844. /**
  120845. * The world matrix
  120846. */
  120847. matrix: Matrix;
  120848. /**
  120849. * Stores the position
  120850. */
  120851. position: Vector3;
  120852. /**
  120853. * Stores the rotation
  120854. */
  120855. rotation: Vector3;
  120856. /**
  120857. * Stores the rotation quaternion
  120858. */
  120859. rotationQuaternion: Nullable<Quaternion>;
  120860. /**
  120861. * Stores the scaling vector
  120862. */
  120863. scaling: Vector3;
  120864. /**
  120865. * Convert the Mesh to CSG
  120866. * @param mesh The Mesh to convert to CSG
  120867. * @returns A new CSG from the Mesh
  120868. */
  120869. static FromMesh(mesh: Mesh): CSG;
  120870. /**
  120871. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120872. * @param polygons Polygons used to construct a CSG solid
  120873. */
  120874. private static FromPolygons;
  120875. /**
  120876. * Clones, or makes a deep copy, of the CSG
  120877. * @returns A new CSG
  120878. */
  120879. clone(): CSG;
  120880. /**
  120881. * Unions this CSG with another CSG
  120882. * @param csg The CSG to union against this CSG
  120883. * @returns The unioned CSG
  120884. */
  120885. union(csg: CSG): CSG;
  120886. /**
  120887. * Unions this CSG with another CSG in place
  120888. * @param csg The CSG to union against this CSG
  120889. */
  120890. unionInPlace(csg: CSG): void;
  120891. /**
  120892. * Subtracts this CSG with another CSG
  120893. * @param csg The CSG to subtract against this CSG
  120894. * @returns A new CSG
  120895. */
  120896. subtract(csg: CSG): CSG;
  120897. /**
  120898. * Subtracts this CSG with another CSG in place
  120899. * @param csg The CSG to subtact against this CSG
  120900. */
  120901. subtractInPlace(csg: CSG): void;
  120902. /**
  120903. * Intersect this CSG with another CSG
  120904. * @param csg The CSG to intersect against this CSG
  120905. * @returns A new CSG
  120906. */
  120907. intersect(csg: CSG): CSG;
  120908. /**
  120909. * Intersects this CSG with another CSG in place
  120910. * @param csg The CSG to intersect against this CSG
  120911. */
  120912. intersectInPlace(csg: CSG): void;
  120913. /**
  120914. * Return a new CSG solid with solid and empty space switched. This solid is
  120915. * not modified.
  120916. * @returns A new CSG solid with solid and empty space switched
  120917. */
  120918. inverse(): CSG;
  120919. /**
  120920. * Inverses the CSG in place
  120921. */
  120922. inverseInPlace(): void;
  120923. /**
  120924. * This is used to keep meshes transformations so they can be restored
  120925. * when we build back a Babylon Mesh
  120926. * NB : All CSG operations are performed in world coordinates
  120927. * @param csg The CSG to copy the transform attributes from
  120928. * @returns This CSG
  120929. */
  120930. copyTransformAttributes(csg: CSG): CSG;
  120931. /**
  120932. * Build Raw mesh from CSG
  120933. * Coordinates here are in world space
  120934. * @param name The name of the mesh geometry
  120935. * @param scene The Scene
  120936. * @param keepSubMeshes Specifies if the submeshes should be kept
  120937. * @returns A new Mesh
  120938. */
  120939. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120940. /**
  120941. * Build Mesh from CSG taking material and transforms into account
  120942. * @param name The name of the Mesh
  120943. * @param material The material of the Mesh
  120944. * @param scene The Scene
  120945. * @param keepSubMeshes Specifies if submeshes should be kept
  120946. * @returns The new Mesh
  120947. */
  120948. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120949. }
  120950. }
  120951. declare module BABYLON {
  120952. /**
  120953. * Class used to create a trail following a mesh
  120954. */
  120955. export class TrailMesh extends Mesh {
  120956. private _generator;
  120957. private _autoStart;
  120958. private _running;
  120959. private _diameter;
  120960. private _length;
  120961. private _sectionPolygonPointsCount;
  120962. private _sectionVectors;
  120963. private _sectionNormalVectors;
  120964. private _beforeRenderObserver;
  120965. /**
  120966. * @constructor
  120967. * @param name The value used by scene.getMeshByName() to do a lookup.
  120968. * @param generator The mesh to generate a trail.
  120969. * @param scene The scene to add this mesh to.
  120970. * @param diameter Diameter of trailing mesh. Default is 1.
  120971. * @param length Length of trailing mesh. Default is 60.
  120972. * @param autoStart Automatically start trailing mesh. Default true.
  120973. */
  120974. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120975. /**
  120976. * "TrailMesh"
  120977. * @returns "TrailMesh"
  120978. */
  120979. getClassName(): string;
  120980. private _createMesh;
  120981. /**
  120982. * Start trailing mesh.
  120983. */
  120984. start(): void;
  120985. /**
  120986. * Stop trailing mesh.
  120987. */
  120988. stop(): void;
  120989. /**
  120990. * Update trailing mesh geometry.
  120991. */
  120992. update(): void;
  120993. /**
  120994. * Returns a new TrailMesh object.
  120995. * @param name is a string, the name given to the new mesh
  120996. * @param newGenerator use new generator object for cloned trail mesh
  120997. * @returns a new mesh
  120998. */
  120999. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  121000. /**
  121001. * Serializes this trail mesh
  121002. * @param serializationObject object to write serialization to
  121003. */
  121004. serialize(serializationObject: any): void;
  121005. /**
  121006. * Parses a serialized trail mesh
  121007. * @param parsedMesh the serialized mesh
  121008. * @param scene the scene to create the trail mesh in
  121009. * @returns the created trail mesh
  121010. */
  121011. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  121012. }
  121013. }
  121014. declare module BABYLON {
  121015. /**
  121016. * Class containing static functions to help procedurally build meshes
  121017. */
  121018. export class TiledBoxBuilder {
  121019. /**
  121020. * Creates a box mesh
  121021. * 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)
  121022. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121026. * @param name defines the name of the mesh
  121027. * @param options defines the options used to create the mesh
  121028. * @param scene defines the hosting scene
  121029. * @returns the box mesh
  121030. */
  121031. static CreateTiledBox(name: string, options: {
  121032. pattern?: number;
  121033. width?: number;
  121034. height?: number;
  121035. depth?: number;
  121036. tileSize?: number;
  121037. tileWidth?: number;
  121038. tileHeight?: number;
  121039. alignHorizontal?: number;
  121040. alignVertical?: number;
  121041. faceUV?: Vector4[];
  121042. faceColors?: Color4[];
  121043. sideOrientation?: number;
  121044. updatable?: boolean;
  121045. }, scene?: Nullable<Scene>): Mesh;
  121046. }
  121047. }
  121048. declare module BABYLON {
  121049. /**
  121050. * Class containing static functions to help procedurally build meshes
  121051. */
  121052. export class TorusKnotBuilder {
  121053. /**
  121054. * Creates a torus knot mesh
  121055. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121056. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121057. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121058. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121062. * @param name defines the name of the mesh
  121063. * @param options defines the options used to create the mesh
  121064. * @param scene defines the hosting scene
  121065. * @returns the torus knot mesh
  121066. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121067. */
  121068. static CreateTorusKnot(name: string, options: {
  121069. radius?: number;
  121070. tube?: number;
  121071. radialSegments?: number;
  121072. tubularSegments?: number;
  121073. p?: number;
  121074. q?: number;
  121075. updatable?: boolean;
  121076. sideOrientation?: number;
  121077. frontUVs?: Vector4;
  121078. backUVs?: Vector4;
  121079. }, scene: any): Mesh;
  121080. }
  121081. }
  121082. declare module BABYLON {
  121083. /**
  121084. * Polygon
  121085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  121086. */
  121087. export class Polygon {
  121088. /**
  121089. * Creates a rectangle
  121090. * @param xmin bottom X coord
  121091. * @param ymin bottom Y coord
  121092. * @param xmax top X coord
  121093. * @param ymax top Y coord
  121094. * @returns points that make the resulting rectation
  121095. */
  121096. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  121097. /**
  121098. * Creates a circle
  121099. * @param radius radius of circle
  121100. * @param cx scale in x
  121101. * @param cy scale in y
  121102. * @param numberOfSides number of sides that make up the circle
  121103. * @returns points that make the resulting circle
  121104. */
  121105. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  121106. /**
  121107. * Creates a polygon from input string
  121108. * @param input Input polygon data
  121109. * @returns the parsed points
  121110. */
  121111. static Parse(input: string): Vector2[];
  121112. /**
  121113. * Starts building a polygon from x and y coordinates
  121114. * @param x x coordinate
  121115. * @param y y coordinate
  121116. * @returns the started path2
  121117. */
  121118. static StartingAt(x: number, y: number): Path2;
  121119. }
  121120. /**
  121121. * Builds a polygon
  121122. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  121123. */
  121124. export class PolygonMeshBuilder {
  121125. private _points;
  121126. private _outlinepoints;
  121127. private _holes;
  121128. private _name;
  121129. private _scene;
  121130. private _epoints;
  121131. private _eholes;
  121132. private _addToepoint;
  121133. /**
  121134. * Babylon reference to the earcut plugin.
  121135. */
  121136. bjsEarcut: any;
  121137. /**
  121138. * Creates a PolygonMeshBuilder
  121139. * @param name name of the builder
  121140. * @param contours Path of the polygon
  121141. * @param scene scene to add to when creating the mesh
  121142. * @param earcutInjection can be used to inject your own earcut reference
  121143. */
  121144. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  121145. /**
  121146. * Adds a whole within the polygon
  121147. * @param hole Array of points defining the hole
  121148. * @returns this
  121149. */
  121150. addHole(hole: Vector2[]): PolygonMeshBuilder;
  121151. /**
  121152. * Creates the polygon
  121153. * @param updatable If the mesh should be updatable
  121154. * @param depth The depth of the mesh created
  121155. * @returns the created mesh
  121156. */
  121157. build(updatable?: boolean, depth?: number): Mesh;
  121158. /**
  121159. * Creates the polygon
  121160. * @param depth The depth of the mesh created
  121161. * @returns the created VertexData
  121162. */
  121163. buildVertexData(depth?: number): VertexData;
  121164. /**
  121165. * Adds a side to the polygon
  121166. * @param positions points that make the polygon
  121167. * @param normals normals of the polygon
  121168. * @param uvs uvs of the polygon
  121169. * @param indices indices of the polygon
  121170. * @param bounds bounds of the polygon
  121171. * @param points points of the polygon
  121172. * @param depth depth of the polygon
  121173. * @param flip flip of the polygon
  121174. */
  121175. private addSide;
  121176. }
  121177. }
  121178. declare module BABYLON {
  121179. /**
  121180. * Class containing static functions to help procedurally build meshes
  121181. */
  121182. export class PolygonBuilder {
  121183. /**
  121184. * Creates a polygon mesh
  121185. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121186. * * 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
  121187. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121190. * * Remember you can only change the shape positions, not their number when updating a polygon
  121191. * @param name defines the name of the mesh
  121192. * @param options defines the options used to create the mesh
  121193. * @param scene defines the hosting scene
  121194. * @param earcutInjection can be used to inject your own earcut reference
  121195. * @returns the polygon mesh
  121196. */
  121197. static CreatePolygon(name: string, options: {
  121198. shape: Vector3[];
  121199. holes?: Vector3[][];
  121200. depth?: number;
  121201. faceUV?: Vector4[];
  121202. faceColors?: Color4[];
  121203. updatable?: boolean;
  121204. sideOrientation?: number;
  121205. frontUVs?: Vector4;
  121206. backUVs?: Vector4;
  121207. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121208. /**
  121209. * Creates an extruded polygon mesh, with depth in the Y direction.
  121210. * * 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)
  121211. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121212. * @param name defines the name of the mesh
  121213. * @param options defines the options used to create the mesh
  121214. * @param scene defines the hosting scene
  121215. * @param earcutInjection can be used to inject your own earcut reference
  121216. * @returns the polygon mesh
  121217. */
  121218. static ExtrudePolygon(name: string, options: {
  121219. shape: Vector3[];
  121220. holes?: Vector3[][];
  121221. depth?: number;
  121222. faceUV?: Vector4[];
  121223. faceColors?: Color4[];
  121224. updatable?: boolean;
  121225. sideOrientation?: number;
  121226. frontUVs?: Vector4;
  121227. backUVs?: Vector4;
  121228. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121229. }
  121230. }
  121231. declare module BABYLON {
  121232. /**
  121233. * Class containing static functions to help procedurally build meshes
  121234. */
  121235. export class LatheBuilder {
  121236. /**
  121237. * Creates lathe mesh.
  121238. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121239. * * 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
  121240. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121241. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121242. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121243. * * 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
  121244. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121245. * * 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
  121246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121248. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121250. * @param name defines the name of the mesh
  121251. * @param options defines the options used to create the mesh
  121252. * @param scene defines the hosting scene
  121253. * @returns the lathe mesh
  121254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121255. */
  121256. static CreateLathe(name: string, options: {
  121257. shape: Vector3[];
  121258. radius?: number;
  121259. tessellation?: number;
  121260. clip?: number;
  121261. arc?: number;
  121262. closed?: boolean;
  121263. updatable?: boolean;
  121264. sideOrientation?: number;
  121265. frontUVs?: Vector4;
  121266. backUVs?: Vector4;
  121267. cap?: number;
  121268. invertUV?: boolean;
  121269. }, scene?: Nullable<Scene>): Mesh;
  121270. }
  121271. }
  121272. declare module BABYLON {
  121273. /**
  121274. * Class containing static functions to help procedurally build meshes
  121275. */
  121276. export class TiledPlaneBuilder {
  121277. /**
  121278. * Creates a tiled plane mesh
  121279. * * The parameter `pattern` will, depending on value, do nothing or
  121280. * * * flip (reflect about central vertical) alternate tiles across and up
  121281. * * * flip every tile on alternate rows
  121282. * * * rotate (180 degs) alternate tiles across and up
  121283. * * * rotate every tile on alternate rows
  121284. * * * flip and rotate alternate tiles across and up
  121285. * * * flip and rotate every tile on alternate rows
  121286. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121287. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121290. * * 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)
  121291. * * 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)
  121292. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121293. * @param name defines the name of the mesh
  121294. * @param options defines the options used to create the mesh
  121295. * @param scene defines the hosting scene
  121296. * @returns the box mesh
  121297. */
  121298. static CreateTiledPlane(name: string, options: {
  121299. pattern?: number;
  121300. tileSize?: number;
  121301. tileWidth?: number;
  121302. tileHeight?: number;
  121303. size?: number;
  121304. width?: number;
  121305. height?: number;
  121306. alignHorizontal?: number;
  121307. alignVertical?: number;
  121308. sideOrientation?: number;
  121309. frontUVs?: Vector4;
  121310. backUVs?: Vector4;
  121311. updatable?: boolean;
  121312. }, scene?: Nullable<Scene>): Mesh;
  121313. }
  121314. }
  121315. declare module BABYLON {
  121316. /**
  121317. * Class containing static functions to help procedurally build meshes
  121318. */
  121319. export class TubeBuilder {
  121320. /**
  121321. * Creates a tube mesh.
  121322. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121323. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121324. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121325. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121326. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121327. * * 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)
  121328. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121329. * * 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
  121330. * * 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
  121331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121335. * @param name defines the name of the mesh
  121336. * @param options defines the options used to create the mesh
  121337. * @param scene defines the hosting scene
  121338. * @returns the tube mesh
  121339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121340. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121341. */
  121342. static CreateTube(name: string, options: {
  121343. path: Vector3[];
  121344. radius?: number;
  121345. tessellation?: number;
  121346. radiusFunction?: {
  121347. (i: number, distance: number): number;
  121348. };
  121349. cap?: number;
  121350. arc?: number;
  121351. updatable?: boolean;
  121352. sideOrientation?: number;
  121353. frontUVs?: Vector4;
  121354. backUVs?: Vector4;
  121355. instance?: Mesh;
  121356. invertUV?: boolean;
  121357. }, scene?: Nullable<Scene>): Mesh;
  121358. }
  121359. }
  121360. declare module BABYLON {
  121361. /**
  121362. * Class containing static functions to help procedurally build meshes
  121363. */
  121364. export class IcoSphereBuilder {
  121365. /**
  121366. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121367. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121368. * * 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`)
  121369. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121370. * * 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
  121371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121374. * @param name defines the name of the mesh
  121375. * @param options defines the options used to create the mesh
  121376. * @param scene defines the hosting scene
  121377. * @returns the icosahedron mesh
  121378. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121379. */
  121380. static CreateIcoSphere(name: string, options: {
  121381. radius?: number;
  121382. radiusX?: number;
  121383. radiusY?: number;
  121384. radiusZ?: number;
  121385. flat?: boolean;
  121386. subdivisions?: number;
  121387. sideOrientation?: number;
  121388. frontUVs?: Vector4;
  121389. backUVs?: Vector4;
  121390. updatable?: boolean;
  121391. }, scene?: Nullable<Scene>): Mesh;
  121392. }
  121393. }
  121394. declare module BABYLON {
  121395. /**
  121396. * Class containing static functions to help procedurally build meshes
  121397. */
  121398. export class DecalBuilder {
  121399. /**
  121400. * Creates a decal mesh.
  121401. * 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
  121402. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121403. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121404. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121405. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121406. * @param name defines the name of the mesh
  121407. * @param sourceMesh defines the mesh where the decal must be applied
  121408. * @param options defines the options used to create the mesh
  121409. * @param scene defines the hosting scene
  121410. * @returns the decal mesh
  121411. * @see https://doc.babylonjs.com/how_to/decals
  121412. */
  121413. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121414. position?: Vector3;
  121415. normal?: Vector3;
  121416. size?: Vector3;
  121417. angle?: number;
  121418. }): Mesh;
  121419. }
  121420. }
  121421. declare module BABYLON {
  121422. /**
  121423. * Class containing static functions to help procedurally build meshes
  121424. */
  121425. export class MeshBuilder {
  121426. /**
  121427. * Creates a box mesh
  121428. * * The parameter `size` sets the size (float) of each box side (default 1)
  121429. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121430. * * 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)
  121431. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121435. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121436. * @param name defines the name of the mesh
  121437. * @param options defines the options used to create the mesh
  121438. * @param scene defines the hosting scene
  121439. * @returns the box mesh
  121440. */
  121441. static CreateBox(name: string, options: {
  121442. size?: number;
  121443. width?: number;
  121444. height?: number;
  121445. depth?: number;
  121446. faceUV?: Vector4[];
  121447. faceColors?: Color4[];
  121448. sideOrientation?: number;
  121449. frontUVs?: Vector4;
  121450. backUVs?: Vector4;
  121451. updatable?: boolean;
  121452. }, scene?: Nullable<Scene>): Mesh;
  121453. /**
  121454. * Creates a tiled box mesh
  121455. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121457. * @param name defines the name of the mesh
  121458. * @param options defines the options used to create the mesh
  121459. * @param scene defines the hosting scene
  121460. * @returns the tiled box mesh
  121461. */
  121462. static CreateTiledBox(name: string, options: {
  121463. pattern?: number;
  121464. size?: number;
  121465. width?: number;
  121466. height?: number;
  121467. depth: number;
  121468. tileSize?: number;
  121469. tileWidth?: number;
  121470. tileHeight?: number;
  121471. faceUV?: Vector4[];
  121472. faceColors?: Color4[];
  121473. alignHorizontal?: number;
  121474. alignVertical?: number;
  121475. sideOrientation?: number;
  121476. updatable?: boolean;
  121477. }, scene?: Nullable<Scene>): Mesh;
  121478. /**
  121479. * Creates a sphere mesh
  121480. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121481. * * 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`)
  121482. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121483. * * 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
  121484. * * 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)
  121485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121488. * @param name defines the name of the mesh
  121489. * @param options defines the options used to create the mesh
  121490. * @param scene defines the hosting scene
  121491. * @returns the sphere mesh
  121492. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121493. */
  121494. static CreateSphere(name: string, options: {
  121495. segments?: number;
  121496. diameter?: number;
  121497. diameterX?: number;
  121498. diameterY?: number;
  121499. diameterZ?: number;
  121500. arc?: number;
  121501. slice?: number;
  121502. sideOrientation?: number;
  121503. frontUVs?: Vector4;
  121504. backUVs?: Vector4;
  121505. updatable?: boolean;
  121506. }, scene?: Nullable<Scene>): Mesh;
  121507. /**
  121508. * Creates a plane polygonal mesh. By default, this is a disc
  121509. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121510. * * 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
  121511. * * 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
  121512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121515. * @param name defines the name of the mesh
  121516. * @param options defines the options used to create the mesh
  121517. * @param scene defines the hosting scene
  121518. * @returns the plane polygonal mesh
  121519. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121520. */
  121521. static CreateDisc(name: string, options: {
  121522. radius?: number;
  121523. tessellation?: number;
  121524. arc?: number;
  121525. updatable?: boolean;
  121526. sideOrientation?: number;
  121527. frontUVs?: Vector4;
  121528. backUVs?: Vector4;
  121529. }, scene?: Nullable<Scene>): Mesh;
  121530. /**
  121531. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121532. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121533. * * 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`)
  121534. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121535. * * 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
  121536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121539. * @param name defines the name of the mesh
  121540. * @param options defines the options used to create the mesh
  121541. * @param scene defines the hosting scene
  121542. * @returns the icosahedron mesh
  121543. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121544. */
  121545. static CreateIcoSphere(name: string, options: {
  121546. radius?: number;
  121547. radiusX?: number;
  121548. radiusY?: number;
  121549. radiusZ?: number;
  121550. flat?: boolean;
  121551. subdivisions?: number;
  121552. sideOrientation?: number;
  121553. frontUVs?: Vector4;
  121554. backUVs?: Vector4;
  121555. updatable?: boolean;
  121556. }, scene?: Nullable<Scene>): Mesh;
  121557. /**
  121558. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121559. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121560. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121561. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121562. * * 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
  121563. * * 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
  121564. * * 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
  121565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121567. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121568. * * 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
  121569. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121570. * * 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
  121571. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121573. * @param name defines the name of the mesh
  121574. * @param options defines the options used to create the mesh
  121575. * @param scene defines the hosting scene
  121576. * @returns the ribbon mesh
  121577. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121578. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121579. */
  121580. static CreateRibbon(name: string, options: {
  121581. pathArray: Vector3[][];
  121582. closeArray?: boolean;
  121583. closePath?: boolean;
  121584. offset?: number;
  121585. updatable?: boolean;
  121586. sideOrientation?: number;
  121587. frontUVs?: Vector4;
  121588. backUVs?: Vector4;
  121589. instance?: Mesh;
  121590. invertUV?: boolean;
  121591. uvs?: Vector2[];
  121592. colors?: Color4[];
  121593. }, scene?: Nullable<Scene>): Mesh;
  121594. /**
  121595. * Creates a cylinder or a cone mesh
  121596. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121597. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121598. * * 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.
  121599. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121600. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121601. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121602. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121603. * * 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).
  121604. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121605. * * 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).
  121606. * * 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
  121607. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121608. * * 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
  121609. * * 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.
  121610. * * If `enclose` is false, a ring surface is one element.
  121611. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121612. * * 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
  121613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121616. * @param name defines the name of the mesh
  121617. * @param options defines the options used to create the mesh
  121618. * @param scene defines the hosting scene
  121619. * @returns the cylinder mesh
  121620. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121621. */
  121622. static CreateCylinder(name: string, options: {
  121623. height?: number;
  121624. diameterTop?: number;
  121625. diameterBottom?: number;
  121626. diameter?: number;
  121627. tessellation?: number;
  121628. subdivisions?: number;
  121629. arc?: number;
  121630. faceColors?: Color4[];
  121631. faceUV?: Vector4[];
  121632. updatable?: boolean;
  121633. hasRings?: boolean;
  121634. enclose?: boolean;
  121635. cap?: number;
  121636. sideOrientation?: number;
  121637. frontUVs?: Vector4;
  121638. backUVs?: Vector4;
  121639. }, scene?: Nullable<Scene>): Mesh;
  121640. /**
  121641. * Creates a torus mesh
  121642. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121643. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121644. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121648. * @param name defines the name of the mesh
  121649. * @param options defines the options used to create the mesh
  121650. * @param scene defines the hosting scene
  121651. * @returns the torus mesh
  121652. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121653. */
  121654. static CreateTorus(name: string, options: {
  121655. diameter?: number;
  121656. thickness?: number;
  121657. tessellation?: number;
  121658. updatable?: boolean;
  121659. sideOrientation?: number;
  121660. frontUVs?: Vector4;
  121661. backUVs?: Vector4;
  121662. }, scene?: Nullable<Scene>): Mesh;
  121663. /**
  121664. * Creates a torus knot mesh
  121665. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121666. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121667. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121668. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121672. * @param name defines the name of the mesh
  121673. * @param options defines the options used to create the mesh
  121674. * @param scene defines the hosting scene
  121675. * @returns the torus knot mesh
  121676. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121677. */
  121678. static CreateTorusKnot(name: string, options: {
  121679. radius?: number;
  121680. tube?: number;
  121681. radialSegments?: number;
  121682. tubularSegments?: number;
  121683. p?: number;
  121684. q?: number;
  121685. updatable?: boolean;
  121686. sideOrientation?: number;
  121687. frontUVs?: Vector4;
  121688. backUVs?: Vector4;
  121689. }, scene?: Nullable<Scene>): Mesh;
  121690. /**
  121691. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121692. * * 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
  121693. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121694. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121695. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121696. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121697. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121698. * * 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
  121699. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121702. * @param name defines the name of the new line system
  121703. * @param options defines the options used to create the line system
  121704. * @param scene defines the hosting scene
  121705. * @returns a new line system mesh
  121706. */
  121707. static CreateLineSystem(name: string, options: {
  121708. lines: Vector3[][];
  121709. updatable?: boolean;
  121710. instance?: Nullable<LinesMesh>;
  121711. colors?: Nullable<Color4[][]>;
  121712. useVertexAlpha?: boolean;
  121713. }, scene: Nullable<Scene>): LinesMesh;
  121714. /**
  121715. * Creates a line mesh
  121716. * 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
  121717. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121718. * * The parameter `points` is an array successive Vector3
  121719. * * 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
  121720. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121721. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121722. * * When updating an instance, remember that only point positions can change, not the number of points
  121723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121725. * @param name defines the name of the new line system
  121726. * @param options defines the options used to create the line system
  121727. * @param scene defines the hosting scene
  121728. * @returns a new line mesh
  121729. */
  121730. static CreateLines(name: string, options: {
  121731. points: Vector3[];
  121732. updatable?: boolean;
  121733. instance?: Nullable<LinesMesh>;
  121734. colors?: Color4[];
  121735. useVertexAlpha?: boolean;
  121736. }, scene?: Nullable<Scene>): LinesMesh;
  121737. /**
  121738. * Creates a dashed line mesh
  121739. * * 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
  121740. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121741. * * The parameter `points` is an array successive Vector3
  121742. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121743. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121744. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121745. * * 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
  121746. * * When updating an instance, remember that only point positions can change, not the number of points
  121747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121748. * @param name defines the name of the mesh
  121749. * @param options defines the options used to create the mesh
  121750. * @param scene defines the hosting scene
  121751. * @returns the dashed line mesh
  121752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121753. */
  121754. static CreateDashedLines(name: string, options: {
  121755. points: Vector3[];
  121756. dashSize?: number;
  121757. gapSize?: number;
  121758. dashNb?: number;
  121759. updatable?: boolean;
  121760. instance?: LinesMesh;
  121761. }, scene?: Nullable<Scene>): LinesMesh;
  121762. /**
  121763. * 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.
  121764. * * 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.
  121765. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121766. * * 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.
  121767. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121768. * * 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
  121769. * * 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
  121770. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121775. * @param name defines the name of the mesh
  121776. * @param options defines the options used to create the mesh
  121777. * @param scene defines the hosting scene
  121778. * @returns the extruded shape mesh
  121779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121781. */
  121782. static ExtrudeShape(name: string, options: {
  121783. shape: Vector3[];
  121784. path: Vector3[];
  121785. scale?: number;
  121786. rotation?: number;
  121787. cap?: number;
  121788. updatable?: boolean;
  121789. sideOrientation?: number;
  121790. frontUVs?: Vector4;
  121791. backUVs?: Vector4;
  121792. instance?: Mesh;
  121793. invertUV?: boolean;
  121794. }, scene?: Nullable<Scene>): Mesh;
  121795. /**
  121796. * Creates an custom extruded shape mesh.
  121797. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121798. * * 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.
  121799. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121800. * * 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
  121801. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121802. * * 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
  121803. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121804. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121805. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121806. * * 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
  121807. * * 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
  121808. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121813. * @param name defines the name of the mesh
  121814. * @param options defines the options used to create the mesh
  121815. * @param scene defines the hosting scene
  121816. * @returns the custom extruded shape mesh
  121817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121820. */
  121821. static ExtrudeShapeCustom(name: string, options: {
  121822. shape: Vector3[];
  121823. path: Vector3[];
  121824. scaleFunction?: any;
  121825. rotationFunction?: any;
  121826. ribbonCloseArray?: boolean;
  121827. ribbonClosePath?: boolean;
  121828. cap?: number;
  121829. updatable?: boolean;
  121830. sideOrientation?: number;
  121831. frontUVs?: Vector4;
  121832. backUVs?: Vector4;
  121833. instance?: Mesh;
  121834. invertUV?: boolean;
  121835. }, scene?: Nullable<Scene>): Mesh;
  121836. /**
  121837. * Creates lathe mesh.
  121838. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121839. * * 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
  121840. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121841. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121842. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121843. * * 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
  121844. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121845. * * 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
  121846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121850. * @param name defines the name of the mesh
  121851. * @param options defines the options used to create the mesh
  121852. * @param scene defines the hosting scene
  121853. * @returns the lathe mesh
  121854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121855. */
  121856. static CreateLathe(name: string, options: {
  121857. shape: Vector3[];
  121858. radius?: number;
  121859. tessellation?: number;
  121860. clip?: number;
  121861. arc?: number;
  121862. closed?: boolean;
  121863. updatable?: boolean;
  121864. sideOrientation?: number;
  121865. frontUVs?: Vector4;
  121866. backUVs?: Vector4;
  121867. cap?: number;
  121868. invertUV?: boolean;
  121869. }, scene?: Nullable<Scene>): Mesh;
  121870. /**
  121871. * Creates a tiled plane mesh
  121872. * * You can set a limited pattern arrangement with the tiles
  121873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121876. * @param name defines the name of the mesh
  121877. * @param options defines the options used to create the mesh
  121878. * @param scene defines the hosting scene
  121879. * @returns the plane mesh
  121880. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121881. */
  121882. static CreateTiledPlane(name: string, options: {
  121883. pattern?: number;
  121884. tileSize?: number;
  121885. tileWidth?: number;
  121886. tileHeight?: number;
  121887. size?: number;
  121888. width?: number;
  121889. height?: number;
  121890. alignHorizontal?: number;
  121891. alignVertical?: number;
  121892. sideOrientation?: number;
  121893. frontUVs?: Vector4;
  121894. backUVs?: Vector4;
  121895. updatable?: boolean;
  121896. }, scene?: Nullable<Scene>): Mesh;
  121897. /**
  121898. * Creates a plane mesh
  121899. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121900. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121901. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121905. * @param name defines the name of the mesh
  121906. * @param options defines the options used to create the mesh
  121907. * @param scene defines the hosting scene
  121908. * @returns the plane mesh
  121909. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121910. */
  121911. static CreatePlane(name: string, options: {
  121912. size?: number;
  121913. width?: number;
  121914. height?: number;
  121915. sideOrientation?: number;
  121916. frontUVs?: Vector4;
  121917. backUVs?: Vector4;
  121918. updatable?: boolean;
  121919. sourcePlane?: Plane;
  121920. }, scene?: Nullable<Scene>): Mesh;
  121921. /**
  121922. * Creates a ground mesh
  121923. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121924. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121926. * @param name defines the name of the mesh
  121927. * @param options defines the options used to create the mesh
  121928. * @param scene defines the hosting scene
  121929. * @returns the ground mesh
  121930. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121931. */
  121932. static CreateGround(name: string, options: {
  121933. width?: number;
  121934. height?: number;
  121935. subdivisions?: number;
  121936. subdivisionsX?: number;
  121937. subdivisionsY?: number;
  121938. updatable?: boolean;
  121939. }, scene?: Nullable<Scene>): Mesh;
  121940. /**
  121941. * Creates a tiled ground mesh
  121942. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121943. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121944. * * 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
  121945. * * 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
  121946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121947. * @param name defines the name of the mesh
  121948. * @param options defines the options used to create the mesh
  121949. * @param scene defines the hosting scene
  121950. * @returns the tiled ground mesh
  121951. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121952. */
  121953. static CreateTiledGround(name: string, options: {
  121954. xmin: number;
  121955. zmin: number;
  121956. xmax: number;
  121957. zmax: number;
  121958. subdivisions?: {
  121959. w: number;
  121960. h: number;
  121961. };
  121962. precision?: {
  121963. w: number;
  121964. h: number;
  121965. };
  121966. updatable?: boolean;
  121967. }, scene?: Nullable<Scene>): Mesh;
  121968. /**
  121969. * Creates a ground mesh from a height map
  121970. * * The parameter `url` sets the URL of the height map image resource.
  121971. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121972. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121973. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121974. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121975. * * 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.
  121976. * * 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).
  121977. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121979. * @param name defines the name of the mesh
  121980. * @param url defines the url to the height map
  121981. * @param options defines the options used to create the mesh
  121982. * @param scene defines the hosting scene
  121983. * @returns the ground mesh
  121984. * @see https://doc.babylonjs.com/babylon101/height_map
  121985. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121986. */
  121987. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121988. width?: number;
  121989. height?: number;
  121990. subdivisions?: number;
  121991. minHeight?: number;
  121992. maxHeight?: number;
  121993. colorFilter?: Color3;
  121994. alphaFilter?: number;
  121995. updatable?: boolean;
  121996. onReady?: (mesh: GroundMesh) => void;
  121997. }, scene?: Nullable<Scene>): GroundMesh;
  121998. /**
  121999. * Creates a polygon mesh
  122000. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122001. * * 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
  122002. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122005. * * Remember you can only change the shape positions, not their number when updating a polygon
  122006. * @param name defines the name of the mesh
  122007. * @param options defines the options used to create the mesh
  122008. * @param scene defines the hosting scene
  122009. * @param earcutInjection can be used to inject your own earcut reference
  122010. * @returns the polygon mesh
  122011. */
  122012. static CreatePolygon(name: string, options: {
  122013. shape: Vector3[];
  122014. holes?: Vector3[][];
  122015. depth?: number;
  122016. faceUV?: Vector4[];
  122017. faceColors?: Color4[];
  122018. updatable?: boolean;
  122019. sideOrientation?: number;
  122020. frontUVs?: Vector4;
  122021. backUVs?: Vector4;
  122022. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122023. /**
  122024. * Creates an extruded polygon mesh, with depth in the Y direction.
  122025. * * 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)
  122026. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122027. * @param name defines the name of the mesh
  122028. * @param options defines the options used to create the mesh
  122029. * @param scene defines the hosting scene
  122030. * @param earcutInjection can be used to inject your own earcut reference
  122031. * @returns the polygon mesh
  122032. */
  122033. static ExtrudePolygon(name: string, options: {
  122034. shape: Vector3[];
  122035. holes?: Vector3[][];
  122036. depth?: number;
  122037. faceUV?: Vector4[];
  122038. faceColors?: Color4[];
  122039. updatable?: boolean;
  122040. sideOrientation?: number;
  122041. frontUVs?: Vector4;
  122042. backUVs?: Vector4;
  122043. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122044. /**
  122045. * Creates a tube mesh.
  122046. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122047. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122048. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122049. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122050. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122051. * * 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)
  122052. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122053. * * 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
  122054. * * 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
  122055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122057. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122059. * @param name defines the name of the mesh
  122060. * @param options defines the options used to create the mesh
  122061. * @param scene defines the hosting scene
  122062. * @returns the tube mesh
  122063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122064. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122065. */
  122066. static CreateTube(name: string, options: {
  122067. path: Vector3[];
  122068. radius?: number;
  122069. tessellation?: number;
  122070. radiusFunction?: {
  122071. (i: number, distance: number): number;
  122072. };
  122073. cap?: number;
  122074. arc?: number;
  122075. updatable?: boolean;
  122076. sideOrientation?: number;
  122077. frontUVs?: Vector4;
  122078. backUVs?: Vector4;
  122079. instance?: Mesh;
  122080. invertUV?: boolean;
  122081. }, scene?: Nullable<Scene>): Mesh;
  122082. /**
  122083. * Creates a polyhedron mesh
  122084. * * 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
  122085. * * The parameter `size` (positive float, default 1) sets the polygon size
  122086. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122087. * * 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`
  122088. * * 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
  122089. * * 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)`)
  122090. * * 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
  122091. * * 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
  122092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122093. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122095. * @param name defines the name of the mesh
  122096. * @param options defines the options used to create the mesh
  122097. * @param scene defines the hosting scene
  122098. * @returns the polyhedron mesh
  122099. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122100. */
  122101. static CreatePolyhedron(name: string, options: {
  122102. type?: number;
  122103. size?: number;
  122104. sizeX?: number;
  122105. sizeY?: number;
  122106. sizeZ?: number;
  122107. custom?: any;
  122108. faceUV?: Vector4[];
  122109. faceColors?: Color4[];
  122110. flat?: boolean;
  122111. updatable?: boolean;
  122112. sideOrientation?: number;
  122113. frontUVs?: Vector4;
  122114. backUVs?: Vector4;
  122115. }, scene?: Nullable<Scene>): Mesh;
  122116. /**
  122117. * Creates a decal mesh.
  122118. * 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
  122119. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122120. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122121. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122122. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122123. * @param name defines the name of the mesh
  122124. * @param sourceMesh defines the mesh where the decal must be applied
  122125. * @param options defines the options used to create the mesh
  122126. * @param scene defines the hosting scene
  122127. * @returns the decal mesh
  122128. * @see https://doc.babylonjs.com/how_to/decals
  122129. */
  122130. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122131. position?: Vector3;
  122132. normal?: Vector3;
  122133. size?: Vector3;
  122134. angle?: number;
  122135. }): Mesh;
  122136. }
  122137. }
  122138. declare module BABYLON {
  122139. /**
  122140. * A simplifier interface for future simplification implementations
  122141. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122142. */
  122143. export interface ISimplifier {
  122144. /**
  122145. * Simplification of a given mesh according to the given settings.
  122146. * Since this requires computation, it is assumed that the function runs async.
  122147. * @param settings The settings of the simplification, including quality and distance
  122148. * @param successCallback A callback that will be called after the mesh was simplified.
  122149. * @param errorCallback in case of an error, this callback will be called. optional.
  122150. */
  122151. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  122152. }
  122153. /**
  122154. * Expected simplification settings.
  122155. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  122156. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122157. */
  122158. export interface ISimplificationSettings {
  122159. /**
  122160. * Gets or sets the expected quality
  122161. */
  122162. quality: number;
  122163. /**
  122164. * Gets or sets the distance when this optimized version should be used
  122165. */
  122166. distance: number;
  122167. /**
  122168. * Gets an already optimized mesh
  122169. */
  122170. optimizeMesh?: boolean;
  122171. }
  122172. /**
  122173. * Class used to specify simplification options
  122174. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122175. */
  122176. export class SimplificationSettings implements ISimplificationSettings {
  122177. /** expected quality */
  122178. quality: number;
  122179. /** distance when this optimized version should be used */
  122180. distance: number;
  122181. /** already optimized mesh */
  122182. optimizeMesh?: boolean | undefined;
  122183. /**
  122184. * Creates a SimplificationSettings
  122185. * @param quality expected quality
  122186. * @param distance distance when this optimized version should be used
  122187. * @param optimizeMesh already optimized mesh
  122188. */
  122189. constructor(
  122190. /** expected quality */
  122191. quality: number,
  122192. /** distance when this optimized version should be used */
  122193. distance: number,
  122194. /** already optimized mesh */
  122195. optimizeMesh?: boolean | undefined);
  122196. }
  122197. /**
  122198. * Interface used to define a simplification task
  122199. */
  122200. export interface ISimplificationTask {
  122201. /**
  122202. * Array of settings
  122203. */
  122204. settings: Array<ISimplificationSettings>;
  122205. /**
  122206. * Simplification type
  122207. */
  122208. simplificationType: SimplificationType;
  122209. /**
  122210. * Mesh to simplify
  122211. */
  122212. mesh: Mesh;
  122213. /**
  122214. * Callback called on success
  122215. */
  122216. successCallback?: () => void;
  122217. /**
  122218. * Defines if parallel processing can be used
  122219. */
  122220. parallelProcessing: boolean;
  122221. }
  122222. /**
  122223. * Queue used to order the simplification tasks
  122224. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122225. */
  122226. export class SimplificationQueue {
  122227. private _simplificationArray;
  122228. /**
  122229. * Gets a boolean indicating that the process is still running
  122230. */
  122231. running: boolean;
  122232. /**
  122233. * Creates a new queue
  122234. */
  122235. constructor();
  122236. /**
  122237. * Adds a new simplification task
  122238. * @param task defines a task to add
  122239. */
  122240. addTask(task: ISimplificationTask): void;
  122241. /**
  122242. * Execute next task
  122243. */
  122244. executeNext(): void;
  122245. /**
  122246. * Execute a simplification task
  122247. * @param task defines the task to run
  122248. */
  122249. runSimplification(task: ISimplificationTask): void;
  122250. private getSimplifier;
  122251. }
  122252. /**
  122253. * The implemented types of simplification
  122254. * At the moment only Quadratic Error Decimation is implemented
  122255. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122256. */
  122257. export enum SimplificationType {
  122258. /** Quadratic error decimation */
  122259. QUADRATIC = 0
  122260. }
  122261. }
  122262. declare module BABYLON {
  122263. interface Scene {
  122264. /** @hidden (Backing field) */
  122265. _simplificationQueue: SimplificationQueue;
  122266. /**
  122267. * Gets or sets the simplification queue attached to the scene
  122268. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122269. */
  122270. simplificationQueue: SimplificationQueue;
  122271. }
  122272. interface Mesh {
  122273. /**
  122274. * Simplify the mesh according to the given array of settings.
  122275. * Function will return immediately and will simplify async
  122276. * @param settings a collection of simplification settings
  122277. * @param parallelProcessing should all levels calculate parallel or one after the other
  122278. * @param simplificationType the type of simplification to run
  122279. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122280. * @returns the current mesh
  122281. */
  122282. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122283. }
  122284. /**
  122285. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122286. * created in a scene
  122287. */
  122288. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122289. /**
  122290. * The component name helpfull to identify the component in the list of scene components.
  122291. */
  122292. readonly name: string;
  122293. /**
  122294. * The scene the component belongs to.
  122295. */
  122296. scene: Scene;
  122297. /**
  122298. * Creates a new instance of the component for the given scene
  122299. * @param scene Defines the scene to register the component in
  122300. */
  122301. constructor(scene: Scene);
  122302. /**
  122303. * Registers the component in a given scene
  122304. */
  122305. register(): void;
  122306. /**
  122307. * Rebuilds the elements related to this component in case of
  122308. * context lost for instance.
  122309. */
  122310. rebuild(): void;
  122311. /**
  122312. * Disposes the component and the associated ressources
  122313. */
  122314. dispose(): void;
  122315. private _beforeCameraUpdate;
  122316. }
  122317. }
  122318. declare module BABYLON {
  122319. /**
  122320. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122321. */
  122322. export interface INavigationEnginePlugin {
  122323. /**
  122324. * plugin name
  122325. */
  122326. name: string;
  122327. /**
  122328. * Creates a navigation mesh
  122329. * @param meshes array of all the geometry used to compute the navigatio mesh
  122330. * @param parameters bunch of parameters used to filter geometry
  122331. */
  122332. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122333. /**
  122334. * Create a navigation mesh debug mesh
  122335. * @param scene is where the mesh will be added
  122336. * @returns debug display mesh
  122337. */
  122338. createDebugNavMesh(scene: Scene): Mesh;
  122339. /**
  122340. * Get a navigation mesh constrained position, closest to the parameter position
  122341. * @param position world position
  122342. * @returns the closest point to position constrained by the navigation mesh
  122343. */
  122344. getClosestPoint(position: Vector3): Vector3;
  122345. /**
  122346. * Get a navigation mesh constrained position, within a particular radius
  122347. * @param position world position
  122348. * @param maxRadius the maximum distance to the constrained world position
  122349. * @returns the closest point to position constrained by the navigation mesh
  122350. */
  122351. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122352. /**
  122353. * Compute the final position from a segment made of destination-position
  122354. * @param position world position
  122355. * @param destination world position
  122356. * @returns the resulting point along the navmesh
  122357. */
  122358. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122359. /**
  122360. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122361. * @param start world position
  122362. * @param end world position
  122363. * @returns array containing world position composing the path
  122364. */
  122365. computePath(start: Vector3, end: Vector3): Vector3[];
  122366. /**
  122367. * If this plugin is supported
  122368. * @returns true if plugin is supported
  122369. */
  122370. isSupported(): boolean;
  122371. /**
  122372. * Create a new Crowd so you can add agents
  122373. * @param maxAgents the maximum agent count in the crowd
  122374. * @param maxAgentRadius the maximum radius an agent can have
  122375. * @param scene to attach the crowd to
  122376. * @returns the crowd you can add agents to
  122377. */
  122378. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122379. /**
  122380. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122381. * The queries will try to find a solution within those bounds
  122382. * default is (1,1,1)
  122383. * @param extent x,y,z value that define the extent around the queries point of reference
  122384. */
  122385. setDefaultQueryExtent(extent: Vector3): void;
  122386. /**
  122387. * Get the Bounding box extent specified by setDefaultQueryExtent
  122388. * @returns the box extent values
  122389. */
  122390. getDefaultQueryExtent(): Vector3;
  122391. /**
  122392. * Release all resources
  122393. */
  122394. dispose(): void;
  122395. }
  122396. /**
  122397. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122398. */
  122399. export interface ICrowd {
  122400. /**
  122401. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122402. * You can attach anything to that node. The node position is updated in the scene update tick.
  122403. * @param pos world position that will be constrained by the navigation mesh
  122404. * @param parameters agent parameters
  122405. * @param transform hooked to the agent that will be update by the scene
  122406. * @returns agent index
  122407. */
  122408. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122409. /**
  122410. * Returns the agent position in world space
  122411. * @param index agent index returned by addAgent
  122412. * @returns world space position
  122413. */
  122414. getAgentPosition(index: number): Vector3;
  122415. /**
  122416. * Gets the agent velocity in world space
  122417. * @param index agent index returned by addAgent
  122418. * @returns world space velocity
  122419. */
  122420. getAgentVelocity(index: number): Vector3;
  122421. /**
  122422. * remove a particular agent previously created
  122423. * @param index agent index returned by addAgent
  122424. */
  122425. removeAgent(index: number): void;
  122426. /**
  122427. * get the list of all agents attached to this crowd
  122428. * @returns list of agent indices
  122429. */
  122430. getAgents(): number[];
  122431. /**
  122432. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122433. * @param deltaTime in seconds
  122434. */
  122435. update(deltaTime: number): void;
  122436. /**
  122437. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122438. * @param index agent index returned by addAgent
  122439. * @param destination targeted world position
  122440. */
  122441. agentGoto(index: number, destination: Vector3): void;
  122442. /**
  122443. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122444. * The queries will try to find a solution within those bounds
  122445. * default is (1,1,1)
  122446. * @param extent x,y,z value that define the extent around the queries point of reference
  122447. */
  122448. setDefaultQueryExtent(extent: Vector3): void;
  122449. /**
  122450. * Get the Bounding box extent specified by setDefaultQueryExtent
  122451. * @returns the box extent values
  122452. */
  122453. getDefaultQueryExtent(): Vector3;
  122454. /**
  122455. * Release all resources
  122456. */
  122457. dispose(): void;
  122458. }
  122459. /**
  122460. * Configures an agent
  122461. */
  122462. export interface IAgentParameters {
  122463. /**
  122464. * Agent radius. [Limit: >= 0]
  122465. */
  122466. radius: number;
  122467. /**
  122468. * Agent height. [Limit: > 0]
  122469. */
  122470. height: number;
  122471. /**
  122472. * Maximum allowed acceleration. [Limit: >= 0]
  122473. */
  122474. maxAcceleration: number;
  122475. /**
  122476. * Maximum allowed speed. [Limit: >= 0]
  122477. */
  122478. maxSpeed: number;
  122479. /**
  122480. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122481. */
  122482. collisionQueryRange: number;
  122483. /**
  122484. * The path visibility optimization range. [Limit: > 0]
  122485. */
  122486. pathOptimizationRange: number;
  122487. /**
  122488. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122489. */
  122490. separationWeight: number;
  122491. }
  122492. /**
  122493. * Configures the navigation mesh creation
  122494. */
  122495. export interface INavMeshParameters {
  122496. /**
  122497. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122498. */
  122499. cs: number;
  122500. /**
  122501. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122502. */
  122503. ch: number;
  122504. /**
  122505. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122506. */
  122507. walkableSlopeAngle: number;
  122508. /**
  122509. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122510. * be considered walkable. [Limit: >= 3] [Units: vx]
  122511. */
  122512. walkableHeight: number;
  122513. /**
  122514. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122515. */
  122516. walkableClimb: number;
  122517. /**
  122518. * The distance to erode/shrink the walkable area of the heightfield away from
  122519. * obstructions. [Limit: >=0] [Units: vx]
  122520. */
  122521. walkableRadius: number;
  122522. /**
  122523. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122524. */
  122525. maxEdgeLen: number;
  122526. /**
  122527. * The maximum distance a simplfied contour's border edges should deviate
  122528. * the original raw contour. [Limit: >=0] [Units: vx]
  122529. */
  122530. maxSimplificationError: number;
  122531. /**
  122532. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122533. */
  122534. minRegionArea: number;
  122535. /**
  122536. * Any regions with a span count smaller than this value will, if possible,
  122537. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122538. */
  122539. mergeRegionArea: number;
  122540. /**
  122541. * The maximum number of vertices allowed for polygons generated during the
  122542. * contour to polygon conversion process. [Limit: >= 3]
  122543. */
  122544. maxVertsPerPoly: number;
  122545. /**
  122546. * Sets the sampling distance to use when generating the detail mesh.
  122547. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122548. */
  122549. detailSampleDist: number;
  122550. /**
  122551. * The maximum distance the detail mesh surface should deviate from heightfield
  122552. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122553. */
  122554. detailSampleMaxError: number;
  122555. }
  122556. }
  122557. declare module BABYLON {
  122558. /**
  122559. * RecastJS navigation plugin
  122560. */
  122561. export class RecastJSPlugin implements INavigationEnginePlugin {
  122562. /**
  122563. * Reference to the Recast library
  122564. */
  122565. bjsRECAST: any;
  122566. /**
  122567. * plugin name
  122568. */
  122569. name: string;
  122570. /**
  122571. * the first navmesh created. We might extend this to support multiple navmeshes
  122572. */
  122573. navMesh: any;
  122574. /**
  122575. * Initializes the recastJS plugin
  122576. * @param recastInjection can be used to inject your own recast reference
  122577. */
  122578. constructor(recastInjection?: any);
  122579. /**
  122580. * Creates a navigation mesh
  122581. * @param meshes array of all the geometry used to compute the navigatio mesh
  122582. * @param parameters bunch of parameters used to filter geometry
  122583. */
  122584. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122585. /**
  122586. * Create a navigation mesh debug mesh
  122587. * @param scene is where the mesh will be added
  122588. * @returns debug display mesh
  122589. */
  122590. createDebugNavMesh(scene: Scene): Mesh;
  122591. /**
  122592. * Get a navigation mesh constrained position, closest to the parameter position
  122593. * @param position world position
  122594. * @returns the closest point to position constrained by the navigation mesh
  122595. */
  122596. getClosestPoint(position: Vector3): Vector3;
  122597. /**
  122598. * Get a navigation mesh constrained position, within a particular radius
  122599. * @param position world position
  122600. * @param maxRadius the maximum distance to the constrained world position
  122601. * @returns the closest point to position constrained by the navigation mesh
  122602. */
  122603. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122604. /**
  122605. * Compute the final position from a segment made of destination-position
  122606. * @param position world position
  122607. * @param destination world position
  122608. * @returns the resulting point along the navmesh
  122609. */
  122610. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122611. /**
  122612. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122613. * @param start world position
  122614. * @param end world position
  122615. * @returns array containing world position composing the path
  122616. */
  122617. computePath(start: Vector3, end: Vector3): Vector3[];
  122618. /**
  122619. * Create a new Crowd so you can add agents
  122620. * @param maxAgents the maximum agent count in the crowd
  122621. * @param maxAgentRadius the maximum radius an agent can have
  122622. * @param scene to attach the crowd to
  122623. * @returns the crowd you can add agents to
  122624. */
  122625. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122626. /**
  122627. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122628. * The queries will try to find a solution within those bounds
  122629. * default is (1,1,1)
  122630. * @param extent x,y,z value that define the extent around the queries point of reference
  122631. */
  122632. setDefaultQueryExtent(extent: Vector3): void;
  122633. /**
  122634. * Get the Bounding box extent specified by setDefaultQueryExtent
  122635. * @returns the box extent values
  122636. */
  122637. getDefaultQueryExtent(): Vector3;
  122638. /**
  122639. * Disposes
  122640. */
  122641. dispose(): void;
  122642. /**
  122643. * If this plugin is supported
  122644. * @returns true if plugin is supported
  122645. */
  122646. isSupported(): boolean;
  122647. }
  122648. /**
  122649. * Recast detour crowd implementation
  122650. */
  122651. export class RecastJSCrowd implements ICrowd {
  122652. /**
  122653. * Recast/detour plugin
  122654. */
  122655. bjsRECASTPlugin: RecastJSPlugin;
  122656. /**
  122657. * Link to the detour crowd
  122658. */
  122659. recastCrowd: any;
  122660. /**
  122661. * One transform per agent
  122662. */
  122663. transforms: TransformNode[];
  122664. /**
  122665. * All agents created
  122666. */
  122667. agents: number[];
  122668. /**
  122669. * Link to the scene is kept to unregister the crowd from the scene
  122670. */
  122671. private _scene;
  122672. /**
  122673. * Observer for crowd updates
  122674. */
  122675. private _onBeforeAnimationsObserver;
  122676. /**
  122677. * Constructor
  122678. * @param plugin recastJS plugin
  122679. * @param maxAgents the maximum agent count in the crowd
  122680. * @param maxAgentRadius the maximum radius an agent can have
  122681. * @param scene to attach the crowd to
  122682. * @returns the crowd you can add agents to
  122683. */
  122684. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122685. /**
  122686. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122687. * You can attach anything to that node. The node position is updated in the scene update tick.
  122688. * @param pos world position that will be constrained by the navigation mesh
  122689. * @param parameters agent parameters
  122690. * @param transform hooked to the agent that will be update by the scene
  122691. * @returns agent index
  122692. */
  122693. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122694. /**
  122695. * Returns the agent position in world space
  122696. * @param index agent index returned by addAgent
  122697. * @returns world space position
  122698. */
  122699. getAgentPosition(index: number): Vector3;
  122700. /**
  122701. * Returns the agent velocity in world space
  122702. * @param index agent index returned by addAgent
  122703. * @returns world space velocity
  122704. */
  122705. getAgentVelocity(index: number): Vector3;
  122706. /**
  122707. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122708. * @param index agent index returned by addAgent
  122709. * @param destination targeted world position
  122710. */
  122711. agentGoto(index: number, destination: Vector3): void;
  122712. /**
  122713. * remove a particular agent previously created
  122714. * @param index agent index returned by addAgent
  122715. */
  122716. removeAgent(index: number): void;
  122717. /**
  122718. * get the list of all agents attached to this crowd
  122719. * @returns list of agent indices
  122720. */
  122721. getAgents(): number[];
  122722. /**
  122723. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122724. * @param deltaTime in seconds
  122725. */
  122726. update(deltaTime: number): void;
  122727. /**
  122728. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122729. * The queries will try to find a solution within those bounds
  122730. * default is (1,1,1)
  122731. * @param extent x,y,z value that define the extent around the queries point of reference
  122732. */
  122733. setDefaultQueryExtent(extent: Vector3): void;
  122734. /**
  122735. * Get the Bounding box extent specified by setDefaultQueryExtent
  122736. * @returns the box extent values
  122737. */
  122738. getDefaultQueryExtent(): Vector3;
  122739. /**
  122740. * Release all resources
  122741. */
  122742. dispose(): void;
  122743. }
  122744. }
  122745. declare module BABYLON {
  122746. /**
  122747. * Class used to enable access to IndexedDB
  122748. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122749. */
  122750. export class Database implements IOfflineProvider {
  122751. private _callbackManifestChecked;
  122752. private _currentSceneUrl;
  122753. private _db;
  122754. private _enableSceneOffline;
  122755. private _enableTexturesOffline;
  122756. private _manifestVersionFound;
  122757. private _mustUpdateRessources;
  122758. private _hasReachedQuota;
  122759. private _isSupported;
  122760. private _idbFactory;
  122761. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122762. private static IsUASupportingBlobStorage;
  122763. /**
  122764. * Gets a boolean indicating if Database storate is enabled (off by default)
  122765. */
  122766. static IDBStorageEnabled: boolean;
  122767. /**
  122768. * Gets a boolean indicating if scene must be saved in the database
  122769. */
  122770. readonly enableSceneOffline: boolean;
  122771. /**
  122772. * Gets a boolean indicating if textures must be saved in the database
  122773. */
  122774. readonly enableTexturesOffline: boolean;
  122775. /**
  122776. * Creates a new Database
  122777. * @param urlToScene defines the url to load the scene
  122778. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122779. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122780. */
  122781. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122782. private static _ParseURL;
  122783. private static _ReturnFullUrlLocation;
  122784. private _checkManifestFile;
  122785. /**
  122786. * Open the database and make it available
  122787. * @param successCallback defines the callback to call on success
  122788. * @param errorCallback defines the callback to call on error
  122789. */
  122790. open(successCallback: () => void, errorCallback: () => void): void;
  122791. /**
  122792. * Loads an image from the database
  122793. * @param url defines the url to load from
  122794. * @param image defines the target DOM image
  122795. */
  122796. loadImage(url: string, image: HTMLImageElement): void;
  122797. private _loadImageFromDBAsync;
  122798. private _saveImageIntoDBAsync;
  122799. private _checkVersionFromDB;
  122800. private _loadVersionFromDBAsync;
  122801. private _saveVersionIntoDBAsync;
  122802. /**
  122803. * Loads a file from database
  122804. * @param url defines the URL to load from
  122805. * @param sceneLoaded defines a callback to call on success
  122806. * @param progressCallBack defines a callback to call when progress changed
  122807. * @param errorCallback defines a callback to call on error
  122808. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122809. */
  122810. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122811. private _loadFileAsync;
  122812. private _saveFileAsync;
  122813. /**
  122814. * Validates if xhr data is correct
  122815. * @param xhr defines the request to validate
  122816. * @param dataType defines the expected data type
  122817. * @returns true if data is correct
  122818. */
  122819. private static _ValidateXHRData;
  122820. }
  122821. }
  122822. declare module BABYLON {
  122823. /** @hidden */
  122824. export var gpuUpdateParticlesPixelShader: {
  122825. name: string;
  122826. shader: string;
  122827. };
  122828. }
  122829. declare module BABYLON {
  122830. /** @hidden */
  122831. export var gpuUpdateParticlesVertexShader: {
  122832. name: string;
  122833. shader: string;
  122834. };
  122835. }
  122836. declare module BABYLON {
  122837. /** @hidden */
  122838. export var clipPlaneFragmentDeclaration2: {
  122839. name: string;
  122840. shader: string;
  122841. };
  122842. }
  122843. declare module BABYLON {
  122844. /** @hidden */
  122845. export var gpuRenderParticlesPixelShader: {
  122846. name: string;
  122847. shader: string;
  122848. };
  122849. }
  122850. declare module BABYLON {
  122851. /** @hidden */
  122852. export var clipPlaneVertexDeclaration2: {
  122853. name: string;
  122854. shader: string;
  122855. };
  122856. }
  122857. declare module BABYLON {
  122858. /** @hidden */
  122859. export var gpuRenderParticlesVertexShader: {
  122860. name: string;
  122861. shader: string;
  122862. };
  122863. }
  122864. declare module BABYLON {
  122865. /**
  122866. * This represents a GPU particle system in Babylon
  122867. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122868. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122869. */
  122870. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122871. /**
  122872. * The layer mask we are rendering the particles through.
  122873. */
  122874. layerMask: number;
  122875. private _capacity;
  122876. private _activeCount;
  122877. private _currentActiveCount;
  122878. private _accumulatedCount;
  122879. private _renderEffect;
  122880. private _updateEffect;
  122881. private _buffer0;
  122882. private _buffer1;
  122883. private _spriteBuffer;
  122884. private _updateVAO;
  122885. private _renderVAO;
  122886. private _targetIndex;
  122887. private _sourceBuffer;
  122888. private _targetBuffer;
  122889. private _engine;
  122890. private _currentRenderId;
  122891. private _started;
  122892. private _stopped;
  122893. private _timeDelta;
  122894. private _randomTexture;
  122895. private _randomTexture2;
  122896. private _attributesStrideSize;
  122897. private _updateEffectOptions;
  122898. private _randomTextureSize;
  122899. private _actualFrame;
  122900. private readonly _rawTextureWidth;
  122901. /**
  122902. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122903. */
  122904. static readonly IsSupported: boolean;
  122905. /**
  122906. * An event triggered when the system is disposed.
  122907. */
  122908. onDisposeObservable: Observable<GPUParticleSystem>;
  122909. /**
  122910. * Gets the maximum number of particles active at the same time.
  122911. * @returns The max number of active particles.
  122912. */
  122913. getCapacity(): number;
  122914. /**
  122915. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122916. * to override the particles.
  122917. */
  122918. forceDepthWrite: boolean;
  122919. /**
  122920. * Gets or set the number of active particles
  122921. */
  122922. activeParticleCount: number;
  122923. private _preWarmDone;
  122924. /**
  122925. * Is this system ready to be used/rendered
  122926. * @return true if the system is ready
  122927. */
  122928. isReady(): boolean;
  122929. /**
  122930. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122931. * @returns True if it has been started, otherwise false.
  122932. */
  122933. isStarted(): boolean;
  122934. /**
  122935. * Starts the particle system and begins to emit
  122936. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122937. */
  122938. start(delay?: number): void;
  122939. /**
  122940. * Stops the particle system.
  122941. */
  122942. stop(): void;
  122943. /**
  122944. * Remove all active particles
  122945. */
  122946. reset(): void;
  122947. /**
  122948. * Returns the string "GPUParticleSystem"
  122949. * @returns a string containing the class name
  122950. */
  122951. getClassName(): string;
  122952. private _colorGradientsTexture;
  122953. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122954. /**
  122955. * Adds a new color gradient
  122956. * @param gradient defines the gradient to use (between 0 and 1)
  122957. * @param color1 defines the color to affect to the specified gradient
  122958. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122959. * @returns the current particle system
  122960. */
  122961. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122962. /**
  122963. * Remove a specific color gradient
  122964. * @param gradient defines the gradient to remove
  122965. * @returns the current particle system
  122966. */
  122967. removeColorGradient(gradient: number): GPUParticleSystem;
  122968. private _angularSpeedGradientsTexture;
  122969. private _sizeGradientsTexture;
  122970. private _velocityGradientsTexture;
  122971. private _limitVelocityGradientsTexture;
  122972. private _dragGradientsTexture;
  122973. private _addFactorGradient;
  122974. /**
  122975. * Adds a new size gradient
  122976. * @param gradient defines the gradient to use (between 0 and 1)
  122977. * @param factor defines the size factor to affect to the specified gradient
  122978. * @returns the current particle system
  122979. */
  122980. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122981. /**
  122982. * Remove a specific size gradient
  122983. * @param gradient defines the gradient to remove
  122984. * @returns the current particle system
  122985. */
  122986. removeSizeGradient(gradient: number): GPUParticleSystem;
  122987. /**
  122988. * Adds a new angular speed gradient
  122989. * @param gradient defines the gradient to use (between 0 and 1)
  122990. * @param factor defines the angular speed to affect to the specified gradient
  122991. * @returns the current particle system
  122992. */
  122993. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122994. /**
  122995. * Remove a specific angular speed gradient
  122996. * @param gradient defines the gradient to remove
  122997. * @returns the current particle system
  122998. */
  122999. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  123000. /**
  123001. * Adds a new velocity gradient
  123002. * @param gradient defines the gradient to use (between 0 and 1)
  123003. * @param factor defines the velocity to affect to the specified gradient
  123004. * @returns the current particle system
  123005. */
  123006. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123007. /**
  123008. * Remove a specific velocity gradient
  123009. * @param gradient defines the gradient to remove
  123010. * @returns the current particle system
  123011. */
  123012. removeVelocityGradient(gradient: number): GPUParticleSystem;
  123013. /**
  123014. * Adds a new limit velocity gradient
  123015. * @param gradient defines the gradient to use (between 0 and 1)
  123016. * @param factor defines the limit velocity value to affect to the specified gradient
  123017. * @returns the current particle system
  123018. */
  123019. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  123020. /**
  123021. * Remove a specific limit velocity gradient
  123022. * @param gradient defines the gradient to remove
  123023. * @returns the current particle system
  123024. */
  123025. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  123026. /**
  123027. * Adds a new drag gradient
  123028. * @param gradient defines the gradient to use (between 0 and 1)
  123029. * @param factor defines the drag value to affect to the specified gradient
  123030. * @returns the current particle system
  123031. */
  123032. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  123033. /**
  123034. * Remove a specific drag gradient
  123035. * @param gradient defines the gradient to remove
  123036. * @returns the current particle system
  123037. */
  123038. removeDragGradient(gradient: number): GPUParticleSystem;
  123039. /**
  123040. * Not supported by GPUParticleSystem
  123041. * @param gradient defines the gradient to use (between 0 and 1)
  123042. * @param factor defines the emit rate value to affect to the specified gradient
  123043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123044. * @returns the current particle system
  123045. */
  123046. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123047. /**
  123048. * Not supported by GPUParticleSystem
  123049. * @param gradient defines the gradient to remove
  123050. * @returns the current particle system
  123051. */
  123052. removeEmitRateGradient(gradient: number): IParticleSystem;
  123053. /**
  123054. * Not supported by GPUParticleSystem
  123055. * @param gradient defines the gradient to use (between 0 and 1)
  123056. * @param factor defines the start size value to affect to the specified gradient
  123057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123058. * @returns the current particle system
  123059. */
  123060. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123061. /**
  123062. * Not supported by GPUParticleSystem
  123063. * @param gradient defines the gradient to remove
  123064. * @returns the current particle system
  123065. */
  123066. removeStartSizeGradient(gradient: number): IParticleSystem;
  123067. /**
  123068. * Not supported by GPUParticleSystem
  123069. * @param gradient defines the gradient to use (between 0 and 1)
  123070. * @param min defines the color remap minimal range
  123071. * @param max defines the color remap maximal range
  123072. * @returns the current particle system
  123073. */
  123074. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123075. /**
  123076. * Not supported by GPUParticleSystem
  123077. * @param gradient defines the gradient to remove
  123078. * @returns the current particle system
  123079. */
  123080. removeColorRemapGradient(): IParticleSystem;
  123081. /**
  123082. * Not supported by GPUParticleSystem
  123083. * @param gradient defines the gradient to use (between 0 and 1)
  123084. * @param min defines the alpha remap minimal range
  123085. * @param max defines the alpha remap maximal range
  123086. * @returns the current particle system
  123087. */
  123088. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123089. /**
  123090. * Not supported by GPUParticleSystem
  123091. * @param gradient defines the gradient to remove
  123092. * @returns the current particle system
  123093. */
  123094. removeAlphaRemapGradient(): IParticleSystem;
  123095. /**
  123096. * Not supported by GPUParticleSystem
  123097. * @param gradient defines the gradient to use (between 0 and 1)
  123098. * @param color defines the color to affect to the specified gradient
  123099. * @returns the current particle system
  123100. */
  123101. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  123102. /**
  123103. * Not supported by GPUParticleSystem
  123104. * @param gradient defines the gradient to remove
  123105. * @returns the current particle system
  123106. */
  123107. removeRampGradient(): IParticleSystem;
  123108. /**
  123109. * Not supported by GPUParticleSystem
  123110. * @returns the list of ramp gradients
  123111. */
  123112. getRampGradients(): Nullable<Array<Color3Gradient>>;
  123113. /**
  123114. * Not supported by GPUParticleSystem
  123115. * Gets or sets a boolean indicating that ramp gradients must be used
  123116. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  123117. */
  123118. useRampGradients: boolean;
  123119. /**
  123120. * Not supported by GPUParticleSystem
  123121. * @param gradient defines the gradient to use (between 0 and 1)
  123122. * @param factor defines the life time factor to affect to the specified gradient
  123123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123124. * @returns the current particle system
  123125. */
  123126. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123127. /**
  123128. * Not supported by GPUParticleSystem
  123129. * @param gradient defines the gradient to remove
  123130. * @returns the current particle system
  123131. */
  123132. removeLifeTimeGradient(gradient: number): IParticleSystem;
  123133. /**
  123134. * Instantiates a GPU particle system.
  123135. * 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.
  123136. * @param name The name of the particle system
  123137. * @param options The options used to create the system
  123138. * @param scene The scene the particle system belongs to
  123139. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  123140. */
  123141. constructor(name: string, options: Partial<{
  123142. capacity: number;
  123143. randomTextureSize: number;
  123144. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  123145. protected _reset(): void;
  123146. private _createUpdateVAO;
  123147. private _createRenderVAO;
  123148. private _initialize;
  123149. /** @hidden */
  123150. _recreateUpdateEffect(): void;
  123151. /** @hidden */
  123152. _recreateRenderEffect(): void;
  123153. /**
  123154. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  123155. * @param preWarm defines if we are in the pre-warmimg phase
  123156. */
  123157. animate(preWarm?: boolean): void;
  123158. private _createFactorGradientTexture;
  123159. private _createSizeGradientTexture;
  123160. private _createAngularSpeedGradientTexture;
  123161. private _createVelocityGradientTexture;
  123162. private _createLimitVelocityGradientTexture;
  123163. private _createDragGradientTexture;
  123164. private _createColorGradientTexture;
  123165. /**
  123166. * Renders the particle system in its current state
  123167. * @param preWarm defines if the system should only update the particles but not render them
  123168. * @returns the current number of particles
  123169. */
  123170. render(preWarm?: boolean): number;
  123171. /**
  123172. * Rebuilds the particle system
  123173. */
  123174. rebuild(): void;
  123175. private _releaseBuffers;
  123176. private _releaseVAOs;
  123177. /**
  123178. * Disposes the particle system and free the associated resources
  123179. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123180. */
  123181. dispose(disposeTexture?: boolean): void;
  123182. /**
  123183. * Clones the particle system.
  123184. * @param name The name of the cloned object
  123185. * @param newEmitter The new emitter to use
  123186. * @returns the cloned particle system
  123187. */
  123188. clone(name: string, newEmitter: any): GPUParticleSystem;
  123189. /**
  123190. * Serializes the particle system to a JSON object.
  123191. * @returns the JSON object
  123192. */
  123193. serialize(): any;
  123194. /**
  123195. * Parses a JSON object to create a GPU particle system.
  123196. * @param parsedParticleSystem The JSON object to parse
  123197. * @param scene The scene to create the particle system in
  123198. * @param rootUrl The root url to use to load external dependencies like texture
  123199. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123200. * @returns the parsed GPU particle system
  123201. */
  123202. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123203. }
  123204. }
  123205. declare module BABYLON {
  123206. /**
  123207. * Represents a set of particle systems working together to create a specific effect
  123208. */
  123209. export class ParticleSystemSet implements IDisposable {
  123210. private _emitterCreationOptions;
  123211. private _emitterNode;
  123212. /**
  123213. * Gets the particle system list
  123214. */
  123215. systems: IParticleSystem[];
  123216. /**
  123217. * Gets the emitter node used with this set
  123218. */
  123219. readonly emitterNode: Nullable<TransformNode>;
  123220. /**
  123221. * Creates a new emitter mesh as a sphere
  123222. * @param options defines the options used to create the sphere
  123223. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123224. * @param scene defines the hosting scene
  123225. */
  123226. setEmitterAsSphere(options: {
  123227. diameter: number;
  123228. segments: number;
  123229. color: Color3;
  123230. }, renderingGroupId: number, scene: Scene): void;
  123231. /**
  123232. * Starts all particle systems of the set
  123233. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123234. */
  123235. start(emitter?: AbstractMesh): void;
  123236. /**
  123237. * Release all associated resources
  123238. */
  123239. dispose(): void;
  123240. /**
  123241. * Serialize the set into a JSON compatible object
  123242. * @returns a JSON compatible representation of the set
  123243. */
  123244. serialize(): any;
  123245. /**
  123246. * Parse a new ParticleSystemSet from a serialized source
  123247. * @param data defines a JSON compatible representation of the set
  123248. * @param scene defines the hosting scene
  123249. * @param gpu defines if we want GPU particles or CPU particles
  123250. * @returns a new ParticleSystemSet
  123251. */
  123252. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123253. }
  123254. }
  123255. declare module BABYLON {
  123256. /**
  123257. * This class is made for on one-liner static method to help creating particle system set.
  123258. */
  123259. export class ParticleHelper {
  123260. /**
  123261. * Gets or sets base Assets URL
  123262. */
  123263. static BaseAssetsUrl: string;
  123264. /**
  123265. * Create a default particle system that you can tweak
  123266. * @param emitter defines the emitter to use
  123267. * @param capacity defines the system capacity (default is 500 particles)
  123268. * @param scene defines the hosting scene
  123269. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123270. * @returns the new Particle system
  123271. */
  123272. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123273. /**
  123274. * This is the main static method (one-liner) of this helper to create different particle systems
  123275. * @param type This string represents the type to the particle system to create
  123276. * @param scene The scene where the particle system should live
  123277. * @param gpu If the system will use gpu
  123278. * @returns the ParticleSystemSet created
  123279. */
  123280. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123281. /**
  123282. * Static function used to export a particle system to a ParticleSystemSet variable.
  123283. * Please note that the emitter shape is not exported
  123284. * @param systems defines the particle systems to export
  123285. * @returns the created particle system set
  123286. */
  123287. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123288. }
  123289. }
  123290. declare module BABYLON {
  123291. interface Engine {
  123292. /**
  123293. * Create an effect to use with particle systems.
  123294. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123295. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123296. * @param uniformsNames defines a list of attribute names
  123297. * @param samplers defines an array of string used to represent textures
  123298. * @param defines defines the string containing the defines to use to compile the shaders
  123299. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123300. * @param onCompiled defines a function to call when the effect creation is successful
  123301. * @param onError defines a function to call when the effect creation has failed
  123302. * @returns the new Effect
  123303. */
  123304. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123305. }
  123306. interface Mesh {
  123307. /**
  123308. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123309. * @returns an array of IParticleSystem
  123310. */
  123311. getEmittedParticleSystems(): IParticleSystem[];
  123312. /**
  123313. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123314. * @returns an array of IParticleSystem
  123315. */
  123316. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123317. }
  123318. /**
  123319. * @hidden
  123320. */
  123321. export var _IDoNeedToBeInTheBuild: number;
  123322. }
  123323. declare module BABYLON {
  123324. interface Scene {
  123325. /** @hidden (Backing field) */
  123326. _physicsEngine: Nullable<IPhysicsEngine>;
  123327. /**
  123328. * Gets the current physics engine
  123329. * @returns a IPhysicsEngine or null if none attached
  123330. */
  123331. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123332. /**
  123333. * Enables physics to the current scene
  123334. * @param gravity defines the scene's gravity for the physics engine
  123335. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123336. * @return a boolean indicating if the physics engine was initialized
  123337. */
  123338. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123339. /**
  123340. * Disables and disposes the physics engine associated with the scene
  123341. */
  123342. disablePhysicsEngine(): void;
  123343. /**
  123344. * Gets a boolean indicating if there is an active physics engine
  123345. * @returns a boolean indicating if there is an active physics engine
  123346. */
  123347. isPhysicsEnabled(): boolean;
  123348. /**
  123349. * Deletes a physics compound impostor
  123350. * @param compound defines the compound to delete
  123351. */
  123352. deleteCompoundImpostor(compound: any): void;
  123353. /**
  123354. * An event triggered when physic simulation is about to be run
  123355. */
  123356. onBeforePhysicsObservable: Observable<Scene>;
  123357. /**
  123358. * An event triggered when physic simulation has been done
  123359. */
  123360. onAfterPhysicsObservable: Observable<Scene>;
  123361. }
  123362. interface AbstractMesh {
  123363. /** @hidden */
  123364. _physicsImpostor: Nullable<PhysicsImpostor>;
  123365. /**
  123366. * Gets or sets impostor used for physic simulation
  123367. * @see http://doc.babylonjs.com/features/physics_engine
  123368. */
  123369. physicsImpostor: Nullable<PhysicsImpostor>;
  123370. /**
  123371. * Gets the current physics impostor
  123372. * @see http://doc.babylonjs.com/features/physics_engine
  123373. * @returns a physics impostor or null
  123374. */
  123375. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123376. /** Apply a physic impulse to the mesh
  123377. * @param force defines the force to apply
  123378. * @param contactPoint defines where to apply the force
  123379. * @returns the current mesh
  123380. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123381. */
  123382. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123383. /**
  123384. * Creates a physic joint between two meshes
  123385. * @param otherMesh defines the other mesh to use
  123386. * @param pivot1 defines the pivot to use on this mesh
  123387. * @param pivot2 defines the pivot to use on the other mesh
  123388. * @param options defines additional options (can be plugin dependent)
  123389. * @returns the current mesh
  123390. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123391. */
  123392. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123393. /** @hidden */
  123394. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123395. }
  123396. /**
  123397. * Defines the physics engine scene component responsible to manage a physics engine
  123398. */
  123399. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123400. /**
  123401. * The component name helpful to identify the component in the list of scene components.
  123402. */
  123403. readonly name: string;
  123404. /**
  123405. * The scene the component belongs to.
  123406. */
  123407. scene: Scene;
  123408. /**
  123409. * Creates a new instance of the component for the given scene
  123410. * @param scene Defines the scene to register the component in
  123411. */
  123412. constructor(scene: Scene);
  123413. /**
  123414. * Registers the component in a given scene
  123415. */
  123416. register(): void;
  123417. /**
  123418. * Rebuilds the elements related to this component in case of
  123419. * context lost for instance.
  123420. */
  123421. rebuild(): void;
  123422. /**
  123423. * Disposes the component and the associated ressources
  123424. */
  123425. dispose(): void;
  123426. }
  123427. }
  123428. declare module BABYLON {
  123429. /**
  123430. * A helper for physics simulations
  123431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123432. */
  123433. export class PhysicsHelper {
  123434. private _scene;
  123435. private _physicsEngine;
  123436. /**
  123437. * Initializes the Physics helper
  123438. * @param scene Babylon.js scene
  123439. */
  123440. constructor(scene: Scene);
  123441. /**
  123442. * Applies a radial explosion impulse
  123443. * @param origin the origin of the explosion
  123444. * @param radiusOrEventOptions the radius or the options of radial explosion
  123445. * @param strength the explosion strength
  123446. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123447. * @returns A physics radial explosion event, or null
  123448. */
  123449. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123450. /**
  123451. * Applies a radial explosion force
  123452. * @param origin the origin of the explosion
  123453. * @param radiusOrEventOptions the radius or the options of radial explosion
  123454. * @param strength the explosion strength
  123455. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123456. * @returns A physics radial explosion event, or null
  123457. */
  123458. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123459. /**
  123460. * Creates a gravitational field
  123461. * @param origin the origin of the explosion
  123462. * @param radiusOrEventOptions the radius or the options of radial explosion
  123463. * @param strength the explosion strength
  123464. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123465. * @returns A physics gravitational field event, or null
  123466. */
  123467. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123468. /**
  123469. * Creates a physics updraft event
  123470. * @param origin the origin of the updraft
  123471. * @param radiusOrEventOptions the radius or the options of the updraft
  123472. * @param strength the strength of the updraft
  123473. * @param height the height of the updraft
  123474. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123475. * @returns A physics updraft event, or null
  123476. */
  123477. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123478. /**
  123479. * Creates a physics vortex event
  123480. * @param origin the of the vortex
  123481. * @param radiusOrEventOptions the radius or the options of the vortex
  123482. * @param strength the strength of the vortex
  123483. * @param height the height of the vortex
  123484. * @returns a Physics vortex event, or null
  123485. * A physics vortex event or null
  123486. */
  123487. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123488. }
  123489. /**
  123490. * Represents a physics radial explosion event
  123491. */
  123492. class PhysicsRadialExplosionEvent {
  123493. private _scene;
  123494. private _options;
  123495. private _sphere;
  123496. private _dataFetched;
  123497. /**
  123498. * Initializes a radial explosioin event
  123499. * @param _scene BabylonJS scene
  123500. * @param _options The options for the vortex event
  123501. */
  123502. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123503. /**
  123504. * Returns the data related to the radial explosion event (sphere).
  123505. * @returns The radial explosion event data
  123506. */
  123507. getData(): PhysicsRadialExplosionEventData;
  123508. /**
  123509. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123510. * @param impostor A physics imposter
  123511. * @param origin the origin of the explosion
  123512. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123513. */
  123514. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123515. /**
  123516. * Triggers affecterd impostors callbacks
  123517. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123518. */
  123519. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123520. /**
  123521. * Disposes the sphere.
  123522. * @param force Specifies if the sphere should be disposed by force
  123523. */
  123524. dispose(force?: boolean): void;
  123525. /*** Helpers ***/
  123526. private _prepareSphere;
  123527. private _intersectsWithSphere;
  123528. }
  123529. /**
  123530. * Represents a gravitational field event
  123531. */
  123532. class PhysicsGravitationalFieldEvent {
  123533. private _physicsHelper;
  123534. private _scene;
  123535. private _origin;
  123536. private _options;
  123537. private _tickCallback;
  123538. private _sphere;
  123539. private _dataFetched;
  123540. /**
  123541. * Initializes the physics gravitational field event
  123542. * @param _physicsHelper A physics helper
  123543. * @param _scene BabylonJS scene
  123544. * @param _origin The origin position of the gravitational field event
  123545. * @param _options The options for the vortex event
  123546. */
  123547. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123548. /**
  123549. * Returns the data related to the gravitational field event (sphere).
  123550. * @returns A gravitational field event
  123551. */
  123552. getData(): PhysicsGravitationalFieldEventData;
  123553. /**
  123554. * Enables the gravitational field.
  123555. */
  123556. enable(): void;
  123557. /**
  123558. * Disables the gravitational field.
  123559. */
  123560. disable(): void;
  123561. /**
  123562. * Disposes the sphere.
  123563. * @param force The force to dispose from the gravitational field event
  123564. */
  123565. dispose(force?: boolean): void;
  123566. private _tick;
  123567. }
  123568. /**
  123569. * Represents a physics updraft event
  123570. */
  123571. class PhysicsUpdraftEvent {
  123572. private _scene;
  123573. private _origin;
  123574. private _options;
  123575. private _physicsEngine;
  123576. private _originTop;
  123577. private _originDirection;
  123578. private _tickCallback;
  123579. private _cylinder;
  123580. private _cylinderPosition;
  123581. private _dataFetched;
  123582. /**
  123583. * Initializes the physics updraft event
  123584. * @param _scene BabylonJS scene
  123585. * @param _origin The origin position of the updraft
  123586. * @param _options The options for the updraft event
  123587. */
  123588. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123589. /**
  123590. * Returns the data related to the updraft event (cylinder).
  123591. * @returns A physics updraft event
  123592. */
  123593. getData(): PhysicsUpdraftEventData;
  123594. /**
  123595. * Enables the updraft.
  123596. */
  123597. enable(): void;
  123598. /**
  123599. * Disables the updraft.
  123600. */
  123601. disable(): void;
  123602. /**
  123603. * Disposes the cylinder.
  123604. * @param force Specifies if the updraft should be disposed by force
  123605. */
  123606. dispose(force?: boolean): void;
  123607. private getImpostorHitData;
  123608. private _tick;
  123609. /*** Helpers ***/
  123610. private _prepareCylinder;
  123611. private _intersectsWithCylinder;
  123612. }
  123613. /**
  123614. * Represents a physics vortex event
  123615. */
  123616. class PhysicsVortexEvent {
  123617. private _scene;
  123618. private _origin;
  123619. private _options;
  123620. private _physicsEngine;
  123621. private _originTop;
  123622. private _tickCallback;
  123623. private _cylinder;
  123624. private _cylinderPosition;
  123625. private _dataFetched;
  123626. /**
  123627. * Initializes the physics vortex event
  123628. * @param _scene The BabylonJS scene
  123629. * @param _origin The origin position of the vortex
  123630. * @param _options The options for the vortex event
  123631. */
  123632. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123633. /**
  123634. * Returns the data related to the vortex event (cylinder).
  123635. * @returns The physics vortex event data
  123636. */
  123637. getData(): PhysicsVortexEventData;
  123638. /**
  123639. * Enables the vortex.
  123640. */
  123641. enable(): void;
  123642. /**
  123643. * Disables the cortex.
  123644. */
  123645. disable(): void;
  123646. /**
  123647. * Disposes the sphere.
  123648. * @param force
  123649. */
  123650. dispose(force?: boolean): void;
  123651. private getImpostorHitData;
  123652. private _tick;
  123653. /*** Helpers ***/
  123654. private _prepareCylinder;
  123655. private _intersectsWithCylinder;
  123656. }
  123657. /**
  123658. * Options fot the radial explosion event
  123659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123660. */
  123661. export class PhysicsRadialExplosionEventOptions {
  123662. /**
  123663. * The radius of the sphere for the radial explosion.
  123664. */
  123665. radius: number;
  123666. /**
  123667. * The strenth of the explosion.
  123668. */
  123669. strength: number;
  123670. /**
  123671. * The strenght of the force in correspondence to the distance of the affected object
  123672. */
  123673. falloff: PhysicsRadialImpulseFalloff;
  123674. /**
  123675. * Sphere options for the radial explosion.
  123676. */
  123677. sphere: {
  123678. segments: number;
  123679. diameter: number;
  123680. };
  123681. /**
  123682. * Sphere options for the radial explosion.
  123683. */
  123684. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123685. }
  123686. /**
  123687. * Options fot the updraft event
  123688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123689. */
  123690. export class PhysicsUpdraftEventOptions {
  123691. /**
  123692. * The radius of the cylinder for the vortex
  123693. */
  123694. radius: number;
  123695. /**
  123696. * The strenth of the updraft.
  123697. */
  123698. strength: number;
  123699. /**
  123700. * The height of the cylinder for the updraft.
  123701. */
  123702. height: number;
  123703. /**
  123704. * The mode for the the updraft.
  123705. */
  123706. updraftMode: PhysicsUpdraftMode;
  123707. }
  123708. /**
  123709. * Options fot the vortex event
  123710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123711. */
  123712. export class PhysicsVortexEventOptions {
  123713. /**
  123714. * The radius of the cylinder for the vortex
  123715. */
  123716. radius: number;
  123717. /**
  123718. * The strenth of the vortex.
  123719. */
  123720. strength: number;
  123721. /**
  123722. * The height of the cylinder for the vortex.
  123723. */
  123724. height: number;
  123725. /**
  123726. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123727. */
  123728. centripetalForceThreshold: number;
  123729. /**
  123730. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123731. */
  123732. centripetalForceMultiplier: number;
  123733. /**
  123734. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123735. */
  123736. centrifugalForceMultiplier: number;
  123737. /**
  123738. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123739. */
  123740. updraftForceMultiplier: number;
  123741. }
  123742. /**
  123743. * The strenght of the force in correspondence to the distance of the affected object
  123744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123745. */
  123746. export enum PhysicsRadialImpulseFalloff {
  123747. /** Defines that impulse is constant in strength across it's whole radius */
  123748. Constant = 0,
  123749. /** Defines that impulse gets weaker if it's further from the origin */
  123750. Linear = 1
  123751. }
  123752. /**
  123753. * The strength of the force in correspondence to the distance of the affected object
  123754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123755. */
  123756. export enum PhysicsUpdraftMode {
  123757. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123758. Center = 0,
  123759. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123760. Perpendicular = 1
  123761. }
  123762. /**
  123763. * Interface for a physics hit data
  123764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123765. */
  123766. export interface PhysicsHitData {
  123767. /**
  123768. * The force applied at the contact point
  123769. */
  123770. force: Vector3;
  123771. /**
  123772. * The contact point
  123773. */
  123774. contactPoint: Vector3;
  123775. /**
  123776. * The distance from the origin to the contact point
  123777. */
  123778. distanceFromOrigin: number;
  123779. }
  123780. /**
  123781. * Interface for radial explosion event data
  123782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123783. */
  123784. export interface PhysicsRadialExplosionEventData {
  123785. /**
  123786. * A sphere used for the radial explosion event
  123787. */
  123788. sphere: Mesh;
  123789. }
  123790. /**
  123791. * Interface for gravitational field event data
  123792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123793. */
  123794. export interface PhysicsGravitationalFieldEventData {
  123795. /**
  123796. * A sphere mesh used for the gravitational field event
  123797. */
  123798. sphere: Mesh;
  123799. }
  123800. /**
  123801. * Interface for updraft event data
  123802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123803. */
  123804. export interface PhysicsUpdraftEventData {
  123805. /**
  123806. * A cylinder used for the updraft event
  123807. */
  123808. cylinder: Mesh;
  123809. }
  123810. /**
  123811. * Interface for vortex event data
  123812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123813. */
  123814. export interface PhysicsVortexEventData {
  123815. /**
  123816. * A cylinder used for the vortex event
  123817. */
  123818. cylinder: Mesh;
  123819. }
  123820. /**
  123821. * Interface for an affected physics impostor
  123822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123823. */
  123824. export interface PhysicsAffectedImpostorWithData {
  123825. /**
  123826. * The impostor affected by the effect
  123827. */
  123828. impostor: PhysicsImpostor;
  123829. /**
  123830. * The data about the hit/horce from the explosion
  123831. */
  123832. hitData: PhysicsHitData;
  123833. }
  123834. }
  123835. declare module BABYLON {
  123836. /** @hidden */
  123837. export var blackAndWhitePixelShader: {
  123838. name: string;
  123839. shader: string;
  123840. };
  123841. }
  123842. declare module BABYLON {
  123843. /**
  123844. * Post process used to render in black and white
  123845. */
  123846. export class BlackAndWhitePostProcess extends PostProcess {
  123847. /**
  123848. * Linear about to convert he result to black and white (default: 1)
  123849. */
  123850. degree: number;
  123851. /**
  123852. * Creates a black and white post process
  123853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123854. * @param name The name of the effect.
  123855. * @param options The required width/height ratio to downsize to before computing the render pass.
  123856. * @param camera The camera to apply the render pass to.
  123857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123858. * @param engine The engine which the post process will be applied. (default: current engine)
  123859. * @param reusable If the post process can be reused on the same frame. (default: false)
  123860. */
  123861. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123862. }
  123863. }
  123864. declare module BABYLON {
  123865. /**
  123866. * This represents a set of one or more post processes in Babylon.
  123867. * A post process can be used to apply a shader to a texture after it is rendered.
  123868. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123869. */
  123870. export class PostProcessRenderEffect {
  123871. private _postProcesses;
  123872. private _getPostProcesses;
  123873. private _singleInstance;
  123874. private _cameras;
  123875. private _indicesForCamera;
  123876. /**
  123877. * Name of the effect
  123878. * @hidden
  123879. */
  123880. _name: string;
  123881. /**
  123882. * Instantiates a post process render effect.
  123883. * A post process can be used to apply a shader to a texture after it is rendered.
  123884. * @param engine The engine the effect is tied to
  123885. * @param name The name of the effect
  123886. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123887. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123888. */
  123889. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123890. /**
  123891. * Checks if all the post processes in the effect are supported.
  123892. */
  123893. readonly isSupported: boolean;
  123894. /**
  123895. * Updates the current state of the effect
  123896. * @hidden
  123897. */
  123898. _update(): void;
  123899. /**
  123900. * Attaches the effect on cameras
  123901. * @param cameras The camera to attach to.
  123902. * @hidden
  123903. */
  123904. _attachCameras(cameras: Camera): void;
  123905. /**
  123906. * Attaches the effect on cameras
  123907. * @param cameras The camera to attach to.
  123908. * @hidden
  123909. */
  123910. _attachCameras(cameras: Camera[]): void;
  123911. /**
  123912. * Detaches the effect on cameras
  123913. * @param cameras The camera to detatch from.
  123914. * @hidden
  123915. */
  123916. _detachCameras(cameras: Camera): void;
  123917. /**
  123918. * Detatches the effect on cameras
  123919. * @param cameras The camera to detatch from.
  123920. * @hidden
  123921. */
  123922. _detachCameras(cameras: Camera[]): void;
  123923. /**
  123924. * Enables the effect on given cameras
  123925. * @param cameras The camera to enable.
  123926. * @hidden
  123927. */
  123928. _enable(cameras: Camera): void;
  123929. /**
  123930. * Enables the effect on given cameras
  123931. * @param cameras The camera to enable.
  123932. * @hidden
  123933. */
  123934. _enable(cameras: Nullable<Camera[]>): void;
  123935. /**
  123936. * Disables the effect on the given cameras
  123937. * @param cameras The camera to disable.
  123938. * @hidden
  123939. */
  123940. _disable(cameras: Camera): void;
  123941. /**
  123942. * Disables the effect on the given cameras
  123943. * @param cameras The camera to disable.
  123944. * @hidden
  123945. */
  123946. _disable(cameras: Nullable<Camera[]>): void;
  123947. /**
  123948. * Gets a list of the post processes contained in the effect.
  123949. * @param camera The camera to get the post processes on.
  123950. * @returns The list of the post processes in the effect.
  123951. */
  123952. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123953. }
  123954. }
  123955. declare module BABYLON {
  123956. /** @hidden */
  123957. export var extractHighlightsPixelShader: {
  123958. name: string;
  123959. shader: string;
  123960. };
  123961. }
  123962. declare module BABYLON {
  123963. /**
  123964. * 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.
  123965. */
  123966. export class ExtractHighlightsPostProcess extends PostProcess {
  123967. /**
  123968. * The luminance threshold, pixels below this value will be set to black.
  123969. */
  123970. threshold: number;
  123971. /** @hidden */
  123972. _exposure: number;
  123973. /**
  123974. * Post process which has the input texture to be used when performing highlight extraction
  123975. * @hidden
  123976. */
  123977. _inputPostProcess: Nullable<PostProcess>;
  123978. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123979. }
  123980. }
  123981. declare module BABYLON {
  123982. /** @hidden */
  123983. export var bloomMergePixelShader: {
  123984. name: string;
  123985. shader: string;
  123986. };
  123987. }
  123988. declare module BABYLON {
  123989. /**
  123990. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123991. */
  123992. export class BloomMergePostProcess extends PostProcess {
  123993. /** Weight of the bloom to be added to the original input. */
  123994. weight: number;
  123995. /**
  123996. * Creates a new instance of @see BloomMergePostProcess
  123997. * @param name The name of the effect.
  123998. * @param originalFromInput Post process which's input will be used for the merge.
  123999. * @param blurred Blurred highlights post process which's output will be used.
  124000. * @param weight Weight of the bloom to be added to the original input.
  124001. * @param options The required width/height ratio to downsize to before computing the render pass.
  124002. * @param camera The camera to apply the render pass to.
  124003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124004. * @param engine The engine which the post process will be applied. (default: current engine)
  124005. * @param reusable If the post process can be reused on the same frame. (default: false)
  124006. * @param textureType Type of textures used when performing the post process. (default: 0)
  124007. * @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)
  124008. */
  124009. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  124010. /** Weight of the bloom to be added to the original input. */
  124011. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124012. }
  124013. }
  124014. declare module BABYLON {
  124015. /**
  124016. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  124017. */
  124018. export class BloomEffect extends PostProcessRenderEffect {
  124019. private bloomScale;
  124020. /**
  124021. * @hidden Internal
  124022. */
  124023. _effects: Array<PostProcess>;
  124024. /**
  124025. * @hidden Internal
  124026. */
  124027. _downscale: ExtractHighlightsPostProcess;
  124028. private _blurX;
  124029. private _blurY;
  124030. private _merge;
  124031. /**
  124032. * The luminance threshold to find bright areas of the image to bloom.
  124033. */
  124034. threshold: number;
  124035. /**
  124036. * The strength of the bloom.
  124037. */
  124038. weight: number;
  124039. /**
  124040. * Specifies the size of the bloom blur kernel, relative to the final output size
  124041. */
  124042. kernel: number;
  124043. /**
  124044. * Creates a new instance of @see BloomEffect
  124045. * @param scene The scene the effect belongs to.
  124046. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  124047. * @param bloomKernel The size of the kernel to be used when applying the blur.
  124048. * @param bloomWeight The the strength of bloom.
  124049. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124050. * @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)
  124051. */
  124052. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  124053. /**
  124054. * Disposes each of the internal effects for a given camera.
  124055. * @param camera The camera to dispose the effect on.
  124056. */
  124057. disposeEffects(camera: Camera): void;
  124058. /**
  124059. * @hidden Internal
  124060. */
  124061. _updateEffects(): void;
  124062. /**
  124063. * Internal
  124064. * @returns if all the contained post processes are ready.
  124065. * @hidden
  124066. */
  124067. _isReady(): boolean;
  124068. }
  124069. }
  124070. declare module BABYLON {
  124071. /** @hidden */
  124072. export var chromaticAberrationPixelShader: {
  124073. name: string;
  124074. shader: string;
  124075. };
  124076. }
  124077. declare module BABYLON {
  124078. /**
  124079. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  124080. */
  124081. export class ChromaticAberrationPostProcess extends PostProcess {
  124082. /**
  124083. * The amount of seperation of rgb channels (default: 30)
  124084. */
  124085. aberrationAmount: number;
  124086. /**
  124087. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  124088. */
  124089. radialIntensity: number;
  124090. /**
  124091. * 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))
  124092. */
  124093. direction: Vector2;
  124094. /**
  124095. * 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))
  124096. */
  124097. centerPosition: Vector2;
  124098. /**
  124099. * Creates a new instance ChromaticAberrationPostProcess
  124100. * @param name The name of the effect.
  124101. * @param screenWidth The width of the screen to apply the effect on.
  124102. * @param screenHeight The height of the screen to apply the effect on.
  124103. * @param options The required width/height ratio to downsize to before computing the render pass.
  124104. * @param camera The camera to apply the render pass to.
  124105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124106. * @param engine The engine which the post process will be applied. (default: current engine)
  124107. * @param reusable If the post process can be reused on the same frame. (default: false)
  124108. * @param textureType Type of textures used when performing the post process. (default: 0)
  124109. * @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)
  124110. */
  124111. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124112. }
  124113. }
  124114. declare module BABYLON {
  124115. /** @hidden */
  124116. export var circleOfConfusionPixelShader: {
  124117. name: string;
  124118. shader: string;
  124119. };
  124120. }
  124121. declare module BABYLON {
  124122. /**
  124123. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  124124. */
  124125. export class CircleOfConfusionPostProcess extends PostProcess {
  124126. /**
  124127. * 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.
  124128. */
  124129. lensSize: number;
  124130. /**
  124131. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124132. */
  124133. fStop: number;
  124134. /**
  124135. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124136. */
  124137. focusDistance: number;
  124138. /**
  124139. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  124140. */
  124141. focalLength: number;
  124142. private _depthTexture;
  124143. /**
  124144. * Creates a new instance CircleOfConfusionPostProcess
  124145. * @param name The name of the effect.
  124146. * @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.
  124147. * @param options The required width/height ratio to downsize to before computing the render pass.
  124148. * @param camera The camera to apply the render pass to.
  124149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124150. * @param engine The engine which the post process will be applied. (default: current engine)
  124151. * @param reusable If the post process can be reused on the same frame. (default: false)
  124152. * @param textureType Type of textures used when performing the post process. (default: 0)
  124153. * @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)
  124154. */
  124155. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124156. /**
  124157. * 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.
  124158. */
  124159. depthTexture: RenderTargetTexture;
  124160. }
  124161. }
  124162. declare module BABYLON {
  124163. /** @hidden */
  124164. export var colorCorrectionPixelShader: {
  124165. name: string;
  124166. shader: string;
  124167. };
  124168. }
  124169. declare module BABYLON {
  124170. /**
  124171. *
  124172. * This post-process allows the modification of rendered colors by using
  124173. * a 'look-up table' (LUT). This effect is also called Color Grading.
  124174. *
  124175. * The object needs to be provided an url to a texture containing the color
  124176. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  124177. * Use an image editing software to tweak the LUT to match your needs.
  124178. *
  124179. * For an example of a color LUT, see here:
  124180. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  124181. * For explanations on color grading, see here:
  124182. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124183. *
  124184. */
  124185. export class ColorCorrectionPostProcess extends PostProcess {
  124186. private _colorTableTexture;
  124187. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124188. }
  124189. }
  124190. declare module BABYLON {
  124191. /** @hidden */
  124192. export var convolutionPixelShader: {
  124193. name: string;
  124194. shader: string;
  124195. };
  124196. }
  124197. declare module BABYLON {
  124198. /**
  124199. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124200. * input texture to perform effects such as edge detection or sharpening
  124201. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124202. */
  124203. export class ConvolutionPostProcess extends PostProcess {
  124204. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124205. kernel: number[];
  124206. /**
  124207. * Creates a new instance ConvolutionPostProcess
  124208. * @param name The name of the effect.
  124209. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124210. * @param options The required width/height ratio to downsize to before computing the render pass.
  124211. * @param camera The camera to apply the render pass to.
  124212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124213. * @param engine The engine which the post process will be applied. (default: current engine)
  124214. * @param reusable If the post process can be reused on the same frame. (default: false)
  124215. * @param textureType Type of textures used when performing the post process. (default: 0)
  124216. */
  124217. constructor(name: string,
  124218. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124219. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124220. /**
  124221. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124222. */
  124223. static EdgeDetect0Kernel: number[];
  124224. /**
  124225. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124226. */
  124227. static EdgeDetect1Kernel: number[];
  124228. /**
  124229. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124230. */
  124231. static EdgeDetect2Kernel: number[];
  124232. /**
  124233. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124234. */
  124235. static SharpenKernel: number[];
  124236. /**
  124237. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124238. */
  124239. static EmbossKernel: number[];
  124240. /**
  124241. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124242. */
  124243. static GaussianKernel: number[];
  124244. }
  124245. }
  124246. declare module BABYLON {
  124247. /**
  124248. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124249. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124250. * based on samples that have a large difference in distance than the center pixel.
  124251. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124252. */
  124253. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124254. direction: Vector2;
  124255. /**
  124256. * Creates a new instance CircleOfConfusionPostProcess
  124257. * @param name The name of the effect.
  124258. * @param scene The scene the effect belongs to.
  124259. * @param direction The direction the blur should be applied.
  124260. * @param kernel The size of the kernel used to blur.
  124261. * @param options The required width/height ratio to downsize to before computing the render pass.
  124262. * @param camera The camera to apply the render pass to.
  124263. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124264. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124266. * @param engine The engine which the post process will be applied. (default: current engine)
  124267. * @param reusable If the post process can be reused on the same frame. (default: false)
  124268. * @param textureType Type of textures used when performing the post process. (default: 0)
  124269. * @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)
  124270. */
  124271. 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);
  124272. }
  124273. }
  124274. declare module BABYLON {
  124275. /** @hidden */
  124276. export var depthOfFieldMergePixelShader: {
  124277. name: string;
  124278. shader: string;
  124279. };
  124280. }
  124281. declare module BABYLON {
  124282. /**
  124283. * Options to be set when merging outputs from the default pipeline.
  124284. */
  124285. export class DepthOfFieldMergePostProcessOptions {
  124286. /**
  124287. * The original image to merge on top of
  124288. */
  124289. originalFromInput: PostProcess;
  124290. /**
  124291. * Parameters to perform the merge of the depth of field effect
  124292. */
  124293. depthOfField?: {
  124294. circleOfConfusion: PostProcess;
  124295. blurSteps: Array<PostProcess>;
  124296. };
  124297. /**
  124298. * Parameters to perform the merge of bloom effect
  124299. */
  124300. bloom?: {
  124301. blurred: PostProcess;
  124302. weight: number;
  124303. };
  124304. }
  124305. /**
  124306. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124307. */
  124308. export class DepthOfFieldMergePostProcess extends PostProcess {
  124309. private blurSteps;
  124310. /**
  124311. * Creates a new instance of DepthOfFieldMergePostProcess
  124312. * @param name The name of the effect.
  124313. * @param originalFromInput Post process which's input will be used for the merge.
  124314. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124315. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124316. * @param options The required width/height ratio to downsize to before computing the render pass.
  124317. * @param camera The camera to apply the render pass to.
  124318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124319. * @param engine The engine which the post process will be applied. (default: current engine)
  124320. * @param reusable If the post process can be reused on the same frame. (default: false)
  124321. * @param textureType Type of textures used when performing the post process. (default: 0)
  124322. * @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)
  124323. */
  124324. 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);
  124325. /**
  124326. * Updates the effect with the current post process compile time values and recompiles the shader.
  124327. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124328. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124329. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124330. * @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
  124331. * @param onCompiled Called when the shader has been compiled.
  124332. * @param onError Called if there is an error when compiling a shader.
  124333. */
  124334. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124335. }
  124336. }
  124337. declare module BABYLON {
  124338. /**
  124339. * Specifies the level of max blur that should be applied when using the depth of field effect
  124340. */
  124341. export enum DepthOfFieldEffectBlurLevel {
  124342. /**
  124343. * Subtle blur
  124344. */
  124345. Low = 0,
  124346. /**
  124347. * Medium blur
  124348. */
  124349. Medium = 1,
  124350. /**
  124351. * Large blur
  124352. */
  124353. High = 2
  124354. }
  124355. /**
  124356. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124357. */
  124358. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124359. private _circleOfConfusion;
  124360. /**
  124361. * @hidden Internal, blurs from high to low
  124362. */
  124363. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124364. private _depthOfFieldBlurY;
  124365. private _dofMerge;
  124366. /**
  124367. * @hidden Internal post processes in depth of field effect
  124368. */
  124369. _effects: Array<PostProcess>;
  124370. /**
  124371. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124372. */
  124373. focalLength: number;
  124374. /**
  124375. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124376. */
  124377. fStop: number;
  124378. /**
  124379. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124380. */
  124381. focusDistance: number;
  124382. /**
  124383. * 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.
  124384. */
  124385. lensSize: number;
  124386. /**
  124387. * Creates a new instance DepthOfFieldEffect
  124388. * @param scene The scene the effect belongs to.
  124389. * @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.
  124390. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124391. * @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)
  124392. */
  124393. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124394. /**
  124395. * Get the current class name of the current effet
  124396. * @returns "DepthOfFieldEffect"
  124397. */
  124398. getClassName(): string;
  124399. /**
  124400. * 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.
  124401. */
  124402. depthTexture: RenderTargetTexture;
  124403. /**
  124404. * Disposes each of the internal effects for a given camera.
  124405. * @param camera The camera to dispose the effect on.
  124406. */
  124407. disposeEffects(camera: Camera): void;
  124408. /**
  124409. * @hidden Internal
  124410. */
  124411. _updateEffects(): void;
  124412. /**
  124413. * Internal
  124414. * @returns if all the contained post processes are ready.
  124415. * @hidden
  124416. */
  124417. _isReady(): boolean;
  124418. }
  124419. }
  124420. declare module BABYLON {
  124421. /** @hidden */
  124422. export var displayPassPixelShader: {
  124423. name: string;
  124424. shader: string;
  124425. };
  124426. }
  124427. declare module BABYLON {
  124428. /**
  124429. * DisplayPassPostProcess which produces an output the same as it's input
  124430. */
  124431. export class DisplayPassPostProcess extends PostProcess {
  124432. /**
  124433. * Creates the DisplayPassPostProcess
  124434. * @param name The name of the effect.
  124435. * @param options The required width/height ratio to downsize to before computing the render pass.
  124436. * @param camera The camera to apply the render pass to.
  124437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124438. * @param engine The engine which the post process will be applied. (default: current engine)
  124439. * @param reusable If the post process can be reused on the same frame. (default: false)
  124440. */
  124441. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124442. }
  124443. }
  124444. declare module BABYLON {
  124445. /** @hidden */
  124446. export var filterPixelShader: {
  124447. name: string;
  124448. shader: string;
  124449. };
  124450. }
  124451. declare module BABYLON {
  124452. /**
  124453. * Applies a kernel filter to the image
  124454. */
  124455. export class FilterPostProcess extends PostProcess {
  124456. /** The matrix to be applied to the image */
  124457. kernelMatrix: Matrix;
  124458. /**
  124459. *
  124460. * @param name The name of the effect.
  124461. * @param kernelMatrix The matrix to be applied to the image
  124462. * @param options The required width/height ratio to downsize to before computing the render pass.
  124463. * @param camera The camera to apply the render pass to.
  124464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124465. * @param engine The engine which the post process will be applied. (default: current engine)
  124466. * @param reusable If the post process can be reused on the same frame. (default: false)
  124467. */
  124468. constructor(name: string,
  124469. /** The matrix to be applied to the image */
  124470. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124471. }
  124472. }
  124473. declare module BABYLON {
  124474. /** @hidden */
  124475. export var fxaaPixelShader: {
  124476. name: string;
  124477. shader: string;
  124478. };
  124479. }
  124480. declare module BABYLON {
  124481. /** @hidden */
  124482. export var fxaaVertexShader: {
  124483. name: string;
  124484. shader: string;
  124485. };
  124486. }
  124487. declare module BABYLON {
  124488. /**
  124489. * Fxaa post process
  124490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124491. */
  124492. export class FxaaPostProcess extends PostProcess {
  124493. /** @hidden */
  124494. texelWidth: number;
  124495. /** @hidden */
  124496. texelHeight: number;
  124497. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124498. private _getDefines;
  124499. }
  124500. }
  124501. declare module BABYLON {
  124502. /** @hidden */
  124503. export var grainPixelShader: {
  124504. name: string;
  124505. shader: string;
  124506. };
  124507. }
  124508. declare module BABYLON {
  124509. /**
  124510. * The GrainPostProcess adds noise to the image at mid luminance levels
  124511. */
  124512. export class GrainPostProcess extends PostProcess {
  124513. /**
  124514. * The intensity of the grain added (default: 30)
  124515. */
  124516. intensity: number;
  124517. /**
  124518. * If the grain should be randomized on every frame
  124519. */
  124520. animated: boolean;
  124521. /**
  124522. * Creates a new instance of @see GrainPostProcess
  124523. * @param name The name of the effect.
  124524. * @param options The required width/height ratio to downsize to before computing the render pass.
  124525. * @param camera The camera to apply the render pass to.
  124526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124527. * @param engine The engine which the post process will be applied. (default: current engine)
  124528. * @param reusable If the post process can be reused on the same frame. (default: false)
  124529. * @param textureType Type of textures used when performing the post process. (default: 0)
  124530. * @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)
  124531. */
  124532. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124533. }
  124534. }
  124535. declare module BABYLON {
  124536. /** @hidden */
  124537. export var highlightsPixelShader: {
  124538. name: string;
  124539. shader: string;
  124540. };
  124541. }
  124542. declare module BABYLON {
  124543. /**
  124544. * Extracts highlights from the image
  124545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124546. */
  124547. export class HighlightsPostProcess extends PostProcess {
  124548. /**
  124549. * Extracts highlights from the image
  124550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124551. * @param name The name of the effect.
  124552. * @param options The required width/height ratio to downsize to before computing the render pass.
  124553. * @param camera The camera to apply the render pass to.
  124554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124555. * @param engine The engine which the post process will be applied. (default: current engine)
  124556. * @param reusable If the post process can be reused on the same frame. (default: false)
  124557. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124558. */
  124559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124560. }
  124561. }
  124562. declare module BABYLON {
  124563. /** @hidden */
  124564. export var mrtFragmentDeclaration: {
  124565. name: string;
  124566. shader: string;
  124567. };
  124568. }
  124569. declare module BABYLON {
  124570. /** @hidden */
  124571. export var geometryPixelShader: {
  124572. name: string;
  124573. shader: string;
  124574. };
  124575. }
  124576. declare module BABYLON {
  124577. /** @hidden */
  124578. export var geometryVertexShader: {
  124579. name: string;
  124580. shader: string;
  124581. };
  124582. }
  124583. declare module BABYLON {
  124584. /** @hidden */
  124585. interface ISavedTransformationMatrix {
  124586. world: Matrix;
  124587. viewProjection: Matrix;
  124588. }
  124589. /**
  124590. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124591. */
  124592. export class GeometryBufferRenderer {
  124593. /**
  124594. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124595. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124596. */
  124597. static readonly POSITION_TEXTURE_TYPE: number;
  124598. /**
  124599. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124600. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124601. */
  124602. static readonly VELOCITY_TEXTURE_TYPE: number;
  124603. /**
  124604. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124605. * in order to compute objects velocities when enableVelocity is set to "true"
  124606. * @hidden
  124607. */
  124608. _previousTransformationMatrices: {
  124609. [index: number]: ISavedTransformationMatrix;
  124610. };
  124611. /**
  124612. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124613. * in order to compute objects velocities when enableVelocity is set to "true"
  124614. * @hidden
  124615. */
  124616. _previousBonesTransformationMatrices: {
  124617. [index: number]: Float32Array;
  124618. };
  124619. /**
  124620. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124621. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124622. */
  124623. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124624. private _scene;
  124625. private _multiRenderTarget;
  124626. private _ratio;
  124627. private _enablePosition;
  124628. private _enableVelocity;
  124629. private _positionIndex;
  124630. private _velocityIndex;
  124631. protected _effect: Effect;
  124632. protected _cachedDefines: string;
  124633. /**
  124634. * Set the render list (meshes to be rendered) used in the G buffer.
  124635. */
  124636. renderList: Mesh[];
  124637. /**
  124638. * Gets wether or not G buffer are supported by the running hardware.
  124639. * This requires draw buffer supports
  124640. */
  124641. readonly isSupported: boolean;
  124642. /**
  124643. * Returns the index of the given texture type in the G-Buffer textures array
  124644. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124645. * @returns the index of the given texture type in the G-Buffer textures array
  124646. */
  124647. getTextureIndex(textureType: number): number;
  124648. /**
  124649. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124650. */
  124651. /**
  124652. * Sets whether or not objects positions are enabled for the G buffer.
  124653. */
  124654. enablePosition: boolean;
  124655. /**
  124656. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124657. */
  124658. /**
  124659. * Sets wether or not objects velocities are enabled for the G buffer.
  124660. */
  124661. enableVelocity: boolean;
  124662. /**
  124663. * Gets the scene associated with the buffer.
  124664. */
  124665. readonly scene: Scene;
  124666. /**
  124667. * Gets the ratio used by the buffer during its creation.
  124668. * How big is the buffer related to the main canvas.
  124669. */
  124670. readonly ratio: number;
  124671. /** @hidden */
  124672. static _SceneComponentInitialization: (scene: Scene) => void;
  124673. /**
  124674. * Creates a new G Buffer for the scene
  124675. * @param scene The scene the buffer belongs to
  124676. * @param ratio How big is the buffer related to the main canvas.
  124677. */
  124678. constructor(scene: Scene, ratio?: number);
  124679. /**
  124680. * Checks wether everything is ready to render a submesh to the G buffer.
  124681. * @param subMesh the submesh to check readiness for
  124682. * @param useInstances is the mesh drawn using instance or not
  124683. * @returns true if ready otherwise false
  124684. */
  124685. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124686. /**
  124687. * Gets the current underlying G Buffer.
  124688. * @returns the buffer
  124689. */
  124690. getGBuffer(): MultiRenderTarget;
  124691. /**
  124692. * Gets the number of samples used to render the buffer (anti aliasing).
  124693. */
  124694. /**
  124695. * Sets the number of samples used to render the buffer (anti aliasing).
  124696. */
  124697. samples: number;
  124698. /**
  124699. * Disposes the renderer and frees up associated resources.
  124700. */
  124701. dispose(): void;
  124702. protected _createRenderTargets(): void;
  124703. private _copyBonesTransformationMatrices;
  124704. }
  124705. }
  124706. declare module BABYLON {
  124707. interface Scene {
  124708. /** @hidden (Backing field) */
  124709. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124710. /**
  124711. * Gets or Sets the current geometry buffer associated to the scene.
  124712. */
  124713. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124714. /**
  124715. * Enables a GeometryBufferRender and associates it with the scene
  124716. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124717. * @returns the GeometryBufferRenderer
  124718. */
  124719. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124720. /**
  124721. * Disables the GeometryBufferRender associated with the scene
  124722. */
  124723. disableGeometryBufferRenderer(): void;
  124724. }
  124725. /**
  124726. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124727. * in several rendering techniques.
  124728. */
  124729. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124730. /**
  124731. * The component name helpful to identify the component in the list of scene components.
  124732. */
  124733. readonly name: string;
  124734. /**
  124735. * The scene the component belongs to.
  124736. */
  124737. scene: Scene;
  124738. /**
  124739. * Creates a new instance of the component for the given scene
  124740. * @param scene Defines the scene to register the component in
  124741. */
  124742. constructor(scene: Scene);
  124743. /**
  124744. * Registers the component in a given scene
  124745. */
  124746. register(): void;
  124747. /**
  124748. * Rebuilds the elements related to this component in case of
  124749. * context lost for instance.
  124750. */
  124751. rebuild(): void;
  124752. /**
  124753. * Disposes the component and the associated ressources
  124754. */
  124755. dispose(): void;
  124756. private _gatherRenderTargets;
  124757. }
  124758. }
  124759. declare module BABYLON {
  124760. /** @hidden */
  124761. export var motionBlurPixelShader: {
  124762. name: string;
  124763. shader: string;
  124764. };
  124765. }
  124766. declare module BABYLON {
  124767. /**
  124768. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124769. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124770. * As an example, all you have to do is to create the post-process:
  124771. * var mb = new BABYLON.MotionBlurPostProcess(
  124772. * 'mb', // The name of the effect.
  124773. * scene, // The scene containing the objects to blur according to their velocity.
  124774. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124775. * camera // The camera to apply the render pass to.
  124776. * );
  124777. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124778. */
  124779. export class MotionBlurPostProcess extends PostProcess {
  124780. /**
  124781. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124782. */
  124783. motionStrength: number;
  124784. /**
  124785. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124786. */
  124787. /**
  124788. * Sets the number of iterations to be used for motion blur quality
  124789. */
  124790. motionBlurSamples: number;
  124791. private _motionBlurSamples;
  124792. private _geometryBufferRenderer;
  124793. /**
  124794. * Creates a new instance MotionBlurPostProcess
  124795. * @param name The name of the effect.
  124796. * @param scene The scene containing the objects to blur according to their velocity.
  124797. * @param options The required width/height ratio to downsize to before computing the render pass.
  124798. * @param camera The camera to apply the render pass to.
  124799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124800. * @param engine The engine which the post process will be applied. (default: current engine)
  124801. * @param reusable If the post process can be reused on the same frame. (default: false)
  124802. * @param textureType Type of textures used when performing the post process. (default: 0)
  124803. * @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)
  124804. */
  124805. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124806. /**
  124807. * Excludes the given skinned mesh from computing bones velocities.
  124808. * 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.
  124809. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124810. */
  124811. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124812. /**
  124813. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124814. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124815. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124816. */
  124817. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124818. /**
  124819. * Disposes the post process.
  124820. * @param camera The camera to dispose the post process on.
  124821. */
  124822. dispose(camera?: Camera): void;
  124823. }
  124824. }
  124825. declare module BABYLON {
  124826. /** @hidden */
  124827. export var refractionPixelShader: {
  124828. name: string;
  124829. shader: string;
  124830. };
  124831. }
  124832. declare module BABYLON {
  124833. /**
  124834. * Post process which applies a refractin texture
  124835. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124836. */
  124837. export class RefractionPostProcess extends PostProcess {
  124838. /** the base color of the refraction (used to taint the rendering) */
  124839. color: Color3;
  124840. /** simulated refraction depth */
  124841. depth: number;
  124842. /** the coefficient of the base color (0 to remove base color tainting) */
  124843. colorLevel: number;
  124844. private _refTexture;
  124845. private _ownRefractionTexture;
  124846. /**
  124847. * Gets or sets the refraction texture
  124848. * Please note that you are responsible for disposing the texture if you set it manually
  124849. */
  124850. refractionTexture: Texture;
  124851. /**
  124852. * Initializes the RefractionPostProcess
  124853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124854. * @param name The name of the effect.
  124855. * @param refractionTextureUrl Url of the refraction texture to use
  124856. * @param color the base color of the refraction (used to taint the rendering)
  124857. * @param depth simulated refraction depth
  124858. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124859. * @param camera The camera to apply the render pass to.
  124860. * @param options The required width/height ratio to downsize to before computing the render pass.
  124861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124862. * @param engine The engine which the post process will be applied. (default: current engine)
  124863. * @param reusable If the post process can be reused on the same frame. (default: false)
  124864. */
  124865. constructor(name: string, refractionTextureUrl: string,
  124866. /** the base color of the refraction (used to taint the rendering) */
  124867. color: Color3,
  124868. /** simulated refraction depth */
  124869. depth: number,
  124870. /** the coefficient of the base color (0 to remove base color tainting) */
  124871. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124872. /**
  124873. * Disposes of the post process
  124874. * @param camera Camera to dispose post process on
  124875. */
  124876. dispose(camera: Camera): void;
  124877. }
  124878. }
  124879. declare module BABYLON {
  124880. /** @hidden */
  124881. export var sharpenPixelShader: {
  124882. name: string;
  124883. shader: string;
  124884. };
  124885. }
  124886. declare module BABYLON {
  124887. /**
  124888. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124889. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124890. */
  124891. export class SharpenPostProcess extends PostProcess {
  124892. /**
  124893. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124894. */
  124895. colorAmount: number;
  124896. /**
  124897. * How much sharpness should be applied (default: 0.3)
  124898. */
  124899. edgeAmount: number;
  124900. /**
  124901. * Creates a new instance ConvolutionPostProcess
  124902. * @param name The name of the effect.
  124903. * @param options The required width/height ratio to downsize to before computing the render pass.
  124904. * @param camera The camera to apply the render pass to.
  124905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124906. * @param engine The engine which the post process will be applied. (default: current engine)
  124907. * @param reusable If the post process can be reused on the same frame. (default: false)
  124908. * @param textureType Type of textures used when performing the post process. (default: 0)
  124909. * @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)
  124910. */
  124911. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124912. }
  124913. }
  124914. declare module BABYLON {
  124915. /**
  124916. * PostProcessRenderPipeline
  124917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124918. */
  124919. export class PostProcessRenderPipeline {
  124920. private engine;
  124921. private _renderEffects;
  124922. private _renderEffectsForIsolatedPass;
  124923. /**
  124924. * List of inspectable custom properties (used by the Inspector)
  124925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124926. */
  124927. inspectableCustomProperties: IInspectable[];
  124928. /**
  124929. * @hidden
  124930. */
  124931. protected _cameras: Camera[];
  124932. /** @hidden */
  124933. _name: string;
  124934. /**
  124935. * Gets pipeline name
  124936. */
  124937. readonly name: string;
  124938. /**
  124939. * Initializes a PostProcessRenderPipeline
  124940. * @param engine engine to add the pipeline to
  124941. * @param name name of the pipeline
  124942. */
  124943. constructor(engine: Engine, name: string);
  124944. /**
  124945. * Gets the class name
  124946. * @returns "PostProcessRenderPipeline"
  124947. */
  124948. getClassName(): string;
  124949. /**
  124950. * If all the render effects in the pipeline are supported
  124951. */
  124952. readonly isSupported: boolean;
  124953. /**
  124954. * Adds an effect to the pipeline
  124955. * @param renderEffect the effect to add
  124956. */
  124957. addEffect(renderEffect: PostProcessRenderEffect): void;
  124958. /** @hidden */
  124959. _rebuild(): void;
  124960. /** @hidden */
  124961. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124962. /** @hidden */
  124963. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124964. /** @hidden */
  124965. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124966. /** @hidden */
  124967. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124968. /** @hidden */
  124969. _attachCameras(cameras: Camera, unique: boolean): void;
  124970. /** @hidden */
  124971. _attachCameras(cameras: Camera[], unique: boolean): void;
  124972. /** @hidden */
  124973. _detachCameras(cameras: Camera): void;
  124974. /** @hidden */
  124975. _detachCameras(cameras: Nullable<Camera[]>): void;
  124976. /** @hidden */
  124977. _update(): void;
  124978. /** @hidden */
  124979. _reset(): void;
  124980. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124981. /**
  124982. * Disposes of the pipeline
  124983. */
  124984. dispose(): void;
  124985. }
  124986. }
  124987. declare module BABYLON {
  124988. /**
  124989. * PostProcessRenderPipelineManager class
  124990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124991. */
  124992. export class PostProcessRenderPipelineManager {
  124993. private _renderPipelines;
  124994. /**
  124995. * Initializes a PostProcessRenderPipelineManager
  124996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124997. */
  124998. constructor();
  124999. /**
  125000. * Gets the list of supported render pipelines
  125001. */
  125002. readonly supportedPipelines: PostProcessRenderPipeline[];
  125003. /**
  125004. * Adds a pipeline to the manager
  125005. * @param renderPipeline The pipeline to add
  125006. */
  125007. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  125008. /**
  125009. * Attaches a camera to the pipeline
  125010. * @param renderPipelineName The name of the pipeline to attach to
  125011. * @param cameras the camera to attach
  125012. * @param unique if the camera can be attached multiple times to the pipeline
  125013. */
  125014. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  125015. /**
  125016. * Detaches a camera from the pipeline
  125017. * @param renderPipelineName The name of the pipeline to detach from
  125018. * @param cameras the camera to detach
  125019. */
  125020. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  125021. /**
  125022. * Enables an effect by name on a pipeline
  125023. * @param renderPipelineName the name of the pipeline to enable the effect in
  125024. * @param renderEffectName the name of the effect to enable
  125025. * @param cameras the cameras that the effect should be enabled on
  125026. */
  125027. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125028. /**
  125029. * Disables an effect by name on a pipeline
  125030. * @param renderPipelineName the name of the pipeline to disable the effect in
  125031. * @param renderEffectName the name of the effect to disable
  125032. * @param cameras the cameras that the effect should be disabled on
  125033. */
  125034. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  125035. /**
  125036. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  125037. */
  125038. update(): void;
  125039. /** @hidden */
  125040. _rebuild(): void;
  125041. /**
  125042. * Disposes of the manager and pipelines
  125043. */
  125044. dispose(): void;
  125045. }
  125046. }
  125047. declare module BABYLON {
  125048. interface Scene {
  125049. /** @hidden (Backing field) */
  125050. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125051. /**
  125052. * Gets the postprocess render pipeline manager
  125053. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125054. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125055. */
  125056. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125057. }
  125058. /**
  125059. * Defines the Render Pipeline scene component responsible to rendering pipelines
  125060. */
  125061. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  125062. /**
  125063. * The component name helpfull to identify the component in the list of scene components.
  125064. */
  125065. readonly name: string;
  125066. /**
  125067. * The scene the component belongs to.
  125068. */
  125069. scene: Scene;
  125070. /**
  125071. * Creates a new instance of the component for the given scene
  125072. * @param scene Defines the scene to register the component in
  125073. */
  125074. constructor(scene: Scene);
  125075. /**
  125076. * Registers the component in a given scene
  125077. */
  125078. register(): void;
  125079. /**
  125080. * Rebuilds the elements related to this component in case of
  125081. * context lost for instance.
  125082. */
  125083. rebuild(): void;
  125084. /**
  125085. * Disposes the component and the associated ressources
  125086. */
  125087. dispose(): void;
  125088. private _gatherRenderTargets;
  125089. }
  125090. }
  125091. declare module BABYLON {
  125092. /**
  125093. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  125094. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125095. */
  125096. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125097. private _scene;
  125098. private _camerasToBeAttached;
  125099. /**
  125100. * ID of the sharpen post process,
  125101. */
  125102. private readonly SharpenPostProcessId;
  125103. /**
  125104. * @ignore
  125105. * ID of the image processing post process;
  125106. */
  125107. readonly ImageProcessingPostProcessId: string;
  125108. /**
  125109. * @ignore
  125110. * ID of the Fast Approximate Anti-Aliasing post process;
  125111. */
  125112. readonly FxaaPostProcessId: string;
  125113. /**
  125114. * ID of the chromatic aberration post process,
  125115. */
  125116. private readonly ChromaticAberrationPostProcessId;
  125117. /**
  125118. * ID of the grain post process
  125119. */
  125120. private readonly GrainPostProcessId;
  125121. /**
  125122. * Sharpen post process which will apply a sharpen convolution to enhance edges
  125123. */
  125124. sharpen: SharpenPostProcess;
  125125. private _sharpenEffect;
  125126. private bloom;
  125127. /**
  125128. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  125129. */
  125130. depthOfField: DepthOfFieldEffect;
  125131. /**
  125132. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125133. */
  125134. fxaa: FxaaPostProcess;
  125135. /**
  125136. * Image post processing pass used to perform operations such as tone mapping or color grading.
  125137. */
  125138. imageProcessing: ImageProcessingPostProcess;
  125139. /**
  125140. * Chromatic aberration post process which will shift rgb colors in the image
  125141. */
  125142. chromaticAberration: ChromaticAberrationPostProcess;
  125143. private _chromaticAberrationEffect;
  125144. /**
  125145. * Grain post process which add noise to the image
  125146. */
  125147. grain: GrainPostProcess;
  125148. private _grainEffect;
  125149. /**
  125150. * Glow post process which adds a glow to emissive areas of the image
  125151. */
  125152. private _glowLayer;
  125153. /**
  125154. * Animations which can be used to tweak settings over a period of time
  125155. */
  125156. animations: Animation[];
  125157. private _imageProcessingConfigurationObserver;
  125158. private _sharpenEnabled;
  125159. private _bloomEnabled;
  125160. private _depthOfFieldEnabled;
  125161. private _depthOfFieldBlurLevel;
  125162. private _fxaaEnabled;
  125163. private _imageProcessingEnabled;
  125164. private _defaultPipelineTextureType;
  125165. private _bloomScale;
  125166. private _chromaticAberrationEnabled;
  125167. private _grainEnabled;
  125168. private _buildAllowed;
  125169. /**
  125170. * Gets active scene
  125171. */
  125172. readonly scene: Scene;
  125173. /**
  125174. * Enable or disable the sharpen process from the pipeline
  125175. */
  125176. sharpenEnabled: boolean;
  125177. private _resizeObserver;
  125178. private _hardwareScaleLevel;
  125179. private _bloomKernel;
  125180. /**
  125181. * Specifies the size of the bloom blur kernel, relative to the final output size
  125182. */
  125183. bloomKernel: number;
  125184. /**
  125185. * Specifies the weight of the bloom in the final rendering
  125186. */
  125187. private _bloomWeight;
  125188. /**
  125189. * Specifies the luma threshold for the area that will be blurred by the bloom
  125190. */
  125191. private _bloomThreshold;
  125192. private _hdr;
  125193. /**
  125194. * The strength of the bloom.
  125195. */
  125196. bloomWeight: number;
  125197. /**
  125198. * The strength of the bloom.
  125199. */
  125200. bloomThreshold: number;
  125201. /**
  125202. * The scale of the bloom, lower value will provide better performance.
  125203. */
  125204. bloomScale: number;
  125205. /**
  125206. * Enable or disable the bloom from the pipeline
  125207. */
  125208. bloomEnabled: boolean;
  125209. private _rebuildBloom;
  125210. /**
  125211. * If the depth of field is enabled.
  125212. */
  125213. depthOfFieldEnabled: boolean;
  125214. /**
  125215. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125216. */
  125217. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125218. /**
  125219. * If the anti aliasing is enabled.
  125220. */
  125221. fxaaEnabled: boolean;
  125222. private _samples;
  125223. /**
  125224. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125225. */
  125226. samples: number;
  125227. /**
  125228. * If image processing is enabled.
  125229. */
  125230. imageProcessingEnabled: boolean;
  125231. /**
  125232. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125233. */
  125234. glowLayerEnabled: boolean;
  125235. /**
  125236. * Gets the glow layer (or null if not defined)
  125237. */
  125238. readonly glowLayer: Nullable<GlowLayer>;
  125239. /**
  125240. * Enable or disable the chromaticAberration process from the pipeline
  125241. */
  125242. chromaticAberrationEnabled: boolean;
  125243. /**
  125244. * Enable or disable the grain process from the pipeline
  125245. */
  125246. grainEnabled: boolean;
  125247. /**
  125248. * @constructor
  125249. * @param name - The rendering pipeline name (default: "")
  125250. * @param hdr - If high dynamic range textures should be used (default: true)
  125251. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125252. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125253. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125254. */
  125255. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125256. /**
  125257. * Get the class name
  125258. * @returns "DefaultRenderingPipeline"
  125259. */
  125260. getClassName(): string;
  125261. /**
  125262. * Force the compilation of the entire pipeline.
  125263. */
  125264. prepare(): void;
  125265. private _hasCleared;
  125266. private _prevPostProcess;
  125267. private _prevPrevPostProcess;
  125268. private _setAutoClearAndTextureSharing;
  125269. private _depthOfFieldSceneObserver;
  125270. private _buildPipeline;
  125271. private _disposePostProcesses;
  125272. /**
  125273. * Adds a camera to the pipeline
  125274. * @param camera the camera to be added
  125275. */
  125276. addCamera(camera: Camera): void;
  125277. /**
  125278. * Removes a camera from the pipeline
  125279. * @param camera the camera to remove
  125280. */
  125281. removeCamera(camera: Camera): void;
  125282. /**
  125283. * Dispose of the pipeline and stop all post processes
  125284. */
  125285. dispose(): void;
  125286. /**
  125287. * Serialize the rendering pipeline (Used when exporting)
  125288. * @returns the serialized object
  125289. */
  125290. serialize(): any;
  125291. /**
  125292. * Parse the serialized pipeline
  125293. * @param source Source pipeline.
  125294. * @param scene The scene to load the pipeline to.
  125295. * @param rootUrl The URL of the serialized pipeline.
  125296. * @returns An instantiated pipeline from the serialized object.
  125297. */
  125298. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125299. }
  125300. }
  125301. declare module BABYLON {
  125302. /** @hidden */
  125303. export var lensHighlightsPixelShader: {
  125304. name: string;
  125305. shader: string;
  125306. };
  125307. }
  125308. declare module BABYLON {
  125309. /** @hidden */
  125310. export var depthOfFieldPixelShader: {
  125311. name: string;
  125312. shader: string;
  125313. };
  125314. }
  125315. declare module BABYLON {
  125316. /**
  125317. * BABYLON.JS Chromatic Aberration GLSL Shader
  125318. * Author: Olivier Guyot
  125319. * Separates very slightly R, G and B colors on the edges of the screen
  125320. * Inspired by Francois Tarlier & Martins Upitis
  125321. */
  125322. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125323. /**
  125324. * @ignore
  125325. * The chromatic aberration PostProcess id in the pipeline
  125326. */
  125327. LensChromaticAberrationEffect: string;
  125328. /**
  125329. * @ignore
  125330. * The highlights enhancing PostProcess id in the pipeline
  125331. */
  125332. HighlightsEnhancingEffect: string;
  125333. /**
  125334. * @ignore
  125335. * The depth-of-field PostProcess id in the pipeline
  125336. */
  125337. LensDepthOfFieldEffect: string;
  125338. private _scene;
  125339. private _depthTexture;
  125340. private _grainTexture;
  125341. private _chromaticAberrationPostProcess;
  125342. private _highlightsPostProcess;
  125343. private _depthOfFieldPostProcess;
  125344. private _edgeBlur;
  125345. private _grainAmount;
  125346. private _chromaticAberration;
  125347. private _distortion;
  125348. private _highlightsGain;
  125349. private _highlightsThreshold;
  125350. private _dofDistance;
  125351. private _dofAperture;
  125352. private _dofDarken;
  125353. private _dofPentagon;
  125354. private _blurNoise;
  125355. /**
  125356. * @constructor
  125357. *
  125358. * Effect parameters are as follow:
  125359. * {
  125360. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125361. * edge_blur: number; // from 0 to x (1 for realism)
  125362. * distortion: number; // from 0 to x (1 for realism)
  125363. * grain_amount: number; // from 0 to 1
  125364. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125365. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125366. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125367. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125368. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125369. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125370. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125371. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125372. * }
  125373. * Note: if an effect parameter is unset, effect is disabled
  125374. *
  125375. * @param name The rendering pipeline name
  125376. * @param parameters - An object containing all parameters (see above)
  125377. * @param scene The scene linked to this pipeline
  125378. * @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)
  125379. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125380. */
  125381. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125382. /**
  125383. * Get the class name
  125384. * @returns "LensRenderingPipeline"
  125385. */
  125386. getClassName(): string;
  125387. /**
  125388. * Gets associated scene
  125389. */
  125390. readonly scene: Scene;
  125391. /**
  125392. * Gets or sets the edge blur
  125393. */
  125394. edgeBlur: number;
  125395. /**
  125396. * Gets or sets the grain amount
  125397. */
  125398. grainAmount: number;
  125399. /**
  125400. * Gets or sets the chromatic aberration amount
  125401. */
  125402. chromaticAberration: number;
  125403. /**
  125404. * Gets or sets the depth of field aperture
  125405. */
  125406. dofAperture: number;
  125407. /**
  125408. * Gets or sets the edge distortion
  125409. */
  125410. edgeDistortion: number;
  125411. /**
  125412. * Gets or sets the depth of field distortion
  125413. */
  125414. dofDistortion: number;
  125415. /**
  125416. * Gets or sets the darken out of focus amount
  125417. */
  125418. darkenOutOfFocus: number;
  125419. /**
  125420. * Gets or sets a boolean indicating if blur noise is enabled
  125421. */
  125422. blurNoise: boolean;
  125423. /**
  125424. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125425. */
  125426. pentagonBokeh: boolean;
  125427. /**
  125428. * Gets or sets the highlight grain amount
  125429. */
  125430. highlightsGain: number;
  125431. /**
  125432. * Gets or sets the highlight threshold
  125433. */
  125434. highlightsThreshold: number;
  125435. /**
  125436. * Sets the amount of blur at the edges
  125437. * @param amount blur amount
  125438. */
  125439. setEdgeBlur(amount: number): void;
  125440. /**
  125441. * Sets edge blur to 0
  125442. */
  125443. disableEdgeBlur(): void;
  125444. /**
  125445. * Sets the amout of grain
  125446. * @param amount Amount of grain
  125447. */
  125448. setGrainAmount(amount: number): void;
  125449. /**
  125450. * Set grain amount to 0
  125451. */
  125452. disableGrain(): void;
  125453. /**
  125454. * Sets the chromatic aberration amount
  125455. * @param amount amount of chromatic aberration
  125456. */
  125457. setChromaticAberration(amount: number): void;
  125458. /**
  125459. * Sets chromatic aberration amount to 0
  125460. */
  125461. disableChromaticAberration(): void;
  125462. /**
  125463. * Sets the EdgeDistortion amount
  125464. * @param amount amount of EdgeDistortion
  125465. */
  125466. setEdgeDistortion(amount: number): void;
  125467. /**
  125468. * Sets edge distortion to 0
  125469. */
  125470. disableEdgeDistortion(): void;
  125471. /**
  125472. * Sets the FocusDistance amount
  125473. * @param amount amount of FocusDistance
  125474. */
  125475. setFocusDistance(amount: number): void;
  125476. /**
  125477. * Disables depth of field
  125478. */
  125479. disableDepthOfField(): void;
  125480. /**
  125481. * Sets the Aperture amount
  125482. * @param amount amount of Aperture
  125483. */
  125484. setAperture(amount: number): void;
  125485. /**
  125486. * Sets the DarkenOutOfFocus amount
  125487. * @param amount amount of DarkenOutOfFocus
  125488. */
  125489. setDarkenOutOfFocus(amount: number): void;
  125490. private _pentagonBokehIsEnabled;
  125491. /**
  125492. * Creates a pentagon bokeh effect
  125493. */
  125494. enablePentagonBokeh(): void;
  125495. /**
  125496. * Disables the pentagon bokeh effect
  125497. */
  125498. disablePentagonBokeh(): void;
  125499. /**
  125500. * Enables noise blur
  125501. */
  125502. enableNoiseBlur(): void;
  125503. /**
  125504. * Disables noise blur
  125505. */
  125506. disableNoiseBlur(): void;
  125507. /**
  125508. * Sets the HighlightsGain amount
  125509. * @param amount amount of HighlightsGain
  125510. */
  125511. setHighlightsGain(amount: number): void;
  125512. /**
  125513. * Sets the HighlightsThreshold amount
  125514. * @param amount amount of HighlightsThreshold
  125515. */
  125516. setHighlightsThreshold(amount: number): void;
  125517. /**
  125518. * Disables highlights
  125519. */
  125520. disableHighlights(): void;
  125521. /**
  125522. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125523. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125524. */
  125525. dispose(disableDepthRender?: boolean): void;
  125526. private _createChromaticAberrationPostProcess;
  125527. private _createHighlightsPostProcess;
  125528. private _createDepthOfFieldPostProcess;
  125529. private _createGrainTexture;
  125530. }
  125531. }
  125532. declare module BABYLON {
  125533. /** @hidden */
  125534. export var ssao2PixelShader: {
  125535. name: string;
  125536. shader: string;
  125537. };
  125538. }
  125539. declare module BABYLON {
  125540. /** @hidden */
  125541. export var ssaoCombinePixelShader: {
  125542. name: string;
  125543. shader: string;
  125544. };
  125545. }
  125546. declare module BABYLON {
  125547. /**
  125548. * Render pipeline to produce ssao effect
  125549. */
  125550. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125551. /**
  125552. * @ignore
  125553. * The PassPostProcess id in the pipeline that contains the original scene color
  125554. */
  125555. SSAOOriginalSceneColorEffect: string;
  125556. /**
  125557. * @ignore
  125558. * The SSAO PostProcess id in the pipeline
  125559. */
  125560. SSAORenderEffect: string;
  125561. /**
  125562. * @ignore
  125563. * The horizontal blur PostProcess id in the pipeline
  125564. */
  125565. SSAOBlurHRenderEffect: string;
  125566. /**
  125567. * @ignore
  125568. * The vertical blur PostProcess id in the pipeline
  125569. */
  125570. SSAOBlurVRenderEffect: string;
  125571. /**
  125572. * @ignore
  125573. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125574. */
  125575. SSAOCombineRenderEffect: string;
  125576. /**
  125577. * The output strength of the SSAO post-process. Default value is 1.0.
  125578. */
  125579. totalStrength: number;
  125580. /**
  125581. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125582. */
  125583. maxZ: number;
  125584. /**
  125585. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125586. */
  125587. minZAspect: number;
  125588. private _samples;
  125589. /**
  125590. * Number of samples used for the SSAO calculations. Default value is 8
  125591. */
  125592. samples: number;
  125593. private _textureSamples;
  125594. /**
  125595. * Number of samples to use for antialiasing
  125596. */
  125597. textureSamples: number;
  125598. /**
  125599. * Ratio object used for SSAO ratio and blur ratio
  125600. */
  125601. private _ratio;
  125602. /**
  125603. * Dynamically generated sphere sampler.
  125604. */
  125605. private _sampleSphere;
  125606. /**
  125607. * Blur filter offsets
  125608. */
  125609. private _samplerOffsets;
  125610. private _expensiveBlur;
  125611. /**
  125612. * If bilateral blur should be used
  125613. */
  125614. expensiveBlur: boolean;
  125615. /**
  125616. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125617. */
  125618. radius: number;
  125619. /**
  125620. * The base color of the SSAO post-process
  125621. * The final result is "base + ssao" between [0, 1]
  125622. */
  125623. base: number;
  125624. /**
  125625. * Support test.
  125626. */
  125627. static readonly IsSupported: boolean;
  125628. private _scene;
  125629. private _depthTexture;
  125630. private _normalTexture;
  125631. private _randomTexture;
  125632. private _originalColorPostProcess;
  125633. private _ssaoPostProcess;
  125634. private _blurHPostProcess;
  125635. private _blurVPostProcess;
  125636. private _ssaoCombinePostProcess;
  125637. private _firstUpdate;
  125638. /**
  125639. * Gets active scene
  125640. */
  125641. readonly scene: Scene;
  125642. /**
  125643. * @constructor
  125644. * @param name The rendering pipeline name
  125645. * @param scene The scene linked to this pipeline
  125646. * @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 }
  125647. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125648. */
  125649. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125650. /**
  125651. * Get the class name
  125652. * @returns "SSAO2RenderingPipeline"
  125653. */
  125654. getClassName(): string;
  125655. /**
  125656. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125657. */
  125658. dispose(disableGeometryBufferRenderer?: boolean): void;
  125659. private _createBlurPostProcess;
  125660. /** @hidden */
  125661. _rebuild(): void;
  125662. private _bits;
  125663. private _radicalInverse_VdC;
  125664. private _hammersley;
  125665. private _hemisphereSample_uniform;
  125666. private _generateHemisphere;
  125667. private _createSSAOPostProcess;
  125668. private _createSSAOCombinePostProcess;
  125669. private _createRandomTexture;
  125670. /**
  125671. * Serialize the rendering pipeline (Used when exporting)
  125672. * @returns the serialized object
  125673. */
  125674. serialize(): any;
  125675. /**
  125676. * Parse the serialized pipeline
  125677. * @param source Source pipeline.
  125678. * @param scene The scene to load the pipeline to.
  125679. * @param rootUrl The URL of the serialized pipeline.
  125680. * @returns An instantiated pipeline from the serialized object.
  125681. */
  125682. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125683. }
  125684. }
  125685. declare module BABYLON {
  125686. /** @hidden */
  125687. export var ssaoPixelShader: {
  125688. name: string;
  125689. shader: string;
  125690. };
  125691. }
  125692. declare module BABYLON {
  125693. /**
  125694. * Render pipeline to produce ssao effect
  125695. */
  125696. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125697. /**
  125698. * @ignore
  125699. * The PassPostProcess id in the pipeline that contains the original scene color
  125700. */
  125701. SSAOOriginalSceneColorEffect: string;
  125702. /**
  125703. * @ignore
  125704. * The SSAO PostProcess id in the pipeline
  125705. */
  125706. SSAORenderEffect: string;
  125707. /**
  125708. * @ignore
  125709. * The horizontal blur PostProcess id in the pipeline
  125710. */
  125711. SSAOBlurHRenderEffect: string;
  125712. /**
  125713. * @ignore
  125714. * The vertical blur PostProcess id in the pipeline
  125715. */
  125716. SSAOBlurVRenderEffect: string;
  125717. /**
  125718. * @ignore
  125719. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125720. */
  125721. SSAOCombineRenderEffect: string;
  125722. /**
  125723. * The output strength of the SSAO post-process. Default value is 1.0.
  125724. */
  125725. totalStrength: number;
  125726. /**
  125727. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125728. */
  125729. radius: number;
  125730. /**
  125731. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125732. * Must not be equal to fallOff and superior to fallOff.
  125733. * Default value is 0.0075
  125734. */
  125735. area: number;
  125736. /**
  125737. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125738. * Must not be equal to area and inferior to area.
  125739. * Default value is 0.000001
  125740. */
  125741. fallOff: number;
  125742. /**
  125743. * The base color of the SSAO post-process
  125744. * The final result is "base + ssao" between [0, 1]
  125745. */
  125746. base: number;
  125747. private _scene;
  125748. private _depthTexture;
  125749. private _randomTexture;
  125750. private _originalColorPostProcess;
  125751. private _ssaoPostProcess;
  125752. private _blurHPostProcess;
  125753. private _blurVPostProcess;
  125754. private _ssaoCombinePostProcess;
  125755. private _firstUpdate;
  125756. /**
  125757. * Gets active scene
  125758. */
  125759. readonly scene: Scene;
  125760. /**
  125761. * @constructor
  125762. * @param name - The rendering pipeline name
  125763. * @param scene - The scene linked to this pipeline
  125764. * @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 }
  125765. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125766. */
  125767. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125768. /**
  125769. * Get the class name
  125770. * @returns "SSAORenderingPipeline"
  125771. */
  125772. getClassName(): string;
  125773. /**
  125774. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125775. */
  125776. dispose(disableDepthRender?: boolean): void;
  125777. private _createBlurPostProcess;
  125778. /** @hidden */
  125779. _rebuild(): void;
  125780. private _createSSAOPostProcess;
  125781. private _createSSAOCombinePostProcess;
  125782. private _createRandomTexture;
  125783. }
  125784. }
  125785. declare module BABYLON {
  125786. /** @hidden */
  125787. export var standardPixelShader: {
  125788. name: string;
  125789. shader: string;
  125790. };
  125791. }
  125792. declare module BABYLON {
  125793. /**
  125794. * Standard rendering pipeline
  125795. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125796. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125797. */
  125798. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125799. /**
  125800. * Public members
  125801. */
  125802. /**
  125803. * Post-process which contains the original scene color before the pipeline applies all the effects
  125804. */
  125805. originalPostProcess: Nullable<PostProcess>;
  125806. /**
  125807. * Post-process used to down scale an image x4
  125808. */
  125809. downSampleX4PostProcess: Nullable<PostProcess>;
  125810. /**
  125811. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125812. */
  125813. brightPassPostProcess: Nullable<PostProcess>;
  125814. /**
  125815. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125816. */
  125817. blurHPostProcesses: PostProcess[];
  125818. /**
  125819. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125820. */
  125821. blurVPostProcesses: PostProcess[];
  125822. /**
  125823. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125824. */
  125825. textureAdderPostProcess: Nullable<PostProcess>;
  125826. /**
  125827. * Post-process used to create volumetric lighting effect
  125828. */
  125829. volumetricLightPostProcess: Nullable<PostProcess>;
  125830. /**
  125831. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125832. */
  125833. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125834. /**
  125835. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125836. */
  125837. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125838. /**
  125839. * Post-process used to merge the volumetric light effect and the real scene color
  125840. */
  125841. volumetricLightMergePostProces: Nullable<PostProcess>;
  125842. /**
  125843. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125844. */
  125845. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125846. /**
  125847. * Base post-process used to calculate the average luminance of the final image for HDR
  125848. */
  125849. luminancePostProcess: Nullable<PostProcess>;
  125850. /**
  125851. * Post-processes used to create down sample post-processes in order to get
  125852. * the average luminance of the final image for HDR
  125853. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125854. */
  125855. luminanceDownSamplePostProcesses: PostProcess[];
  125856. /**
  125857. * Post-process used to create a HDR effect (light adaptation)
  125858. */
  125859. hdrPostProcess: Nullable<PostProcess>;
  125860. /**
  125861. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125862. */
  125863. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125864. /**
  125865. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125866. */
  125867. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125868. /**
  125869. * Post-process used to merge the final HDR post-process and the real scene color
  125870. */
  125871. hdrFinalPostProcess: Nullable<PostProcess>;
  125872. /**
  125873. * Post-process used to create a lens flare effect
  125874. */
  125875. lensFlarePostProcess: Nullable<PostProcess>;
  125876. /**
  125877. * Post-process that merges the result of the lens flare post-process and the real scene color
  125878. */
  125879. lensFlareComposePostProcess: Nullable<PostProcess>;
  125880. /**
  125881. * Post-process used to create a motion blur effect
  125882. */
  125883. motionBlurPostProcess: Nullable<PostProcess>;
  125884. /**
  125885. * Post-process used to create a depth of field effect
  125886. */
  125887. depthOfFieldPostProcess: Nullable<PostProcess>;
  125888. /**
  125889. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125890. */
  125891. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125892. /**
  125893. * Represents the brightness threshold in order to configure the illuminated surfaces
  125894. */
  125895. brightThreshold: number;
  125896. /**
  125897. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125898. */
  125899. blurWidth: number;
  125900. /**
  125901. * Sets if the blur for highlighted surfaces must be only horizontal
  125902. */
  125903. horizontalBlur: boolean;
  125904. /**
  125905. * Gets the overall exposure used by the pipeline
  125906. */
  125907. /**
  125908. * Sets the overall exposure used by the pipeline
  125909. */
  125910. exposure: number;
  125911. /**
  125912. * Texture used typically to simulate "dirty" on camera lens
  125913. */
  125914. lensTexture: Nullable<Texture>;
  125915. /**
  125916. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125917. */
  125918. volumetricLightCoefficient: number;
  125919. /**
  125920. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125921. */
  125922. volumetricLightPower: number;
  125923. /**
  125924. * Used the set the blur intensity to smooth the volumetric lights
  125925. */
  125926. volumetricLightBlurScale: number;
  125927. /**
  125928. * Light (spot or directional) used to generate the volumetric lights rays
  125929. * The source light must have a shadow generate so the pipeline can get its
  125930. * depth map
  125931. */
  125932. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125933. /**
  125934. * For eye adaptation, represents the minimum luminance the eye can see
  125935. */
  125936. hdrMinimumLuminance: number;
  125937. /**
  125938. * For eye adaptation, represents the decrease luminance speed
  125939. */
  125940. hdrDecreaseRate: number;
  125941. /**
  125942. * For eye adaptation, represents the increase luminance speed
  125943. */
  125944. hdrIncreaseRate: number;
  125945. /**
  125946. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125947. */
  125948. /**
  125949. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125950. */
  125951. hdrAutoExposure: boolean;
  125952. /**
  125953. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125954. */
  125955. lensColorTexture: Nullable<Texture>;
  125956. /**
  125957. * The overall strengh for the lens flare effect
  125958. */
  125959. lensFlareStrength: number;
  125960. /**
  125961. * Dispersion coefficient for lens flare ghosts
  125962. */
  125963. lensFlareGhostDispersal: number;
  125964. /**
  125965. * Main lens flare halo width
  125966. */
  125967. lensFlareHaloWidth: number;
  125968. /**
  125969. * Based on the lens distortion effect, defines how much the lens flare result
  125970. * is distorted
  125971. */
  125972. lensFlareDistortionStrength: number;
  125973. /**
  125974. * Configures the blur intensity used for for lens flare (halo)
  125975. */
  125976. lensFlareBlurWidth: number;
  125977. /**
  125978. * Lens star texture must be used to simulate rays on the flares and is available
  125979. * in the documentation
  125980. */
  125981. lensStarTexture: Nullable<Texture>;
  125982. /**
  125983. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125984. * flare effect by taking account of the dirt texture
  125985. */
  125986. lensFlareDirtTexture: Nullable<Texture>;
  125987. /**
  125988. * Represents the focal length for the depth of field effect
  125989. */
  125990. depthOfFieldDistance: number;
  125991. /**
  125992. * Represents the blur intensity for the blurred part of the depth of field effect
  125993. */
  125994. depthOfFieldBlurWidth: number;
  125995. /**
  125996. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125997. */
  125998. /**
  125999. * Sets how much the image is blurred by the movement while using the motion blur post-process
  126000. */
  126001. motionStrength: number;
  126002. /**
  126003. * Gets wether or not the motion blur post-process is object based or screen based.
  126004. */
  126005. /**
  126006. * Sets wether or not the motion blur post-process should be object based or screen based
  126007. */
  126008. objectBasedMotionBlur: boolean;
  126009. /**
  126010. * List of animations for the pipeline (IAnimatable implementation)
  126011. */
  126012. animations: Animation[];
  126013. /**
  126014. * Private members
  126015. */
  126016. private _scene;
  126017. private _currentDepthOfFieldSource;
  126018. private _basePostProcess;
  126019. private _fixedExposure;
  126020. private _currentExposure;
  126021. private _hdrAutoExposure;
  126022. private _hdrCurrentLuminance;
  126023. private _motionStrength;
  126024. private _isObjectBasedMotionBlur;
  126025. private _floatTextureType;
  126026. private _camerasToBeAttached;
  126027. private _ratio;
  126028. private _bloomEnabled;
  126029. private _depthOfFieldEnabled;
  126030. private _vlsEnabled;
  126031. private _lensFlareEnabled;
  126032. private _hdrEnabled;
  126033. private _motionBlurEnabled;
  126034. private _fxaaEnabled;
  126035. private _motionBlurSamples;
  126036. private _volumetricLightStepsCount;
  126037. private _samples;
  126038. /**
  126039. * @ignore
  126040. * Specifies if the bloom pipeline is enabled
  126041. */
  126042. BloomEnabled: boolean;
  126043. /**
  126044. * @ignore
  126045. * Specifies if the depth of field pipeline is enabed
  126046. */
  126047. DepthOfFieldEnabled: boolean;
  126048. /**
  126049. * @ignore
  126050. * Specifies if the lens flare pipeline is enabed
  126051. */
  126052. LensFlareEnabled: boolean;
  126053. /**
  126054. * @ignore
  126055. * Specifies if the HDR pipeline is enabled
  126056. */
  126057. HDREnabled: boolean;
  126058. /**
  126059. * @ignore
  126060. * Specifies if the volumetric lights scattering effect is enabled
  126061. */
  126062. VLSEnabled: boolean;
  126063. /**
  126064. * @ignore
  126065. * Specifies if the motion blur effect is enabled
  126066. */
  126067. MotionBlurEnabled: boolean;
  126068. /**
  126069. * Specifies if anti-aliasing is enabled
  126070. */
  126071. fxaaEnabled: boolean;
  126072. /**
  126073. * Specifies the number of steps used to calculate the volumetric lights
  126074. * Typically in interval [50, 200]
  126075. */
  126076. volumetricLightStepsCount: number;
  126077. /**
  126078. * Specifies the number of samples used for the motion blur effect
  126079. * Typically in interval [16, 64]
  126080. */
  126081. motionBlurSamples: number;
  126082. /**
  126083. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126084. */
  126085. samples: number;
  126086. /**
  126087. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126088. * @constructor
  126089. * @param name The rendering pipeline name
  126090. * @param scene The scene linked to this pipeline
  126091. * @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)
  126092. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  126093. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126094. */
  126095. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  126096. private _buildPipeline;
  126097. private _createDownSampleX4PostProcess;
  126098. private _createBrightPassPostProcess;
  126099. private _createBlurPostProcesses;
  126100. private _createTextureAdderPostProcess;
  126101. private _createVolumetricLightPostProcess;
  126102. private _createLuminancePostProcesses;
  126103. private _createHdrPostProcess;
  126104. private _createLensFlarePostProcess;
  126105. private _createDepthOfFieldPostProcess;
  126106. private _createMotionBlurPostProcess;
  126107. private _getDepthTexture;
  126108. private _disposePostProcesses;
  126109. /**
  126110. * Dispose of the pipeline and stop all post processes
  126111. */
  126112. dispose(): void;
  126113. /**
  126114. * Serialize the rendering pipeline (Used when exporting)
  126115. * @returns the serialized object
  126116. */
  126117. serialize(): any;
  126118. /**
  126119. * Parse the serialized pipeline
  126120. * @param source Source pipeline.
  126121. * @param scene The scene to load the pipeline to.
  126122. * @param rootUrl The URL of the serialized pipeline.
  126123. * @returns An instantiated pipeline from the serialized object.
  126124. */
  126125. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  126126. /**
  126127. * Luminance steps
  126128. */
  126129. static LuminanceSteps: number;
  126130. }
  126131. }
  126132. declare module BABYLON {
  126133. /** @hidden */
  126134. export var tonemapPixelShader: {
  126135. name: string;
  126136. shader: string;
  126137. };
  126138. }
  126139. declare module BABYLON {
  126140. /** Defines operator used for tonemapping */
  126141. export enum TonemappingOperator {
  126142. /** Hable */
  126143. Hable = 0,
  126144. /** Reinhard */
  126145. Reinhard = 1,
  126146. /** HejiDawson */
  126147. HejiDawson = 2,
  126148. /** Photographic */
  126149. Photographic = 3
  126150. }
  126151. /**
  126152. * Defines a post process to apply tone mapping
  126153. */
  126154. export class TonemapPostProcess extends PostProcess {
  126155. private _operator;
  126156. /** Defines the required exposure adjustement */
  126157. exposureAdjustment: number;
  126158. /**
  126159. * Creates a new TonemapPostProcess
  126160. * @param name defines the name of the postprocess
  126161. * @param _operator defines the operator to use
  126162. * @param exposureAdjustment defines the required exposure adjustement
  126163. * @param camera defines the camera to use (can be null)
  126164. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  126165. * @param engine defines the hosting engine (can be ignore if camera is set)
  126166. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126167. */
  126168. constructor(name: string, _operator: TonemappingOperator,
  126169. /** Defines the required exposure adjustement */
  126170. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  126171. }
  126172. }
  126173. declare module BABYLON {
  126174. /** @hidden */
  126175. export var depthVertexShader: {
  126176. name: string;
  126177. shader: string;
  126178. };
  126179. }
  126180. declare module BABYLON {
  126181. /** @hidden */
  126182. export var volumetricLightScatteringPixelShader: {
  126183. name: string;
  126184. shader: string;
  126185. };
  126186. }
  126187. declare module BABYLON {
  126188. /** @hidden */
  126189. export var volumetricLightScatteringPassVertexShader: {
  126190. name: string;
  126191. shader: string;
  126192. };
  126193. }
  126194. declare module BABYLON {
  126195. /** @hidden */
  126196. export var volumetricLightScatteringPassPixelShader: {
  126197. name: string;
  126198. shader: string;
  126199. };
  126200. }
  126201. declare module BABYLON {
  126202. /**
  126203. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126204. */
  126205. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126206. private _volumetricLightScatteringPass;
  126207. private _volumetricLightScatteringRTT;
  126208. private _viewPort;
  126209. private _screenCoordinates;
  126210. private _cachedDefines;
  126211. /**
  126212. * If not undefined, the mesh position is computed from the attached node position
  126213. */
  126214. attachedNode: {
  126215. position: Vector3;
  126216. };
  126217. /**
  126218. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126219. */
  126220. customMeshPosition: Vector3;
  126221. /**
  126222. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126223. */
  126224. useCustomMeshPosition: boolean;
  126225. /**
  126226. * If the post-process should inverse the light scattering direction
  126227. */
  126228. invert: boolean;
  126229. /**
  126230. * The internal mesh used by the post-process
  126231. */
  126232. mesh: Mesh;
  126233. /**
  126234. * @hidden
  126235. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126236. */
  126237. useDiffuseColor: boolean;
  126238. /**
  126239. * Array containing the excluded meshes not rendered in the internal pass
  126240. */
  126241. excludedMeshes: AbstractMesh[];
  126242. /**
  126243. * Controls the overall intensity of the post-process
  126244. */
  126245. exposure: number;
  126246. /**
  126247. * Dissipates each sample's contribution in range [0, 1]
  126248. */
  126249. decay: number;
  126250. /**
  126251. * Controls the overall intensity of each sample
  126252. */
  126253. weight: number;
  126254. /**
  126255. * Controls the density of each sample
  126256. */
  126257. density: number;
  126258. /**
  126259. * @constructor
  126260. * @param name The post-process name
  126261. * @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)
  126262. * @param camera The camera that the post-process will be attached to
  126263. * @param mesh The mesh used to create the light scattering
  126264. * @param samples The post-process quality, default 100
  126265. * @param samplingModeThe post-process filtering mode
  126266. * @param engine The babylon engine
  126267. * @param reusable If the post-process is reusable
  126268. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126269. */
  126270. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126271. /**
  126272. * Returns the string "VolumetricLightScatteringPostProcess"
  126273. * @returns "VolumetricLightScatteringPostProcess"
  126274. */
  126275. getClassName(): string;
  126276. private _isReady;
  126277. /**
  126278. * Sets the new light position for light scattering effect
  126279. * @param position The new custom light position
  126280. */
  126281. setCustomMeshPosition(position: Vector3): void;
  126282. /**
  126283. * Returns the light position for light scattering effect
  126284. * @return Vector3 The custom light position
  126285. */
  126286. getCustomMeshPosition(): Vector3;
  126287. /**
  126288. * Disposes the internal assets and detaches the post-process from the camera
  126289. */
  126290. dispose(camera: Camera): void;
  126291. /**
  126292. * Returns the render target texture used by the post-process
  126293. * @return the render target texture used by the post-process
  126294. */
  126295. getPass(): RenderTargetTexture;
  126296. private _meshExcluded;
  126297. private _createPass;
  126298. private _updateMeshScreenCoordinates;
  126299. /**
  126300. * Creates a default mesh for the Volumeric Light Scattering post-process
  126301. * @param name The mesh name
  126302. * @param scene The scene where to create the mesh
  126303. * @return the default mesh
  126304. */
  126305. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126306. }
  126307. }
  126308. declare module BABYLON {
  126309. interface Scene {
  126310. /** @hidden (Backing field) */
  126311. _boundingBoxRenderer: BoundingBoxRenderer;
  126312. /** @hidden (Backing field) */
  126313. _forceShowBoundingBoxes: boolean;
  126314. /**
  126315. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126316. */
  126317. forceShowBoundingBoxes: boolean;
  126318. /**
  126319. * Gets the bounding box renderer associated with the scene
  126320. * @returns a BoundingBoxRenderer
  126321. */
  126322. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126323. }
  126324. interface AbstractMesh {
  126325. /** @hidden (Backing field) */
  126326. _showBoundingBox: boolean;
  126327. /**
  126328. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126329. */
  126330. showBoundingBox: boolean;
  126331. }
  126332. /**
  126333. * Component responsible of rendering the bounding box of the meshes in a scene.
  126334. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126335. */
  126336. export class BoundingBoxRenderer implements ISceneComponent {
  126337. /**
  126338. * The component name helpfull to identify the component in the list of scene components.
  126339. */
  126340. readonly name: string;
  126341. /**
  126342. * The scene the component belongs to.
  126343. */
  126344. scene: Scene;
  126345. /**
  126346. * Color of the bounding box lines placed in front of an object
  126347. */
  126348. frontColor: Color3;
  126349. /**
  126350. * Color of the bounding box lines placed behind an object
  126351. */
  126352. backColor: Color3;
  126353. /**
  126354. * Defines if the renderer should show the back lines or not
  126355. */
  126356. showBackLines: boolean;
  126357. /**
  126358. * @hidden
  126359. */
  126360. renderList: SmartArray<BoundingBox>;
  126361. private _colorShader;
  126362. private _vertexBuffers;
  126363. private _indexBuffer;
  126364. private _fillIndexBuffer;
  126365. private _fillIndexData;
  126366. /**
  126367. * Instantiates a new bounding box renderer in a scene.
  126368. * @param scene the scene the renderer renders in
  126369. */
  126370. constructor(scene: Scene);
  126371. /**
  126372. * Registers the component in a given scene
  126373. */
  126374. register(): void;
  126375. private _evaluateSubMesh;
  126376. private _activeMesh;
  126377. private _prepareRessources;
  126378. private _createIndexBuffer;
  126379. /**
  126380. * Rebuilds the elements related to this component in case of
  126381. * context lost for instance.
  126382. */
  126383. rebuild(): void;
  126384. /**
  126385. * @hidden
  126386. */
  126387. reset(): void;
  126388. /**
  126389. * Render the bounding boxes of a specific rendering group
  126390. * @param renderingGroupId defines the rendering group to render
  126391. */
  126392. render(renderingGroupId: number): void;
  126393. /**
  126394. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126395. * @param mesh Define the mesh to render the occlusion bounding box for
  126396. */
  126397. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126398. /**
  126399. * Dispose and release the resources attached to this renderer.
  126400. */
  126401. dispose(): void;
  126402. }
  126403. }
  126404. declare module BABYLON {
  126405. /** @hidden */
  126406. export var depthPixelShader: {
  126407. name: string;
  126408. shader: string;
  126409. };
  126410. }
  126411. declare module BABYLON {
  126412. /**
  126413. * This represents a depth renderer in Babylon.
  126414. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126415. */
  126416. export class DepthRenderer {
  126417. private _scene;
  126418. private _depthMap;
  126419. private _effect;
  126420. private readonly _storeNonLinearDepth;
  126421. private readonly _clearColor;
  126422. /** Get if the depth renderer is using packed depth or not */
  126423. readonly isPacked: boolean;
  126424. private _cachedDefines;
  126425. private _camera;
  126426. /**
  126427. * Specifiess that the depth renderer will only be used within
  126428. * the camera it is created for.
  126429. * This can help forcing its rendering during the camera processing.
  126430. */
  126431. useOnlyInActiveCamera: boolean;
  126432. /** @hidden */
  126433. static _SceneComponentInitialization: (scene: Scene) => void;
  126434. /**
  126435. * Instantiates a depth renderer
  126436. * @param scene The scene the renderer belongs to
  126437. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126438. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126439. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126440. */
  126441. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126442. /**
  126443. * Creates the depth rendering effect and checks if the effect is ready.
  126444. * @param subMesh The submesh to be used to render the depth map of
  126445. * @param useInstances If multiple world instances should be used
  126446. * @returns if the depth renderer is ready to render the depth map
  126447. */
  126448. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126449. /**
  126450. * Gets the texture which the depth map will be written to.
  126451. * @returns The depth map texture
  126452. */
  126453. getDepthMap(): RenderTargetTexture;
  126454. /**
  126455. * Disposes of the depth renderer.
  126456. */
  126457. dispose(): void;
  126458. }
  126459. }
  126460. declare module BABYLON {
  126461. interface Scene {
  126462. /** @hidden (Backing field) */
  126463. _depthRenderer: {
  126464. [id: string]: DepthRenderer;
  126465. };
  126466. /**
  126467. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126468. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126469. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126470. * @returns the created depth renderer
  126471. */
  126472. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126473. /**
  126474. * Disables a depth renderer for a given camera
  126475. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126476. */
  126477. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126478. }
  126479. /**
  126480. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126481. * in several rendering techniques.
  126482. */
  126483. export class DepthRendererSceneComponent implements ISceneComponent {
  126484. /**
  126485. * The component name helpfull to identify the component in the list of scene components.
  126486. */
  126487. readonly name: string;
  126488. /**
  126489. * The scene the component belongs to.
  126490. */
  126491. scene: Scene;
  126492. /**
  126493. * Creates a new instance of the component for the given scene
  126494. * @param scene Defines the scene to register the component in
  126495. */
  126496. constructor(scene: Scene);
  126497. /**
  126498. * Registers the component in a given scene
  126499. */
  126500. register(): void;
  126501. /**
  126502. * Rebuilds the elements related to this component in case of
  126503. * context lost for instance.
  126504. */
  126505. rebuild(): void;
  126506. /**
  126507. * Disposes the component and the associated ressources
  126508. */
  126509. dispose(): void;
  126510. private _gatherRenderTargets;
  126511. private _gatherActiveCameraRenderTargets;
  126512. }
  126513. }
  126514. declare module BABYLON {
  126515. /** @hidden */
  126516. export var outlinePixelShader: {
  126517. name: string;
  126518. shader: string;
  126519. };
  126520. }
  126521. declare module BABYLON {
  126522. /** @hidden */
  126523. export var outlineVertexShader: {
  126524. name: string;
  126525. shader: string;
  126526. };
  126527. }
  126528. declare module BABYLON {
  126529. interface Scene {
  126530. /** @hidden */
  126531. _outlineRenderer: OutlineRenderer;
  126532. /**
  126533. * Gets the outline renderer associated with the scene
  126534. * @returns a OutlineRenderer
  126535. */
  126536. getOutlineRenderer(): OutlineRenderer;
  126537. }
  126538. interface AbstractMesh {
  126539. /** @hidden (Backing field) */
  126540. _renderOutline: boolean;
  126541. /**
  126542. * Gets or sets a boolean indicating if the outline must be rendered as well
  126543. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126544. */
  126545. renderOutline: boolean;
  126546. /** @hidden (Backing field) */
  126547. _renderOverlay: boolean;
  126548. /**
  126549. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126550. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126551. */
  126552. renderOverlay: boolean;
  126553. }
  126554. /**
  126555. * This class is responsible to draw bothe outline/overlay of meshes.
  126556. * It should not be used directly but through the available method on mesh.
  126557. */
  126558. export class OutlineRenderer implements ISceneComponent {
  126559. /**
  126560. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126561. */
  126562. private static _StencilReference;
  126563. /**
  126564. * The name of the component. Each component must have a unique name.
  126565. */
  126566. name: string;
  126567. /**
  126568. * The scene the component belongs to.
  126569. */
  126570. scene: Scene;
  126571. /**
  126572. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126573. */
  126574. zOffset: number;
  126575. private _engine;
  126576. private _effect;
  126577. private _cachedDefines;
  126578. private _savedDepthWrite;
  126579. /**
  126580. * Instantiates a new outline renderer. (There could be only one per scene).
  126581. * @param scene Defines the scene it belongs to
  126582. */
  126583. constructor(scene: Scene);
  126584. /**
  126585. * Register the component to one instance of a scene.
  126586. */
  126587. register(): void;
  126588. /**
  126589. * Rebuilds the elements related to this component in case of
  126590. * context lost for instance.
  126591. */
  126592. rebuild(): void;
  126593. /**
  126594. * Disposes the component and the associated ressources.
  126595. */
  126596. dispose(): void;
  126597. /**
  126598. * Renders the outline in the canvas.
  126599. * @param subMesh Defines the sumesh to render
  126600. * @param batch Defines the batch of meshes in case of instances
  126601. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126602. */
  126603. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126604. /**
  126605. * Returns whether or not the outline renderer is ready for a given submesh.
  126606. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126607. * @param subMesh Defines the submesh to check readyness for
  126608. * @param useInstances Defines wheter wee are trying to render instances or not
  126609. * @returns true if ready otherwise false
  126610. */
  126611. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126612. private _beforeRenderingMesh;
  126613. private _afterRenderingMesh;
  126614. }
  126615. }
  126616. declare module BABYLON {
  126617. /**
  126618. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126619. * @see http://doc.babylonjs.com/babylon101/sprites
  126620. */
  126621. export class SpritePackedManager extends SpriteManager {
  126622. /** defines the packed manager's name */
  126623. name: string;
  126624. /**
  126625. * Creates a new sprite manager from a packed sprite sheet
  126626. * @param name defines the manager's name
  126627. * @param imgUrl defines the sprite sheet url
  126628. * @param capacity defines the maximum allowed number of sprites
  126629. * @param scene defines the hosting scene
  126630. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126631. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126632. * @param samplingMode defines the smapling mode to use with spritesheet
  126633. * @param fromPacked set to true; do not alter
  126634. */
  126635. constructor(
  126636. /** defines the packed manager's name */
  126637. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126638. }
  126639. }
  126640. declare module BABYLON {
  126641. /**
  126642. * Defines the list of states available for a task inside a AssetsManager
  126643. */
  126644. export enum AssetTaskState {
  126645. /**
  126646. * Initialization
  126647. */
  126648. INIT = 0,
  126649. /**
  126650. * Running
  126651. */
  126652. RUNNING = 1,
  126653. /**
  126654. * Done
  126655. */
  126656. DONE = 2,
  126657. /**
  126658. * Error
  126659. */
  126660. ERROR = 3
  126661. }
  126662. /**
  126663. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126664. */
  126665. export abstract class AbstractAssetTask {
  126666. /**
  126667. * Task name
  126668. */ name: string;
  126669. /**
  126670. * Callback called when the task is successful
  126671. */
  126672. onSuccess: (task: any) => void;
  126673. /**
  126674. * Callback called when the task is not successful
  126675. */
  126676. onError: (task: any, message?: string, exception?: any) => void;
  126677. /**
  126678. * Creates a new AssetsManager
  126679. * @param name defines the name of the task
  126680. */
  126681. constructor(
  126682. /**
  126683. * Task name
  126684. */ name: string);
  126685. private _isCompleted;
  126686. private _taskState;
  126687. private _errorObject;
  126688. /**
  126689. * Get if the task is completed
  126690. */
  126691. readonly isCompleted: boolean;
  126692. /**
  126693. * Gets the current state of the task
  126694. */
  126695. readonly taskState: AssetTaskState;
  126696. /**
  126697. * Gets the current error object (if task is in error)
  126698. */
  126699. readonly errorObject: {
  126700. message?: string;
  126701. exception?: any;
  126702. };
  126703. /**
  126704. * Internal only
  126705. * @hidden
  126706. */
  126707. _setErrorObject(message?: string, exception?: any): void;
  126708. /**
  126709. * Execute the current task
  126710. * @param scene defines the scene where you want your assets to be loaded
  126711. * @param onSuccess is a callback called when the task is successfully executed
  126712. * @param onError is a callback called if an error occurs
  126713. */
  126714. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126715. /**
  126716. * Execute the current task
  126717. * @param scene defines the scene where you want your assets to be loaded
  126718. * @param onSuccess is a callback called when the task is successfully executed
  126719. * @param onError is a callback called if an error occurs
  126720. */
  126721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126722. /**
  126723. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126724. * This can be used with failed tasks that have the reason for failure fixed.
  126725. */
  126726. reset(): void;
  126727. private onErrorCallback;
  126728. private onDoneCallback;
  126729. }
  126730. /**
  126731. * Define the interface used by progress events raised during assets loading
  126732. */
  126733. export interface IAssetsProgressEvent {
  126734. /**
  126735. * Defines the number of remaining tasks to process
  126736. */
  126737. remainingCount: number;
  126738. /**
  126739. * Defines the total number of tasks
  126740. */
  126741. totalCount: number;
  126742. /**
  126743. * Defines the task that was just processed
  126744. */
  126745. task: AbstractAssetTask;
  126746. }
  126747. /**
  126748. * Class used to share progress information about assets loading
  126749. */
  126750. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126751. /**
  126752. * Defines the number of remaining tasks to process
  126753. */
  126754. remainingCount: number;
  126755. /**
  126756. * Defines the total number of tasks
  126757. */
  126758. totalCount: number;
  126759. /**
  126760. * Defines the task that was just processed
  126761. */
  126762. task: AbstractAssetTask;
  126763. /**
  126764. * Creates a AssetsProgressEvent
  126765. * @param remainingCount defines the number of remaining tasks to process
  126766. * @param totalCount defines the total number of tasks
  126767. * @param task defines the task that was just processed
  126768. */
  126769. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126770. }
  126771. /**
  126772. * Define a task used by AssetsManager to load meshes
  126773. */
  126774. export class MeshAssetTask extends AbstractAssetTask {
  126775. /**
  126776. * Defines the name of the task
  126777. */
  126778. name: string;
  126779. /**
  126780. * Defines the list of mesh's names you want to load
  126781. */
  126782. meshesNames: any;
  126783. /**
  126784. * Defines the root url to use as a base to load your meshes and associated resources
  126785. */
  126786. rootUrl: string;
  126787. /**
  126788. * Defines the filename of the scene to load from
  126789. */
  126790. sceneFilename: string;
  126791. /**
  126792. * Gets the list of loaded meshes
  126793. */
  126794. loadedMeshes: Array<AbstractMesh>;
  126795. /**
  126796. * Gets the list of loaded particle systems
  126797. */
  126798. loadedParticleSystems: Array<IParticleSystem>;
  126799. /**
  126800. * Gets the list of loaded skeletons
  126801. */
  126802. loadedSkeletons: Array<Skeleton>;
  126803. /**
  126804. * Gets the list of loaded animation groups
  126805. */
  126806. loadedAnimationGroups: Array<AnimationGroup>;
  126807. /**
  126808. * Callback called when the task is successful
  126809. */
  126810. onSuccess: (task: MeshAssetTask) => void;
  126811. /**
  126812. * Callback called when the task is successful
  126813. */
  126814. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126815. /**
  126816. * Creates a new MeshAssetTask
  126817. * @param name defines the name of the task
  126818. * @param meshesNames defines the list of mesh's names you want to load
  126819. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126820. * @param sceneFilename defines the filename of the scene to load from
  126821. */
  126822. constructor(
  126823. /**
  126824. * Defines the name of the task
  126825. */
  126826. name: string,
  126827. /**
  126828. * Defines the list of mesh's names you want to load
  126829. */
  126830. meshesNames: any,
  126831. /**
  126832. * Defines the root url to use as a base to load your meshes and associated resources
  126833. */
  126834. rootUrl: string,
  126835. /**
  126836. * Defines the filename of the scene to load from
  126837. */
  126838. sceneFilename: string);
  126839. /**
  126840. * Execute the current task
  126841. * @param scene defines the scene where you want your assets to be loaded
  126842. * @param onSuccess is a callback called when the task is successfully executed
  126843. * @param onError is a callback called if an error occurs
  126844. */
  126845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126846. }
  126847. /**
  126848. * Define a task used by AssetsManager to load text content
  126849. */
  126850. export class TextFileAssetTask extends AbstractAssetTask {
  126851. /**
  126852. * Defines the name of the task
  126853. */
  126854. name: string;
  126855. /**
  126856. * Defines the location of the file to load
  126857. */
  126858. url: string;
  126859. /**
  126860. * Gets the loaded text string
  126861. */
  126862. text: string;
  126863. /**
  126864. * Callback called when the task is successful
  126865. */
  126866. onSuccess: (task: TextFileAssetTask) => void;
  126867. /**
  126868. * Callback called when the task is successful
  126869. */
  126870. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126871. /**
  126872. * Creates a new TextFileAssetTask object
  126873. * @param name defines the name of the task
  126874. * @param url defines the location of the file to load
  126875. */
  126876. constructor(
  126877. /**
  126878. * Defines the name of the task
  126879. */
  126880. name: string,
  126881. /**
  126882. * Defines the location of the file to load
  126883. */
  126884. url: string);
  126885. /**
  126886. * Execute the current task
  126887. * @param scene defines the scene where you want your assets to be loaded
  126888. * @param onSuccess is a callback called when the task is successfully executed
  126889. * @param onError is a callback called if an error occurs
  126890. */
  126891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126892. }
  126893. /**
  126894. * Define a task used by AssetsManager to load binary data
  126895. */
  126896. export class BinaryFileAssetTask extends AbstractAssetTask {
  126897. /**
  126898. * Defines the name of the task
  126899. */
  126900. name: string;
  126901. /**
  126902. * Defines the location of the file to load
  126903. */
  126904. url: string;
  126905. /**
  126906. * Gets the lodaded data (as an array buffer)
  126907. */
  126908. data: ArrayBuffer;
  126909. /**
  126910. * Callback called when the task is successful
  126911. */
  126912. onSuccess: (task: BinaryFileAssetTask) => void;
  126913. /**
  126914. * Callback called when the task is successful
  126915. */
  126916. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126917. /**
  126918. * Creates a new BinaryFileAssetTask object
  126919. * @param name defines the name of the new task
  126920. * @param url defines the location of the file to load
  126921. */
  126922. constructor(
  126923. /**
  126924. * Defines the name of the task
  126925. */
  126926. name: string,
  126927. /**
  126928. * Defines the location of the file to load
  126929. */
  126930. url: string);
  126931. /**
  126932. * Execute the current task
  126933. * @param scene defines the scene where you want your assets to be loaded
  126934. * @param onSuccess is a callback called when the task is successfully executed
  126935. * @param onError is a callback called if an error occurs
  126936. */
  126937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126938. }
  126939. /**
  126940. * Define a task used by AssetsManager to load images
  126941. */
  126942. export class ImageAssetTask extends AbstractAssetTask {
  126943. /**
  126944. * Defines the name of the task
  126945. */
  126946. name: string;
  126947. /**
  126948. * Defines the location of the image to load
  126949. */
  126950. url: string;
  126951. /**
  126952. * Gets the loaded images
  126953. */
  126954. image: HTMLImageElement;
  126955. /**
  126956. * Callback called when the task is successful
  126957. */
  126958. onSuccess: (task: ImageAssetTask) => void;
  126959. /**
  126960. * Callback called when the task is successful
  126961. */
  126962. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126963. /**
  126964. * Creates a new ImageAssetTask
  126965. * @param name defines the name of the task
  126966. * @param url defines the location of the image to load
  126967. */
  126968. constructor(
  126969. /**
  126970. * Defines the name of the task
  126971. */
  126972. name: string,
  126973. /**
  126974. * Defines the location of the image to load
  126975. */
  126976. url: string);
  126977. /**
  126978. * Execute the current task
  126979. * @param scene defines the scene where you want your assets to be loaded
  126980. * @param onSuccess is a callback called when the task is successfully executed
  126981. * @param onError is a callback called if an error occurs
  126982. */
  126983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126984. }
  126985. /**
  126986. * Defines the interface used by texture loading tasks
  126987. */
  126988. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126989. /**
  126990. * Gets the loaded texture
  126991. */
  126992. texture: TEX;
  126993. }
  126994. /**
  126995. * Define a task used by AssetsManager to load 2D textures
  126996. */
  126997. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126998. /**
  126999. * Defines the name of the task
  127000. */
  127001. name: string;
  127002. /**
  127003. * Defines the location of the file to load
  127004. */
  127005. url: string;
  127006. /**
  127007. * Defines if mipmap should not be generated (default is false)
  127008. */
  127009. noMipmap?: boolean | undefined;
  127010. /**
  127011. * Defines if texture must be inverted on Y axis (default is false)
  127012. */
  127013. invertY?: boolean | undefined;
  127014. /**
  127015. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127016. */
  127017. samplingMode: number;
  127018. /**
  127019. * Gets the loaded texture
  127020. */
  127021. texture: Texture;
  127022. /**
  127023. * Callback called when the task is successful
  127024. */
  127025. onSuccess: (task: TextureAssetTask) => void;
  127026. /**
  127027. * Callback called when the task is successful
  127028. */
  127029. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  127030. /**
  127031. * Creates a new TextureAssetTask object
  127032. * @param name defines the name of the task
  127033. * @param url defines the location of the file to load
  127034. * @param noMipmap defines if mipmap should not be generated (default is false)
  127035. * @param invertY defines if texture must be inverted on Y axis (default is false)
  127036. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127037. */
  127038. constructor(
  127039. /**
  127040. * Defines the name of the task
  127041. */
  127042. name: string,
  127043. /**
  127044. * Defines the location of the file to load
  127045. */
  127046. url: string,
  127047. /**
  127048. * Defines if mipmap should not be generated (default is false)
  127049. */
  127050. noMipmap?: boolean | undefined,
  127051. /**
  127052. * Defines if texture must be inverted on Y axis (default is false)
  127053. */
  127054. invertY?: boolean | undefined,
  127055. /**
  127056. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127057. */
  127058. samplingMode?: number);
  127059. /**
  127060. * Execute the current task
  127061. * @param scene defines the scene where you want your assets to be loaded
  127062. * @param onSuccess is a callback called when the task is successfully executed
  127063. * @param onError is a callback called if an error occurs
  127064. */
  127065. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127066. }
  127067. /**
  127068. * Define a task used by AssetsManager to load cube textures
  127069. */
  127070. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  127071. /**
  127072. * Defines the name of the task
  127073. */
  127074. name: string;
  127075. /**
  127076. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127077. */
  127078. url: string;
  127079. /**
  127080. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127081. */
  127082. extensions?: string[] | undefined;
  127083. /**
  127084. * Defines if mipmaps should not be generated (default is false)
  127085. */
  127086. noMipmap?: boolean | undefined;
  127087. /**
  127088. * Defines the explicit list of files (undefined by default)
  127089. */
  127090. files?: string[] | undefined;
  127091. /**
  127092. * Gets the loaded texture
  127093. */
  127094. texture: CubeTexture;
  127095. /**
  127096. * Callback called when the task is successful
  127097. */
  127098. onSuccess: (task: CubeTextureAssetTask) => void;
  127099. /**
  127100. * Callback called when the task is successful
  127101. */
  127102. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  127103. /**
  127104. * Creates a new CubeTextureAssetTask
  127105. * @param name defines the name of the task
  127106. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127107. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127108. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127109. * @param files defines the explicit list of files (undefined by default)
  127110. */
  127111. constructor(
  127112. /**
  127113. * Defines the name of the task
  127114. */
  127115. name: string,
  127116. /**
  127117. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127118. */
  127119. url: string,
  127120. /**
  127121. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127122. */
  127123. extensions?: string[] | undefined,
  127124. /**
  127125. * Defines if mipmaps should not be generated (default is false)
  127126. */
  127127. noMipmap?: boolean | undefined,
  127128. /**
  127129. * Defines the explicit list of files (undefined by default)
  127130. */
  127131. files?: string[] | undefined);
  127132. /**
  127133. * Execute the current task
  127134. * @param scene defines the scene where you want your assets to be loaded
  127135. * @param onSuccess is a callback called when the task is successfully executed
  127136. * @param onError is a callback called if an error occurs
  127137. */
  127138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127139. }
  127140. /**
  127141. * Define a task used by AssetsManager to load HDR cube textures
  127142. */
  127143. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  127144. /**
  127145. * Defines the name of the task
  127146. */
  127147. name: string;
  127148. /**
  127149. * Defines the location of the file to load
  127150. */
  127151. url: string;
  127152. /**
  127153. * Defines the desired size (the more it increases the longer the generation will be)
  127154. */
  127155. size: number;
  127156. /**
  127157. * Defines if mipmaps should not be generated (default is false)
  127158. */
  127159. noMipmap: boolean;
  127160. /**
  127161. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127162. */
  127163. generateHarmonics: boolean;
  127164. /**
  127165. * 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)
  127166. */
  127167. gammaSpace: boolean;
  127168. /**
  127169. * Internal Use Only
  127170. */
  127171. reserved: boolean;
  127172. /**
  127173. * Gets the loaded texture
  127174. */
  127175. texture: HDRCubeTexture;
  127176. /**
  127177. * Callback called when the task is successful
  127178. */
  127179. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  127180. /**
  127181. * Callback called when the task is successful
  127182. */
  127183. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127184. /**
  127185. * Creates a new HDRCubeTextureAssetTask object
  127186. * @param name defines the name of the task
  127187. * @param url defines the location of the file to load
  127188. * @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.
  127189. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127190. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127191. * @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)
  127192. * @param reserved Internal use only
  127193. */
  127194. constructor(
  127195. /**
  127196. * Defines the name of the task
  127197. */
  127198. name: string,
  127199. /**
  127200. * Defines the location of the file to load
  127201. */
  127202. url: string,
  127203. /**
  127204. * Defines the desired size (the more it increases the longer the generation will be)
  127205. */
  127206. size: number,
  127207. /**
  127208. * Defines if mipmaps should not be generated (default is false)
  127209. */
  127210. noMipmap?: boolean,
  127211. /**
  127212. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127213. */
  127214. generateHarmonics?: boolean,
  127215. /**
  127216. * 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)
  127217. */
  127218. gammaSpace?: boolean,
  127219. /**
  127220. * Internal Use Only
  127221. */
  127222. reserved?: boolean);
  127223. /**
  127224. * Execute the current task
  127225. * @param scene defines the scene where you want your assets to be loaded
  127226. * @param onSuccess is a callback called when the task is successfully executed
  127227. * @param onError is a callback called if an error occurs
  127228. */
  127229. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127230. }
  127231. /**
  127232. * Define a task used by AssetsManager to load Equirectangular cube textures
  127233. */
  127234. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127235. /**
  127236. * Defines the name of the task
  127237. */
  127238. name: string;
  127239. /**
  127240. * Defines the location of the file to load
  127241. */
  127242. url: string;
  127243. /**
  127244. * Defines the desired size (the more it increases the longer the generation will be)
  127245. */
  127246. size: number;
  127247. /**
  127248. * Defines if mipmaps should not be generated (default is false)
  127249. */
  127250. noMipmap: boolean;
  127251. /**
  127252. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127253. * but the standard material would require them in Gamma space) (default is true)
  127254. */
  127255. gammaSpace: boolean;
  127256. /**
  127257. * Gets the loaded texture
  127258. */
  127259. texture: EquiRectangularCubeTexture;
  127260. /**
  127261. * Callback called when the task is successful
  127262. */
  127263. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127264. /**
  127265. * Callback called when the task is successful
  127266. */
  127267. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127268. /**
  127269. * Creates a new EquiRectangularCubeTextureAssetTask object
  127270. * @param name defines the name of the task
  127271. * @param url defines the location of the file to load
  127272. * @param size defines the desired size (the more it increases the longer the generation will be)
  127273. * If the size is omitted this implies you are using a preprocessed cubemap.
  127274. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127275. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127276. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127277. * (default is true)
  127278. */
  127279. constructor(
  127280. /**
  127281. * Defines the name of the task
  127282. */
  127283. name: string,
  127284. /**
  127285. * Defines the location of the file to load
  127286. */
  127287. url: string,
  127288. /**
  127289. * Defines the desired size (the more it increases the longer the generation will be)
  127290. */
  127291. size: number,
  127292. /**
  127293. * Defines if mipmaps should not be generated (default is false)
  127294. */
  127295. noMipmap?: boolean,
  127296. /**
  127297. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127298. * but the standard material would require them in Gamma space) (default is true)
  127299. */
  127300. gammaSpace?: boolean);
  127301. /**
  127302. * Execute the current task
  127303. * @param scene defines the scene where you want your assets to be loaded
  127304. * @param onSuccess is a callback called when the task is successfully executed
  127305. * @param onError is a callback called if an error occurs
  127306. */
  127307. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127308. }
  127309. /**
  127310. * This class can be used to easily import assets into a scene
  127311. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127312. */
  127313. export class AssetsManager {
  127314. private _scene;
  127315. private _isLoading;
  127316. protected _tasks: AbstractAssetTask[];
  127317. protected _waitingTasksCount: number;
  127318. protected _totalTasksCount: number;
  127319. /**
  127320. * Callback called when all tasks are processed
  127321. */
  127322. onFinish: (tasks: AbstractAssetTask[]) => void;
  127323. /**
  127324. * Callback called when a task is successful
  127325. */
  127326. onTaskSuccess: (task: AbstractAssetTask) => void;
  127327. /**
  127328. * Callback called when a task had an error
  127329. */
  127330. onTaskError: (task: AbstractAssetTask) => void;
  127331. /**
  127332. * Callback called when a task is done (whatever the result is)
  127333. */
  127334. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127335. /**
  127336. * Observable called when all tasks are processed
  127337. */
  127338. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127339. /**
  127340. * Observable called when a task had an error
  127341. */
  127342. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127343. /**
  127344. * Observable called when all tasks were executed
  127345. */
  127346. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127347. /**
  127348. * Observable called when a task is done (whatever the result is)
  127349. */
  127350. onProgressObservable: Observable<IAssetsProgressEvent>;
  127351. /**
  127352. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127353. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127354. */
  127355. useDefaultLoadingScreen: boolean;
  127356. /**
  127357. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127358. * when all assets have been downloaded.
  127359. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127360. */
  127361. autoHideLoadingUI: boolean;
  127362. /**
  127363. * Creates a new AssetsManager
  127364. * @param scene defines the scene to work on
  127365. */
  127366. constructor(scene: Scene);
  127367. /**
  127368. * Add a MeshAssetTask to the list of active tasks
  127369. * @param taskName defines the name of the new task
  127370. * @param meshesNames defines the name of meshes to load
  127371. * @param rootUrl defines the root url to use to locate files
  127372. * @param sceneFilename defines the filename of the scene file
  127373. * @returns a new MeshAssetTask object
  127374. */
  127375. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127376. /**
  127377. * Add a TextFileAssetTask to the list of active tasks
  127378. * @param taskName defines the name of the new task
  127379. * @param url defines the url of the file to load
  127380. * @returns a new TextFileAssetTask object
  127381. */
  127382. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127383. /**
  127384. * Add a BinaryFileAssetTask to the list of active tasks
  127385. * @param taskName defines the name of the new task
  127386. * @param url defines the url of the file to load
  127387. * @returns a new BinaryFileAssetTask object
  127388. */
  127389. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127390. /**
  127391. * Add a ImageAssetTask to the list of active tasks
  127392. * @param taskName defines the name of the new task
  127393. * @param url defines the url of the file to load
  127394. * @returns a new ImageAssetTask object
  127395. */
  127396. addImageTask(taskName: string, url: string): ImageAssetTask;
  127397. /**
  127398. * Add a TextureAssetTask to the list of active tasks
  127399. * @param taskName defines the name of the new task
  127400. * @param url defines the url of the file to load
  127401. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127402. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127403. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127404. * @returns a new TextureAssetTask object
  127405. */
  127406. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127407. /**
  127408. * Add a CubeTextureAssetTask to the list of active tasks
  127409. * @param taskName defines the name of the new task
  127410. * @param url defines the url of the file to load
  127411. * @param extensions defines the extension to use to load the cube map (can be null)
  127412. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127413. * @param files defines the list of files to load (can be null)
  127414. * @returns a new CubeTextureAssetTask object
  127415. */
  127416. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127417. /**
  127418. *
  127419. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127420. * @param taskName defines the name of the new task
  127421. * @param url defines the url of the file to load
  127422. * @param size defines the size you want for the cubemap (can be null)
  127423. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127424. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127425. * @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)
  127426. * @param reserved Internal use only
  127427. * @returns a new HDRCubeTextureAssetTask object
  127428. */
  127429. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127430. /**
  127431. *
  127432. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127433. * @param taskName defines the name of the new task
  127434. * @param url defines the url of the file to load
  127435. * @param size defines the size you want for the cubemap (can be null)
  127436. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127437. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127438. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127439. * @returns a new EquiRectangularCubeTextureAssetTask object
  127440. */
  127441. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127442. /**
  127443. * Remove a task from the assets manager.
  127444. * @param task the task to remove
  127445. */
  127446. removeTask(task: AbstractAssetTask): void;
  127447. private _decreaseWaitingTasksCount;
  127448. private _runTask;
  127449. /**
  127450. * Reset the AssetsManager and remove all tasks
  127451. * @return the current instance of the AssetsManager
  127452. */
  127453. reset(): AssetsManager;
  127454. /**
  127455. * Start the loading process
  127456. * @return the current instance of the AssetsManager
  127457. */
  127458. load(): AssetsManager;
  127459. /**
  127460. * Start the loading process as an async operation
  127461. * @return a promise returning the list of failed tasks
  127462. */
  127463. loadAsync(): Promise<void>;
  127464. }
  127465. }
  127466. declare module BABYLON {
  127467. /**
  127468. * Wrapper class for promise with external resolve and reject.
  127469. */
  127470. export class Deferred<T> {
  127471. /**
  127472. * The promise associated with this deferred object.
  127473. */
  127474. readonly promise: Promise<T>;
  127475. private _resolve;
  127476. private _reject;
  127477. /**
  127478. * The resolve method of the promise associated with this deferred object.
  127479. */
  127480. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127481. /**
  127482. * The reject method of the promise associated with this deferred object.
  127483. */
  127484. readonly reject: (reason?: any) => void;
  127485. /**
  127486. * Constructor for this deferred object.
  127487. */
  127488. constructor();
  127489. }
  127490. }
  127491. declare module BABYLON {
  127492. /**
  127493. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127494. */
  127495. export class MeshExploder {
  127496. private _centerMesh;
  127497. private _meshes;
  127498. private _meshesOrigins;
  127499. private _toCenterVectors;
  127500. private _scaledDirection;
  127501. private _newPosition;
  127502. private _centerPosition;
  127503. /**
  127504. * Explodes meshes from a center mesh.
  127505. * @param meshes The meshes to explode.
  127506. * @param centerMesh The mesh to be center of explosion.
  127507. */
  127508. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127509. private _setCenterMesh;
  127510. /**
  127511. * Get class name
  127512. * @returns "MeshExploder"
  127513. */
  127514. getClassName(): string;
  127515. /**
  127516. * "Exploded meshes"
  127517. * @returns Array of meshes with the centerMesh at index 0.
  127518. */
  127519. getMeshes(): Array<Mesh>;
  127520. /**
  127521. * Explodes meshes giving a specific direction
  127522. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127523. */
  127524. explode(direction?: number): void;
  127525. }
  127526. }
  127527. declare module BABYLON {
  127528. /**
  127529. * Class used to help managing file picking and drag'n'drop
  127530. */
  127531. export class FilesInput {
  127532. /**
  127533. * List of files ready to be loaded
  127534. */
  127535. static readonly FilesToLoad: {
  127536. [key: string]: File;
  127537. };
  127538. /**
  127539. * Callback called when a file is processed
  127540. */
  127541. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127542. private _engine;
  127543. private _currentScene;
  127544. private _sceneLoadedCallback;
  127545. private _progressCallback;
  127546. private _additionalRenderLoopLogicCallback;
  127547. private _textureLoadingCallback;
  127548. private _startingProcessingFilesCallback;
  127549. private _onReloadCallback;
  127550. private _errorCallback;
  127551. private _elementToMonitor;
  127552. private _sceneFileToLoad;
  127553. private _filesToLoad;
  127554. /**
  127555. * Creates a new FilesInput
  127556. * @param engine defines the rendering engine
  127557. * @param scene defines the hosting scene
  127558. * @param sceneLoadedCallback callback called when scene is loaded
  127559. * @param progressCallback callback called to track progress
  127560. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127561. * @param textureLoadingCallback callback called when a texture is loading
  127562. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127563. * @param onReloadCallback callback called when a reload is requested
  127564. * @param errorCallback callback call if an error occurs
  127565. */
  127566. 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);
  127567. private _dragEnterHandler;
  127568. private _dragOverHandler;
  127569. private _dropHandler;
  127570. /**
  127571. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127572. * @param elementToMonitor defines the DOM element to track
  127573. */
  127574. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127575. /**
  127576. * Release all associated resources
  127577. */
  127578. dispose(): void;
  127579. private renderFunction;
  127580. private drag;
  127581. private drop;
  127582. private _traverseFolder;
  127583. private _processFiles;
  127584. /**
  127585. * Load files from a drop event
  127586. * @param event defines the drop event to use as source
  127587. */
  127588. loadFiles(event: any): void;
  127589. private _processReload;
  127590. /**
  127591. * Reload the current scene from the loaded files
  127592. */
  127593. reload(): void;
  127594. }
  127595. }
  127596. declare module BABYLON {
  127597. /**
  127598. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127600. */
  127601. export class SceneOptimization {
  127602. /**
  127603. * Defines the priority of this optimization (0 by default which means first in the list)
  127604. */
  127605. priority: number;
  127606. /**
  127607. * Gets a string describing the action executed by the current optimization
  127608. * @returns description string
  127609. */
  127610. getDescription(): string;
  127611. /**
  127612. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127613. * @param scene defines the current scene where to apply this optimization
  127614. * @param optimizer defines the current optimizer
  127615. * @returns true if everything that can be done was applied
  127616. */
  127617. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127618. /**
  127619. * Creates the SceneOptimization object
  127620. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127621. * @param desc defines the description associated with the optimization
  127622. */
  127623. constructor(
  127624. /**
  127625. * Defines the priority of this optimization (0 by default which means first in the list)
  127626. */
  127627. priority?: number);
  127628. }
  127629. /**
  127630. * Defines an optimization used to reduce the size of render target textures
  127631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127632. */
  127633. export class TextureOptimization extends SceneOptimization {
  127634. /**
  127635. * Defines the priority of this optimization (0 by default which means first in the list)
  127636. */
  127637. priority: number;
  127638. /**
  127639. * 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
  127640. */
  127641. maximumSize: number;
  127642. /**
  127643. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127644. */
  127645. step: number;
  127646. /**
  127647. * Gets a string describing the action executed by the current optimization
  127648. * @returns description string
  127649. */
  127650. getDescription(): string;
  127651. /**
  127652. * Creates the TextureOptimization object
  127653. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127654. * @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
  127655. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127656. */
  127657. constructor(
  127658. /**
  127659. * Defines the priority of this optimization (0 by default which means first in the list)
  127660. */
  127661. priority?: number,
  127662. /**
  127663. * 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
  127664. */
  127665. maximumSize?: number,
  127666. /**
  127667. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127668. */
  127669. step?: number);
  127670. /**
  127671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127672. * @param scene defines the current scene where to apply this optimization
  127673. * @param optimizer defines the current optimizer
  127674. * @returns true if everything that can be done was applied
  127675. */
  127676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127677. }
  127678. /**
  127679. * Defines an optimization used to increase or decrease the rendering resolution
  127680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127681. */
  127682. export class HardwareScalingOptimization extends SceneOptimization {
  127683. /**
  127684. * Defines the priority of this optimization (0 by default which means first in the list)
  127685. */
  127686. priority: number;
  127687. /**
  127688. * Defines the maximum scale to use (2 by default)
  127689. */
  127690. maximumScale: number;
  127691. /**
  127692. * Defines the step to use between two passes (0.5 by default)
  127693. */
  127694. step: number;
  127695. private _currentScale;
  127696. private _directionOffset;
  127697. /**
  127698. * Gets a string describing the action executed by the current optimization
  127699. * @return description string
  127700. */
  127701. getDescription(): string;
  127702. /**
  127703. * Creates the HardwareScalingOptimization object
  127704. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127705. * @param maximumScale defines the maximum scale to use (2 by default)
  127706. * @param step defines the step to use between two passes (0.5 by default)
  127707. */
  127708. constructor(
  127709. /**
  127710. * Defines the priority of this optimization (0 by default which means first in the list)
  127711. */
  127712. priority?: number,
  127713. /**
  127714. * Defines the maximum scale to use (2 by default)
  127715. */
  127716. maximumScale?: number,
  127717. /**
  127718. * Defines the step to use between two passes (0.5 by default)
  127719. */
  127720. step?: number);
  127721. /**
  127722. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127723. * @param scene defines the current scene where to apply this optimization
  127724. * @param optimizer defines the current optimizer
  127725. * @returns true if everything that can be done was applied
  127726. */
  127727. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127728. }
  127729. /**
  127730. * Defines an optimization used to remove shadows
  127731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127732. */
  127733. export class ShadowsOptimization extends SceneOptimization {
  127734. /**
  127735. * Gets a string describing the action executed by the current optimization
  127736. * @return description string
  127737. */
  127738. getDescription(): string;
  127739. /**
  127740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127741. * @param scene defines the current scene where to apply this optimization
  127742. * @param optimizer defines the current optimizer
  127743. * @returns true if everything that can be done was applied
  127744. */
  127745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127746. }
  127747. /**
  127748. * Defines an optimization used to turn post-processes off
  127749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127750. */
  127751. export class PostProcessesOptimization extends SceneOptimization {
  127752. /**
  127753. * Gets a string describing the action executed by the current optimization
  127754. * @return description string
  127755. */
  127756. getDescription(): string;
  127757. /**
  127758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127759. * @param scene defines the current scene where to apply this optimization
  127760. * @param optimizer defines the current optimizer
  127761. * @returns true if everything that can be done was applied
  127762. */
  127763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127764. }
  127765. /**
  127766. * Defines an optimization used to turn lens flares off
  127767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127768. */
  127769. export class LensFlaresOptimization extends SceneOptimization {
  127770. /**
  127771. * Gets a string describing the action executed by the current optimization
  127772. * @return description string
  127773. */
  127774. getDescription(): string;
  127775. /**
  127776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127777. * @param scene defines the current scene where to apply this optimization
  127778. * @param optimizer defines the current optimizer
  127779. * @returns true if everything that can be done was applied
  127780. */
  127781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127782. }
  127783. /**
  127784. * Defines an optimization based on user defined callback.
  127785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127786. */
  127787. export class CustomOptimization extends SceneOptimization {
  127788. /**
  127789. * Callback called to apply the custom optimization.
  127790. */
  127791. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127792. /**
  127793. * Callback called to get custom description
  127794. */
  127795. onGetDescription: () => string;
  127796. /**
  127797. * Gets a string describing the action executed by the current optimization
  127798. * @returns description string
  127799. */
  127800. getDescription(): string;
  127801. /**
  127802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127803. * @param scene defines the current scene where to apply this optimization
  127804. * @param optimizer defines the current optimizer
  127805. * @returns true if everything that can be done was applied
  127806. */
  127807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127808. }
  127809. /**
  127810. * Defines an optimization used to turn particles off
  127811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127812. */
  127813. export class ParticlesOptimization extends SceneOptimization {
  127814. /**
  127815. * Gets a string describing the action executed by the current optimization
  127816. * @return description string
  127817. */
  127818. getDescription(): string;
  127819. /**
  127820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127821. * @param scene defines the current scene where to apply this optimization
  127822. * @param optimizer defines the current optimizer
  127823. * @returns true if everything that can be done was applied
  127824. */
  127825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127826. }
  127827. /**
  127828. * Defines an optimization used to turn render targets off
  127829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127830. */
  127831. export class RenderTargetsOptimization extends SceneOptimization {
  127832. /**
  127833. * Gets a string describing the action executed by the current optimization
  127834. * @return description string
  127835. */
  127836. getDescription(): string;
  127837. /**
  127838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127839. * @param scene defines the current scene where to apply this optimization
  127840. * @param optimizer defines the current optimizer
  127841. * @returns true if everything that can be done was applied
  127842. */
  127843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127844. }
  127845. /**
  127846. * Defines an optimization used to merge meshes with compatible materials
  127847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127848. */
  127849. export class MergeMeshesOptimization extends SceneOptimization {
  127850. private static _UpdateSelectionTree;
  127851. /**
  127852. * Gets or sets a boolean which defines if optimization octree has to be updated
  127853. */
  127854. /**
  127855. * Gets or sets a boolean which defines if optimization octree has to be updated
  127856. */
  127857. static UpdateSelectionTree: boolean;
  127858. /**
  127859. * Gets a string describing the action executed by the current optimization
  127860. * @return description string
  127861. */
  127862. getDescription(): string;
  127863. private _canBeMerged;
  127864. /**
  127865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127866. * @param scene defines the current scene where to apply this optimization
  127867. * @param optimizer defines the current optimizer
  127868. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127869. * @returns true if everything that can be done was applied
  127870. */
  127871. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127872. }
  127873. /**
  127874. * Defines a list of options used by SceneOptimizer
  127875. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127876. */
  127877. export class SceneOptimizerOptions {
  127878. /**
  127879. * Defines the target frame rate to reach (60 by default)
  127880. */
  127881. targetFrameRate: number;
  127882. /**
  127883. * Defines the interval between two checkes (2000ms by default)
  127884. */
  127885. trackerDuration: number;
  127886. /**
  127887. * Gets the list of optimizations to apply
  127888. */
  127889. optimizations: SceneOptimization[];
  127890. /**
  127891. * Creates a new list of options used by SceneOptimizer
  127892. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127893. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127894. */
  127895. constructor(
  127896. /**
  127897. * Defines the target frame rate to reach (60 by default)
  127898. */
  127899. targetFrameRate?: number,
  127900. /**
  127901. * Defines the interval between two checkes (2000ms by default)
  127902. */
  127903. trackerDuration?: number);
  127904. /**
  127905. * Add a new optimization
  127906. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127907. * @returns the current SceneOptimizerOptions
  127908. */
  127909. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127910. /**
  127911. * Add a new custom optimization
  127912. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127913. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127914. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127915. * @returns the current SceneOptimizerOptions
  127916. */
  127917. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127918. /**
  127919. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127920. * @param targetFrameRate defines the target frame rate (60 by default)
  127921. * @returns a SceneOptimizerOptions object
  127922. */
  127923. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127924. /**
  127925. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127926. * @param targetFrameRate defines the target frame rate (60 by default)
  127927. * @returns a SceneOptimizerOptions object
  127928. */
  127929. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127930. /**
  127931. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127932. * @param targetFrameRate defines the target frame rate (60 by default)
  127933. * @returns a SceneOptimizerOptions object
  127934. */
  127935. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127936. }
  127937. /**
  127938. * Class used to run optimizations in order to reach a target frame rate
  127939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127940. */
  127941. export class SceneOptimizer implements IDisposable {
  127942. private _isRunning;
  127943. private _options;
  127944. private _scene;
  127945. private _currentPriorityLevel;
  127946. private _targetFrameRate;
  127947. private _trackerDuration;
  127948. private _currentFrameRate;
  127949. private _sceneDisposeObserver;
  127950. private _improvementMode;
  127951. /**
  127952. * Defines an observable called when the optimizer reaches the target frame rate
  127953. */
  127954. onSuccessObservable: Observable<SceneOptimizer>;
  127955. /**
  127956. * Defines an observable called when the optimizer enables an optimization
  127957. */
  127958. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127959. /**
  127960. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127961. */
  127962. onFailureObservable: Observable<SceneOptimizer>;
  127963. /**
  127964. * Gets a boolean indicating if the optimizer is in improvement mode
  127965. */
  127966. readonly isInImprovementMode: boolean;
  127967. /**
  127968. * Gets the current priority level (0 at start)
  127969. */
  127970. readonly currentPriorityLevel: number;
  127971. /**
  127972. * Gets the current frame rate checked by the SceneOptimizer
  127973. */
  127974. readonly currentFrameRate: number;
  127975. /**
  127976. * Gets or sets the current target frame rate (60 by default)
  127977. */
  127978. /**
  127979. * Gets or sets the current target frame rate (60 by default)
  127980. */
  127981. targetFrameRate: number;
  127982. /**
  127983. * Gets or sets the current interval between two checks (every 2000ms by default)
  127984. */
  127985. /**
  127986. * Gets or sets the current interval between two checks (every 2000ms by default)
  127987. */
  127988. trackerDuration: number;
  127989. /**
  127990. * Gets the list of active optimizations
  127991. */
  127992. readonly optimizations: SceneOptimization[];
  127993. /**
  127994. * Creates a new SceneOptimizer
  127995. * @param scene defines the scene to work on
  127996. * @param options defines the options to use with the SceneOptimizer
  127997. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127998. * @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)
  127999. */
  128000. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  128001. /**
  128002. * Stops the current optimizer
  128003. */
  128004. stop(): void;
  128005. /**
  128006. * Reset the optimizer to initial step (current priority level = 0)
  128007. */
  128008. reset(): void;
  128009. /**
  128010. * Start the optimizer. By default it will try to reach a specific framerate
  128011. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  128012. */
  128013. start(): void;
  128014. private _checkCurrentState;
  128015. /**
  128016. * Release all resources
  128017. */
  128018. dispose(): void;
  128019. /**
  128020. * Helper function to create a SceneOptimizer with one single line of code
  128021. * @param scene defines the scene to work on
  128022. * @param options defines the options to use with the SceneOptimizer
  128023. * @param onSuccess defines a callback to call on success
  128024. * @param onFailure defines a callback to call on failure
  128025. * @returns the new SceneOptimizer object
  128026. */
  128027. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  128028. }
  128029. }
  128030. declare module BABYLON {
  128031. /**
  128032. * Class used to serialize a scene into a string
  128033. */
  128034. export class SceneSerializer {
  128035. /**
  128036. * Clear cache used by a previous serialization
  128037. */
  128038. static ClearCache(): void;
  128039. /**
  128040. * Serialize a scene into a JSON compatible object
  128041. * @param scene defines the scene to serialize
  128042. * @returns a JSON compatible object
  128043. */
  128044. static Serialize(scene: Scene): any;
  128045. /**
  128046. * Serialize a mesh into a JSON compatible object
  128047. * @param toSerialize defines the mesh to serialize
  128048. * @param withParents defines if parents must be serialized as well
  128049. * @param withChildren defines if children must be serialized as well
  128050. * @returns a JSON compatible object
  128051. */
  128052. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  128053. }
  128054. }
  128055. declare module BABYLON {
  128056. /**
  128057. * Class used to host texture specific utilities
  128058. */
  128059. export class TextureTools {
  128060. /**
  128061. * Uses the GPU to create a copy texture rescaled at a given size
  128062. * @param texture Texture to copy from
  128063. * @param width defines the desired width
  128064. * @param height defines the desired height
  128065. * @param useBilinearMode defines if bilinear mode has to be used
  128066. * @return the generated texture
  128067. */
  128068. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  128069. }
  128070. }
  128071. declare module BABYLON {
  128072. /**
  128073. * This represents the different options available for the video capture.
  128074. */
  128075. export interface VideoRecorderOptions {
  128076. /** Defines the mime type of the video. */
  128077. mimeType: string;
  128078. /** Defines the FPS the video should be recorded at. */
  128079. fps: number;
  128080. /** Defines the chunk size for the recording data. */
  128081. recordChunckSize: number;
  128082. /** The audio tracks to attach to the recording. */
  128083. audioTracks?: MediaStreamTrack[];
  128084. }
  128085. /**
  128086. * This can help with recording videos from BabylonJS.
  128087. * This is based on the available WebRTC functionalities of the browser.
  128088. *
  128089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  128090. */
  128091. export class VideoRecorder {
  128092. private static readonly _defaultOptions;
  128093. /**
  128094. * Returns whether or not the VideoRecorder is available in your browser.
  128095. * @param engine Defines the Babylon Engine.
  128096. * @returns true if supported otherwise false.
  128097. */
  128098. static IsSupported(engine: Engine): boolean;
  128099. private readonly _options;
  128100. private _canvas;
  128101. private _mediaRecorder;
  128102. private _recordedChunks;
  128103. private _fileName;
  128104. private _resolve;
  128105. private _reject;
  128106. /**
  128107. * True when a recording is already in progress.
  128108. */
  128109. readonly isRecording: boolean;
  128110. /**
  128111. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  128112. * @param engine Defines the BabylonJS Engine you wish to record.
  128113. * @param options Defines options that can be used to customize the capture.
  128114. */
  128115. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  128116. /**
  128117. * Stops the current recording before the default capture timeout passed in the startRecording function.
  128118. */
  128119. stopRecording(): void;
  128120. /**
  128121. * Starts recording the canvas for a max duration specified in parameters.
  128122. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  128123. * If null no automatic download will start and you can rely on the promise to get the data back.
  128124. * @param maxDuration Defines the maximum recording time in seconds.
  128125. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  128126. * @return A promise callback at the end of the recording with the video data in Blob.
  128127. */
  128128. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  128129. /**
  128130. * Releases internal resources used during the recording.
  128131. */
  128132. dispose(): void;
  128133. private _handleDataAvailable;
  128134. private _handleError;
  128135. private _handleStop;
  128136. }
  128137. }
  128138. declare module BABYLON {
  128139. /**
  128140. * Class containing a set of static utilities functions for screenshots
  128141. */
  128142. export class ScreenshotTools {
  128143. /**
  128144. * Captures a screenshot of the current rendering
  128145. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128146. * @param engine defines the rendering engine
  128147. * @param camera defines the source camera
  128148. * @param size This parameter can be set to a single number or to an object with the
  128149. * following (optional) properties: precision, width, height. If a single number is passed,
  128150. * it will be used for both width and height. If an object is passed, the screenshot size
  128151. * will be derived from the parameters. The precision property is a multiplier allowing
  128152. * rendering at a higher or lower resolution
  128153. * @param successCallback defines the callback receives a single parameter which contains the
  128154. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128155. * src parameter of an <img> to display it
  128156. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128157. * Check your browser for supported MIME types
  128158. */
  128159. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  128160. /**
  128161. * Captures a screenshot of the current rendering
  128162. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128163. * @param engine defines the rendering engine
  128164. * @param camera defines the source camera
  128165. * @param size This parameter can be set to a single number or to an object with the
  128166. * following (optional) properties: precision, width, height. If a single number is passed,
  128167. * it will be used for both width and height. If an object is passed, the screenshot size
  128168. * will be derived from the parameters. The precision property is a multiplier allowing
  128169. * rendering at a higher or lower resolution
  128170. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128171. * Check your browser for supported MIME types
  128172. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128173. * to the src parameter of an <img> to display it
  128174. */
  128175. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  128176. /**
  128177. * Generates an image screenshot from the specified camera.
  128178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128179. * @param engine The engine to use for rendering
  128180. * @param camera The camera to use for rendering
  128181. * @param size This parameter can be set to a single number or to an object with the
  128182. * following (optional) properties: precision, width, height. If a single number is passed,
  128183. * it will be used for both width and height. If an object is passed, the screenshot size
  128184. * will be derived from the parameters. The precision property is a multiplier allowing
  128185. * rendering at a higher or lower resolution
  128186. * @param successCallback The callback receives a single parameter which contains the
  128187. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128188. * src parameter of an <img> to display it
  128189. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128190. * Check your browser for supported MIME types
  128191. * @param samples Texture samples (default: 1)
  128192. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128193. * @param fileName A name for for the downloaded file.
  128194. */
  128195. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128196. /**
  128197. * Generates an image screenshot from the specified camera.
  128198. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128199. * @param engine The engine to use for rendering
  128200. * @param camera The camera to use for rendering
  128201. * @param size This parameter can be set to a single number or to an object with the
  128202. * following (optional) properties: precision, width, height. If a single number is passed,
  128203. * it will be used for both width and height. If an object is passed, the screenshot size
  128204. * will be derived from the parameters. The precision property is a multiplier allowing
  128205. * rendering at a higher or lower resolution
  128206. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128207. * Check your browser for supported MIME types
  128208. * @param samples Texture samples (default: 1)
  128209. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128210. * @param fileName A name for for the downloaded file.
  128211. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128212. * to the src parameter of an <img> to display it
  128213. */
  128214. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128215. /**
  128216. * Gets height and width for screenshot size
  128217. * @private
  128218. */
  128219. private static _getScreenshotSize;
  128220. }
  128221. }
  128222. declare module BABYLON {
  128223. /**
  128224. * A cursor which tracks a point on a path
  128225. */
  128226. export class PathCursor {
  128227. private path;
  128228. /**
  128229. * Stores path cursor callbacks for when an onchange event is triggered
  128230. */
  128231. private _onchange;
  128232. /**
  128233. * The value of the path cursor
  128234. */
  128235. value: number;
  128236. /**
  128237. * The animation array of the path cursor
  128238. */
  128239. animations: Animation[];
  128240. /**
  128241. * Initializes the path cursor
  128242. * @param path The path to track
  128243. */
  128244. constructor(path: Path2);
  128245. /**
  128246. * Gets the cursor point on the path
  128247. * @returns A point on the path cursor at the cursor location
  128248. */
  128249. getPoint(): Vector3;
  128250. /**
  128251. * Moves the cursor ahead by the step amount
  128252. * @param step The amount to move the cursor forward
  128253. * @returns This path cursor
  128254. */
  128255. moveAhead(step?: number): PathCursor;
  128256. /**
  128257. * Moves the cursor behind by the step amount
  128258. * @param step The amount to move the cursor back
  128259. * @returns This path cursor
  128260. */
  128261. moveBack(step?: number): PathCursor;
  128262. /**
  128263. * Moves the cursor by the step amount
  128264. * If the step amount is greater than one, an exception is thrown
  128265. * @param step The amount to move the cursor
  128266. * @returns This path cursor
  128267. */
  128268. move(step: number): PathCursor;
  128269. /**
  128270. * Ensures that the value is limited between zero and one
  128271. * @returns This path cursor
  128272. */
  128273. private ensureLimits;
  128274. /**
  128275. * Runs onchange callbacks on change (used by the animation engine)
  128276. * @returns This path cursor
  128277. */
  128278. private raiseOnChange;
  128279. /**
  128280. * Executes a function on change
  128281. * @param f A path cursor onchange callback
  128282. * @returns This path cursor
  128283. */
  128284. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128285. }
  128286. }
  128287. declare module BABYLON {
  128288. /** @hidden */
  128289. export var blurPixelShader: {
  128290. name: string;
  128291. shader: string;
  128292. };
  128293. }
  128294. declare module BABYLON {
  128295. /** @hidden */
  128296. export var pointCloudVertexDeclaration: {
  128297. name: string;
  128298. shader: string;
  128299. };
  128300. }
  128301. // Mixins
  128302. interface Window {
  128303. mozIndexedDB: IDBFactory;
  128304. webkitIndexedDB: IDBFactory;
  128305. msIndexedDB: IDBFactory;
  128306. webkitURL: typeof URL;
  128307. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128308. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128309. WebGLRenderingContext: WebGLRenderingContext;
  128310. MSGesture: MSGesture;
  128311. CANNON: any;
  128312. AudioContext: AudioContext;
  128313. webkitAudioContext: AudioContext;
  128314. PointerEvent: any;
  128315. Math: Math;
  128316. Uint8Array: Uint8ArrayConstructor;
  128317. Float32Array: Float32ArrayConstructor;
  128318. mozURL: typeof URL;
  128319. msURL: typeof URL;
  128320. VRFrameData: any; // WebVR, from specs 1.1
  128321. DracoDecoderModule: any;
  128322. setImmediate(handler: (...args: any[]) => void): number;
  128323. }
  128324. interface HTMLCanvasElement {
  128325. requestPointerLock(): void;
  128326. msRequestPointerLock?(): void;
  128327. mozRequestPointerLock?(): void;
  128328. webkitRequestPointerLock?(): void;
  128329. /** Track wether a record is in progress */
  128330. isRecording: boolean;
  128331. /** Capture Stream method defined by some browsers */
  128332. captureStream(fps?: number): MediaStream;
  128333. }
  128334. interface CanvasRenderingContext2D {
  128335. msImageSmoothingEnabled: boolean;
  128336. }
  128337. interface MouseEvent {
  128338. mozMovementX: number;
  128339. mozMovementY: number;
  128340. webkitMovementX: number;
  128341. webkitMovementY: number;
  128342. msMovementX: number;
  128343. msMovementY: number;
  128344. }
  128345. interface Navigator {
  128346. mozGetVRDevices: (any: any) => any;
  128347. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128348. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128349. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128350. webkitGetGamepads(): Gamepad[];
  128351. msGetGamepads(): Gamepad[];
  128352. webkitGamepads(): Gamepad[];
  128353. }
  128354. interface HTMLVideoElement {
  128355. mozSrcObject: any;
  128356. }
  128357. interface Math {
  128358. fround(x: number): number;
  128359. imul(a: number, b: number): number;
  128360. }
  128361. interface WebGLRenderingContext {
  128362. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128363. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128364. vertexAttribDivisor(index: number, divisor: number): void;
  128365. createVertexArray(): any;
  128366. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128367. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128368. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128369. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128370. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128371. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128372. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128373. // Queries
  128374. createQuery(): WebGLQuery;
  128375. deleteQuery(query: WebGLQuery): void;
  128376. beginQuery(target: number, query: WebGLQuery): void;
  128377. endQuery(target: number): void;
  128378. getQueryParameter(query: WebGLQuery, pname: number): any;
  128379. getQuery(target: number, pname: number): any;
  128380. MAX_SAMPLES: number;
  128381. RGBA8: number;
  128382. READ_FRAMEBUFFER: number;
  128383. DRAW_FRAMEBUFFER: number;
  128384. UNIFORM_BUFFER: number;
  128385. HALF_FLOAT_OES: number;
  128386. RGBA16F: number;
  128387. RGBA32F: number;
  128388. R32F: number;
  128389. RG32F: number;
  128390. RGB32F: number;
  128391. R16F: number;
  128392. RG16F: number;
  128393. RGB16F: number;
  128394. RED: number;
  128395. RG: number;
  128396. R8: number;
  128397. RG8: number;
  128398. UNSIGNED_INT_24_8: number;
  128399. DEPTH24_STENCIL8: number;
  128400. MIN: number;
  128401. MAX: number;
  128402. /* Multiple Render Targets */
  128403. drawBuffers(buffers: number[]): void;
  128404. readBuffer(src: number): void;
  128405. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128406. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128407. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128408. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128409. // Occlusion Query
  128410. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128411. ANY_SAMPLES_PASSED: number;
  128412. QUERY_RESULT_AVAILABLE: number;
  128413. QUERY_RESULT: number;
  128414. }
  128415. interface WebGLProgram {
  128416. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128417. }
  128418. interface EXT_disjoint_timer_query {
  128419. QUERY_COUNTER_BITS_EXT: number;
  128420. TIME_ELAPSED_EXT: number;
  128421. TIMESTAMP_EXT: number;
  128422. GPU_DISJOINT_EXT: number;
  128423. QUERY_RESULT_EXT: number;
  128424. QUERY_RESULT_AVAILABLE_EXT: number;
  128425. queryCounterEXT(query: WebGLQuery, target: number): void;
  128426. createQueryEXT(): WebGLQuery;
  128427. beginQueryEXT(target: number, query: WebGLQuery): void;
  128428. endQueryEXT(target: number): void;
  128429. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128430. deleteQueryEXT(query: WebGLQuery): void;
  128431. }
  128432. interface WebGLUniformLocation {
  128433. _currentState: any;
  128434. }
  128435. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128436. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128437. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128438. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128439. interface WebGLRenderingContext {
  128440. readonly RASTERIZER_DISCARD: number;
  128441. readonly DEPTH_COMPONENT24: number;
  128442. readonly TEXTURE_3D: number;
  128443. readonly TEXTURE_2D_ARRAY: number;
  128444. readonly TEXTURE_COMPARE_FUNC: number;
  128445. readonly TEXTURE_COMPARE_MODE: number;
  128446. readonly COMPARE_REF_TO_TEXTURE: number;
  128447. readonly TEXTURE_WRAP_R: number;
  128448. readonly HALF_FLOAT: number;
  128449. readonly RGB8: number;
  128450. readonly RED_INTEGER: number;
  128451. readonly RG_INTEGER: number;
  128452. readonly RGB_INTEGER: number;
  128453. readonly RGBA_INTEGER: number;
  128454. readonly R8_SNORM: number;
  128455. readonly RG8_SNORM: number;
  128456. readonly RGB8_SNORM: number;
  128457. readonly RGBA8_SNORM: number;
  128458. readonly R8I: number;
  128459. readonly RG8I: number;
  128460. readonly RGB8I: number;
  128461. readonly RGBA8I: number;
  128462. readonly R8UI: number;
  128463. readonly RG8UI: number;
  128464. readonly RGB8UI: number;
  128465. readonly RGBA8UI: number;
  128466. readonly R16I: number;
  128467. readonly RG16I: number;
  128468. readonly RGB16I: number;
  128469. readonly RGBA16I: number;
  128470. readonly R16UI: number;
  128471. readonly RG16UI: number;
  128472. readonly RGB16UI: number;
  128473. readonly RGBA16UI: number;
  128474. readonly R32I: number;
  128475. readonly RG32I: number;
  128476. readonly RGB32I: number;
  128477. readonly RGBA32I: number;
  128478. readonly R32UI: number;
  128479. readonly RG32UI: number;
  128480. readonly RGB32UI: number;
  128481. readonly RGBA32UI: number;
  128482. readonly RGB10_A2UI: number;
  128483. readonly R11F_G11F_B10F: number;
  128484. readonly RGB9_E5: number;
  128485. readonly RGB10_A2: number;
  128486. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128487. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128488. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128489. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128490. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128491. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128492. 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;
  128493. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128494. readonly TRANSFORM_FEEDBACK: number;
  128495. readonly INTERLEAVED_ATTRIBS: number;
  128496. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128497. createTransformFeedback(): WebGLTransformFeedback;
  128498. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128499. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128500. beginTransformFeedback(primitiveMode: number): void;
  128501. endTransformFeedback(): void;
  128502. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128503. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128504. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128505. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128506. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128507. }
  128508. interface ImageBitmap {
  128509. readonly width: number;
  128510. readonly height: number;
  128511. close(): void;
  128512. }
  128513. interface WebGLQuery extends WebGLObject {
  128514. }
  128515. declare var WebGLQuery: {
  128516. prototype: WebGLQuery;
  128517. new(): WebGLQuery;
  128518. };
  128519. interface WebGLSampler extends WebGLObject {
  128520. }
  128521. declare var WebGLSampler: {
  128522. prototype: WebGLSampler;
  128523. new(): WebGLSampler;
  128524. };
  128525. interface WebGLSync extends WebGLObject {
  128526. }
  128527. declare var WebGLSync: {
  128528. prototype: WebGLSync;
  128529. new(): WebGLSync;
  128530. };
  128531. interface WebGLTransformFeedback extends WebGLObject {
  128532. }
  128533. declare var WebGLTransformFeedback: {
  128534. prototype: WebGLTransformFeedback;
  128535. new(): WebGLTransformFeedback;
  128536. };
  128537. interface WebGLVertexArrayObject extends WebGLObject {
  128538. }
  128539. declare var WebGLVertexArrayObject: {
  128540. prototype: WebGLVertexArrayObject;
  128541. new(): WebGLVertexArrayObject;
  128542. };
  128543. // Type definitions for WebVR API
  128544. // Project: https://w3c.github.io/webvr/
  128545. // Definitions by: six a <https://github.com/lostfictions>
  128546. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128547. interface VRDisplay extends EventTarget {
  128548. /**
  128549. * Dictionary of capabilities describing the VRDisplay.
  128550. */
  128551. readonly capabilities: VRDisplayCapabilities;
  128552. /**
  128553. * z-depth defining the far plane of the eye view frustum
  128554. * enables mapping of values in the render target depth
  128555. * attachment to scene coordinates. Initially set to 10000.0.
  128556. */
  128557. depthFar: number;
  128558. /**
  128559. * z-depth defining the near plane of the eye view frustum
  128560. * enables mapping of values in the render target depth
  128561. * attachment to scene coordinates. Initially set to 0.01.
  128562. */
  128563. depthNear: number;
  128564. /**
  128565. * An identifier for this distinct VRDisplay. Used as an
  128566. * association point in the Gamepad API.
  128567. */
  128568. readonly displayId: number;
  128569. /**
  128570. * A display name, a user-readable name identifying it.
  128571. */
  128572. readonly displayName: string;
  128573. readonly isConnected: boolean;
  128574. readonly isPresenting: boolean;
  128575. /**
  128576. * If this VRDisplay supports room-scale experiences, the optional
  128577. * stage attribute contains details on the room-scale parameters.
  128578. */
  128579. readonly stageParameters: VRStageParameters | null;
  128580. /**
  128581. * Passing the value returned by `requestAnimationFrame` to
  128582. * `cancelAnimationFrame` will unregister the callback.
  128583. * @param handle Define the hanle of the request to cancel
  128584. */
  128585. cancelAnimationFrame(handle: number): void;
  128586. /**
  128587. * Stops presenting to the VRDisplay.
  128588. * @returns a promise to know when it stopped
  128589. */
  128590. exitPresent(): Promise<void>;
  128591. /**
  128592. * Return the current VREyeParameters for the given eye.
  128593. * @param whichEye Define the eye we want the parameter for
  128594. * @returns the eye parameters
  128595. */
  128596. getEyeParameters(whichEye: string): VREyeParameters;
  128597. /**
  128598. * Populates the passed VRFrameData with the information required to render
  128599. * the current frame.
  128600. * @param frameData Define the data structure to populate
  128601. * @returns true if ok otherwise false
  128602. */
  128603. getFrameData(frameData: VRFrameData): boolean;
  128604. /**
  128605. * Get the layers currently being presented.
  128606. * @returns the list of VR layers
  128607. */
  128608. getLayers(): VRLayer[];
  128609. /**
  128610. * Return a VRPose containing the future predicted pose of the VRDisplay
  128611. * when the current frame will be presented. The value returned will not
  128612. * change until JavaScript has returned control to the browser.
  128613. *
  128614. * The VRPose will contain the position, orientation, velocity,
  128615. * and acceleration of each of these properties.
  128616. * @returns the pose object
  128617. */
  128618. getPose(): VRPose;
  128619. /**
  128620. * Return the current instantaneous pose of the VRDisplay, with no
  128621. * prediction applied.
  128622. * @returns the current instantaneous pose
  128623. */
  128624. getImmediatePose(): VRPose;
  128625. /**
  128626. * The callback passed to `requestAnimationFrame` will be called
  128627. * any time a new frame should be rendered. When the VRDisplay is
  128628. * presenting the callback will be called at the native refresh
  128629. * rate of the HMD. When not presenting this function acts
  128630. * identically to how window.requestAnimationFrame acts. Content should
  128631. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128632. * asynchronously from other displays and at differing refresh rates.
  128633. * @param callback Define the eaction to run next frame
  128634. * @returns the request handle it
  128635. */
  128636. requestAnimationFrame(callback: FrameRequestCallback): number;
  128637. /**
  128638. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128639. * Repeat calls while already presenting will update the VRLayers being displayed.
  128640. * @param layers Define the list of layer to present
  128641. * @returns a promise to know when the request has been fulfilled
  128642. */
  128643. requestPresent(layers: VRLayer[]): Promise<void>;
  128644. /**
  128645. * Reset the pose for this display, treating its current position and
  128646. * orientation as the "origin/zero" values. VRPose.position,
  128647. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128648. * updated when calling resetPose(). This should be called in only
  128649. * sitting-space experiences.
  128650. */
  128651. resetPose(): void;
  128652. /**
  128653. * The VRLayer provided to the VRDisplay will be captured and presented
  128654. * in the HMD. Calling this function has the same effect on the source
  128655. * canvas as any other operation that uses its source image, and canvases
  128656. * created without preserveDrawingBuffer set to true will be cleared.
  128657. * @param pose Define the pose to submit
  128658. */
  128659. submitFrame(pose?: VRPose): void;
  128660. }
  128661. declare var VRDisplay: {
  128662. prototype: VRDisplay;
  128663. new(): VRDisplay;
  128664. };
  128665. interface VRLayer {
  128666. leftBounds?: number[] | Float32Array | null;
  128667. rightBounds?: number[] | Float32Array | null;
  128668. source?: HTMLCanvasElement | null;
  128669. }
  128670. interface VRDisplayCapabilities {
  128671. readonly canPresent: boolean;
  128672. readonly hasExternalDisplay: boolean;
  128673. readonly hasOrientation: boolean;
  128674. readonly hasPosition: boolean;
  128675. readonly maxLayers: number;
  128676. }
  128677. interface VREyeParameters {
  128678. /** @deprecated */
  128679. readonly fieldOfView: VRFieldOfView;
  128680. readonly offset: Float32Array;
  128681. readonly renderHeight: number;
  128682. readonly renderWidth: number;
  128683. }
  128684. interface VRFieldOfView {
  128685. readonly downDegrees: number;
  128686. readonly leftDegrees: number;
  128687. readonly rightDegrees: number;
  128688. readonly upDegrees: number;
  128689. }
  128690. interface VRFrameData {
  128691. readonly leftProjectionMatrix: Float32Array;
  128692. readonly leftViewMatrix: Float32Array;
  128693. readonly pose: VRPose;
  128694. readonly rightProjectionMatrix: Float32Array;
  128695. readonly rightViewMatrix: Float32Array;
  128696. readonly timestamp: number;
  128697. }
  128698. interface VRPose {
  128699. readonly angularAcceleration: Float32Array | null;
  128700. readonly angularVelocity: Float32Array | null;
  128701. readonly linearAcceleration: Float32Array | null;
  128702. readonly linearVelocity: Float32Array | null;
  128703. readonly orientation: Float32Array | null;
  128704. readonly position: Float32Array | null;
  128705. readonly timestamp: number;
  128706. }
  128707. interface VRStageParameters {
  128708. sittingToStandingTransform?: Float32Array;
  128709. sizeX?: number;
  128710. sizeY?: number;
  128711. }
  128712. interface Navigator {
  128713. getVRDisplays(): Promise<VRDisplay[]>;
  128714. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128715. }
  128716. interface Window {
  128717. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128718. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128719. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128720. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128721. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128722. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128723. }
  128724. interface Gamepad {
  128725. readonly displayId: number;
  128726. }
  128727. type XRSessionMode =
  128728. | "inline"
  128729. | "immersive-vr"
  128730. | "immersive-ar";
  128731. type XRReferenceSpaceType =
  128732. | "viewer"
  128733. | "local"
  128734. | "local-floor"
  128735. | "bounded-floor"
  128736. | "unbounded";
  128737. type XREnvironmentBlendMode =
  128738. | "opaque"
  128739. | "additive"
  128740. | "alpha-blend";
  128741. type XRVisibilityState =
  128742. | "visible"
  128743. | "visible-blurred"
  128744. | "hidden";
  128745. type XRHandedness =
  128746. | "none"
  128747. | "left"
  128748. | "right";
  128749. type XRTargetRayMode =
  128750. | "gaze"
  128751. | "tracked-pointer"
  128752. | "screen";
  128753. type XREye =
  128754. | "none"
  128755. | "left"
  128756. | "right";
  128757. interface XRSpace extends EventTarget {
  128758. }
  128759. interface XRRenderState {
  128760. depthNear?: number;
  128761. depthFar?: number;
  128762. inlineVerticalFieldOfView?: number;
  128763. baseLayer?: XRWebGLLayer;
  128764. }
  128765. interface XRInputSource {
  128766. handedness: XRHandedness;
  128767. targetRayMode: XRTargetRayMode;
  128768. targetRaySpace: XRSpace;
  128769. gripSpace: XRSpace | undefined;
  128770. gamepad: Gamepad | undefined;
  128771. profiles: Array<string>;
  128772. }
  128773. interface XRSession {
  128774. addEventListener: Function;
  128775. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128776. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128777. requestAnimationFrame: Function;
  128778. end(): Promise<void>;
  128779. renderState: XRRenderState;
  128780. inputSources: Array<XRInputSource>;
  128781. }
  128782. interface XRReferenceSpace extends XRSpace {
  128783. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128784. onreset: any;
  128785. }
  128786. interface XRFrame {
  128787. session: XRSession;
  128788. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128789. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128790. }
  128791. interface XRViewerPose extends XRPose {
  128792. views: Array<XRView>;
  128793. }
  128794. interface XRPose {
  128795. transform: XRRigidTransform;
  128796. emulatedPosition: boolean;
  128797. }
  128798. declare var XRWebGLLayer: {
  128799. prototype: XRWebGLLayer;
  128800. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128801. };
  128802. interface XRWebGLLayer {
  128803. framebuffer: WebGLFramebuffer;
  128804. framebufferWidth: number;
  128805. framebufferHeight: number;
  128806. getViewport: Function;
  128807. }
  128808. interface XRRigidTransform {
  128809. position: DOMPointReadOnly;
  128810. orientation: DOMPointReadOnly;
  128811. matrix: Float32Array;
  128812. inverse: XRRigidTransform;
  128813. }
  128814. interface XRView {
  128815. eye: XREye;
  128816. projectionMatrix: Float32Array;
  128817. transform: XRRigidTransform;
  128818. }
  128819. interface XRInputSourceChangeEvent {
  128820. session: XRSession;
  128821. removed: Array<XRInputSource>;
  128822. added: Array<XRInputSource>;
  128823. }